From b95d9498ca59300da02ae7b5c15977d023aa6864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 21 Aug 2013 13:37:56 -0700 Subject: [PATCH 1/3] add version information to status --- .../com/metamx/druid/http/StatusResource.java | 98 ++++++++++++++++--- 1 file changed, 85 insertions(+), 13 deletions(-) diff --git a/client/src/main/java/com/metamx/druid/http/StatusResource.java b/client/src/main/java/com/metamx/druid/http/StatusResource.java index 2c4aed29614..ebe2f0e855a 100644 --- a/client/src/main/java/com/metamx/druid/http/StatusResource.java +++ b/client/src/main/java/com/metamx/druid/http/StatusResource.java @@ -1,9 +1,29 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 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 com.metamx.druid.http; +import com.fasterxml.jackson.annotation.JsonProperty; + import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; /** */ @@ -11,21 +31,73 @@ import javax.ws.rs.core.Response; public class StatusResource { @GET - @Produces("text/plain") - public Response doGet() + @Produces("application/json") + public Status doGet() { - StringBuffer buf = new StringBuffer(); + return new Status( + StatusResource.class.getPackage().getImplementationVersion(), + new Memory(Runtime.getRuntime()) + ); + } - Runtime runtime = Runtime.getRuntime(); - long maxMemory = runtime.maxMemory(); - long totalMemory = runtime.totalMemory(); - long freeMemory = runtime.freeMemory(); + public static class Status { + final String version; + final Memory memory; - buf.append(String.format("Max Memory:\t%,18d\t%1$d%n", maxMemory)); - buf.append(String.format("Total Memory:\t%,18d\t%1$d%n", totalMemory)); - buf.append(String.format("Free Memory:\t%,18d\t%1$d%n", freeMemory)); - buf.append(String.format("Used Memory:\t%,18d\t%1$d%n", totalMemory - freeMemory)); + public Status(String version, Memory memory) + { + this.version = version; + this.memory = memory; + } - return Response.ok(buf.toString()).build(); + @JsonProperty + public String getVersion() + { + return version; + } + + @JsonProperty + public Memory getMemory() + { + return memory; + } + } + + public static class Memory { + final long maxMemory; + final long totalMemory; + final long freeMemory; + final long usedMemory; + + public Memory(Runtime runtime) { + maxMemory = runtime.maxMemory(); + totalMemory = runtime.totalMemory(); + freeMemory = runtime.freeMemory(); + usedMemory = totalMemory - freeMemory; + } + + @JsonProperty + public long getMaxMemory() + { + return maxMemory; + } + + @JsonProperty + public long getTotalMemory() + { + return totalMemory; + } + + @JsonProperty + public long getFreeMemory() + { + return freeMemory; + } + + @JsonProperty + public long getUsedMemory() + { + return usedMemory; + } } } From d5b3f7103359587ad60b5f71b31454f6e6dc71ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 21 Aug 2013 13:45:39 -0700 Subject: [PATCH 2/3] replace StatusServlet with StatusResource --- .../com/metamx/druid/http/StatusServlet.java | 57 ------------------- .../http/IndexerCoordinatorNode.java | 3 +- .../http/IndexerCoordinatorServletModule.java | 2 + .../worker/executor/ExecutorNode.java | 3 +- .../executor/ExecutorServletModule.java | 2 + .../indexing/worker/http/WorkerNode.java | 3 +- .../worker/http/WorkerServletModule.java | 2 + .../metamx/druid/realtime/RealtimeNode.java | 12 +++- .../druid/realtime/RealtimeServletModule.java | 37 ++++++++++++ 9 files changed, 56 insertions(+), 65 deletions(-) delete mode 100644 client/src/main/java/com/metamx/druid/http/StatusServlet.java create mode 100644 realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java diff --git a/client/src/main/java/com/metamx/druid/http/StatusServlet.java b/client/src/main/java/com/metamx/druid/http/StatusServlet.java deleted file mode 100644 index 95a40c543b8..00000000000 --- a/client/src/main/java/com/metamx/druid/http/StatusServlet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Druid - a distributed column store. - * Copyright (C) 2012 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 com.metamx.druid.http; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -/** - */ -public class StatusServlet extends HttpServlet -{ - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException - { - ByteArrayOutputStream retVal = new ByteArrayOutputStream(); - PrintWriter out = new PrintWriter(new OutputStreamWriter(retVal)); - - Runtime runtime = Runtime.getRuntime(); - long maxMemory = runtime.maxMemory(); - long totalMemory = runtime.totalMemory(); - long freeMemory = runtime.freeMemory(); - - out.printf("Max Memory:\t%,18d\t%1$d%n", maxMemory); - out.printf("Total Memory:\t%,18d\t%1$d%n", totalMemory); - out.printf("Free Memory:\t%,18d\t%1$d%n", freeMemory); - out.printf("Used Memory:\t%,18d\t%1$d%n", totalMemory - freeMemory); - - out.flush(); - - resp.setStatus(HttpServletResponse.SC_OK); - resp.setContentType("text/plain"); - resp.getOutputStream().write(retVal.toByteArray()); - } -} diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java b/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java index 61191da91e5..bf278590f48 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java @@ -56,7 +56,6 @@ import com.metamx.druid.db.DbTablesConfig; import com.metamx.druid.http.GuiceServletConfig; import com.metamx.druid.http.RedirectFilter; import com.metamx.druid.http.RedirectInfo; -import com.metamx.druid.http.StatusServlet; import com.metamx.druid.indexing.common.actions.LocalTaskActionClientFactory; import com.metamx.druid.indexing.common.actions.TaskActionClientFactory; import com.metamx.druid.indexing.common.actions.TaskActionToolbox; @@ -321,7 +320,6 @@ public class IndexerCoordinatorNode extends QueryableNode ); final ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); - root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); root.addEventListener(new GuiceServletConfig(injector)); + root.addFilter(GuiceFilter.class, "/status", null); root.addFilter(GuiceFilter.class, "/druid/worker/v1/*", null); root.addServlet( new ServletHolder( diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java index 1350094420c..d10d136d9c2 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java @@ -3,6 +3,7 @@ package com.metamx.druid.indexing.worker.executor; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import com.google.inject.Provides; +import com.metamx.druid.http.StatusResource; import com.metamx.druid.indexing.common.index.ChatHandlerProvider; import com.sun.jersey.guice.JerseyServletModule; import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; @@ -26,6 +27,7 @@ public class ExecutorServletModule extends JerseyServletModule @Override protected void configureServlets() { + bind(StatusResource.class); bind(ChatHandlerResource.class); bind(ObjectMapper.class).toInstance(jsonMapper); bind(ChatHandlerProvider.class).toInstance(receivers); diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java index 90890ca7a37..767823301be 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java @@ -36,7 +36,6 @@ import com.metamx.common.lifecycle.LifecycleStop; import com.metamx.druid.QueryableNode; import com.metamx.druid.curator.CuratorConfig; import com.metamx.druid.http.GuiceServletConfig; -import com.metamx.druid.http.StatusServlet; import com.metamx.druid.indexing.common.config.IndexerZkConfig; import com.metamx.druid.indexing.common.config.TaskLogConfig; import com.metamx.druid.indexing.common.index.EventReceiverFirehoseFactory; @@ -205,9 +204,9 @@ public class WorkerNode extends QueryableNode ); final ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); - root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); root.addEventListener(new GuiceServletConfig(injector)); + root.addFilter(GuiceFilter.class, "/status", null); root.addFilter(GuiceFilter.class, "/druid/worker/v1/*", null); } diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java index b135af7dcb6..1fec950af48 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java @@ -22,6 +22,7 @@ package com.metamx.druid.indexing.worker.http; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import com.google.inject.Provides; +import com.metamx.druid.http.StatusResource; import com.metamx.druid.indexing.coordinator.ForkingTaskRunner; import com.metamx.emitter.service.ServiceEmitter; import com.sun.jersey.guice.JerseyServletModule; @@ -51,6 +52,7 @@ public class WorkerServletModule extends JerseyServletModule @Override protected void configureServlets() { + bind(StatusResource.class); bind(WorkerResource.class); bind(ObjectMapper.class).toInstance(jsonMapper); bind(ServiceEmitter.class).toInstance(emitter); diff --git a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java index 4357f39c2b5..efc599db89d 100644 --- a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java +++ b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java @@ -29,6 +29,9 @@ import com.google.common.base.Preconditions; import com.google.common.base.Suppliers; import com.google.common.base.Throwables; import com.google.common.collect.Maps; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.servlet.GuiceFilter; import com.metamx.common.ISE; import com.metamx.common.config.Config; import com.metamx.common.lifecycle.Lifecycle; @@ -38,8 +41,8 @@ import com.metamx.common.logger.Logger; import com.metamx.druid.BaseServerNode; import com.metamx.druid.db.DbConnector; import com.metamx.druid.db.DbConnectorConfig; +import com.metamx.druid.http.GuiceServletConfig; import com.metamx.druid.http.QueryServlet; -import com.metamx.druid.http.StatusServlet; import com.metamx.druid.initialization.Initialization; import com.metamx.druid.initialization.ServerInit; import com.metamx.druid.jackson.DefaultObjectMapper; @@ -148,8 +151,13 @@ public class RealtimeNode extends BaseServerNode startMonitoring(monitors); + final Injector injector = Guice.createInjector( + new RealtimeServletModule(getJsonMapper()) + ); + final ServletContextHandler root = new ServletContextHandler(getServer(), "/", ServletContextHandler.SESSIONS); - root.addServlet(new ServletHolder(new StatusServlet()), "/status"); + root.addEventListener(new GuiceServletConfig(injector)); + root.addFilter(GuiceFilter.class, "/status", null); root.addServlet( new ServletHolder( new QueryServlet(getJsonMapper(), getSmileMapper(), realtimeManager, emitter, getRequestLogger()) diff --git a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java new file mode 100644 index 00000000000..4419e69b0fe --- /dev/null +++ b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java @@ -0,0 +1,37 @@ +package com.metamx.druid.realtime; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import com.google.inject.Provides; +import com.metamx.druid.http.StatusResource; +import com.sun.jersey.guice.JerseyServletModule; +import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; + +import javax.inject.Singleton; + +public class RealtimeServletModule extends JerseyServletModule +{ + private final ObjectMapper jsonMapper; + + public RealtimeServletModule(ObjectMapper jsonMapper) + { + this.jsonMapper = jsonMapper; + } + + @Override + protected void configureServlets() + { + bind(StatusResource.class); + + serve("/*").with(GuiceContainer.class); + } + + @Provides + @Singleton + public JacksonJsonProvider getJacksonJsonProvider() + { + final JacksonJsonProvider provider = new JacksonJsonProvider(); + provider.setMapper(jsonMapper); + return provider; + } +} From 3adcaab1ef4bb221b9dbae86a3d8548b9d2f3a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 21 Aug 2013 13:58:02 -0700 Subject: [PATCH 3/3] Eric said I did too much work This reverts commit d5b3f7103359587ad60b5f71b31454f6e6dc71ba. --- .../com/metamx/druid/http/StatusServlet.java | 57 +++++++++++++++++++ .../http/IndexerCoordinatorNode.java | 3 +- .../http/IndexerCoordinatorServletModule.java | 2 - .../worker/executor/ExecutorNode.java | 3 +- .../executor/ExecutorServletModule.java | 2 - .../indexing/worker/http/WorkerNode.java | 3 +- .../worker/http/WorkerServletModule.java | 2 - .../metamx/druid/realtime/RealtimeNode.java | 12 +--- .../druid/realtime/RealtimeServletModule.java | 37 ------------ 9 files changed, 65 insertions(+), 56 deletions(-) create mode 100644 client/src/main/java/com/metamx/druid/http/StatusServlet.java delete mode 100644 realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java diff --git a/client/src/main/java/com/metamx/druid/http/StatusServlet.java b/client/src/main/java/com/metamx/druid/http/StatusServlet.java new file mode 100644 index 00000000000..95a40c543b8 --- /dev/null +++ b/client/src/main/java/com/metamx/druid/http/StatusServlet.java @@ -0,0 +1,57 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012 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 com.metamx.druid.http; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; + +/** + */ +public class StatusServlet extends HttpServlet +{ + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + ByteArrayOutputStream retVal = new ByteArrayOutputStream(); + PrintWriter out = new PrintWriter(new OutputStreamWriter(retVal)); + + Runtime runtime = Runtime.getRuntime(); + long maxMemory = runtime.maxMemory(); + long totalMemory = runtime.totalMemory(); + long freeMemory = runtime.freeMemory(); + + out.printf("Max Memory:\t%,18d\t%1$d%n", maxMemory); + out.printf("Total Memory:\t%,18d\t%1$d%n", totalMemory); + out.printf("Free Memory:\t%,18d\t%1$d%n", freeMemory); + out.printf("Used Memory:\t%,18d\t%1$d%n", totalMemory - freeMemory); + + out.flush(); + + resp.setStatus(HttpServletResponse.SC_OK); + resp.setContentType("text/plain"); + resp.getOutputStream().write(retVal.toByteArray()); + } +} diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java b/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java index bf278590f48..61191da91e5 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/coordinator/http/IndexerCoordinatorNode.java @@ -56,6 +56,7 @@ import com.metamx.druid.db.DbTablesConfig; import com.metamx.druid.http.GuiceServletConfig; import com.metamx.druid.http.RedirectFilter; import com.metamx.druid.http.RedirectInfo; +import com.metamx.druid.http.StatusServlet; import com.metamx.druid.indexing.common.actions.LocalTaskActionClientFactory; import com.metamx.druid.indexing.common.actions.TaskActionClientFactory; import com.metamx.druid.indexing.common.actions.TaskActionToolbox; @@ -320,6 +321,7 @@ public class IndexerCoordinatorNode extends QueryableNode ); final ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); + root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); root.addEventListener(new GuiceServletConfig(injector)); - root.addFilter(GuiceFilter.class, "/status", null); root.addFilter(GuiceFilter.class, "/druid/worker/v1/*", null); root.addServlet( new ServletHolder( diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java index d10d136d9c2..1350094420c 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/executor/ExecutorServletModule.java @@ -3,7 +3,6 @@ package com.metamx.druid.indexing.worker.executor; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import com.google.inject.Provides; -import com.metamx.druid.http.StatusResource; import com.metamx.druid.indexing.common.index.ChatHandlerProvider; import com.sun.jersey.guice.JerseyServletModule; import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; @@ -27,7 +26,6 @@ public class ExecutorServletModule extends JerseyServletModule @Override protected void configureServlets() { - bind(StatusResource.class); bind(ChatHandlerResource.class); bind(ObjectMapper.class).toInstance(jsonMapper); bind(ChatHandlerProvider.class).toInstance(receivers); diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java index 767823301be..90890ca7a37 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerNode.java @@ -36,6 +36,7 @@ import com.metamx.common.lifecycle.LifecycleStop; import com.metamx.druid.QueryableNode; import com.metamx.druid.curator.CuratorConfig; import com.metamx.druid.http.GuiceServletConfig; +import com.metamx.druid.http.StatusServlet; import com.metamx.druid.indexing.common.config.IndexerZkConfig; import com.metamx.druid.indexing.common.config.TaskLogConfig; import com.metamx.druid.indexing.common.index.EventReceiverFirehoseFactory; @@ -204,9 +205,9 @@ public class WorkerNode extends QueryableNode ); final ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); + root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); root.addEventListener(new GuiceServletConfig(injector)); - root.addFilter(GuiceFilter.class, "/status", null); root.addFilter(GuiceFilter.class, "/druid/worker/v1/*", null); } diff --git a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java index 1fec950af48..b135af7dcb6 100644 --- a/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java +++ b/indexing-service/src/main/java/com/metamx/druid/indexing/worker/http/WorkerServletModule.java @@ -22,7 +22,6 @@ package com.metamx.druid.indexing.worker.http; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import com.google.inject.Provides; -import com.metamx.druid.http.StatusResource; import com.metamx.druid.indexing.coordinator.ForkingTaskRunner; import com.metamx.emitter.service.ServiceEmitter; import com.sun.jersey.guice.JerseyServletModule; @@ -52,7 +51,6 @@ public class WorkerServletModule extends JerseyServletModule @Override protected void configureServlets() { - bind(StatusResource.class); bind(WorkerResource.class); bind(ObjectMapper.class).toInstance(jsonMapper); bind(ServiceEmitter.class).toInstance(emitter); diff --git a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java index efc599db89d..4357f39c2b5 100644 --- a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java +++ b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeNode.java @@ -29,9 +29,6 @@ import com.google.common.base.Preconditions; import com.google.common.base.Suppliers; import com.google.common.base.Throwables; import com.google.common.collect.Maps; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.servlet.GuiceFilter; import com.metamx.common.ISE; import com.metamx.common.config.Config; import com.metamx.common.lifecycle.Lifecycle; @@ -41,8 +38,8 @@ import com.metamx.common.logger.Logger; import com.metamx.druid.BaseServerNode; import com.metamx.druid.db.DbConnector; import com.metamx.druid.db.DbConnectorConfig; -import com.metamx.druid.http.GuiceServletConfig; import com.metamx.druid.http.QueryServlet; +import com.metamx.druid.http.StatusServlet; import com.metamx.druid.initialization.Initialization; import com.metamx.druid.initialization.ServerInit; import com.metamx.druid.jackson.DefaultObjectMapper; @@ -151,13 +148,8 @@ public class RealtimeNode extends BaseServerNode startMonitoring(monitors); - final Injector injector = Guice.createInjector( - new RealtimeServletModule(getJsonMapper()) - ); - final ServletContextHandler root = new ServletContextHandler(getServer(), "/", ServletContextHandler.SESSIONS); - root.addEventListener(new GuiceServletConfig(injector)); - root.addFilter(GuiceFilter.class, "/status", null); + root.addServlet(new ServletHolder(new StatusServlet()), "/status"); root.addServlet( new ServletHolder( new QueryServlet(getJsonMapper(), getSmileMapper(), realtimeManager, emitter, getRequestLogger()) diff --git a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java b/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java deleted file mode 100644 index 4419e69b0fe..00000000000 --- a/realtime/src/main/java/com/metamx/druid/realtime/RealtimeServletModule.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.metamx.druid.realtime; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; -import com.google.inject.Provides; -import com.metamx.druid.http.StatusResource; -import com.sun.jersey.guice.JerseyServletModule; -import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; - -import javax.inject.Singleton; - -public class RealtimeServletModule extends JerseyServletModule -{ - private final ObjectMapper jsonMapper; - - public RealtimeServletModule(ObjectMapper jsonMapper) - { - this.jsonMapper = jsonMapper; - } - - @Override - protected void configureServlets() - { - bind(StatusResource.class); - - serve("/*").with(GuiceContainer.class); - } - - @Provides - @Singleton - public JacksonJsonProvider getJacksonJsonProvider() - { - final JacksonJsonProvider provider = new JacksonJsonProvider(); - provider.setMapper(jsonMapper); - return provider; - } -}