Merge pull request #653 from metamx/override-static-resource

allow overriding coordinator static resource
This commit is contained in:
fjy 2014-07-29 17:15:01 -06:00
commit 43d4e5418a
3 changed files with 26 additions and 2 deletions

View File

@ -59,4 +59,10 @@ public abstract class DruidCoordinatorConfig
{ {
return new Duration(15 * 60 * 1000); return new Duration(15 * 60 * 1000);
} }
@Config("druid.coordinator.console.static")
public String getConsoleStatic()
{
return null;
}
} }

View File

@ -108,7 +108,9 @@ public class CliCoordinator extends ServerRunnable
LifecycleModule.register(binder, DruidCoordinator.class); LifecycleModule.register(binder, DruidCoordinator.class);
binder.bind(JettyServerInitializer.class).toInstance(new CoordinatorJettyServerInitializer()); binder.bind(JettyServerInitializer.class)
.to(CoordinatorJettyServerInitializer.class);
Jerseys.addResource(binder, BackwardsCompatibleInfoResource.class); Jerseys.addResource(binder, BackwardsCompatibleInfoResource.class);
Jerseys.addResource(binder, InfoResource.class); Jerseys.addResource(binder, InfoResource.class);
Jerseys.addResource(binder, BackwardsCompatibleCoordinatorResource.class); Jerseys.addResource(binder, BackwardsCompatibleCoordinatorResource.class);

View File

@ -19,9 +19,11 @@
package io.druid.cli; package io.druid.cli;
import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.servlet.GuiceFilter; import com.google.inject.servlet.GuiceFilter;
import io.druid.server.coordinator.DruidCoordinator; import io.druid.server.coordinator.DruidCoordinator;
import io.druid.server.coordinator.DruidCoordinatorConfig;
import io.druid.server.http.RedirectFilter; import io.druid.server.http.RedirectFilter;
import io.druid.server.initialization.JettyServerInitializer; import io.druid.server.initialization.JettyServerInitializer;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
@ -32,11 +34,20 @@ import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlets.GzipFilter; import org.eclipse.jetty.servlets.GzipFilter;
import org.eclipse.jetty.util.resource.Resource;
/** /**
*/ */
class CoordinatorJettyServerInitializer implements JettyServerInitializer class CoordinatorJettyServerInitializer implements JettyServerInitializer
{ {
private final DruidCoordinatorConfig config;
@Inject
CoordinatorJettyServerInitializer(DruidCoordinatorConfig config)
{
this.config = config;
}
@Override @Override
public void initialize(Server server, Injector injector) public void initialize(Server server, Injector injector)
{ {
@ -45,7 +56,12 @@ class CoordinatorJettyServerInitializer implements JettyServerInitializer
ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class); ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);
root.addServlet(holderPwd, "/"); root.addServlet(holderPwd, "/");
root.setResourceBase(DruidCoordinator.class.getClassLoader().getResource("static").toExternalForm()); if(config.getConsoleStatic() == null) {
root.setBaseResource(Resource.newClassPathResource("static"));
} else {
root.setResourceBase(config.getConsoleStatic());
}
root.addFilter(new FilterHolder(injector.getInstance(RedirectFilter.class)), "/*", null); root.addFilter(new FilterHolder(injector.getInstance(RedirectFilter.class)), "/*", null);
root.addFilter(GzipFilter.class, "/*", null); root.addFilter(GzipFilter.class, "/*", null);