From 4c4d30cf66ced2ee0fb630644317c09d02b6364d Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 19 Apr 2013 15:45:00 -0700 Subject: [PATCH] Initialization: Set service discovery address equal to druid.host (without port if any) --- .../metamx/druid/initialization/Initialization.java | 11 +++++++++++ .../druid/initialization/ServiceDiscoveryConfig.java | 3 +++ 2 files changed, 14 insertions(+) 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();