@Override protected void configure() { try { RestLiConfig restLiConfig = new RestLiConfig(); restLiConfig.setResourcePackageNames("org.apache.gobblin.restli.throttling"); bind(RestLiConfig.class).toInstance(restLiConfig); bind(SharedResourcesBroker.class).annotatedWith(Names.named(LimiterServerResource.BROKER_INJECT_NAME)).toInstance(topLevelBroker); MetricContext metricContext = topLevelBroker.getSharedResource(new MetricContextFactory<ThrottlingServerScopes>(), new MetricContextKey()); Timer timer = metricContext.timer(LimiterServerResource.REQUEST_TIMER_NAME); bind(MetricContext.class).annotatedWith(Names.named(LimiterServerResource.METRIC_CONTEXT_INJECT_NAME)).toInstance(metricContext); bind(Timer.class).annotatedWith(Names.named(LimiterServerResource.REQUEST_TIMER_INJECT_NAME)).toInstance(timer); bind(new TypeLiteral<Optional<LeaderFinder<URIMetadata>>>() { }).annotatedWith(Names.named(LimiterServerResource.LEADER_FINDER_INJECT_NAME)).toInstance(leaderFinder); List<RestFilter> restFilters = new ArrayList<>(); restFilters.add(new ServerCompressionFilter(EncodingType.SNAPPY.getHttpName())); List<StreamFilter> streamFilters = new ArrayList<>(); streamFilters.add(new SimpleLoggingFilter()); FilterChain filterChain = FilterChains.create(restFilters, streamFilters); bind(FilterChain.class).toInstance(filterChain); } catch (NotConfiguredException nce) { throw new RuntimeException(nce); } } }, new ServletModule() {
@Override protected void startUp() throws Exception { RestLiConfig config = new RestLiConfig(); Set<String> resourceClassNames = Sets.newHashSet(); for (Class<? extends BaseResource> resClass : this.resources) { resourceClassNames.add(resClass.getName()); } config.addResourceClassNames(resourceClassNames); config.setServerNodeUri(this.serverUri); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); config.addFilter(new RestLiValidationFilter()); ResourceFactory factory = new GuiceInjectResourceFactory(this.injector); 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(this.port, dispatcher)); this.log.info("Starting the {} embedded server at port {}.", this.name, this.port); this.httpServer.get().start(); }
@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(); }
/** * Creates {@link RestLiConfig} to be used by a {@link RestLiServer} * * @param port the port the server will run on * @return */ private static RestLiConfig createConfig(int port) { RestLiConfig restLiConfig = new RestLiConfig(); restLiConfig.setServerNodeUri(URI.create(LOCALHOST + port)); restLiConfig.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); return restLiConfig; }
@Override protected void configure() { try { RestLiConfig restLiConfig = new RestLiConfig(); restLiConfig.setResourcePackageNames("org.apache.gobblin.restli.throttling"); bind(RestLiConfig.class).toInstance(restLiConfig); bind(SharedResourcesBroker.class).annotatedWith(Names.named(LimiterServerResource.BROKER_INJECT_NAME)).toInstance(topLevelBroker); MetricContext metricContext = topLevelBroker.getSharedResource(new MetricContextFactory<ThrottlingServerScopes>(), new MetricContextKey()); Timer timer = metricContext.timer(LimiterServerResource.REQUEST_TIMER_NAME); bind(MetricContext.class).annotatedWith(Names.named(LimiterServerResource.METRIC_CONTEXT_INJECT_NAME)).toInstance(metricContext); bind(Timer.class).annotatedWith(Names.named(LimiterServerResource.REQUEST_TIMER_INJECT_NAME)).toInstance(timer); bind(new TypeLiteral<Optional<LeaderFinder<URIMetadata>>>() { }).annotatedWith(Names.named(LimiterServerResource.LEADER_FINDER_INJECT_NAME)).toInstance(leaderFinder); List<RestFilter> restFilters = new ArrayList<>(); restFilters.add(new ServerCompressionFilter(EncodingType.SNAPPY.getHttpName())); List<StreamFilter> streamFilters = new ArrayList<>(); streamFilters.add(new SimpleLoggingFilter()); FilterChain filterChain = FilterChains.create(restFilters, streamFilters); bind(FilterChain.class).toInstance(filterChain); } catch (NotConfiguredException nce) { throw new RuntimeException(nce); } } }, new ServletModule() {
@Override protected void configure() { try { RestLiConfig restLiConfig = new RestLiConfig(); restLiConfig.setResourcePackageNames("gobblin.restli.throttling"); bind(RestLiConfig.class).toInstance(restLiConfig); bind(SharedResourcesBroker.class).annotatedWith(Names.named(LimiterServerResource.BROKER_INJECT_NAME)).toInstance(topLevelBroker); MetricContext metricContext = topLevelBroker.getSharedResource(new MetricContextFactory<ThrottlingServerScopes>(), new MetricContextKey()); Timer timer = metricContext.timer(LimiterServerResource.REQUEST_TIMER_NAME); bind(MetricContext.class).annotatedWith(Names.named(LimiterServerResource.METRIC_CONTEXT_INJECT_NAME)).toInstance(metricContext); bind(Timer.class).annotatedWith(Names.named(LimiterServerResource.REQUEST_TIMER_INJECT_NAME)).toInstance(timer); bind(new TypeLiteral<Optional<LeaderFinder<URIMetadata>>>() { }).annotatedWith(Names.named(LimiterServerResource.LEADER_FINDER_INJECT_NAME)).toInstance(leaderFinder); List<RestFilter> restFilters = new ArrayList<>(); restFilters.add(new ServerCompressionFilter(EncodingType.SNAPPY.getHttpName())); List<StreamFilter> streamFilters = new ArrayList<>(); streamFilters.add(new SimpleLoggingFilter()); FilterChain filterChain = FilterChains.create(restFilters, streamFilters); bind(FilterChain.class).toInstance(filterChain); } catch (NotConfiguredException nce) { throw new RuntimeException(nce); } } }, new ServletModule() {
@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(); }
throws IOException final RestLiConfig config = new RestLiConfig(); if (resourcePackages != null)
@Override protected void startUp() throws Exception { RestLiConfig config = new RestLiConfig(); Set<String> resourceClassNames = Sets.newHashSet(); for (Class<? extends BaseResource> resClass : this.resources) { resourceClassNames.add(resClass.getName()); } config.addResourceClassNames(resourceClassNames); config.setServerNodeUri(this.serverUri); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); config.addFilter(new RestLiValidationFilter()); ResourceFactory factory = new GuiceInjectResourceFactory(this.injector); 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(this.port, dispatcher)); this.log.info("Starting the {} embedded server at port {}.", this.name, this.port); this.httpServer.get().start(); }
@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(); }
throws IOException final RestLiConfig config = new RestLiConfig(); if (resourcePackages != null)
RestLiConfig config = new RestLiConfig(); config.setResourcePackageNamesSet(getResourcePackageSet(servletConfig));
_packages = packages; final RestLiConfig config = new RestLiConfig(); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); config.setServerNodeUri(URI.create("/"));
boolean useDebugHandler) RestLiConfig config = new RestLiConfig(); config.addResourcePackageNames(RESOURCE_PACKAGE_NAMES); config.setServerNodeUri(URI.create("http://localhost:" + port));