Search in sources :

Example 1 with BiDiGzipHandler

use of io.dropwizard.jetty.BiDiGzipHandler in project airpal by airbnb.

the class AirpalApplicationBase method run.

@Override
public void run(T config, Environment environment) throws Exception {
    this.injector = Guice.createInjector(Stage.PRODUCTION, getModules(config, environment));
    System.setProperty(IO_BUFFER_SIZE, String.valueOf(config.getBufferSize().toBytes()));
    environment.healthChecks().register("presto", injector.getInstance(PrestoHealthCheck.class));
    environment.jersey().register(injector.getInstance(ExecuteResource.class));
    environment.jersey().register(injector.getInstance(QueryResource.class));
    environment.jersey().register(injector.getInstance(QueriesResource.class));
    environment.jersey().register(injector.getInstance(UserResource.class));
    environment.jersey().register(injector.getInstance(UsersResource.class));
    environment.jersey().register(injector.getInstance(TablesResource.class));
    environment.jersey().register(injector.getInstance(HealthResource.class));
    environment.jersey().register(injector.getInstance(PingResource.class));
    environment.jersey().register(injector.getInstance(SessionResource.class));
    environment.jersey().register(injector.getInstance(FilesResource.class));
    environment.jersey().register(injector.getInstance(ResultsPreviewResource.class));
    environment.jersey().register(injector.getInstance(S3FilesResource.class));
    environment.jersey().register(injector.getInstance(AirpalUserFactory.class));
    // Setup SSE (Server Sent Events)
    ServletRegistration.Dynamic sseServlet = environment.servlets().addServlet("updates", injector.getInstance(SSEEventSourceServlet.class));
    sseServlet.setAsyncSupported(true);
    sseServlet.addMapping("/api/updates/subscribe");
    // Disable GZIP content encoding for SSE endpoints
    environment.lifecycle().addServerLifecycleListener(server -> {
        for (Handler handler : server.getChildHandlersByClass(BiDiGzipHandler.class)) {
            ((BiDiGzipHandler) handler).addExcludedMimeTypes(SERVER_SENT_EVENTS);
        }
    });
}
Also used : SSEEventSourceServlet(com.airbnb.airpal.resources.sse.SSEEventSourceServlet) SessionResource(com.airbnb.airpal.resources.SessionResource) QueryResource(com.airbnb.airpal.resources.QueryResource) PrestoHealthCheck(com.airbnb.airpal.core.health.PrestoHealthCheck) UserResource(com.airbnb.airpal.resources.UserResource) Handler(org.eclipse.jetty.server.Handler) BiDiGzipHandler(io.dropwizard.jetty.BiDiGzipHandler) FilesResource(com.airbnb.airpal.resources.FilesResource) S3FilesResource(com.airbnb.airpal.resources.S3FilesResource) PingResource(com.airbnb.airpal.resources.PingResource) AirpalUserFactory(com.airbnb.airpal.core.AirpalUserFactory) ResultsPreviewResource(com.airbnb.airpal.resources.ResultsPreviewResource) ExecuteResource(com.airbnb.airpal.resources.ExecuteResource) ServletRegistration(javax.servlet.ServletRegistration) QueriesResource(com.airbnb.airpal.resources.QueriesResource) TablesResource(com.airbnb.airpal.resources.TablesResource) UsersResource(com.airbnb.airpal.resources.UsersResource) S3FilesResource(com.airbnb.airpal.resources.S3FilesResource) HealthResource(com.airbnb.airpal.resources.HealthResource) BiDiGzipHandler(io.dropwizard.jetty.BiDiGzipHandler)

Aggregations

AirpalUserFactory (com.airbnb.airpal.core.AirpalUserFactory)1 PrestoHealthCheck (com.airbnb.airpal.core.health.PrestoHealthCheck)1 ExecuteResource (com.airbnb.airpal.resources.ExecuteResource)1 FilesResource (com.airbnb.airpal.resources.FilesResource)1 HealthResource (com.airbnb.airpal.resources.HealthResource)1 PingResource (com.airbnb.airpal.resources.PingResource)1 QueriesResource (com.airbnb.airpal.resources.QueriesResource)1 QueryResource (com.airbnb.airpal.resources.QueryResource)1 ResultsPreviewResource (com.airbnb.airpal.resources.ResultsPreviewResource)1 S3FilesResource (com.airbnb.airpal.resources.S3FilesResource)1 SessionResource (com.airbnb.airpal.resources.SessionResource)1 TablesResource (com.airbnb.airpal.resources.TablesResource)1 UserResource (com.airbnb.airpal.resources.UserResource)1 UsersResource (com.airbnb.airpal.resources.UsersResource)1 SSEEventSourceServlet (com.airbnb.airpal.resources.sse.SSEEventSourceServlet)1 BiDiGzipHandler (io.dropwizard.jetty.BiDiGzipHandler)1 ServletRegistration (javax.servlet.ServletRegistration)1 Handler (org.eclipse.jetty.server.Handler)1