Initialization: Set service discovery address equal to druid.host (without port if any)

This commit is contained in:
Gian Merlino 2013-04-19 15:45:00 -07:00
parent 376df4032d
commit 4c4d30cf66
2 changed files with 14 additions and 0 deletions

View File

@ -278,6 +278,7 @@ public class Initialization
final ServiceInstance serviceInstance = final ServiceInstance serviceInstance =
ServiceInstance.builder() ServiceInstance.builder()
.name(config.getServiceName().replace('/', ':')) .name(config.getServiceName().replace('/', ':'))
.address(addressFromHost(config.getHost()))
.port(config.getPort()) .port(config.getPort())
.build(); .build();
final ServiceDiscovery serviceDiscovery = final ServiceDiscovery serviceDiscovery =
@ -361,6 +362,16 @@ public class Initialization
return String.format("%s/%s", basePath, PROP_SUBPATH); 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. * Validate and Resolve Properties.
* Resolve zpaths with props like druid.zk.paths.*Path using druid.zk.paths.base value. * Resolve zpaths with props like druid.zk.paths.*Path using druid.zk.paths.base value.

View File

@ -28,6 +28,9 @@ public abstract class ServiceDiscoveryConfig extends CuratorConfig
@Config("druid.service") @Config("druid.service")
public abstract String getServiceName(); public abstract String getServiceName();
@Config("druid.host")
public abstract String getHost();
@Config("druid.port") @Config("druid.port")
public abstract int getPort(); public abstract int getPort();