Search in sources :

Example 41 with Service

use of com.google.common.util.concurrent.Service in project cdap by caskdata.

the class MetricsTestBase method init.

@Before
public void init() throws IOException, UnsupportedTypeException {
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    injector = Guice.createInjector(getModules());
    messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    metricValueType = TypeToken.of(MetricValues.class);
    schema = new ReflectionSchemaGenerator().generate(metricValueType.getType());
    recordWriter = new ASMDatumWriterFactory(new ASMFieldAccessorFactory()).create(metricValueType, schema);
}
Also used : ASMFieldAccessorFactory(co.cask.cdap.internal.io.ASMFieldAccessorFactory) ASMDatumWriterFactory(co.cask.cdap.internal.io.ASMDatumWriterFactory) MessagingService(co.cask.cdap.messaging.MessagingService) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) Service(com.google.common.util.concurrent.Service) MetricValues(co.cask.cdap.api.metrics.MetricValues) ReflectionSchemaGenerator(co.cask.cdap.internal.io.ReflectionSchemaGenerator) MessagingService(co.cask.cdap.messaging.MessagingService) Before(org.junit.Before)

Example 42 with Service

use of com.google.common.util.concurrent.Service in project cdap by caskdata.

the class MessagingServiceTwillRunnable method addServices.

@Override
protected void addServices(List<? super Service> services) {
    MessagingService messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        services.add((Service) messagingService);
    }
    services.add(injector.getInstance(MessagingHttpService.class));
}
Also used : MessagingService(co.cask.cdap.messaging.MessagingService) MessagingHttpService(co.cask.cdap.messaging.server.MessagingHttpService) Service(com.google.common.util.concurrent.Service) MessagingHttpService(co.cask.cdap.messaging.server.MessagingHttpService) MessagingService(co.cask.cdap.messaging.MessagingService)

Example 43 with Service

use of com.google.common.util.concurrent.Service in project cdap by caskdata.

the class StandaloneMain method startUp.

/**
   * Start the service.
   */
public void startUp() throws Exception {
    // Workaround for release of file descriptors opened by URLClassLoader - https://issues.cask.co/browse/CDAP-2841
    URLConnections.setDefaultUseCaches(false);
    cleanupTempDir();
    ConfigurationLogger.logImportantConfig(cConf);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    // TODO: CDAP-7688, remove next line after the issue is resolved
    injector.getInstance(MessagingHttpService.class).startAndWait();
    // Authorization bootstrapping is a blocking call, because CDAP will not start successfully if it does not
    // succeed on an authorization-enabled cluster
    authorizationBootstrapper.run();
    txService.startAndWait();
    metricsCollectionService.startAndWait();
    datasetService.startAndWait();
    serviceStore.startAndWait();
    streamService.startAndWait();
    // Validate the logging pipeline configuration.
    // Do it explicitly as Standalone doesn't have a separate master check phase as the distributed does.
    new LogPipelineLoader(cConf).validate();
    // It is recommended to initialize log appender after datasetService is started,
    // since log appender instantiates a dataset.
    logAppenderInitializer.initialize();
    Service.State state = appFabricServer.startAndWait();
    if (state != Service.State.RUNNING) {
        throw new Exception("Failed to start Application Fabric");
    }
    metricsQueryService.startAndWait();
    router.startAndWait();
    if (userInterfaceService != null) {
        userInterfaceService.startAndWait();
    }
    if (securityEnabled) {
        externalAuthenticationServer.startAndWait();
    }
    if (exploreExecutorService != null) {
        exploreExecutorService.startAndWait();
    }
    metadataService.startAndWait();
    if (trackerAppCreationService != null) {
        trackerAppCreationService.startAndWait();
    }
    wranglerAppCreationService.startAndWait();
    remoteSystemOperationsService.startAndWait();
    operationalStatsService.startAndWait();
    String protocol = sslEnabled ? "https" : "http";
    int dashboardPort = sslEnabled ? cConf.getInt(Constants.Dashboard.SSL_BIND_PORT) : cConf.getInt(Constants.Dashboard.BIND_PORT);
    System.out.println("CDAP Sandbox started successfully.");
    System.out.printf("Connect to the CDAP UI at %s://%s:%d\n", protocol, "localhost", dashboardPort);
}
Also used : MessagingService(co.cask.cdap.messaging.MessagingService) MessagingHttpService(co.cask.cdap.messaging.server.MessagingHttpService) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) MetricsQueryService(co.cask.cdap.metrics.query.MetricsQueryService) StreamService(co.cask.cdap.data.stream.service.StreamService) RemoteSystemOperationsService(co.cask.cdap.gateway.handlers.meta.RemoteSystemOperationsService) MetadataService(co.cask.cdap.metadata.MetadataService) ExploreExecutorService(co.cask.cdap.explore.executor.ExploreExecutorService) OperationalStatsService(co.cask.cdap.operations.OperationalStatsService) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) Service(com.google.common.util.concurrent.Service) InMemoryTransactionService(org.apache.tephra.inmemory.InMemoryTransactionService) LogPipelineLoader(co.cask.cdap.logging.framework.LogPipelineLoader) MessagingHttpService(co.cask.cdap.messaging.server.MessagingHttpService) ServiceBindException(co.cask.cdap.common.ServiceBindException) IOException(java.io.IOException)

Aggregations

Service (com.google.common.util.concurrent.Service)43 MessagingService (co.cask.cdap.messaging.MessagingService)15 AbstractIdleService (com.google.common.util.concurrent.AbstractIdleService)15 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)14 Test (org.junit.Test)14 IOException (java.io.IOException)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ProgramId (co.cask.cdap.proto.id.ProgramId)7 ProgramContextAware (co.cask.cdap.data.ProgramContextAware)6 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)6 BasicProgramContext (co.cask.cdap.internal.app.runtime.BasicProgramContext)6 ProgramType (co.cask.cdap.proto.ProgramType)6 RunId (org.apache.twill.api.RunId)6 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)5 CConfiguration (co.cask.cdap.common.conf.CConfiguration)5 Injector (com.google.inject.Injector)5 PluginInstantiator (co.cask.cdap.internal.app.runtime.plugin.PluginInstantiator)4 RunId (com.continuuity.weave.api.RunId)4 ZKClientService (com.continuuity.weave.zookeeper.ZKClientService)4 Configuration (org.apache.hadoop.conf.Configuration)4