use of co.cask.cdap.common.metrics.MetricsReporterHook in project cdap by caskdata.
the class MetadataService method startUp.
@Override
protected void startUp() throws Exception {
LOG.info("Starting Metadata Service");
metadataUpgrader.createOrUpgradeIfNecessary();
httpService = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.METADATA_SERVICE).setHttpHandlers(handlers).setHandlerHooks(ImmutableList.of(new MetricsReporterHook(metricsCollectionService, Constants.Service.METADATA_SERVICE))).setHost(cConf.get(Constants.Metadata.SERVICE_BIND_ADDRESS)).setPort(cConf.getInt(Constants.Metadata.SERVICE_BIND_PORT)).setWorkerThreadPoolSize(cConf.getInt(Constants.Metadata.SERVICE_WORKER_THREADS)).setExecThreadPoolSize(cConf.getInt(Constants.Metadata.SERVICE_EXEC_THREADS)).setConnectionBacklog(20000).build();
httpService.start();
InetSocketAddress socketAddress = httpService.getBindAddress();
LOG.info("Metadata service running at {}", socketAddress);
cancelDiscovery = discoveryService.register(ResolvingDiscoverable.of(new Discoverable(Constants.Service.METADATA_SERVICE, socketAddress)));
}
use of co.cask.cdap.common.metrics.MetricsReporterHook in project cdap by caskdata.
the class MessagingHttpService method startUp.
@Override
protected void startUp() throws Exception {
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) {
// TODO: CDAP-7688. Override the handling to return 400 on IllegalArgumentException
if (t instanceof IllegalArgumentException) {
logWithTrace(request, t);
responder.sendString(HttpResponseStatus.BAD_REQUEST, t.getMessage());
} else {
super.handle(t, request, responder);
}
}
private void logWithTrace(HttpRequest request, Throwable t) {
LOG.trace("Error in handling request={} {} for user={}:", request.method().name(), request.uri(), Objects.firstNonNull(SecurityRequestContext.getUserId(), "<null>"), t);
}
}).setHttpHandlers(handlers).build();
httpService.start();
cancelDiscovery = discoveryService.register(new Discoverable(Constants.Service.MESSAGING_SERVICE, httpService.getBindAddress()));
LOG.info("Messaging HTTP server started on {}", httpService.getBindAddress());
}
use of co.cask.cdap.common.metrics.MetricsReporterHook in project cdap by caskdata.
the class AppFabricServer method startUp.
/**
* Configures the AppFabricService pre-start.
*/
@Override
protected void startUp() throws Exception {
LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.APP_FABRIC_HTTP));
Futures.allAsList(ImmutableList.of(notificationService.start(), applicationLifecycleService.start(), systemArtifactLoader.start(), programRuntimeService.start(), streamCoordinatorClient.start(), programNotificationSubscriberService.start(), programLifecycleService.start(), runRecordCorrectorService.start(), pluginService.start(), coreSchedulerService.start())).get();
// Create handler hooks
ImmutableList.Builder<HandlerHook> builder = ImmutableList.builder();
for (String hook : handlerHookNames) {
builder.add(new MetricsReporterHook(metricsCollectionService, hook));
}
// Run http service on random port
NettyHttpService.Builder httpServiceBuilder = new CommonNettyHttpServiceBuilder(cConf, 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));
String password = generateRandomPassword();
KeyStore ks = KeyStores.generatedCertKeyStore(sConf, password);
SSLHandlerFactory sslHandlerFactory = new SSLHandlerFactory(ks, password);
httpServiceBuilder.enableSSL(sslHandlerFactory);
} else {
httpServiceBuilder.setPort(cConf.getInt(Constants.AppFabric.SERVER_PORT));
}
cancelHttpService = startHttpService(httpServiceBuilder.build());
defaultNamespaceEnsurer.startAndWait();
if (appVersionUpgradeService != null) {
appVersionUpgradeService.startAndWait();
}
}
Aggregations