From 956361dbbd0b6d27502a22d90141794da6976b8f Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Wed, 4 Mar 2015 14:49:09 -0600 Subject: [PATCH] Refactoring: Moved BaseJettyServerInitializer.java to JettyServerInitUtils.java and changed it from abstract class to a utils class containing static methods And, moved jetty stuff to its own package io.druid.server.initialization.jetty --- .../druid/initialization/Initialization.java | 2 +- .../JettyServerInitUtils.java} | 42 ++++++++++--------- .../{ => jetty}/JettyServerInitializer.java | 2 +- .../{ => jetty}/JettyServerModule.java | 4 +- .../{ => jetty}/ServletFilterHolder.java | 2 +- .../AsyncQueryForwardingServletTest.java | 10 ++--- .../server/initialization/BaseJettyTest.java | 10 +++-- .../src/main/java/io/druid/cli/CliBridge.java | 3 +- .../src/main/java/io/druid/cli/CliBroker.java | 2 +- .../java/io/druid/cli/CliCoordinator.java | 2 +- .../main/java/io/druid/cli/CliHistorical.java | 2 +- .../java/io/druid/cli/CliMiddleManager.java | 3 +- .../main/java/io/druid/cli/CliOverlord.java | 10 ++--- .../src/main/java/io/druid/cli/CliPeon.java | 3 +- .../src/main/java/io/druid/cli/CliRouter.java | 2 +- .../CoordinatorJettyServerInitializer.java | 10 +++-- .../MiddleManagerJettyServerInitializer.java | 10 +++-- .../cli/QueryJettyServerInitializer.java | 11 +++-- .../cli/RouterJettyServerInitializer.java | 9 ++-- .../java/io/druid/guice/RealtimeModule.java | 3 +- 20 files changed, 81 insertions(+), 61 deletions(-) rename server/src/main/java/io/druid/server/initialization/{BaseJettyServerInitializer.java => jetty/JettyServerInitUtils.java} (68%) rename server/src/main/java/io/druid/server/initialization/{ => jetty}/JettyServerInitializer.java (94%) rename server/src/main/java/io/druid/server/initialization/{ => jetty}/JettyServerModule.java (98%) rename server/src/main/java/io/druid/server/initialization/{ => jetty}/ServletFilterHolder.java (98%) diff --git a/server/src/main/java/io/druid/initialization/Initialization.java b/server/src/main/java/io/druid/initialization/Initialization.java index a249f21be15..c43f0d5ec7c 100644 --- a/server/src/main/java/io/druid/initialization/Initialization.java +++ b/server/src/main/java/io/druid/initialization/Initialization.java @@ -55,7 +55,7 @@ import io.druid.guice.annotations.Json; import io.druid.guice.annotations.Smile; import io.druid.guice.http.HttpClientModule; import io.druid.server.initialization.EmitterModule; -import io.druid.server.initialization.JettyServerModule; +import io.druid.server.initialization.jetty.JettyServerModule; import io.druid.server.metrics.MetricsModule; import io.tesla.aether.Repository; import io.tesla.aether.TeslaAether; diff --git a/server/src/main/java/io/druid/server/initialization/BaseJettyServerInitializer.java b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitUtils.java similarity index 68% rename from server/src/main/java/io/druid/server/initialization/BaseJettyServerInitializer.java rename to server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitUtils.java index 98949a4a534..20b1de93178 100644 --- a/server/src/main/java/io/druid/server/initialization/BaseJettyServerInitializer.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitUtils.java @@ -1,21 +1,23 @@ /* - * Druid - a distributed column store. - * Copyright 2012 - 2015 Metamarkets Group Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Licensed to Metamarkets Group Inc. (Metamarkets) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. Metamarkets licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ -package io.druid.server.initialization; +package io.druid.server.initialization.jetty; import java.util.Set; @@ -32,19 +34,19 @@ import org.eclipse.jetty.servlets.GzipFilter; import javax.ws.rs.HttpMethod; -public abstract class BaseJettyServerInitializer implements JettyServerInitializer +public class JettyServerInitUtils { public static final String GZIP_METHODS = Joiner.on(",").join(HttpMethod.GET, HttpMethod.POST); - public FilterHolder defaultGzipFilterHolder() + public static FilterHolder defaultGzipFilterHolder() { final FilterHolder gzipFilterHolder = new FilterHolder(GzipFilter.class); setDefaultGzipFilterHolderParameters(gzipFilterHolder); return gzipFilterHolder; } - public FilterHolder defaultAsyncGzipFilterHolder() + public static FilterHolder defaultAsyncGzipFilterHolder() { final FilterHolder gzipFilterHolder = new FilterHolder(AsyncGzipFilter.class); setDefaultGzipFilterHolderParameters(gzipFilterHolder); @@ -60,7 +62,7 @@ public abstract class BaseJettyServerInitializer implements JettyServerInitializ filterHolder.setInitParameter("checkGzExists", String.valueOf(false)); } - public void addExtensionFilters(ServletContextHandler handler, Injector injector) { + public static void addExtensionFilters(ServletContextHandler handler, Injector injector) { Set extensionFilters = injector.getInstance(Key.get(new TypeLiteral>(){})); for (ServletFilterHolder servletFilterHolder : extensionFilters) { diff --git a/server/src/main/java/io/druid/server/initialization/JettyServerInitializer.java b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitializer.java similarity index 94% rename from server/src/main/java/io/druid/server/initialization/JettyServerInitializer.java rename to server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitializer.java index a57cc35a14a..bd66785002f 100644 --- a/server/src/main/java/io/druid/server/initialization/JettyServerInitializer.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerInitializer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package io.druid.server.initialization; +package io.druid.server.initialization.jetty; import com.google.inject.Injector; import org.eclipse.jetty.server.Server; diff --git a/server/src/main/java/io/druid/server/initialization/JettyServerModule.java b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java similarity index 98% rename from server/src/main/java/io/druid/server/initialization/JettyServerModule.java rename to server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java index e4f5beb4002..1e071648b23 100644 --- a/server/src/main/java/io/druid/server/initialization/JettyServerModule.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package io.druid.server.initialization; +package io.druid.server.initialization.jetty; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @@ -45,6 +45,8 @@ import io.druid.guice.annotations.Json; import io.druid.guice.annotations.Self; import io.druid.server.DruidNode; import io.druid.server.StatusResource; +import io.druid.server.initialization.ServerConfig; + import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; diff --git a/server/src/main/java/io/druid/server/initialization/ServletFilterHolder.java b/server/src/main/java/io/druid/server/initialization/jetty/ServletFilterHolder.java similarity index 98% rename from server/src/main/java/io/druid/server/initialization/ServletFilterHolder.java rename to server/src/main/java/io/druid/server/initialization/jetty/ServletFilterHolder.java index dfd8de8169c..104272d572b 100644 --- a/server/src/main/java/io/druid/server/initialization/ServletFilterHolder.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/ServletFilterHolder.java @@ -17,7 +17,7 @@ * under the License. */ -package io.druid.server.initialization; +package io.druid.server.initialization.jetty; import javax.servlet.DispatcherType; import javax.servlet.Filter; diff --git a/server/src/test/java/io/druid/server/AsyncQueryForwardingServletTest.java b/server/src/test/java/io/druid/server/AsyncQueryForwardingServletTest.java index 5376315a366..097358645c3 100644 --- a/server/src/test/java/io/druid/server/AsyncQueryForwardingServletTest.java +++ b/server/src/test/java/io/druid/server/AsyncQueryForwardingServletTest.java @@ -38,9 +38,9 @@ import io.druid.guice.annotations.Smile; import io.druid.guice.http.DruidHttpClientConfig; import io.druid.initialization.Initialization; import io.druid.query.Query; -import io.druid.server.initialization.BaseJettyServerInitializer; -import io.druid.server.initialization.JettyServerInitializer; import io.druid.server.initialization.BaseJettyTest; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.log.RequestLogger; import io.druid.server.metrics.NoopServiceEmitter; import io.druid.server.router.QueryHostFinder; @@ -122,7 +122,7 @@ public class AsyncQueryForwardingServletTest extends BaseJettyTest Assert.assertNotEquals("gzip", postNoGzip.getContentEncoding()); } - public static class ProxyJettyServerInit extends BaseJettyServerInitializer + public static class ProxyJettyServerInit implements JettyServerInitializer { private final DruidNode node; @@ -181,8 +181,8 @@ public class AsyncQueryForwardingServletTest extends BaseJettyTest } ), "/proxy/*" ); - - root.addFilter(defaultAsyncGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultAsyncGzipFilterHolder(), "/*", null); root.addFilter(GuiceFilter.class, "/slow/*", null); root.addFilter(GuiceFilter.class, "/default/*", null); root.addFilter(GuiceFilter.class, "/exception/*", null); diff --git a/server/src/test/java/io/druid/server/initialization/BaseJettyTest.java b/server/src/test/java/io/druid/server/initialization/BaseJettyTest.java index 01b6ade6706..9a5d6f4603b 100644 --- a/server/src/test/java/io/druid/server/initialization/BaseJettyTest.java +++ b/server/src/test/java/io/druid/server/initialization/BaseJettyTest.java @@ -39,6 +39,10 @@ import io.druid.guice.LifecycleModule; import io.druid.guice.annotations.Self; import io.druid.initialization.Initialization; import io.druid.server.DruidNode; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; +import io.druid.server.initialization.jetty.ServletFilterHolder; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; @@ -189,7 +193,7 @@ public class BaseJettyTest } } - public static class JettyServerInit extends BaseJettyServerInitializer + public static class JettyServerInit implements JettyServerInitializer { @Override @@ -197,8 +201,8 @@ public class BaseJettyTest { final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); - addExtensionFilters(root, injector); - root.addFilter(defaultGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultGzipFilterHolder(), "/*", null); root.addFilter(GuiceFilter.class, "/*", null); final HandlerList handlerList = new HandlerList(); diff --git a/services/src/main/java/io/druid/cli/CliBridge.java b/services/src/main/java/io/druid/cli/CliBridge.java index 06dbea7417d..4ea4c8ebf0a 100644 --- a/services/src/main/java/io/druid/cli/CliBridge.java +++ b/services/src/main/java/io/druid/cli/CliBridge.java @@ -54,8 +54,9 @@ import io.druid.server.coordination.AbstractDataSegmentAnnouncer; import io.druid.server.coordination.BatchDataSegmentAnnouncer; import io.druid.server.coordination.DruidServerMetadata; import io.druid.server.initialization.BatchDataSegmentAnnouncerConfig; -import io.druid.server.initialization.JettyServerInitializer; import io.druid.server.initialization.ZkPathsConfig; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.BoundedExponentialBackoffRetry; diff --git a/services/src/main/java/io/druid/cli/CliBroker.java b/services/src/main/java/io/druid/cli/CliBroker.java index 73c8961ed8a..048d0ac9b3e 100644 --- a/services/src/main/java/io/druid/cli/CliBroker.java +++ b/services/src/main/java/io/druid/cli/CliBroker.java @@ -47,7 +47,7 @@ import io.druid.server.ClientQuerySegmentWalker; import io.druid.server.QueryResource; import io.druid.server.coordination.broker.DruidBroker; import io.druid.server.http.BrokerResource; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.metrics.MetricsModule; import io.druid.server.router.TieredBrokerConfig; import org.eclipse.jetty.server.Server; diff --git a/services/src/main/java/io/druid/cli/CliCoordinator.java b/services/src/main/java/io/druid/cli/CliCoordinator.java index 5c287202235..d4c41388a23 100644 --- a/services/src/main/java/io/druid/cli/CliCoordinator.java +++ b/services/src/main/java/io/druid/cli/CliCoordinator.java @@ -54,7 +54,7 @@ import io.druid.server.http.RedirectInfo; import io.druid.server.http.RulesResource; import io.druid.server.http.ServersResource; import io.druid.server.http.TiersResource; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.router.TieredBrokerConfig; import org.apache.curator.framework.CuratorFramework; import org.eclipse.jetty.server.Server; diff --git a/services/src/main/java/io/druid/cli/CliHistorical.java b/services/src/main/java/io/druid/cli/CliHistorical.java index d1720423125..d9fdaf76c90 100644 --- a/services/src/main/java/io/druid/cli/CliHistorical.java +++ b/services/src/main/java/io/druid/cli/CliHistorical.java @@ -38,7 +38,7 @@ import io.druid.server.QueryResource; import io.druid.server.coordination.ServerManager; import io.druid.server.coordination.ZkCoordinator; import io.druid.server.http.HistoricalResource; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.metrics.MetricsModule; import org.eclipse.jetty.server.Server; diff --git a/services/src/main/java/io/druid/cli/CliMiddleManager.java b/services/src/main/java/io/druid/cli/CliMiddleManager.java index f1e1af24db0..443aaf00daf 100644 --- a/services/src/main/java/io/druid/cli/CliMiddleManager.java +++ b/services/src/main/java/io/druid/cli/CliMiddleManager.java @@ -44,7 +44,8 @@ import io.druid.indexing.worker.config.WorkerConfig; import io.druid.indexing.worker.http.WorkerResource; import io.druid.segment.realtime.firehose.ChatHandlerProvider; import io.druid.server.DruidNode; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.eclipse.jetty.server.Server; import java.util.List; diff --git a/services/src/main/java/io/druid/cli/CliOverlord.java b/services/src/main/java/io/druid/cli/CliOverlord.java index 2faf7f009fd..22a002b03db 100644 --- a/services/src/main/java/io/druid/cli/CliOverlord.java +++ b/services/src/main/java/io/druid/cli/CliOverlord.java @@ -71,8 +71,8 @@ import io.druid.indexing.worker.config.WorkerConfig; import io.druid.segment.realtime.firehose.ChatHandlerProvider; import io.druid.server.http.RedirectFilter; import io.druid.server.http.RedirectInfo; -import io.druid.server.initialization.BaseJettyServerInitializer; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.tasklogs.TaskLogStreamer; import io.druid.tasklogs.TaskLogs; import org.eclipse.jetty.server.Handler; @@ -217,7 +217,7 @@ public class CliOverlord extends ServerRunnable /** */ - private static class OverlordJettyServerInitializer extends BaseJettyServerInitializer + private static class OverlordJettyServerInitializer implements JettyServerInitializer { @Override public void initialize(Server server, Injector injector) @@ -235,8 +235,8 @@ public class CliOverlord extends ServerRunnable } ) ); - addExtensionFilters(root, injector); - root.addFilter(defaultGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultGzipFilterHolder(), "/*", null); // /status should not redirect, so add first root.addFilter(GuiceFilter.class, "/status/*", null); diff --git a/services/src/main/java/io/druid/cli/CliPeon.java b/services/src/main/java/io/druid/cli/CliPeon.java index acf22c5646f..4cdd7365fd9 100644 --- a/services/src/main/java/io/druid/cli/CliPeon.java +++ b/services/src/main/java/io/druid/cli/CliPeon.java @@ -69,7 +69,8 @@ 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; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.eclipse.jetty.server.Server; import java.io.File; diff --git a/services/src/main/java/io/druid/cli/CliRouter.java b/services/src/main/java/io/druid/cli/CliRouter.java index f115029e936..59645fd4b44 100644 --- a/services/src/main/java/io/druid/cli/CliRouter.java +++ b/services/src/main/java/io/druid/cli/CliRouter.java @@ -34,7 +34,7 @@ import io.druid.guice.LifecycleModule; import io.druid.guice.ManageLifecycle; import io.druid.guice.annotations.Self; import io.druid.guice.http.JettyHttpClientModule; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.router.CoordinatorRuleManager; import io.druid.server.router.QueryHostFinder; import io.druid.server.router.Router; diff --git a/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java b/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java index 1bf59ad8d36..2059714a657 100644 --- a/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/CoordinatorJettyServerInitializer.java @@ -22,7 +22,9 @@ import com.google.inject.Injector; import com.google.inject.servlet.GuiceFilter; import io.druid.server.coordinator.DruidCoordinatorConfig; import io.druid.server.http.RedirectFilter; -import io.druid.server.initialization.BaseJettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; @@ -34,7 +36,7 @@ import org.eclipse.jetty.util.resource.Resource; /** */ -class CoordinatorJettyServerInitializer extends BaseJettyServerInitializer +class CoordinatorJettyServerInitializer implements JettyServerInitializer { private final DruidCoordinatorConfig config; @@ -57,8 +59,8 @@ class CoordinatorJettyServerInitializer extends BaseJettyServerInitializer } else { root.setResourceBase(config.getConsoleStatic()); } - addExtensionFilters(root, injector); - root.addFilter(defaultGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultGzipFilterHolder(), "/*", null); // /status should not redirect, so add first root.addFilter(GuiceFilter.class, "/status/*", null); diff --git a/services/src/main/java/io/druid/cli/MiddleManagerJettyServerInitializer.java b/services/src/main/java/io/druid/cli/MiddleManagerJettyServerInitializer.java index 256e9d8bd42..a1b6e80def9 100644 --- a/services/src/main/java/io/druid/cli/MiddleManagerJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/MiddleManagerJettyServerInitializer.java @@ -17,9 +17,11 @@ package io.druid.cli; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import com.google.inject.Injector; import com.google.inject.servlet.GuiceFilter; -import io.druid.server.initialization.BaseJettyServerInitializer; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; @@ -30,15 +32,15 @@ import org.eclipse.jetty.servlet.ServletHolder; /** */ -class MiddleManagerJettyServerInitializer extends BaseJettyServerInitializer +class MiddleManagerJettyServerInitializer implements JettyServerInitializer { @Override public void initialize(Server server, Injector injector) { final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); - addExtensionFilters(root, injector); - root.addFilter(defaultGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultGzipFilterHolder(), "/*", null); root.addFilter(GuiceFilter.class, "/*", null); final HandlerList handlerList = new HandlerList(); diff --git a/services/src/main/java/io/druid/cli/QueryJettyServerInitializer.java b/services/src/main/java/io/druid/cli/QueryJettyServerInitializer.java index 8ae902634f8..8b0e188544b 100644 --- a/services/src/main/java/io/druid/cli/QueryJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/QueryJettyServerInitializer.java @@ -19,7 +19,10 @@ package io.druid.cli; import com.google.inject.Injector; import com.google.inject.servlet.GuiceFilter; -import io.druid.server.initialization.BaseJettyServerInitializer; + +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; @@ -29,15 +32,15 @@ import org.eclipse.jetty.servlet.ServletHolder; /** */ -public class QueryJettyServerInitializer extends BaseJettyServerInitializer +public class QueryJettyServerInitializer implements JettyServerInitializer { @Override public void initialize(Server server, Injector injector) { final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS); root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); - addExtensionFilters(root, injector); - root.addFilter(defaultGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultGzipFilterHolder(), "/*", null); root.addFilter(GuiceFilter.class, "/*", null); diff --git a/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java b/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java index e54d0e413b1..0301cc2da52 100644 --- a/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java @@ -27,7 +27,8 @@ import io.druid.guice.annotations.Json; import io.druid.guice.annotations.Smile; import io.druid.guice.http.DruidHttpClientConfig; import io.druid.server.AsyncQueryForwardingServlet; -import io.druid.server.initialization.BaseJettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitUtils; +import io.druid.server.initialization.jetty.JettyServerInitializer; import io.druid.server.log.RequestLogger; import io.druid.server.router.QueryHostFinder; import io.druid.server.router.Router; @@ -41,7 +42,7 @@ import org.eclipse.jetty.servlet.ServletHolder; /** */ -public class RouterJettyServerInitializer extends BaseJettyServerInitializer +public class RouterJettyServerInitializer implements JettyServerInitializer { private final ObjectMapper jsonMapper; private final ObjectMapper smileMapper; @@ -89,8 +90,8 @@ public class RouterJettyServerInitializer extends BaseJettyServerInitializer ); asyncQueryForwardingServlet.setTimeout(httpClientConfig.getReadTimeout().getMillis()); root.addServlet(new ServletHolder(asyncQueryForwardingServlet), "/druid/v2/*"); - addExtensionFilters(root, injector); - root.addFilter(defaultAsyncGzipFilterHolder(), "/*", null); + JettyServerInitUtils.addExtensionFilters(root, injector); + root.addFilter(JettyServerInitUtils.defaultAsyncGzipFilterHolder(), "/*", null); // Can't use '/*' here because of Guice conflicts with AsyncQueryForwardingServlet path root.addFilter(GuiceFilter.class, "/status/*", null); diff --git a/services/src/main/java/io/druid/guice/RealtimeModule.java b/services/src/main/java/io/druid/guice/RealtimeModule.java index 5b58b586adc..df4c08c99d7 100644 --- a/services/src/main/java/io/druid/guice/RealtimeModule.java +++ b/services/src/main/java/io/druid/guice/RealtimeModule.java @@ -34,7 +34,8 @@ 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; -import io.druid.server.initialization.JettyServerInitializer; +import io.druid.server.initialization.jetty.JettyServerInitializer; + import org.eclipse.jetty.server.Server; import java.util.List;