From 1843316db60c3f130e73cfa36f090e4613baefaf Mon Sep 17 00:00:00 2001 From: fjy Date: Thu, 3 Apr 2014 20:46:36 -0700 Subject: [PATCH 1/6] commonalize event receiver firehose --- .../io/druid/guice/IndexingServiceFirehoseModule.java | 2 +- .../indexing/worker/executor/ChatHandlerResource.java | 4 ++-- server/src/main/java/io/druid/guice/FirehoseModule.java | 4 +++- .../io/druid/segment/realtime/firehose}/ChatHandler.java | 2 +- .../segment/realtime/firehose}/ChatHandlerProvider.java | 2 +- .../druid/segment/realtime/firehose}/EventReceiver.java | 2 +- .../realtime/firehose}/EventReceiverFirehoseFactory.java | 9 +++++---- .../realtime/firehose}/NoopChatHandlerProvider.java | 2 +- .../firehose}/ServiceAnnouncingChatHandlerProvider.java | 2 +- .../src/main/java/io/druid/cli/CliMiddleManager.java | 2 +- services/src/main/java/io/druid/cli/CliOverlord.java | 2 +- services/src/main/java/io/druid/cli/CliPeon.java | 6 +++--- 12 files changed, 21 insertions(+), 18 deletions(-) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/ChatHandler.java (96%) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/ChatHandlerProvider.java (96%) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/EventReceiver.java (95%) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/EventReceiverFirehoseFactory.java (93%) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/NoopChatHandlerProvider.java (96%) rename {indexing-service/src/main/java/io/druid/indexing/common/index => server/src/main/java/io/druid/segment/realtime/firehose}/ServiceAnnouncingChatHandlerProvider.java (98%) diff --git a/indexing-service/src/main/java/io/druid/guice/IndexingServiceFirehoseModule.java b/indexing-service/src/main/java/io/druid/guice/IndexingServiceFirehoseModule.java index ed9f628452c..b8609453f3d 100644 --- a/indexing-service/src/main/java/io/druid/guice/IndexingServiceFirehoseModule.java +++ b/indexing-service/src/main/java/io/druid/guice/IndexingServiceFirehoseModule.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; -import io.druid.indexing.common.index.EventReceiverFirehoseFactory; +import io.druid.segment.realtime.firehose.EventReceiverFirehoseFactory; import io.druid.initialization.DruidModule; import java.util.List; diff --git a/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java b/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java index c52745c5d58..e218602aff5 100644 --- a/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java +++ b/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java @@ -21,8 +21,8 @@ package io.druid.indexing.worker.executor; import com.google.common.base.Optional; import com.google.inject.Inject; -import io.druid.indexing.common.index.ChatHandler; -import io.druid.indexing.common.index.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.ChatHandler; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; import javax.ws.rs.Path; import javax.ws.rs.PathParam; diff --git a/server/src/main/java/io/druid/guice/FirehoseModule.java b/server/src/main/java/io/druid/guice/FirehoseModule.java index aacc217e208..5e9530c5534 100644 --- a/server/src/main/java/io/druid/guice/FirehoseModule.java +++ b/server/src/main/java/io/druid/guice/FirehoseModule.java @@ -26,6 +26,7 @@ import com.google.inject.Binder; import io.druid.data.input.ProtoBufInputRowParser; import io.druid.initialization.DruidModule; import io.druid.segment.realtime.firehose.ClippedFirehoseFactory; +import io.druid.segment.realtime.firehose.EventReceiverFirehoseFactory; import io.druid.segment.realtime.firehose.IrcFirehoseFactory; import io.druid.segment.realtime.firehose.LocalFirehoseFactory; import io.druid.segment.realtime.firehose.TimedShutoffFirehoseFactory; @@ -52,7 +53,8 @@ public class FirehoseModule implements DruidModule new NamedType(TimedShutoffFirehoseFactory.class, "timed"), new NamedType(IrcFirehoseFactory.class, "irc"), new NamedType(LocalFirehoseFactory.class, "local"), - new NamedType(ProtoBufInputRowParser.class, "protobuf") + new NamedType(ProtoBufInputRowParser.class, "protobuf"), + new NamedType(EventReceiverFirehoseFactory.class, "receiver") ) ); } diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandler.java similarity index 96% rename from indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java rename to server/src/main/java/io/druid/segment/realtime/firehose/ChatHandler.java index f10ed444b9a..898bc5cb25e 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandler.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandler.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; /** * Objects that can be registered with a {@link ServiceAnnouncingChatHandlerProvider} and provide http endpoints for indexing-related diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerProvider.java similarity index 96% rename from indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java rename to server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerProvider.java index 01af5c3cc62..f8ba66af1af 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/ChatHandlerProvider.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerProvider.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; import com.google.common.base.Optional; diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiver.java b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiver.java similarity index 95% rename from indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiver.java rename to server/src/main/java/io/druid/segment/realtime/firehose/EventReceiver.java index 9454fa7c2f4..491f7d37f7a 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiver.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiver.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; import java.util.Collection; import java.util.Map; diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java similarity index 93% rename from indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java rename to server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java index 31716232207..da8bca155ba 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonCreator; @@ -33,6 +33,8 @@ import io.druid.data.input.Firehose; import io.druid.data.input.FirehoseFactory; import io.druid.data.input.InputRow; import io.druid.data.input.impl.MapInputRowParser; +import io.druid.segment.realtime.firehose.ChatHandler; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -48,10 +50,9 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; /** - * Builds firehoses that accept events through the {@link EventReceiver} interface. Can also register these - * firehoses with an {@link ServiceAnnouncingChatHandlerProvider}. + * Builds firehoses that accept events through the {@link io.druid.segment.realtime.firehose.EventReceiver} interface. Can also register these + * firehoses with an {@link io.druid.segment.realtime.firehose.ServiceAnnouncingChatHandlerProvider}. */ -@JsonTypeName("receiver") public class EventReceiverFirehoseFactory implements FirehoseFactory { private static final EmittingLogger log = new EmittingLogger(EventReceiverFirehoseFactory.class); diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java b/server/src/main/java/io/druid/segment/realtime/firehose/NoopChatHandlerProvider.java similarity index 96% rename from indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java rename to server/src/main/java/io/druid/segment/realtime/firehose/NoopChatHandlerProvider.java index e75cce88e28..ae4bd3cbb95 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/NoopChatHandlerProvider.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/NoopChatHandlerProvider.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; import com.google.common.base.Optional; diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java b/server/src/main/java/io/druid/segment/realtime/firehose/ServiceAnnouncingChatHandlerProvider.java similarity index 98% rename from indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java rename to server/src/main/java/io/druid/segment/realtime/firehose/ServiceAnnouncingChatHandlerProvider.java index 5b24ac94943..c96e47ccb31 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/ServiceAnnouncingChatHandlerProvider.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/ServiceAnnouncingChatHandlerProvider.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package io.druid.indexing.common.index; +package io.druid.segment.realtime.firehose; import com.google.common.base.Optional; import com.google.common.collect.Maps; diff --git a/services/src/main/java/io/druid/cli/CliMiddleManager.java b/services/src/main/java/io/druid/cli/CliMiddleManager.java index d0867b42aa6..e3356012358 100644 --- a/services/src/main/java/io/druid/cli/CliMiddleManager.java +++ b/services/src/main/java/io/druid/cli/CliMiddleManager.java @@ -35,7 +35,7 @@ import io.druid.guice.LazySingleton; import io.druid.guice.LifecycleModule; import io.druid.guice.ManageLifecycle; import io.druid.guice.annotations.Self; -import io.druid.indexing.common.index.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; import io.druid.indexing.overlord.ForkingTaskRunner; import io.druid.indexing.overlord.TaskRunner; import io.druid.indexing.worker.Worker; diff --git a/services/src/main/java/io/druid/cli/CliOverlord.java b/services/src/main/java/io/druid/cli/CliOverlord.java index e7208224033..cbdbcb89b1f 100644 --- a/services/src/main/java/io/druid/cli/CliOverlord.java +++ b/services/src/main/java/io/druid/cli/CliOverlord.java @@ -45,7 +45,7 @@ import io.druid.indexing.common.actions.LocalTaskActionClientFactory; import io.druid.indexing.common.actions.TaskActionClientFactory; import io.druid.indexing.common.actions.TaskActionToolbox; import io.druid.indexing.common.config.TaskStorageConfig; -import io.druid.indexing.common.index.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; import io.druid.indexing.common.tasklogs.SwitchingTaskLogStreamer; import io.druid.indexing.common.tasklogs.TaskRunnerTaskLogStreamer; import io.druid.indexing.overlord.DbTaskStorage; diff --git a/services/src/main/java/io/druid/cli/CliPeon.java b/services/src/main/java/io/druid/cli/CliPeon.java index 7204e5fc63a..36812948900 100644 --- a/services/src/main/java/io/druid/cli/CliPeon.java +++ b/services/src/main/java/io/druid/cli/CliPeon.java @@ -48,9 +48,9 @@ import io.druid.indexing.common.actions.RemoteTaskActionClientFactory; import io.druid.indexing.common.actions.TaskActionClientFactory; import io.druid.indexing.common.actions.TaskActionToolbox; import io.druid.indexing.common.config.TaskConfig; -import io.druid.indexing.common.index.ChatHandlerProvider; -import io.druid.indexing.common.index.NoopChatHandlerProvider; -import io.druid.indexing.common.index.ServiceAnnouncingChatHandlerProvider; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.NoopChatHandlerProvider; +import io.druid.segment.realtime.firehose.ServiceAnnouncingChatHandlerProvider; import io.druid.indexing.overlord.HeapMemoryTaskStorage; import io.druid.indexing.overlord.IndexerDBCoordinator; import io.druid.indexing.overlord.TaskRunner; From c6f4b344cbf6585057af61945893e3959f3e72c6 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Tue, 8 Apr 2014 11:56:23 +0530 Subject: [PATCH 2/6] add bindings for chat handler provider --- .../java/io/druid/guice/RealtimeModule.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/src/main/java/io/druid/guice/RealtimeModule.java b/services/src/main/java/io/druid/guice/RealtimeModule.java index 276f850049a..ae4ca1319df 100644 --- a/services/src/main/java/io/druid/guice/RealtimeModule.java +++ b/services/src/main/java/io/druid/guice/RealtimeModule.java @@ -31,6 +31,9 @@ import io.druid.segment.realtime.FireDepartment; import io.druid.segment.realtime.NoopSegmentPublisher; import io.druid.segment.realtime.RealtimeManager; import io.druid.segment.realtime.SegmentPublisher; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.NoopChatHandlerProvider; +import io.druid.segment.realtime.firehose.ServiceAnnouncingChatHandlerProvider; import io.druid.server.QueryResource; import io.druid.server.initialization.JettyServerInitializer; import org.eclipse.jetty.server.Server; @@ -57,6 +60,20 @@ public class RealtimeModule implements Module publisherBinder.addBinding("noop").to(NoopSegmentPublisher.class); binder.bind(DbSegmentPublisher.class).in(LazySingleton.class); + PolyBind.createChoice( + binder, + "druid.realtime.chathandler.type", + Key.get(ChatHandlerProvider.class), + Key.get(NoopChatHandlerProvider.class) + ); + final MapBinder handlerProviderBinder = PolyBind.optionBinder( + binder, Key.get(ChatHandlerProvider.class) + ); + handlerProviderBinder.addBinding("announce") + .to(ServiceAnnouncingChatHandlerProvider.class).in(LazySingleton.class); + handlerProviderBinder.addBinding("noop") + .to(NoopChatHandlerProvider.class).in(LazySingleton.class); + JsonConfigProvider.bind(binder, "druid.realtime", RealtimeManagerConfig.class); binder.bind(new TypeLiteral>(){}) .toProvider(FireDepartmentsProvider.class) From ea8b2dffd599c5e9704a5ef753b94ffaa74fba07 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Wed, 9 Apr 2014 14:25:18 +0530 Subject: [PATCH 3/6] Add chatHandlerResource --- .../firehose/ChatHandlerResource.java | 55 +++++++++++++++++++ .../src/main/java/io/druid/cli/CliPeon.java | 2 +- .../java/io/druid/guice/RealtimeModule.java | 2 + 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerResource.java diff --git a/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerResource.java b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerResource.java new file mode 100644 index 00000000000..a1d26b56dfd --- /dev/null +++ b/server/src/main/java/io/druid/segment/realtime/firehose/ChatHandlerResource.java @@ -0,0 +1,55 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012, 2013 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.segment.realtime.firehose; + +import com.google.common.base.Optional; +import com.google.inject.Inject; +import io.druid.segment.realtime.firehose.ChatHandler; +import io.druid.segment.realtime.firehose.ChatHandlerProvider; + +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +@Path("/druid/worker/v1") +public class ChatHandlerResource +{ + private final ChatHandlerProvider handlers; + + @Inject + public ChatHandlerResource(ChatHandlerProvider handlers) + { + this.handlers = handlers; + } + + @Path("/chat/{id}") + public Object doTaskChat( + @PathParam("id") String handlerId + ) + { + final Optional handler = handlers.get(handlerId); + + if (handler.isPresent()) { + return handler.get(); + } else { + return Response.status(Response.Status.NOT_FOUND).build(); + } + } +} diff --git a/services/src/main/java/io/druid/cli/CliPeon.java b/services/src/main/java/io/druid/cli/CliPeon.java index 36812948900..d4eb0228c9a 100644 --- a/services/src/main/java/io/druid/cli/CliPeon.java +++ b/services/src/main/java/io/druid/cli/CliPeon.java @@ -56,7 +56,7 @@ import io.druid.indexing.overlord.IndexerDBCoordinator; import io.druid.indexing.overlord.TaskRunner; import io.druid.indexing.overlord.TaskStorage; import io.druid.indexing.overlord.ThreadPoolTaskRunner; -import io.druid.indexing.worker.executor.ChatHandlerResource; +import io.druid.segment.realtime.firehose.ChatHandlerResource; import io.druid.indexing.worker.executor.ExecutorLifecycle; import io.druid.indexing.worker.executor.ExecutorLifecycleConfig; import io.druid.query.QuerySegmentWalker; diff --git a/services/src/main/java/io/druid/guice/RealtimeModule.java b/services/src/main/java/io/druid/guice/RealtimeModule.java index ae4ca1319df..7bcce15823a 100644 --- a/services/src/main/java/io/druid/guice/RealtimeModule.java +++ b/services/src/main/java/io/druid/guice/RealtimeModule.java @@ -32,6 +32,7 @@ import io.druid.segment.realtime.NoopSegmentPublisher; import io.druid.segment.realtime.RealtimeManager; import io.druid.segment.realtime.SegmentPublisher; import io.druid.segment.realtime.firehose.ChatHandlerProvider; +import io.druid.segment.realtime.firehose.ChatHandlerResource; import io.druid.segment.realtime.firehose.NoopChatHandlerProvider; import io.druid.segment.realtime.firehose.ServiceAnnouncingChatHandlerProvider; import io.druid.server.QueryResource; @@ -83,6 +84,7 @@ public class RealtimeModule implements Module binder.bind(NodeTypeConfig.class).toInstance(new NodeTypeConfig("realtime")); binder.bind(JettyServerInitializer.class).to(QueryJettyServerInitializer.class).in(LazySingleton.class); Jerseys.addResource(binder, QueryResource.class); + Jerseys.addResource(binder, ChatHandlerResource.class); LifecycleModule.register(binder, QueryResource.class); LifecycleModule.register(binder, Server.class); From 0c95c0b689acf31482d90da182e51087129d1d9e Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Wed, 9 Apr 2014 14:25:31 +0530 Subject: [PATCH 4/6] moved file --- .../worker/executor/ChatHandlerResource.java | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java diff --git a/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java b/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java deleted file mode 100644 index e218602aff5..00000000000 --- a/indexing-service/src/main/java/io/druid/indexing/worker/executor/ChatHandlerResource.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Druid - a distributed column store. - * Copyright (C) 2012, 2013 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.indexing.worker.executor; - -import com.google.common.base.Optional; -import com.google.inject.Inject; -import io.druid.segment.realtime.firehose.ChatHandler; -import io.druid.segment.realtime.firehose.ChatHandlerProvider; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -@Path("/druid/worker/v1") -public class ChatHandlerResource -{ - private final ChatHandlerProvider handlers; - - @Inject - public ChatHandlerResource(ChatHandlerProvider handlers) - { - this.handlers = handlers; - } - - @Path("/chat/{id}") - public Object doTaskChat( - @PathParam("id") String handlerId - ) - { - final Optional handler = handlers.get(handlerId); - - if (handler.isPresent()) { - return handler.get(); - } else { - return Response.status(Response.Status.NOT_FOUND).build(); - } - } -} From cd1c1d261565446ae33c21d235e406b58abe4deb Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Tue, 15 Apr 2014 23:32:54 +0530 Subject: [PATCH 5/6] fix casing issue when parsing event --- .../realtime/firehose/EventReceiverFirehoseFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java index da8bca155ba..858a1aaf84c 100644 --- a/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java +++ b/server/src/main/java/io/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java @@ -32,6 +32,7 @@ import com.metamx.emitter.EmittingLogger; import io.druid.data.input.Firehose; import io.druid.data.input.FirehoseFactory; import io.druid.data.input.InputRow; +import io.druid.data.input.Rows; import io.druid.data.input.impl.MapInputRowParser; import io.druid.segment.realtime.firehose.ChatHandler; import io.druid.segment.realtime.firehose.ChatHandlerProvider; @@ -139,7 +140,8 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory final List rows = Lists.newArrayList(); for (final Map event : events) { // Might throw an exception. We'd like that to happen now, instead of while adding to the row buffer. - rows.add(parser.parse(event)); + InputRow row = parser.parse(event); + rows.add(Rows.toCaseInsensitiveInputRow(row,row.getDimensions())); } try { From a33c2f7880d30ca59a7b83c2bf7153e6b355226b Mon Sep 17 00:00:00 2001 From: fjy Date: Fri, 25 Apr 2014 14:20:02 -0700 Subject: [PATCH 6/6] clean up firehose module and introduce parsers module --- .../java/io/druid/guice/FirehoseModule.java | 2 - .../java/io/druid/guice/ParsersModule.java | 51 +++++++++++++++++++ .../druid/initialization/Initialization.java | 4 +- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 server/src/main/java/io/druid/guice/ParsersModule.java diff --git a/server/src/main/java/io/druid/guice/FirehoseModule.java b/server/src/main/java/io/druid/guice/FirehoseModule.java index 5e9530c5534..ac10c297dd4 100644 --- a/server/src/main/java/io/druid/guice/FirehoseModule.java +++ b/server/src/main/java/io/druid/guice/FirehoseModule.java @@ -53,10 +53,8 @@ public class FirehoseModule implements DruidModule new NamedType(TimedShutoffFirehoseFactory.class, "timed"), new NamedType(IrcFirehoseFactory.class, "irc"), new NamedType(LocalFirehoseFactory.class, "local"), - new NamedType(ProtoBufInputRowParser.class, "protobuf"), new NamedType(EventReceiverFirehoseFactory.class, "receiver") ) ); } - } diff --git a/server/src/main/java/io/druid/guice/ParsersModule.java b/server/src/main/java/io/druid/guice/ParsersModule.java new file mode 100644 index 00000000000..7c9d76c30e1 --- /dev/null +++ b/server/src/main/java/io/druid/guice/ParsersModule.java @@ -0,0 +1,51 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012, 2013 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.guice; + +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.google.inject.Binder; +import io.druid.data.input.ProtoBufInputRowParser; +import io.druid.initialization.DruidModule; + +import java.util.Arrays; +import java.util.List; + +/** + */ +public class ParsersModule implements DruidModule +{ + @Override + public void configure(Binder binder) + { + } + + @Override + public List getJacksonModules() + { + return Arrays.asList( + new SimpleModule("ParsersModule") + .registerSubtypes( + new NamedType(ProtoBufInputRowParser.class, "protobuf") + ) + ); + } +} diff --git a/server/src/main/java/io/druid/initialization/Initialization.java b/server/src/main/java/io/druid/initialization/Initialization.java index 66748fdf5d0..292aa3c95cf 100644 --- a/server/src/main/java/io/druid/initialization/Initialization.java +++ b/server/src/main/java/io/druid/initialization/Initialization.java @@ -47,6 +47,7 @@ import io.druid.guice.JacksonConfigManagerModule; import io.druid.guice.JsonConfigProvider; import io.druid.guice.LifecycleModule; import io.druid.guice.LocalDataStorageDruidModule; +import io.druid.guice.ParsersModule; import io.druid.guice.QueryRunnerFactoryModule; import io.druid.guice.QueryableModule; import io.druid.guice.ServerModule; @@ -327,7 +328,8 @@ public class Initialization new JacksonConfigManagerModule(), new IndexingServiceDiscoveryModule(), new LocalDataStorageDruidModule(), - new FirehoseModule() + new FirehoseModule(), + new ParsersModule() ); ModuleList actualModules = new ModuleList(baseInjector);