mirror of https://github.com/apache/druid.git
Merge pull request #829 from metamx/default-servicenames
provide proper defaults for indexing service name
This commit is contained in:
commit
8d1a8564c4
|
@ -25,8 +25,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
*/
|
*/
|
||||||
public class IndexingServiceSelectorConfig
|
public class IndexingServiceSelectorConfig
|
||||||
{
|
{
|
||||||
|
public static final String DEFAULT_SERVICE_NAME = "druid/overlord";
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String serviceName = null;
|
private String serviceName = DEFAULT_SERVICE_NAME;
|
||||||
|
|
||||||
public String getServiceName()
|
public String getServiceName()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer
|
||||||
@Override
|
@Override
|
||||||
public void announce(DruidNode service)
|
public void announce(DruidNode service)
|
||||||
{
|
{
|
||||||
final String serviceName = getServiceName(service);
|
final String serviceName = CuratorServiceUtils.makeCanonicalServiceName(service.getServiceName());
|
||||||
|
|
||||||
final ServiceInstance<Void> instance;
|
final ServiceInstance<Void> instance;
|
||||||
synchronized (monitor) {
|
synchronized (monitor) {
|
||||||
|
@ -89,7 +89,7 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer
|
||||||
@Override
|
@Override
|
||||||
public void unannounce(DruidNode service)
|
public void unannounce(DruidNode service)
|
||||||
{
|
{
|
||||||
final String serviceName = getServiceName(service);
|
final String serviceName = CuratorServiceUtils.makeCanonicalServiceName(service.getServiceName());
|
||||||
final ServiceInstance<Void> instance;
|
final ServiceInstance<Void> instance;
|
||||||
|
|
||||||
synchronized (monitor) {
|
synchronized (monitor) {
|
||||||
|
@ -115,8 +115,4 @@ public class CuratorServiceAnnouncer implements ServiceAnnouncer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getServiceName(DruidNode service) {
|
|
||||||
return service.getServiceName().replaceAll("/", ":");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("/", ":");
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,12 +29,10 @@ public class NoopServiceAnnouncer implements ServiceAnnouncer
|
||||||
@Override
|
@Override
|
||||||
public void announce(DruidNode node)
|
public void announce(DruidNode node)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unannounce(DruidNode node)
|
public void unannounce(DruidNode node)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,9 @@ public class ServerDiscoveryFactory
|
||||||
private final ServiceDiscovery<Void> serviceDiscovery;
|
private final ServiceDiscovery<Void> serviceDiscovery;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ServerDiscoveryFactory(ServiceDiscovery<Void> serviceDiscovery)
|
public ServerDiscoveryFactory(
|
||||||
|
ServiceDiscovery<Void> serviceDiscovery
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.serviceDiscovery = serviceDiscovery;
|
this.serviceDiscovery = serviceDiscovery;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +47,10 @@ public class ServerDiscoveryFactory
|
||||||
return new ServerDiscoverySelector(new NoopServiceProvider());
|
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);
|
return new ServerDiscoverySelector(serviceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.google.inject.servlet.GuiceFilter;
|
||||||
import com.google.inject.util.Providers;
|
import com.google.inject.util.Providers;
|
||||||
import com.metamx.common.logger.Logger;
|
import com.metamx.common.logger.Logger;
|
||||||
import io.airlift.command.Command;
|
import io.airlift.command.Command;
|
||||||
|
import io.druid.client.indexing.IndexingServiceSelectorConfig;
|
||||||
import io.druid.guice.IndexingServiceFirehoseModule;
|
import io.druid.guice.IndexingServiceFirehoseModule;
|
||||||
import io.druid.guice.IndexingServiceModuleHelper;
|
import io.druid.guice.IndexingServiceModuleHelper;
|
||||||
import io.druid.guice.IndexingServiceTaskLogsModule;
|
import io.druid.guice.IndexingServiceTaskLogsModule;
|
||||||
|
@ -117,7 +118,7 @@ public class CliOverlord extends ServerRunnable
|
||||||
@Override
|
@Override
|
||||||
public void configure(Binder binder)
|
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);
|
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8090);
|
||||||
|
|
||||||
JsonConfigProvider.bind(binder, "druid.indexer.queue", TaskQueueConfig.class);
|
JsonConfigProvider.bind(binder, "druid.indexer.queue", TaskQueueConfig.class);
|
||||||
|
|
Loading…
Reference in New Issue