Merge branch 'master' into subquery

This commit is contained in:
Yuval Oren 2014-01-27 14:57:14 -08:00
commit 1c0b818cb2
8 changed files with 134 additions and 9 deletions

View File

@ -19,7 +19,7 @@ datasource_intervalStart_intervalEnd_version_partitionNum
Segment Components Segment Components
------------------ ------------------
A segment is compromised of several files, listed below. A segment is comprised of several files, listed below.
* `version.bin` * `version.bin`

View File

@ -29,7 +29,7 @@ public class WebJsonSupplierTest
public void checkInvalidUrl() throws Exception public void checkInvalidUrl() throws Exception
{ {
String invalidURL = "http://invalid.url"; String invalidURL = "http://invalid.url.";
WebJsonSupplier supplier = new WebJsonSupplier(invalidURL); WebJsonSupplier supplier = new WebJsonSupplier(invalidURL);
supplier.getInput(); supplier.getInput();
} }

View File

@ -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("/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();
}
}

View File

@ -19,6 +19,7 @@
package io.druid.server.http; package io.druid.server.http;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.druid.client.InventoryView; import io.druid.client.InventoryView;
import io.druid.client.indexing.IndexingServiceClient; import io.druid.client.indexing.IndexingServiceClient;
@ -31,6 +32,7 @@ import javax.ws.rs.Path;
/** /**
*/ */
@Deprecated
@Path("/static/info") @Path("/static/info")
public class BackwardsCompatibleInfoResource extends InfoResource public class BackwardsCompatibleInfoResource extends InfoResource
{ {
@ -40,9 +42,17 @@ public class BackwardsCompatibleInfoResource extends InfoResource
InventoryView serverInventoryView, InventoryView serverInventoryView,
DatabaseSegmentManager databaseSegmentManager, DatabaseSegmentManager databaseSegmentManager,
DatabaseRuleManager databaseRuleManager, DatabaseRuleManager databaseRuleManager,
@Nullable IndexingServiceClient indexingServiceClient @Nullable IndexingServiceClient indexingServiceClient,
ObjectMapper jsonMapper
) )
{ {
super(coordinator, serverInventoryView, databaseSegmentManager, databaseRuleManager, indexingServiceClient); super(
coordinator,
serverInventoryView,
databaseSegmentManager,
databaseRuleManager,
indexingServiceClient,
jsonMapper
);
} }
} }

View File

@ -70,7 +70,7 @@ public class CoordinatorResource
} }
@GET @GET
@Path("loadqueue") @Path("/loadqueue")
@Produces("application/json") @Produces("application/json")
public Response getLoadQueue( public Response getLoadQueue(
@QueryParam("simple") String simple @QueryParam("simple") String simple

View File

@ -19,6 +19,9 @@
package io.druid.server.http; 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.base.Function;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableMap; 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.DatabaseRuleManager;
import io.druid.db.DatabaseSegmentManager; import io.druid.db.DatabaseSegmentManager;
import io.druid.server.coordinator.DruidCoordinator; import io.druid.server.coordinator.DruidCoordinator;
import io.druid.server.coordinator.rules.LoadRule;
import io.druid.server.coordinator.rules.Rule; import io.druid.server.coordinator.rules.Rule;
import io.druid.timeline.DataSegment; import io.druid.timeline.DataSegment;
import org.joda.time.Interval; import org.joda.time.Interval;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -103,6 +108,8 @@ public class InfoResource
private final DatabaseRuleManager databaseRuleManager; private final DatabaseRuleManager databaseRuleManager;
private final IndexingServiceClient indexingServiceClient; private final IndexingServiceClient indexingServiceClient;
private final ObjectMapper jsonMapper;
@Inject @Inject
public InfoResource( public InfoResource(
DruidCoordinator coordinator, DruidCoordinator coordinator,
@ -110,7 +117,8 @@ public class InfoResource
DatabaseSegmentManager databaseSegmentManager, DatabaseSegmentManager databaseSegmentManager,
DatabaseRuleManager databaseRuleManager, DatabaseRuleManager databaseRuleManager,
@Nullable @Nullable
IndexingServiceClient indexingServiceClient IndexingServiceClient indexingServiceClient,
ObjectMapper jsonMapper
) )
{ {
this.coordinator = coordinator; this.coordinator = coordinator;
@ -118,6 +126,7 @@ public class InfoResource
this.databaseSegmentManager = databaseSegmentManager; this.databaseSegmentManager = databaseSegmentManager;
this.databaseRuleManager = databaseRuleManager; this.databaseRuleManager = databaseRuleManager;
this.indexingServiceClient = indexingServiceClient; this.indexingServiceClient = indexingServiceClient;
this.jsonMapper = jsonMapper;
} }
@GET @GET
@ -347,9 +356,49 @@ public class InfoResource
@Produces("application/json") @Produces("application/json")
public Response getRules() public Response getRules()
{ {
return Response.status(Response.Status.OK) // FUGLY, backwards compatibility
.entity(databaseRuleManager.getAllRules()) // This will def. be removed as part of the next release
.build(); return Response.ok().entity(
Maps.transformValues(
databaseRuleManager.getAllRules(),
new Function<List<Rule>, Object>()
{
@Override
public Object apply(List<Rule> rules)
{
return Lists.transform(
rules,
new Function<Rule, Object>()
{
@Override
public Object apply(Rule rule)
{
if (rule instanceof LoadRule) {
Map<String, Object> newRule = jsonMapper.convertValue(
rule, new TypeReference<Map<String, Object>>()
{
}
);
Set<String> 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 @GET

View File

@ -43,6 +43,7 @@ import io.druid.guice.ManageLifecycle;
import io.druid.server.coordinator.DruidCoordinator; import io.druid.server.coordinator.DruidCoordinator;
import io.druid.server.coordinator.DruidCoordinatorConfig; import io.druid.server.coordinator.DruidCoordinatorConfig;
import io.druid.server.coordinator.LoadQueueTaskMaster; import io.druid.server.coordinator.LoadQueueTaskMaster;
import io.druid.server.http.BackwardsCompatibleCoordinatorResource;
import io.druid.server.http.BackwardsCompatibleInfoResource; import io.druid.server.http.BackwardsCompatibleInfoResource;
import io.druid.server.http.CoordinatorDynamicConfigsResource; import io.druid.server.http.CoordinatorDynamicConfigsResource;
import io.druid.server.http.CoordinatorRedirectInfo; import io.druid.server.http.CoordinatorRedirectInfo;
@ -110,6 +111,7 @@ public class CliCoordinator extends ServerRunnable
binder.bind(JettyServerInitializer.class).toInstance(new CoordinatorJettyServerInitializer()); binder.bind(JettyServerInitializer.class).toInstance(new CoordinatorJettyServerInitializer());
Jerseys.addResource(binder, BackwardsCompatibleInfoResource.class); Jerseys.addResource(binder, BackwardsCompatibleInfoResource.class);
Jerseys.addResource(binder, InfoResource.class); Jerseys.addResource(binder, InfoResource.class);
Jerseys.addResource(binder, BackwardsCompatibleCoordinatorResource.class);
Jerseys.addResource(binder, CoordinatorResource.class); Jerseys.addResource(binder, CoordinatorResource.class);
Jerseys.addResource(binder, CoordinatorDynamicConfigsResource.class); Jerseys.addResource(binder, CoordinatorDynamicConfigsResource.class);
Jerseys.addResource(binder, TiersResource.class); Jerseys.addResource(binder, TiersResource.class);

View File

@ -54,6 +54,8 @@ class CoordinatorJettyServerInitializer implements JettyServerInitializer
root.addFilter(GuiceFilter.class, "/status/*", null); root.addFilter(GuiceFilter.class, "/status/*", null);
root.addFilter(GuiceFilter.class, "/info/*", null); root.addFilter(GuiceFilter.class, "/info/*", null);
root.addFilter(GuiceFilter.class, "/druid/coordinator/*", 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 handlerList = new HandlerList();
handlerList.setHandlers(new Handler[]{root}); handlerList.setHandlers(new Handler[]{root});