Search in sources :

Example 6 with ServerCompressionFilter

use of com.linkedin.r2.filter.compression.ServerCompressionFilter in project incubator-gobblin by apache.

the class JobExecutionInfoServer method startUp.

@Override
protected void startUp() throws Exception {
    // Server configuration
    RestLiConfig config = new RestLiConfig();
    config.addResourcePackageNames(JobExecutionInfoResource.class.getPackage().getName());
    config.setServerNodeUri(serverUri);
    config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler());
    // Handle dependency injection
    Injector injector = Guice.createInjector(new MetaStoreModule(properties));
    JobHistoryStore jobHistoryStore = injector.getInstance(JobHistoryStore.class);
    SimpleBeanProvider beanProvider = new SimpleBeanProvider();
    beanProvider.add("jobHistoryStore", jobHistoryStore);
    // Use InjectMockResourceFactory to keep this Spring free
    ResourceFactory factory = new InjectMockResourceFactory(beanProvider);
    // Create and start the HTTP server
    TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory));
    String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName();
    FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters));
    this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(port, dispatcher));
    LOGGER.info("Starting the job execution information server");
    this.httpServer.get().start();
}
Also used : JobHistoryStore(org.apache.gobblin.metastore.JobHistoryStore) RestLiServer(com.linkedin.restli.server.RestLiServer) SimpleBeanProvider(com.linkedin.restli.server.mock.SimpleBeanProvider) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) HttpNettyServerFactory(com.linkedin.r2.transport.http.server.HttpNettyServerFactory) ServerCompressionFilter(com.linkedin.r2.filter.compression.ServerCompressionFilter) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) FilterChain(com.linkedin.r2.filter.FilterChain) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) ResourceFactory(com.linkedin.restli.server.resources.ResourceFactory) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) Injector(com.google.inject.Injector) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) MetaStoreModule(org.apache.gobblin.metastore.MetaStoreModule) RestLiConfig(com.linkedin.restli.server.RestLiConfig)

Aggregations

FilterChain (com.linkedin.r2.filter.FilterChain)5 ServerCompressionFilter (com.linkedin.r2.filter.compression.ServerCompressionFilter)5 SimpleLoggingFilter (com.linkedin.r2.filter.logging.SimpleLoggingFilter)3 CompressionConfig (com.linkedin.r2.filter.CompressionConfig)2 RequestContext (com.linkedin.r2.message.RequestContext)2 TransportDispatcher (com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)2 HttpNettyServerFactory (com.linkedin.r2.transport.http.server.HttpNettyServerFactory)2 DefaultDocumentationRequestHandler (com.linkedin.restli.docgen.DefaultDocumentationRequestHandler)2 DelegatingTransportDispatcher (com.linkedin.restli.server.DelegatingTransportDispatcher)2 RestLiConfig (com.linkedin.restli.server.RestLiConfig)2 RestLiServer (com.linkedin.restli.server.RestLiServer)2 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)2 ResourceFactory (com.linkedin.restli.server.resources.ResourceFactory)2 BeforeClass (org.testng.annotations.BeforeClass)2 Injector (com.google.inject.Injector)1 NextFilter (com.linkedin.r2.filter.NextFilter)1 RestFilter (com.linkedin.r2.filter.message.rest.RestFilter)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 RestResponse (com.linkedin.r2.message.rest.RestResponse)1 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)1