diff --git a/server/src/main/java/io/druid/client/indexing/IndexingServiceSelectorConfig.java b/server/src/main/java/io/druid/client/indexing/IndexingServiceSelectorConfig.java index 976225f6665..31f106f75d9 100644 --- a/server/src/main/java/io/druid/client/indexing/IndexingServiceSelectorConfig.java +++ b/server/src/main/java/io/druid/client/indexing/IndexingServiceSelectorConfig.java @@ -25,8 +25,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ public class IndexingServiceSelectorConfig { + public static final String DEFAULT_SERVICE_NAME = "druid/overlord"; + @JsonProperty - private String serviceName = null; + private String serviceName = DEFAULT_SERVICE_NAME; public String getServiceName() { diff --git a/server/src/main/java/io/druid/curator/discovery/CuratorServiceAnnouncer.java b/server/src/main/java/io/druid/curator/discovery/CuratorServiceAnnouncer.java index 2a0eb3b770c..581f91a57c1 100644 --- a/server/src/main/java/io/druid/curator/discovery/CuratorServiceAnnouncer.java +++ b/server/src/main/java/io/druid/curator/discovery/CuratorServiceAnnouncer.java @@ -51,7 +51,7 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer @Override public void announce(DruidNode service) { - final String serviceName = getServiceName(service); + final String serviceName = CuratorServiceUtils.makeCanonicalServiceName(service.getServiceName()); final ServiceInstance instance; synchronized (monitor) { @@ -89,7 +89,7 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer @Override public void unannounce(DruidNode service) { - final String serviceName = getServiceName(service); + final String serviceName = CuratorServiceUtils.makeCanonicalServiceName(service.getServiceName()); final ServiceInstance instance; synchronized (monitor) { @@ -115,8 +115,4 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer } } } - - private String getServiceName(DruidNode service) { - return service.getServiceName().replaceAll("/", ":"); - } } diff --git a/server/src/main/java/io/druid/curator/discovery/CuratorServiceUtils.java b/server/src/main/java/io/druid/curator/discovery/CuratorServiceUtils.java new file mode 100644 index 00000000000..ad7781622a8 --- /dev/null +++ b/server/src/main/java/io/druid/curator/discovery/CuratorServiceUtils.java @@ -0,0 +1,27 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2014 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.curator.discovery; + +public class CuratorServiceUtils +{ + public static String makeCanonicalServiceName(String serviceName) { + return serviceName.replaceAll("/", ":"); + } +} diff --git a/server/src/main/java/io/druid/curator/discovery/NoopServiceAnnouncer.java b/server/src/main/java/io/druid/curator/discovery/NoopServiceAnnouncer.java index 672b900d5bf..59dbe7172a3 100644 --- a/server/src/main/java/io/druid/curator/discovery/NoopServiceAnnouncer.java +++ b/server/src/main/java/io/druid/curator/discovery/NoopServiceAnnouncer.java @@ -29,12 +29,10 @@ public class NoopServiceAnnouncer implements ServiceAnnouncer @Override public void announce(DruidNode node) { - } @Override public void unannounce(DruidNode node) { - } } diff --git a/server/src/main/java/io/druid/curator/discovery/ServerDiscoveryFactory.java b/server/src/main/java/io/druid/curator/discovery/ServerDiscoveryFactory.java index d8e5814e0d6..2913715bbfe 100644 --- a/server/src/main/java/io/druid/curator/discovery/ServerDiscoveryFactory.java +++ b/server/src/main/java/io/druid/curator/discovery/ServerDiscoveryFactory.java @@ -34,7 +34,9 @@ public class ServerDiscoveryFactory private final ServiceDiscovery serviceDiscovery; @Inject - public ServerDiscoveryFactory(ServiceDiscovery serviceDiscovery) + public ServerDiscoveryFactory( + ServiceDiscovery serviceDiscovery + ) { this.serviceDiscovery = serviceDiscovery; } @@ -45,7 +47,10 @@ public class ServerDiscoveryFactory return new ServerDiscoverySelector(new NoopServiceProvider()); } - final ServiceProvider serviceProvider = serviceDiscovery.serviceProviderBuilder().serviceName(serviceName).build(); + final ServiceProvider serviceProvider = serviceDiscovery + .serviceProviderBuilder() + .serviceName(CuratorServiceUtils.makeCanonicalServiceName(serviceName)) + .build(); return new ServerDiscoverySelector(serviceProvider); } diff --git a/services/src/main/java/io/druid/cli/CliOverlord.java b/services/src/main/java/io/druid/cli/CliOverlord.java index bfa6cf1d4e0..e4f2040b818 100644 --- a/services/src/main/java/io/druid/cli/CliOverlord.java +++ b/services/src/main/java/io/druid/cli/CliOverlord.java @@ -31,6 +31,7 @@ import com.google.inject.servlet.GuiceFilter; import com.google.inject.util.Providers; import com.metamx.common.logger.Logger; import io.airlift.command.Command; +import io.druid.client.indexing.IndexingServiceSelectorConfig; import io.druid.guice.IndexingServiceFirehoseModule; import io.druid.guice.IndexingServiceModuleHelper; import io.druid.guice.IndexingServiceTaskLogsModule; @@ -117,7 +118,7 @@ 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("serviceName")).to(IndexingServiceSelectorConfig.DEFAULT_SERVICE_NAME); binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8090); JsonConfigProvider.bind(binder, "druid.indexer.queue", TaskQueueConfig.class);