Search in sources :

Example 1 with RetryOnStartFailureService

use of io.cdap.cdap.common.service.RetryOnStartFailureService in project cdap by caskdata.

the class AppFabricServiceMain method addServices.

@Override
protected void addServices(Injector injector, List<? super Service> services, List<? super AutoCloseable> closeableResources, MasterEnvironment masterEnv, MasterEnvironmentContext masterEnvContext, EnvironmentOptions options) {
    CConfiguration cConf = injector.getInstance(CConfiguration.class);
    if (SecurityUtil.isInternalAuthEnabled(cConf)) {
        services.add(injector.getInstance(TokenManager.class));
    }
    closeableResources.add(injector.getInstance(AccessControllerInstantiator.class));
    services.add(injector.getInstance(OperationalStatsService.class));
    services.add(injector.getInstance(SecureStoreService.class));
    services.add(injector.getInstance(DatasetOpExecutorService.class));
    services.add(injector.getInstance(ServiceStore.class));
    HealthCheckService healthCheckService = injector.getInstance(HealthCheckService.class);
    healthCheckService.helper(Constants.AppFabricHealthCheck.APP_FABRIC_HEALTH_CHECK_SERVICE, cConf, Constants.Service.MASTER_SERVICES_BIND_ADDRESS);
    services.add(healthCheckService);
    Binding<ZKClientService> zkBinding = injector.getExistingBinding(Key.get(ZKClientService.class));
    if (zkBinding != null) {
        services.add(zkBinding.getProvider().get());
    }
    // Start both the remote TwillRunnerService and regular TwillRunnerService
    TwillRunnerService remoteTwillRunner = injector.getInstance(Key.get(TwillRunnerService.class, Constants.AppFabric.RemoteExecution.class));
    services.add(new TwillRunnerServiceWrapper(remoteTwillRunner));
    services.add(new TwillRunnerServiceWrapper(injector.getInstance(TwillRunnerService.class)));
    services.add(new RetryOnStartFailureService(() -> injector.getInstance(DatasetService.class), RetryStrategies.exponentialDelay(200, 5000, TimeUnit.MILLISECONDS)));
    services.add(injector.getInstance(AppFabricServer.class));
    services.add(injector.getInstance(TetheringClientSubscriberService.class));
    if (cConf.getBoolean(Constants.TaskWorker.POOL_ENABLE)) {
        services.add(injector.getInstance(TaskWorkerServiceLauncher.class));
    }
    if (cConf.getBoolean(SystemWorker.POOL_ENABLE)) {
        services.add(injector.getInstance(SystemWorkerServiceLauncher.class));
    }
    // Optionally adds the master environment task
    masterEnv.getTask().ifPresent(task -> services.add(new MasterTaskExecutorService(task, masterEnvContext)));
}
Also used : TetheringClientSubscriberService(io.cdap.cdap.internal.tethering.TetheringClientSubscriberService) HealthCheckService(io.cdap.cdap.common.service.HealthCheckService) AppFabricServer(io.cdap.cdap.internal.app.services.AppFabricServer) AccessControllerInstantiator(io.cdap.cdap.security.authorization.AccessControllerInstantiator) Constants(io.cdap.cdap.common.conf.Constants) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) TaskWorkerServiceLauncher(io.cdap.cdap.internal.app.worker.TaskWorkerServiceLauncher) OperationalStatsService(io.cdap.cdap.operations.OperationalStatsService) ServiceStore(io.cdap.cdap.app.store.ServiceStore) ZKClientService(org.apache.twill.zookeeper.ZKClientService) DatasetOpExecutorService(io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService) TwillRunnerService(org.apache.twill.api.TwillRunnerService) SystemWorkerServiceLauncher(io.cdap.cdap.internal.app.worker.system.SystemWorkerServiceLauncher) RetryOnStartFailureService(io.cdap.cdap.common.service.RetryOnStartFailureService) TokenManager(io.cdap.cdap.security.auth.TokenManager) SecureStoreService(io.cdap.cdap.security.store.SecureStoreService)

Example 2 with RetryOnStartFailureService

use of io.cdap.cdap.common.service.RetryOnStartFailureService in project cdap by caskdata.

the class LogBufferService method loadLogPipelines.

/**
 * Load log buffer pipelines.
 */
@SuppressWarnings("unchecked")
private List<LogBufferProcessorPipeline> loadLogPipelines() {
    Map<String, LogPipelineSpecification<AppenderContext>> specs = new LogPipelineLoader(cConf).load(contextProvider);
    int pipelineCount = specs.size();
    List<LogBufferProcessorPipeline> bufferPipelines = new ArrayList<>();
    // Create one LogBufferProcessorPipeline per spec
    for (LogPipelineSpecification<AppenderContext> pipelineSpec : specs.values()) {
        CConfiguration cConf = pipelineSpec.getConf();
        AppenderContext context = pipelineSpec.getContext();
        long bufferSize = getBufferSize(pipelineCount, cConf);
        LogBufferPipelineConfig config = new LogBufferPipelineConfig(bufferSize, cConf.getLong(Constants.Logging.PIPELINE_EVENT_DELAY_MS), cConf.getLong(Constants.Logging.PIPELINE_CHECKPOINT_INTERVAL_MS), cConf.getLong(Constants.LogBuffer.LOG_BUFFER_PIPELINE_BATCH_SIZE, 1000));
        CheckpointManager checkpointManager = checkpointManagerFactory.create(pipelineSpec.getCheckpointPrefix(), CheckpointManagerFactory.Type.LOG_BUFFER);
        LogBufferProcessorPipeline pipeline = new LogBufferProcessorPipeline(new LogProcessorPipelineContext(cConf, context.getName(), context, context.getMetricsContext(), context.getInstanceId()), config, checkpointManager, 0);
        RetryStrategy retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.log.process.");
        pipelines.add(new RetryOnStartFailureService(() -> pipeline, retryStrategy));
        bufferPipelines.add(pipeline);
        checkpointManagers.add(checkpointManager);
    }
    return bufferPipelines;
}
Also used : LogPipelineSpecification(io.cdap.cdap.logging.framework.LogPipelineSpecification) CheckpointManager(io.cdap.cdap.logging.meta.CheckpointManager) ArrayList(java.util.ArrayList) LogPipelineLoader(io.cdap.cdap.logging.framework.LogPipelineLoader) LogProcessorPipelineContext(io.cdap.cdap.logging.pipeline.LogProcessorPipelineContext) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) LogBufferProcessorPipeline(io.cdap.cdap.logging.pipeline.logbuffer.LogBufferProcessorPipeline) LogBufferPipelineConfig(io.cdap.cdap.logging.pipeline.logbuffer.LogBufferPipelineConfig) AppenderContext(io.cdap.cdap.api.logging.AppenderContext) RetryOnStartFailureService(io.cdap.cdap.common.service.RetryOnStartFailureService) RetryStrategy(io.cdap.cdap.common.service.RetryStrategy)

Example 3 with RetryOnStartFailureService

use of io.cdap.cdap.common.service.RetryOnStartFailureService in project cdap by caskdata.

the class DistributedLogFramework method createService.

@Override
@SuppressWarnings("unchecked")
protected Service createService(Set<Integer> partitions) {
    Map<String, LogPipelineSpecification<AppenderContext>> specs = new LogPipelineLoader(cConf).load(contextProvider);
    int pipelineCount = specs.size();
    // Create one KafkaLogProcessorPipeline per spec
    final List<Service> pipelines = new ArrayList<>();
    for (final LogPipelineSpecification<AppenderContext> pipelineSpec : specs.values()) {
        final CConfiguration cConf = pipelineSpec.getConf();
        final AppenderContext context = pipelineSpec.getContext();
        long bufferSize = getBufferSize(pipelineCount, cConf, partitions.size());
        final String topic = cConf.get(Constants.Logging.KAFKA_TOPIC);
        final KafkaPipelineConfig config = new KafkaPipelineConfig(topic, partitions, bufferSize, cConf.getLong(Constants.Logging.PIPELINE_EVENT_DELAY_MS), cConf.getInt(Constants.Logging.PIPELINE_KAFKA_FETCH_SIZE), cConf.getLong(Constants.Logging.PIPELINE_CHECKPOINT_INTERVAL_MS));
        RetryStrategy retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.log.process.");
        pipelines.add(new RetryOnStartFailureService(() -> new KafkaLogProcessorPipeline(new LogProcessorPipelineContext(cConf, context.getName(), context, context.getMetricsContext(), context.getInstanceId()), checkpointManagerFactory.create(pipelineSpec.getCheckpointPrefix() + topic, CheckpointManagerFactory.Type.KAFKA), brokerService, config), retryStrategy));
    }
    // Returns a Service that start/stop all pipelines.
    return new AbstractIdleService() {

        @Override
        protected void startUp() throws Exception {
            // Starts all pipeline
            validateAllFutures(Iterables.transform(pipelines, Service::start));
        }

        @Override
        protected void shutDown() throws Exception {
            // Stops all pipeline
            validateAllFutures(Iterables.transform(pipelines, Service::stop));
        }
    };
}
Also used : LogPipelineSpecification(io.cdap.cdap.logging.framework.LogPipelineSpecification) ArrayList(java.util.ArrayList) KafkaPipelineConfig(io.cdap.cdap.logging.pipeline.kafka.KafkaPipelineConfig) RetryOnStartFailureService(io.cdap.cdap.common.service.RetryOnStartFailureService) AbstractIdleService(com.google.common.util.concurrent.AbstractIdleService) DiscoveryService(org.apache.twill.discovery.DiscoveryService) ResourceBalancerService(io.cdap.cdap.common.resource.ResourceBalancerService) Service(com.google.common.util.concurrent.Service) BrokerService(org.apache.twill.kafka.client.BrokerService) LogPipelineLoader(io.cdap.cdap.logging.framework.LogPipelineLoader) LogProcessorPipelineContext(io.cdap.cdap.logging.pipeline.LogProcessorPipelineContext) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) KafkaLogProcessorPipeline(io.cdap.cdap.logging.pipeline.kafka.KafkaLogProcessorPipeline) AppenderContext(io.cdap.cdap.api.logging.AppenderContext) RetryOnStartFailureService(io.cdap.cdap.common.service.RetryOnStartFailureService) AbstractIdleService(com.google.common.util.concurrent.AbstractIdleService) RetryStrategy(io.cdap.cdap.common.service.RetryStrategy)

Aggregations

CConfiguration (io.cdap.cdap.common.conf.CConfiguration)3 RetryOnStartFailureService (io.cdap.cdap.common.service.RetryOnStartFailureService)3 AppenderContext (io.cdap.cdap.api.logging.AppenderContext)2 RetryStrategy (io.cdap.cdap.common.service.RetryStrategy)2 LogPipelineLoader (io.cdap.cdap.logging.framework.LogPipelineLoader)2 LogPipelineSpecification (io.cdap.cdap.logging.framework.LogPipelineSpecification)2 LogProcessorPipelineContext (io.cdap.cdap.logging.pipeline.LogProcessorPipelineContext)2 ArrayList (java.util.ArrayList)2 AbstractIdleService (com.google.common.util.concurrent.AbstractIdleService)1 Service (com.google.common.util.concurrent.Service)1 ServiceStore (io.cdap.cdap.app.store.ServiceStore)1 Constants (io.cdap.cdap.common.conf.Constants)1 ResourceBalancerService (io.cdap.cdap.common.resource.ResourceBalancerService)1 HealthCheckService (io.cdap.cdap.common.service.HealthCheckService)1 DatasetOpExecutorService (io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService)1 AppFabricServer (io.cdap.cdap.internal.app.services.AppFabricServer)1 TaskWorkerServiceLauncher (io.cdap.cdap.internal.app.worker.TaskWorkerServiceLauncher)1 SystemWorkerServiceLauncher (io.cdap.cdap.internal.app.worker.system.SystemWorkerServiceLauncher)1 TetheringClientSubscriberService (io.cdap.cdap.internal.tethering.TetheringClientSubscriberService)1 CheckpointManager (io.cdap.cdap.logging.meta.CheckpointManager)1