Merge pull request #686 from metamx/default-host-port

default service/host/port for all nodes
This commit is contained in:
fjy 2014-08-18 10:52:58 -06:00
commit 74b8adf5b0
14 changed files with 58 additions and 19 deletions

View File

@ -49,7 +49,7 @@ public class ForkingTaskRunnerConfig
@JsonProperty
@Min(1024)
@Max(65535)
private int startPort = 8081;
private int startPort = 8100;
@JsonProperty
@NotNull

View File

@ -19,8 +19,10 @@
package io.druid.server;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.inject.name.Named;
import io.druid.common.utils.SocketUtil;
import javax.validation.constraints.Max;
@ -31,15 +33,17 @@ import javax.validation.constraints.NotNull;
*/
public class DruidNode
{
public static final String DEFAULT_HOST = "localhost";
private String hostNoPort;
@JsonProperty("service")
@NotNull
private String serviceName = null;
private String serviceName;
@JsonProperty
@NotNull
private String host = null;
private String host;
@JsonProperty
@Min(0) @Max(0xffff)
@ -47,16 +51,21 @@ public class DruidNode
@JsonCreator
public DruidNode(
@JsonProperty("service") String serviceName,
@JacksonInject @Named("serviceName") @JsonProperty("service") String serviceName,
@JsonProperty("host") String host,
@JsonProperty("port") Integer port
@JacksonInject @Named("servicePort") @JsonProperty("port") Integer port
)
{
init(serviceName, host, port);
}
private void init(String serviceName, String host, Integer port)
{
this.serviceName = serviceName;
if (port == null) {
if (host == null) {
setHostAndPort(null, -1, null);
setHostAndPort(DEFAULT_HOST, -1, DEFAULT_HOST);
}
else if (host.contains(":")) {
final String[] hostParts = host.split(":");
@ -74,7 +83,7 @@ public class DruidNode
}
else {
if (host == null || host.contains(":")) {
setHostAndPort(host, port, host == null ? null : host.split(":")[0]);
setHostAndPort(host == null ? DEFAULT_HOST : host, port, host == null ? DEFAULT_HOST : host.split(":")[0]);
}
else {
setHostAndPort(String.format("%s:%d", host, port), port, host);

View File

@ -454,7 +454,7 @@ public class DruidCoordinator
private LeaderLatch createNewLeaderLatch()
{
final LeaderLatch newLeaderLatch = new LeaderLatch(
curator, ZKPaths.makePath(zkPaths.getCoordinatorPath(), COORDINATOR_OWNER_NODE), config.getHost()
curator, ZKPaths.makePath(zkPaths.getCoordinatorPath(), COORDINATOR_OWNER_NODE), self.getHost()
);
newLeaderLatch.addListener(

View File

@ -27,9 +27,6 @@ import org.skife.config.Default;
*/
public abstract class DruidCoordinatorConfig
{
@Config("druid.host")
public abstract String getHost();
@Config("druid.coordinator.startDelay")
@Default("PT300s")
public abstract Duration getCoordinatorStartDelay();

View File

@ -109,7 +109,7 @@ public class InitializationTest
public void configure(Binder binder)
{
JsonConfigProvider.bindInstance(
binder, Key.get(DruidNode.class, Self.class), new DruidNode("hadoop-indexer", "localhost", -1)
binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", "localhost", -1)
);
}
}

View File

@ -77,12 +77,6 @@ public class DruidCoordinatorTest
coordinator = new DruidCoordinator(
new DruidCoordinatorConfig()
{
@Override
public String getHost()
{
return null;
}
@Override
public Duration getCoordinatorStartDelay()
{

View File

@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.name.Names;
import com.metamx.common.lifecycle.Lifecycle;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
@ -69,6 +70,9 @@ public class CliBridge extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/bridge");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8081);
ConfigProvider.bind(binder, BridgeCuratorConfig.class);
binder.bind(BridgeZkCoordinator.class).in(ManageLifecycle.class);

View File

@ -22,6 +22,7 @@ package io.druid.cli;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.name.Names;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
import io.druid.client.BrokerServerView;
@ -78,6 +79,9 @@ public class CliBroker extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/broker");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8082);
binder.bind(QueryToolChestWarehouse.class).to(MapQueryToolChestWarehouse.class);
binder.bind(CachingClusteredClient.class).in(LazySingleton.class);

View File

@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.name.Names;
import com.metamx.common.concurrent.ScheduledExecutorFactory;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
@ -87,6 +88,9 @@ public class CliCoordinator extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/coordinator");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8081);
ConfigProvider.bind(binder, DruidCoordinatorConfig.class);
JsonConfigProvider.bind(binder, "druid.manager.segments", DatabaseSegmentManagerConfig.class);

View File

@ -22,6 +22,7 @@ package io.druid.cli;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.name.Names;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
import io.druid.client.cache.Cache;
@ -68,6 +69,9 @@ public class CliHistorical extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/historical");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8083);
binder.bind(ServerManager.class).in(LazySingleton.class);
binder.bind(ZkCoordinator.class).in(ManageLifecycle.class);
binder.bind(QuerySegmentWalker.class).to(ServerManager.class).in(LazySingleton.class);

View File

@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.name.Names;
import com.google.inject.util.Providers;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
@ -74,6 +75,9 @@ public class CliMiddleManager extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/middlemanager");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8091);
IndexingServiceModuleHelper.configureTaskRunnerConfigs(binder);
JsonConfigProvider.bind(binder, "druid.indexer.task", TaskConfig.class);

View File

@ -26,6 +26,7 @@ import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.name.Names;
import com.google.inject.servlet.GuiceFilter;
import com.google.inject.util.Providers;
import com.metamx.common.logger.Logger;
@ -114,6 +115,9 @@ public class CliOverlord extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/overlord");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8090);
JsonConfigProvider.bind(binder, "druid.indexer.queue", TaskQueueConfig.class);
JsonConfigProvider.bind(binder, "druid.indexer.task", TaskConfig.class);

View File

@ -20,6 +20,9 @@
package io.druid.cli;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.name.Names;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
import io.druid.guice.RealtimeModule;
@ -45,7 +48,15 @@ public class CliRealtime extends ServerRunnable
protected List<Object> getModules()
{
return ImmutableList.<Object>of(
new RealtimeModule()
new RealtimeModule(),
new Module() {
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/realtime");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8084);
}
}
);
}
}

View File

@ -24,6 +24,7 @@ import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
import com.metamx.common.logger.Logger;
import io.airlift.command.Command;
import io.druid.curator.discovery.DiscoveryModule;
@ -72,6 +73,9 @@ public class CliRouter extends ServerRunnable
@Override
public void configure(Binder binder)
{
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/router");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8888);
JsonConfigProvider.bind(binder, "druid.router", TieredBrokerConfig.class);
binder.bind(CoordinatorRuleManager.class);