Search in sources :

Example 16 with MetadataStorage

use of io.cdap.cdap.spi.metadata.MetadataStorage in project cdap by caskdata.

the class MetadataServiceMain method addServices.

@Override
protected void addServices(Injector injector, List<? super Service> services, List<? super AutoCloseable> closeableResources, MasterEnvironment masterEnv, MasterEnvironmentContext masterEnvContext, EnvironmentOptions options) {
    services.add(injector.getInstance(MetadataService.class));
    services.add(injector.getInstance(MetadataSubscriberService.class));
    Binding<ZKClientService> zkBinding = injector.getExistingBinding(Key.get(ZKClientService.class));
    if (zkBinding != null) {
        services.add(zkBinding.getProvider().get());
    }
    CConfiguration cConf = injector.getInstance(CConfiguration.class);
    if (SecurityUtil.isInternalAuthEnabled(cConf)) {
        services.add(injector.getInstance(TokenManager.class));
    }
    // Add a service just for closing MetadataStorage to release resource.
    // MetadataStorage is binded as Singleton, so ok to get the instance and close it.
    MetadataStorage metadataStorage = injector.getInstance(MetadataStorage.class);
    services.add(new AbstractService() {

        @Override
        protected void doStart() {
            notifyStarted();
        }

        @Override
        protected void doStop() {
            Closeables.closeQuietly(metadataStorage);
            notifyStopped();
        }
    });
}
Also used : ZKClientService(org.apache.twill.zookeeper.ZKClientService) MetadataSubscriberService(io.cdap.cdap.metadata.MetadataSubscriberService) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) TokenManager(io.cdap.cdap.security.auth.TokenManager) AbstractService(com.google.common.util.concurrent.AbstractService) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MetadataService(io.cdap.cdap.metadata.MetadataService)

Aggregations

MetadataStorage (io.cdap.cdap.spi.metadata.MetadataStorage)16 Injector (com.google.inject.Injector)7 Test (org.junit.Test)7 StructuredTableAdmin (io.cdap.cdap.spi.data.StructuredTableAdmin)6 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)5 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)5 MessagingService (io.cdap.cdap.messaging.MessagingService)5 MetadataService (io.cdap.cdap.metadata.MetadataService)5 MetadataSubscriberService (io.cdap.cdap.metadata.MetadataSubscriberService)5 Metadata (io.cdap.cdap.spi.metadata.Metadata)5 TransactionManager (org.apache.tephra.TransactionManager)5 BeforeClass (org.junit.BeforeClass)5 Service (com.google.common.util.concurrent.Service)4 AbstractModule (com.google.inject.AbstractModule)4 MetadataEntity (io.cdap.cdap.api.metadata.MetadataEntity)4 DatasetService (io.cdap.cdap.data2.datafabric.dataset.service.DatasetService)4 DatasetOpExecutorService (io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService)4 AppFabricServer (io.cdap.cdap.internal.app.services.AppFabricServer)4 AppFabricTestModule (io.cdap.cdap.internal.guice.AppFabricTestModule)4 CoreSchedulerService (io.cdap.cdap.scheduler.CoreSchedulerService)4