From 384dcda7e4583c822609b64dfaf905ea529a6d52 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Tue, 1 Oct 2013 17:45:53 -0700 Subject: [PATCH] Chat handlers still don't work, but, they're closer maybe. --- .../java/io/druid/indexing/common/index/ChatHandler.java | 2 +- .../druid/indexing/common/index/ChatHandlerProvider.java | 2 -- .../common/index/EventReceiverFirehoseFactory.java | 5 +++-- .../indexing/common/index/NoopChatHandlerProvider.java | 6 ------ ...ider.java => ServiceAnnouncingChatHandlerProvider.java} | 6 +++--- services/src/main/java/io/druid/cli/CliPeon.java | 7 ++++--- 6 files changed, 11 insertions(+), 17 deletions(-) rename indexing-service/src/main/java/io/druid/indexing/common/index/{EventReceivingChatHandlerProvider.java => ServiceAnnouncingChatHandlerProvider.java} (93%) diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java b/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java index d52ea38b567..f10ed444b9a 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java @@ -20,7 +20,7 @@ package io.druid.indexing.common.index; /** - * Objects that can be registered with a {@link EventReceivingChatHandlerProvider} and provide http endpoints for indexing-related + * Objects that can be registered with a {@link ServiceAnnouncingChatHandlerProvider} and provide http endpoints for indexing-related * objects. This interface is empty because it only exists to signal intent. The actual http endpoints are provided * through JAX-RS annotations on the {@link ChatHandler} objects. */ diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java b/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java index 49e74df0717..01af5c3cc62 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java @@ -25,8 +25,6 @@ import com.google.common.base.Optional; */ public interface ChatHandlerProvider { - public String getType(); - public void register(final String key, ChatHandler handler); public void unregister(final String key); diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java b/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java index 8e66fd8f357..168d3e9a7b3 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java @@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit; /** * Builds firehoses that accept events through the {@link EventReceiver} interface. Can also register these - * firehoses with an {@link EventReceivingChatHandlerProvider}. + * firehoses with an {@link ServiceAnnouncingChatHandlerProvider}. */ @JsonTypeName("receiver") public class EventReceiverFirehoseFactory implements FirehoseFactory @@ -84,8 +84,9 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory final EventReceiverFirehose firehose = new EventReceiverFirehose(); if (chatHandlerProvider.isPresent()) { - log.info("Found chathandler with type[%s]", chatHandlerProvider.get().getType()); + log.info("Found chathandler of class[%s]", chatHandlerProvider.get().getClass().getName()); chatHandlerProvider.get().register(serviceName, firehose); + chatHandlerProvider.get().register(serviceName.replaceAll(".*:", ""), firehose); // rolf } else { log.info("No chathandler detected"); } diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java b/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java index b0b2d9069a7..e75cce88e28 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java @@ -25,12 +25,6 @@ import com.google.common.base.Optional; */ public class NoopChatHandlerProvider implements ChatHandlerProvider { - @Override - public String getType() - { - return "noop"; - } - @Override public void register(String key, ChatHandler handler) { diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceivingChatHandlerProvider.java b/indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java similarity index 93% rename from indexing-service/src/main/java/io/druid/indexing/common/index/EventReceivingChatHandlerProvider.java rename to indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java index 93bdd2a53c6..013cd4dfe21 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceivingChatHandlerProvider.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java @@ -35,16 +35,16 @@ import java.util.concurrent.ConcurrentMap; * allows anyone with a reference to this object to obtain a particular {@link ChatHandler}. An embedded * {@link ServiceAnnouncer} will be used to advertise handlers on this host. */ -public class EventReceivingChatHandlerProvider implements ChatHandlerProvider +public class ServiceAnnouncingChatHandlerProvider implements ChatHandlerProvider { - private static final Logger log = new Logger(EventReceivingChatHandlerProvider.class); + private static final Logger log = new Logger(ServiceAnnouncingChatHandlerProvider.class); private final DruidNode node; private final ServiceAnnouncer serviceAnnouncer; private final ConcurrentMap handlers; @Inject - public EventReceivingChatHandlerProvider( + public ServiceAnnouncingChatHandlerProvider( @Self DruidNode node, ServiceAnnouncer serviceAnnouncer ) diff --git a/services/src/main/java/io/druid/cli/CliPeon.java b/services/src/main/java/io/druid/cli/CliPeon.java index aea4bfe881c..e255e160b01 100644 --- a/services/src/main/java/io/druid/cli/CliPeon.java +++ b/services/src/main/java/io/druid/cli/CliPeon.java @@ -45,8 +45,9 @@ import io.druid.indexing.common.actions.RemoteTaskActionClientFactory; import io.druid.indexing.common.actions.TaskActionClientFactory; import io.druid.indexing.common.config.TaskConfig; import io.druid.indexing.common.index.ChatHandlerProvider; -import io.druid.indexing.common.index.EventReceivingChatHandlerProvider; +import io.druid.indexing.common.index.ServiceAnnouncingChatHandlerProvider; import io.druid.indexing.common.index.NoopChatHandlerProvider; +import io.druid.indexing.common.index.ServiceAnnouncingChatHandlerProvider; import io.druid.indexing.coordinator.TaskRunner; import io.druid.indexing.coordinator.ThreadPoolTaskRunner; import io.druid.indexing.worker.executor.ChatHandlerResource; @@ -104,8 +105,8 @@ public class CliPeon extends GuiceRunnable final MapBinder handlerProviderBinder = PolyBind.optionBinder( binder, Key.get(ChatHandlerProvider.class) ); - handlerProviderBinder.addBinding("receiver") - .to(EventReceivingChatHandlerProvider.class).in(LazySingleton.class); + handlerProviderBinder.addBinding("announce") + .to(ServiceAnnouncingChatHandlerProvider.class).in(LazySingleton.class); handlerProviderBinder.addBinding("noop") .to(NoopChatHandlerProvider.class).in(LazySingleton.class);