Search in sources :

Example 1 with LogBufferHandler

use of io.cdap.cdap.logging.logbuffer.handler.LogBufferHandler in project cdap by caskdata.

the class LogBufferService method startUp.

@Override
protected void startUp() throws Exception {
    // load log pipelines
    List<LogBufferProcessorPipeline> bufferPipelines = loadLogPipelines();
    // start all the log pipelines
    validateAllFutures(Iterables.transform(pipelines, Service::start));
    // recovery service and http handler will send log events to log pipelines. In order to avoid deleting file while
    // reading them in recovery service, we will pass in an atomic boolean will be set to true by recovery service
    // when it is done recovering data. So while recovery service is running, cleanup task will be a no-op
    AtomicBoolean startCleanup = new AtomicBoolean(false);
    // start log recovery service to recover all the pending logs.
    recoveryService = new LogBufferRecoveryService(cConf, bufferPipelines, checkpointManagers, startCleanup);
    recoveryService.startAndWait();
    // create concurrent writer
    ConcurrentLogBufferWriter concurrentWriter = new ConcurrentLogBufferWriter(cConf, bufferPipelines, new LogBufferCleaner(cConf, checkpointManagers, startCleanup));
    // create and start http service
    NettyHttpService.Builder builder = new CommonNettyHttpServiceBuilder(cConf, Constants.Service.LOG_BUFFER_SERVICE).setHttpHandlers(new LogBufferHandler(concurrentWriter)).setExceptionHandler(new HttpExceptionHandler()).setHost(cConf.get(Constants.LogBuffer.LOG_BUFFER_SERVER_BIND_ADDRESS)).setPort(cConf.getInt(Constants.LogBuffer.LOG_BUFFER_SERVER_BIND_PORT));
    if (cConf.getBoolean(Constants.Security.SSL.INTERNAL_ENABLED)) {
        new HttpsEnabler().configureKeyStore(cConf, sConf).enable(builder);
    }
    httpService = builder.build();
    httpService.start();
    cancellable = discoveryService.register(ResolvingDiscoverable.of(URIScheme.createDiscoverable(Constants.Service.LOG_BUFFER_SERVICE, httpService)));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogBufferCleaner(io.cdap.cdap.logging.logbuffer.cleaner.LogBufferCleaner) CommonNettyHttpServiceBuilder(io.cdap.cdap.common.http.CommonNettyHttpServiceBuilder) LogBufferProcessorPipeline(io.cdap.cdap.logging.pipeline.logbuffer.LogBufferProcessorPipeline) LogBufferRecoveryService(io.cdap.cdap.logging.logbuffer.recover.LogBufferRecoveryService) LogBufferHandler(io.cdap.cdap.logging.logbuffer.handler.LogBufferHandler) NettyHttpService(io.cdap.http.NettyHttpService) HttpsEnabler(io.cdap.cdap.common.security.HttpsEnabler) HttpExceptionHandler(io.cdap.cdap.common.HttpExceptionHandler)

Aggregations

HttpExceptionHandler (io.cdap.cdap.common.HttpExceptionHandler)1 CommonNettyHttpServiceBuilder (io.cdap.cdap.common.http.CommonNettyHttpServiceBuilder)1 HttpsEnabler (io.cdap.cdap.common.security.HttpsEnabler)1 LogBufferCleaner (io.cdap.cdap.logging.logbuffer.cleaner.LogBufferCleaner)1 LogBufferHandler (io.cdap.cdap.logging.logbuffer.handler.LogBufferHandler)1 LogBufferRecoveryService (io.cdap.cdap.logging.logbuffer.recover.LogBufferRecoveryService)1 LogBufferProcessorPipeline (io.cdap.cdap.logging.pipeline.logbuffer.LogBufferProcessorPipeline)1 NettyHttpService (io.cdap.http.NettyHttpService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1