diff --git a/client/src/main/java/com/metamx/druid/initialization/Initialization.java b/client/src/main/java/com/metamx/druid/initialization/Initialization.java index 1b4dcbd3a27..fd0e4390fbd 100644 --- a/client/src/main/java/com/metamx/druid/initialization/Initialization.java +++ b/client/src/main/java/com/metamx/druid/initialization/Initialization.java @@ -278,6 +278,7 @@ public class Initialization final ServiceInstance serviceInstance = ServiceInstance.builder() .name(config.getServiceName().replace('/', ':')) + .address(addressFromHost(config.getHost())) .port(config.getPort()) .build(); final ServiceDiscovery serviceDiscovery = @@ -361,6 +362,16 @@ public class Initialization return String.format("%s/%s", basePath, PROP_SUBPATH); } + public static String addressFromHost(final String host) + { + final int colon = host.indexOf(':'); + if (colon < 0) { + return host; + } else { + return host.substring(0, colon); + } + } + /** * Validate and Resolve Properties. * Resolve zpaths with props like druid.zk.paths.*Path using druid.zk.paths.base value. diff --git a/client/src/main/java/com/metamx/druid/initialization/ServiceDiscoveryConfig.java b/client/src/main/java/com/metamx/druid/initialization/ServiceDiscoveryConfig.java index 62cbfe44eb9..04776d6545a 100644 --- a/client/src/main/java/com/metamx/druid/initialization/ServiceDiscoveryConfig.java +++ b/client/src/main/java/com/metamx/druid/initialization/ServiceDiscoveryConfig.java @@ -28,6 +28,9 @@ public abstract class ServiceDiscoveryConfig extends CuratorConfig @Config("druid.service") public abstract String getServiceName(); + @Config("druid.host") + public abstract String getHost(); + @Config("druid.port") public abstract int getPort();