.setHttpHandlers(httpHandler) .build();
@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.RUNTIME_HTTP)); // Enable SSL for communication. NettyHttpService.Builder builder = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.RUNTIME_HTTP) .setHttpHandlers(new RuntimeHandler(cConf, messagingContext)) .setExceptionHandler(new HttpExceptionHandler()) .setHost(InetAddress.getLoopbackAddress().getHostName()); httpService = new HttpsEnabler() .setKeyStore(keyStore, ""::toCharArray) .setTrustStore(trustStore) .enable(builder) .build(); httpService.start(); // Writes the port to a local file Retries.runWithRetries( () -> { String content = GSON.toJson(new RuntimeMonitorServerInfo(httpService.getBindAddress().getPort())); java.nio.file.Path infoFile = Paths.get(cConf.get(Constants.RuntimeMonitor.SERVER_INFO_FILE)); Files.deleteIfExists(infoFile); Files.move(Files.write(Files.createTempFile(infoFile.getFileName().toString(), ".tmp"), Collections.singletonList(content)), infoFile); }, RetryStrategies.fixDelay(1, TimeUnit.SECONDS), IOException.class::isInstance); LOG.info("Runtime monitor server started on {}", httpService.getBindAddress()); }
@Inject public MetricsQueryService(CConfiguration cConf, @Named(Constants.Service.METRICS) Set<HttpHandler> handlers, DiscoveryService discoveryService, @Nullable MetricsCollectionService metricsCollectionService) { // netty http server config String address = cConf.get(Constants.Metrics.ADDRESS); int backlogcnxs = cConf.getInt(Constants.Metrics.BACKLOG_CONNECTIONS, 20000); int execthreads = cConf.getInt(Constants.Metrics.EXEC_THREADS, 20); int bossthreads = cConf.getInt(Constants.Metrics.BOSS_THREADS, 1); int workerthreads = cConf.getInt(Constants.Metrics.WORKER_THREADS, 10); NettyHttpService.Builder builder = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.METRICS); builder.setHttpHandlers(handlers); builder.setHandlerHooks(ImmutableList.of(new MetricsReporterHook(metricsCollectionService, Constants.Service.METRICS))); builder.setHost(address); builder.setConnectionBacklog(backlogcnxs); builder.setExecThreadPoolSize(execthreads); builder.setBossThreadPoolSize(bossthreads); builder.setWorkerThreadPoolSize(workerthreads); this.httpService = builder.build(); this.discoveryService = discoveryService; LOG.info("Configuring MetricsService " + ", address: " + address + ", backlog connections: " + backlogcnxs + ", execthreads: " + execthreads + ", bossthreads: " + bossthreads + ", workerthreads: " + workerthreads); }
.build(); service.start(); try {
.setHttpHandlers(httpHandler, httpHandlerWithoutAnnotation) .build();
Constants.Service.APP_FABRIC_HTTP) .setHost(hostname.getCanonicalHostName()) .setHandlerHooks(builder.build()) .setHttpHandlers(handlers) .setConnectionBacklog(cConf.getInt(Constants.AppFabric.BACKLOG_CONNECTIONS, Constants.AppFabric.DEFAULT_BACKLOG)) .setExecThreadPoolSize(cConf.getInt(Constants.AppFabric.EXEC_THREADS, Constants.AppFabric.DEFAULT_EXEC_THREADS)) .setBossThreadPoolSize(cConf.getInt(Constants.AppFabric.BOSS_THREADS, Constants.AppFabric.DEFAULT_BOSS_THREADS)) .setWorkerThreadPoolSize(cConf.getInt(Constants.AppFabric.WORKER_THREADS, Constants.AppFabric.DEFAULT_WORKER_THREADS)); if (sslEnabled) { httpServiceBuilder.setPort(cConf.getInt(Constants.AppFabric.SERVER_SSL_PORT)); new HttpsEnabler().setKeyStore(ks, password::toCharArray).enable(httpServiceBuilder); } else { httpServiceBuilder.setPort(cConf.getInt(Constants.AppFabric.SERVER_PORT)); cancelHttpService = startHttpService(httpServiceBuilder.build()); if (runCountUpgradeService != null) { runCountUpgradeService.startAndWait();
.setHttpHandlers(httpHandler) .build();
.setHttpHandlers(new UGIProviderTestHandler()) .build();
.setHandlerHooks(ImmutableList.of(new MetricsReporterHook(metricsCollectionService, Constants.Service.DATASET_MANAGER))) .setHost(cConf.get(Constants.Service.MASTER_SERVICES_BIND_ADDRESS)) .setPort(cConf.getInt(Constants.Dataset.Manager.PORT)) .setConnectionBacklog(cConf.getInt(Constants.Dataset.Manager.BACKLOG_CONNECTIONS)) .setExecThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.EXEC_THREADS)) .setBossThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.BOSS_THREADS)) .setWorkerThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.WORKER_THREADS)) .build(); this.discoveryService = discoveryService; this.discoveryServiceClient = discoveryServiceClient;
.setHost(host) .setPort(0) .setHttpHandlers(nettyHttpHandlers); return SystemArguments.configureNettyHttpService(programOptions.getUserArguments().asMap(), builder).build();
.setChannelPipelineModifier(new ChannelPipelineModifier() { @Override public void modify(ChannelPipeline pipeline) { .build(); service.start();
Constants.Service.APP_FABRIC_HTTP) .setHost(hostname.getCanonicalHostName()) .setHandlerHooks(builder.build()) .setHttpHandlers(handlers) .setConnectionBacklog(cConf.getInt(Constants.AppFabric.BACKLOG_CONNECTIONS, Constants.AppFabric.DEFAULT_BACKLOG)) .setExecThreadPoolSize(cConf.getInt(Constants.AppFabric.EXEC_THREADS, Constants.AppFabric.DEFAULT_EXEC_THREADS)) .setBossThreadPoolSize(cConf.getInt(Constants.AppFabric.BOSS_THREADS, Constants.AppFabric.DEFAULT_BOSS_THREADS)) .setWorkerThreadPoolSize(cConf.getInt(Constants.AppFabric.WORKER_THREADS, Constants.AppFabric.DEFAULT_WORKER_THREADS)); if (sslEnabled) { httpServiceBuilder.setPort(cConf.getInt(Constants.AppFabric.SERVER_SSL_PORT)); new HttpsEnabler().setKeyStore(ks, password::toCharArray).enable(httpServiceBuilder); } else { httpServiceBuilder.setPort(cConf.getInt(Constants.AppFabric.SERVER_PORT)); cancelHttpService = startHttpService(httpServiceBuilder.build()); if (runCountUpgradeService != null) { runCountUpgradeService.startAndWait();
.setHandlerHooks(ImmutableList.of(new MetricsReporterHook(metricsCollectionService, Constants.Service.DATASET_MANAGER))) .setHost(cConf.get(Constants.Service.MASTER_SERVICES_BIND_ADDRESS)) .setPort(cConf.getInt(Constants.Dataset.Manager.PORT)) .setConnectionBacklog(cConf.getInt(Constants.Dataset.Manager.BACKLOG_CONNECTIONS)) .setExecThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.EXEC_THREADS)) .setBossThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.BOSS_THREADS)) .setWorkerThreadPoolSize(cConf.getInt(Constants.Dataset.Manager.WORKER_THREADS)) .build(); this.discoveryService = discoveryService; this.discoveryServiceClient = discoveryServiceClient;
.setHost(host) .setPort(0) .setHttpHandlers(nettyHttpHandlers); return SystemArguments.configureNettyHttpService(programOptions.getUserArguments().asMap(), builder).build();
builder.addHttpHandlers(handlers); builder.setHost(host); builder.setPort(port); builder.setConnectionBacklog(20000); builder.setExecThreadPoolSize(numExecThreads); builder.setBossThreadPoolSize(1); builder.setWorkerThreadPoolSize(numWorkerThreads); if (securityEnabled) { builder.modifyChannelPipeline(new Function<ChannelPipeline, ChannelPipeline>() { @Nullable @Override this.httpService = builder.build();
.setHttpHandlers(new PingHandler()) ).build();
.enable( NettyHttpService.builder("test") .setHttpHandlers(new PingHandler()) ).build();
/** * Validates the given set of user service handlers. * * @param handlers set of service handlers to validate. * @param <T> type of the handler * @throws IllegalArgumentException if any of the service handler is not valid */ public <T> void validateHttpHandler(Iterable<T> handlers) { List<HttpHandler> httpHandlers = new ArrayList<>(); NoopMetricsContext metricsContext = new NoopMetricsContext(); for (T handler : handlers) { try { @SuppressWarnings("unchecked") TypeToken<T> type = (TypeToken<T>) TypeToken.of(handler.getClass()); httpHandlers.add(createHttpHandler(type, new VerificationDelegateContext<>(handler), metricsContext)); } catch (Exception e) { throw new IllegalArgumentException("Invalid http handler class " + handler.getClass().getName()); } } try { // Constructs a NettyHttpService, to verify that the handlers passed in by the user are valid. NettyHttpService.builder("service-configurer") .setHttpHandlers(httpHandlers) .build(); } catch (Exception e) { throw new IllegalArgumentException("Invalid http handler", e); } }
httpService = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.MESSAGING_SERVICE) .setHost(cConf.get(Constants.MessagingSystem.HTTP_SERVER_BIND_ADDRESS)) .setHandlerHooks(ImmutableList.of( new MetricsReporterHook(metricsCollectionService, Constants.Service.MESSAGING_SERVICE))) .setWorkerThreadPoolSize(cConf.getInt(Constants.MessagingSystem.HTTP_SERVER_WORKER_THREADS)) .setExecThreadPoolSize(cConf.getInt(Constants.MessagingSystem.HTTP_SERVER_EXECUTOR_THREADS)) .setHttpChunkLimit(cConf.getInt(Constants.MessagingSystem.HTTP_SERVER_MAX_REQUEST_SIZE_MB) * 1024 * 1024) .setExceptionHandler(new HttpExceptionHandler() { @Override public void handle(Throwable t, HttpRequest request, HttpResponder responder) { .setHttpHandlers(handlers) .build(); httpService.start(); cancelDiscovery = discoveryService.register(new Discoverable(Constants.Service.MESSAGING_SERVICE,
@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.RUNTIME_HTTP)); // Enable SSL for communication. NettyHttpService.Builder builder = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.RUNTIME_HTTP) .setHttpHandlers(new RuntimeHandler(cConf, messagingContext)) .setExceptionHandler(new HttpExceptionHandler()) .setHost(InetAddress.getLoopbackAddress().getHostName()); httpService = new HttpsEnabler() .setKeyStore(keyStore, ""::toCharArray) .setTrustStore(trustStore) .enable(builder) .build(); httpService.start(); // Writes the port to a local file Retries.runWithRetries( () -> { String content = GSON.toJson(new RuntimeMonitorServerInfo(httpService.getBindAddress().getPort())); java.nio.file.Path infoFile = Paths.get(cConf.get(Constants.RuntimeMonitor.SERVER_INFO_FILE)); Files.deleteIfExists(infoFile); Files.move(Files.write(Files.createTempFile(infoFile.getFileName().toString(), ".tmp"), Collections.singletonList(content)), infoFile); }, RetryStrategies.fixDelay(1, TimeUnit.SECONDS), IOException.class::isInstance); LOG.info("Runtime monitor server started on {}", httpService.getBindAddress()); }