From 8ab0636f5cff62a354e3954023bf460d8c6ab5ce Mon Sep 17 00:00:00 2001 From: fjy Date: Sun, 26 Jan 2014 20:04:04 +0800 Subject: [PATCH 1/7] fix coord resource --- .../src/main/java/io/druid/server/http/CoordinatorResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/io/druid/server/http/CoordinatorResource.java b/server/src/main/java/io/druid/server/http/CoordinatorResource.java index d1eba7f95ae..aea61681183 100644 --- a/server/src/main/java/io/druid/server/http/CoordinatorResource.java +++ b/server/src/main/java/io/druid/server/http/CoordinatorResource.java @@ -70,7 +70,7 @@ public class CoordinatorResource } @GET - @Path("loadqueue") + @Path("/loadqueue") @Produces("application/json") public Response getLoadQueue( @QueryParam("simple") String simple From 158a725985dd3470748b5dabd7dd530d52c26214 Mon Sep 17 00:00:00 2001 From: fjy Date: Sun, 26 Jan 2014 20:07:09 +0800 Subject: [PATCH 2/7] fix backwards compat issues --- ...ackwardsCompatibleCoordinatorResource.java | 62 +++++++++++++++++++ .../http/BackwardsCompatibleInfoResource.java | 1 + .../java/io/druid/cli/CliCoordinator.java | 2 + 3 files changed, 65 insertions(+) create mode 100644 server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java diff --git a/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java b/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java new file mode 100644 index 00000000000..ccccdaf0f13 --- /dev/null +++ b/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java @@ -0,0 +1,62 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012, 2013 Metamarkets Group Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package io.druid.server.http; + +import com.google.inject.Inject; +import io.druid.server.coordinator.DruidCoordinator; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +/** + */ +@Deprecated +@Path("/druid/coordinator") +public class BackwardsCompatibleCoordinatorResource +{ + private final DruidCoordinator coordinator; + + @Inject + public BackwardsCompatibleCoordinatorResource( + DruidCoordinator coordinator + ) + { + this.coordinator = coordinator; + } + + @GET + @Path("/leader") + @Produces("application/json") + public Response getLeader() + { + return Response.ok(coordinator.getCurrentLeader()).build(); + } + + @GET + @Path("/loadstatus") + @Produces("application/json") + public Response getLoadStatus( + ) + { + return Response.ok(coordinator.getLoadStatus()).build(); + } +} \ No newline at end of file diff --git a/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java b/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java index ed1cf580887..6fce94bc493 100644 --- a/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java +++ b/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java @@ -31,6 +31,7 @@ import javax.ws.rs.Path; /** */ +@Deprecated @Path("/static/info") public class BackwardsCompatibleInfoResource extends InfoResource { diff --git a/services/src/main/java/io/druid/cli/CliCoordinator.java b/services/src/main/java/io/druid/cli/CliCoordinator.java index 0055c6a0a45..319ece9215f 100644 --- a/services/src/main/java/io/druid/cli/CliCoordinator.java +++ b/services/src/main/java/io/druid/cli/CliCoordinator.java @@ -43,6 +43,7 @@ import io.druid.guice.ManageLifecycle; import io.druid.server.coordinator.DruidCoordinator; import io.druid.server.coordinator.DruidCoordinatorConfig; import io.druid.server.coordinator.LoadQueueTaskMaster; +import io.druid.server.http.BackwardsCompatibleCoordinatorResource; import io.druid.server.http.BackwardsCompatibleInfoResource; import io.druid.server.http.CoordinatorDynamicConfigsResource; import io.druid.server.http.CoordinatorRedirectInfo; @@ -110,6 +111,7 @@ public class CliCoordinator extends ServerRunnable binder.bind(JettyServerInitializer.class).toInstance(new CoordinatorJettyServerInitializer()); Jerseys.addResource(binder, BackwardsCompatibleInfoResource.class); Jerseys.addResource(binder, InfoResource.class); + Jerseys.addResource(binder, BackwardsCompatibleCoordinatorResource.class); Jerseys.addResource(binder, CoordinatorResource.class); Jerseys.addResource(binder, CoordinatorDynamicConfigsResource.class); Jerseys.addResource(binder, TiersResource.class); From 7800dac7f79f03e415eb02b488039ee49b6ef7a0 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Sun, 26 Jan 2014 20:34:43 +0800 Subject: [PATCH 3/7] backwards compatibility fix --- .../server/http/BackwardsCompatibleCoordinatorResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java b/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java index ccccdaf0f13..0ea5329e910 100644 --- a/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java +++ b/server/src/main/java/io/druid/server/http/BackwardsCompatibleCoordinatorResource.java @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; /** */ @Deprecated -@Path("/druid/coordinator") +@Path("/coordinator") public class BackwardsCompatibleCoordinatorResource { private final DruidCoordinator coordinator; From 8edf0cf13641f6bdb1a5bc8cbef56f7608352941 Mon Sep 17 00:00:00 2001 From: fjy Date: Sun, 26 Jan 2014 21:27:34 +0800 Subject: [PATCH 4/7] more backwards compatability fix --- .../java/io/druid/cli/CoordinatorJettyServerInitializer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java b/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java index 665573530f1..5f1ad32edd7 100644 --- a/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java @@ -54,6 +54,8 @@ class CoordinatorJettyServerInitializer implements JettyServerInitializer root.addFilter(GuiceFilter.class, "/status/*", null); root.addFilter(GuiceFilter.class, "/info/*", null); root.addFilter(GuiceFilter.class, "/druid/coordinator/*", null); + // this will be removed in the next major release + root.addFilter(GuiceFilter.class, "/coordinator/*", null); HandlerList handlerList = new HandlerList(); handlerList.setHandlers(new Handler[]{root}); From f293794710b08ebc5a7c88f48b7f98adbc76ad9e Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Mon, 27 Jan 2014 19:49:01 +0800 Subject: [PATCH 5/7] WebJsonSupplierTest: Use fqdn to avoid search domain wonkiness (fixes #275) --- .../test/java/io/druid/examples/web/WebJsonSupplierTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/test/java/io/druid/examples/web/WebJsonSupplierTest.java b/examples/src/test/java/io/druid/examples/web/WebJsonSupplierTest.java index d80fd5479f9..ca181427c82 100644 --- a/examples/src/test/java/io/druid/examples/web/WebJsonSupplierTest.java +++ b/examples/src/test/java/io/druid/examples/web/WebJsonSupplierTest.java @@ -29,7 +29,7 @@ public class WebJsonSupplierTest public void checkInvalidUrl() throws Exception { - String invalidURL = "http://invalid.url"; + String invalidURL = "http://invalid.url."; WebJsonSupplier supplier = new WebJsonSupplier(invalidURL); supplier.getInput(); } From 7a116bf7846efa61aad44325c2dcb91e2664fbef Mon Sep 17 00:00:00 2001 From: fjy Date: Mon, 27 Jan 2014 20:47:11 +0800 Subject: [PATCH 6/7] backwards compatibility fix for rules serde --- .../http/BackwardsCompatibleInfoResource.java | 13 ++++- .../io/druid/server/http/InfoResource.java | 57 +++++++++++++++++-- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java b/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java index 6fce94bc493..a7ebf36856a 100644 --- a/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java +++ b/server/src/main/java/io/druid/server/http/BackwardsCompatibleInfoResource.java @@ -19,6 +19,7 @@ package io.druid.server.http; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; import io.druid.client.InventoryView; import io.druid.client.indexing.IndexingServiceClient; @@ -41,9 +42,17 @@ public class BackwardsCompatibleInfoResource extends InfoResource InventoryView serverInventoryView, DatabaseSegmentManager databaseSegmentManager, DatabaseRuleManager databaseRuleManager, - @Nullable IndexingServiceClient indexingServiceClient + @Nullable IndexingServiceClient indexingServiceClient, + ObjectMapper jsonMapper ) { - super(coordinator, serverInventoryView, databaseSegmentManager, databaseRuleManager, indexingServiceClient); + super( + coordinator, + serverInventoryView, + databaseSegmentManager, + databaseRuleManager, + indexingServiceClient, + jsonMapper + ); } } diff --git a/server/src/main/java/io/druid/server/http/InfoResource.java b/server/src/main/java/io/druid/server/http/InfoResource.java index 725210e38bc..0786e51b34a 100644 --- a/server/src/main/java/io/druid/server/http/InfoResource.java +++ b/server/src/main/java/io/druid/server/http/InfoResource.java @@ -19,6 +19,9 @@ package io.druid.server.http; +import com.fasterxml.jackson.annotation.JacksonInject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; @@ -34,11 +37,13 @@ import io.druid.client.indexing.IndexingServiceClient; import io.druid.db.DatabaseRuleManager; import io.druid.db.DatabaseSegmentManager; import io.druid.server.coordinator.DruidCoordinator; +import io.druid.server.coordinator.rules.LoadRule; import io.druid.server.coordinator.rules.Rule; import io.druid.timeline.DataSegment; import org.joda.time.Interval; import javax.annotation.Nullable; +import javax.validation.constraints.NotNull; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -103,6 +108,8 @@ public class InfoResource private final DatabaseRuleManager databaseRuleManager; private final IndexingServiceClient indexingServiceClient; + private final ObjectMapper jsonMapper; + @Inject public InfoResource( DruidCoordinator coordinator, @@ -110,7 +117,8 @@ public class InfoResource DatabaseSegmentManager databaseSegmentManager, DatabaseRuleManager databaseRuleManager, @Nullable - IndexingServiceClient indexingServiceClient + IndexingServiceClient indexingServiceClient, + ObjectMapper jsonMapper ) { this.coordinator = coordinator; @@ -118,6 +126,7 @@ public class InfoResource this.databaseSegmentManager = databaseSegmentManager; this.databaseRuleManager = databaseRuleManager; this.indexingServiceClient = indexingServiceClient; + this.jsonMapper = jsonMapper; } @GET @@ -347,9 +356,49 @@ public class InfoResource @Produces("application/json") public Response getRules() { - return Response.status(Response.Status.OK) - .entity(databaseRuleManager.getAllRules()) - .build(); + // FUGLY, backwards compatibility + // This will def. be removed as part of the next release + return Response.ok().entity( + Maps.transformValues( + databaseRuleManager.getAllRules(), + new Function, Object>() + { + @Override + public Object apply(List rules) + { + return Lists.transform( + rules, + new Function() + { + @Override + public Object apply(Rule rule) + { + if (rule instanceof LoadRule) { + Map newRule = jsonMapper.convertValue( + rule, new TypeReference>() + { + } + ); + Set tiers = Sets.newHashSet(((LoadRule) rule).getTieredReplicants().keySet()); + String tier = DruidServer.DEFAULT_TIER; + if (tiers.size() > 1) { + tiers.remove(DruidServer.DEFAULT_TIER); + tier = tiers.iterator().next(); + } + + newRule.put("tier", tier); + newRule.put("replicants", ((LoadRule) rule).getNumReplicants(tier)); + + return newRule; + } + return rule; + } + } + ); + } + } + ) + ).build(); } @GET From 74dd855a45eeff9a532302c8a4f71268c4877e37 Mon Sep 17 00:00:00 2001 From: fjy Date: Tue, 28 Jan 2014 05:50:23 +0800 Subject: [PATCH 7/7] fix spelling --- docs/content/Segments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/Segments.md b/docs/content/Segments.md index 644fea72579..eeefd5b80d3 100644 --- a/docs/content/Segments.md +++ b/docs/content/Segments.md @@ -19,7 +19,7 @@ datasource_intervalStart_intervalEnd_version_partitionNum Segment Components ------------------ -A segment is compromised of several files, listed below. +A segment is comprised of several files, listed below. * `version.bin`