Search in sources :

Example 21 with PrivateModule

use of com.google.inject.PrivateModule in project cdap by caskdata.

the class DataSetServiceModules method getInMemoryModules.

@Override
public Module getInMemoryModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            // Add the system dataset runtime module as public binding so that adding bindings could be added
            install(new SystemDatasetRuntimeModule().getInMemoryModules());
            install(new PrivateModule() {

                @Override
                protected void configure() {
                    install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
                    bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).toProvider(DatasetMdsProvider.class).in(Singleton.class);
                    expose(DatasetFramework.class).annotatedWith(Names.named("datasetMDS"));
                    bind(DatasetService.class);
                    expose(DatasetService.class);
                    Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
                    Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
                    CommonHandlers.add(handlerBinder);
                    handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
                    Multibinder.newSetBinder(binder(), DatasetMetricsReporter.class);
                    bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
                    expose(DatasetOpExecutorService.class);
                    bind(DatasetOpExecutor.class).to(LocalDatasetOpExecutor.class);
                    expose(DatasetOpExecutor.class);
                }
            });
        }
    };
}
Also used : Named(com.google.inject.name.Named) HttpHandler(co.cask.http.HttpHandler) DatasetAdminOpHTTPHandler(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpHTTPHandler) Multibinder(com.google.inject.multibindings.Multibinder) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) DefaultDatasetDefinitionRegistry(co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry) DatasetDefinitionRegistry(co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry) LocalDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.LocalDatasetOpExecutor) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) YarnDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.YarnDatasetOpExecutor) AbstractModule(com.google.inject.AbstractModule) DefaultDatasetDefinitionRegistry(co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry) Singleton(com.google.inject.Singleton) DatasetOpExecutorService(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService) LevelDBDatasetMetricsReporter(co.cask.cdap.data2.metrics.LevelDBDatasetMetricsReporter) DatasetMetricsReporter(co.cask.cdap.data2.metrics.DatasetMetricsReporter) HBaseDatasetMetricsReporter(co.cask.cdap.data2.metrics.HBaseDatasetMetricsReporter) LocalDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.LocalDatasetOpExecutor) PrivateModule(com.google.inject.PrivateModule)

Example 22 with PrivateModule

use of com.google.inject.PrivateModule in project cdap by caskdata.

the class DataSetsModules method getModule.

private Module getModule() {
    return new PrivateModule() {

        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            bind(MetadataStore.class).to(DefaultMetadataStore.class);
            expose(MetadataStore.class);
            bind(DatasetFramework.class).annotatedWith(Names.named(BASE_DATASET_FRAMEWORK)).to(RemoteDatasetFramework.class);
            bind(LineageStoreReader.class).to(LineageStore.class);
            bind(LineageStoreWriter.class).to(LineageStore.class);
            // Need to expose LineageStoreReader as it's being used by the LineageHandler (through LineageAdmin)
            expose(LineageStoreReader.class);
            bind(LineageWriter.class).to(BasicLineageWriter.class);
            expose(LineageWriter.class);
            bind(UsageRegistry.class).to(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
            expose(UsageRegistry.class);
            bind(RuntimeUsageRegistry.class).to(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
            expose(RuntimeUsageRegistry.class);
            bind(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
            bind(DatasetFramework.class).to(LineageWriterDatasetFramework.class);
            expose(DatasetFramework.class);
            bind(DefaultOwnerStore.class).in(Scopes.SINGLETON);
            bind(OwnerStore.class).to(DefaultOwnerStore.class);
            expose(OwnerStore.class);
        }
    };
}
Also used : DefaultMetadataStore(co.cask.cdap.data2.metadata.store.DefaultMetadataStore) NoOpMetadataStore(co.cask.cdap.data2.metadata.store.NoOpMetadataStore) MetadataStore(co.cask.cdap.data2.metadata.store.MetadataStore) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) RemoteDatasetFramework(co.cask.cdap.data2.datafabric.dataset.RemoteDatasetFramework) LineageWriterDatasetFramework(co.cask.cdap.data2.metadata.writer.LineageWriterDatasetFramework) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) LineageWriter(co.cask.cdap.data2.metadata.writer.LineageWriter) BasicLineageWriter(co.cask.cdap.data2.metadata.writer.BasicLineageWriter) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) LineageStoreReader(co.cask.cdap.data2.metadata.lineage.LineageStoreReader) DefaultOwnerStore(co.cask.cdap.store.DefaultOwnerStore) LineageStoreWriter(co.cask.cdap.data2.metadata.lineage.LineageStoreWriter) DefaultUsageRegistry(co.cask.cdap.data2.registry.DefaultUsageRegistry) PrivateModule(com.google.inject.PrivateModule) OwnerStore(co.cask.cdap.security.impersonation.OwnerStore) DefaultOwnerStore(co.cask.cdap.store.DefaultOwnerStore)

Example 23 with PrivateModule

use of com.google.inject.PrivateModule in project cdap by caskdata.

the class PreviewDataModules method getDataSetsModule.

public Module getDataSetsModule(final DatasetFramework remoteDatasetFramework) {
    return new PrivateModule() {

        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            bind(MetadataStore.class).to(DefaultMetadataStore.class);
            expose(MetadataStore.class);
            bind(DatasetFramework.class).annotatedWith(Names.named("localDatasetFramework")).to(RemoteDatasetFramework.class);
            bind(DatasetFramework.class).annotatedWith(Names.named("actualDatasetFramework")).toInstance(remoteDatasetFramework);
            bind(DatasetFramework.class).annotatedWith(Names.named(BASE_DATASET_FRAMEWORK)).toProvider(PreviewDatasetFrameworkProvider.class).in(Scopes.SINGLETON);
            bind(DatasetFramework.class).toProvider(PreviewDatasetFrameworkProvider.class).in(Scopes.SINGLETON);
            expose(DatasetFramework.class);
            bind(LineageStoreReader.class).to(LineageStore.class);
            bind(LineageStoreWriter.class).to(LineageStore.class);
            // Need to expose LineageStoreReader as it's being used by the LineageHandler (through LineageAdmin)
            expose(LineageStoreReader.class);
            bind(LineageWriter.class).to(BasicLineageWriter.class);
            expose(LineageWriter.class);
            bind(RuntimeUsageRegistry.class).to(NoOpUsageRegistry.class).in(Scopes.SINGLETON);
            expose(RuntimeUsageRegistry.class);
            bind(UsageRegistry.class).to(NoOpUsageRegistry.class).in(Scopes.SINGLETON);
            expose(UsageRegistry.class);
        }
    };
}
Also used : DefaultMetadataStore(co.cask.cdap.data2.metadata.store.DefaultMetadataStore) MetadataStore(co.cask.cdap.data2.metadata.store.MetadataStore) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) RemoteDatasetFramework(co.cask.cdap.data2.datafabric.dataset.RemoteDatasetFramework) PreviewDatasetFramework(co.cask.cdap.data2.dataset2.preview.PreviewDatasetFramework) DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) LineageWriter(co.cask.cdap.data2.metadata.writer.LineageWriter) BasicLineageWriter(co.cask.cdap.data2.metadata.writer.BasicLineageWriter) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) LineageStoreReader(co.cask.cdap.data2.metadata.lineage.LineageStoreReader) LineageStoreWriter(co.cask.cdap.data2.metadata.lineage.LineageStoreWriter) NoOpUsageRegistry(co.cask.cdap.data2.registry.NoOpUsageRegistry) PrivateModule(com.google.inject.PrivateModule)

Example 24 with PrivateModule

use of com.google.inject.PrivateModule in project cdap by caskdata.

the class DatasetFrameworkTestUtil method before.

@Override
protected void before() throws Throwable {
    this.tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    File localDataDir = tmpFolder.newFolder();
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, localDataDir.getAbsolutePath());
    injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new PrivateModule() {

        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
            expose(DatasetFramework.class);
        }
    });
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    framework = injector.getInstance(DatasetFramework.class);
}
Also used : TransactionModules(org.apache.tephra.runtime.TransactionModules) TransactionExecutorModule(co.cask.cdap.data.runtime.TransactionExecutorModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) TransactionManager(org.apache.tephra.TransactionManager) TemporaryFolder(org.junit.rules.TemporaryFolder) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) File(java.io.File) PrivateModule(com.google.inject.PrivateModule)

Example 25 with PrivateModule

use of com.google.inject.PrivateModule in project cdap by caskdata.

the class AppFabricTestModule method configure.

@Override
protected void configure() {
    install(new DataFabricModules().getInMemoryModules());
    install(new DataSetsModules().getStandaloneModules());
    install(new TransactionExecutorModule());
    install(new DataSetServiceModules().getInMemoryModules());
    install(new ConfigModule(cConf, hConf, sConf));
    install(new IOModule());
    install(new DiscoveryRuntimeModule().getInMemoryModules());
    install(new AppFabricServiceRuntimeModule().getInMemoryModules());
    install(new ServiceStoreModules().getInMemoryModules());
    install(new PrivateModule() {

        @Override
        protected void configure() {
            bind(Scheduler.class).annotatedWith(Assisted.class).toInstance(createNoopScheduler());
        }
    });
    install(new ProgramRunnerRuntimeModule().getInMemoryModules());
    install(new NonCustomLocationUnitTestModule().getModule());
    install(new LoggingModules().getInMemoryModules());
    install(new LogReaderRuntimeModules().getInMemoryModules());
    install(new MetricsHandlerModule());
    install(new MetricsClientRuntimeModule().getInMemoryModules());
    install(new ExploreClientModule());
    install(new NotificationFeedServiceRuntimeModule().getInMemoryModules());
    install(new NotificationServiceRuntimeModule().getInMemoryModules());
    install(new ConfigStoreModule().getInMemoryModule());
    install(new ViewAdminModules().getInMemoryModules());
    install(new StreamAdminModules().getInMemoryModules());
    install(new StreamServiceRuntimeModule().getInMemoryModules());
    install(new NamespaceStoreModule().getStandaloneModules());
    install(new MetadataServiceModule());
    install(new RemoteSystemOperationsServiceModule());
    install(new AuthorizationModule());
    install(new AuthorizationEnforcementModule().getStandaloneModules());
    install(new SecureStoreModules().getInMemoryModules());
    install(new MessagingServerRuntimeModule().getInMemoryModules());
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) DataSetServiceModules(co.cask.cdap.data.runtime.DataSetServiceModules) ConfigModule(co.cask.cdap.common.guice.ConfigModule) Scheduler(co.cask.cdap.internal.app.runtime.schedule.Scheduler) NamespaceStoreModule(co.cask.cdap.store.guice.NamespaceStoreModule) MessagingServerRuntimeModule(co.cask.cdap.messaging.guice.MessagingServerRuntimeModule) MetricsClientRuntimeModule(co.cask.cdap.metrics.guice.MetricsClientRuntimeModule) NotificationServiceRuntimeModule(co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule) RemoteSystemOperationsServiceModule(co.cask.cdap.gateway.handlers.meta.RemoteSystemOperationsServiceModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) TransactionExecutorModule(co.cask.cdap.data.runtime.TransactionExecutorModule) StreamServiceRuntimeModule(co.cask.cdap.data.stream.service.StreamServiceRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) ConfigStoreModule(co.cask.cdap.config.guice.ConfigStoreModule) AuthorizationModule(co.cask.cdap.app.guice.AuthorizationModule) PrivateModule(com.google.inject.PrivateModule) LogReaderRuntimeModules(co.cask.cdap.logging.guice.LogReaderRuntimeModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) SecureStoreModules(co.cask.cdap.security.guice.SecureStoreModules) MetadataServiceModule(co.cask.cdap.metadata.MetadataServiceModule) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) LoggingModules(co.cask.cdap.logging.guice.LoggingModules) StreamAdminModules(co.cask.cdap.data.stream.StreamAdminModules) ProgramRunnerRuntimeModule(co.cask.cdap.app.guice.ProgramRunnerRuntimeModule) MetricsHandlerModule(co.cask.cdap.metrics.guice.MetricsHandlerModule) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) NotificationFeedServiceRuntimeModule(co.cask.cdap.notifications.feeds.guice.NotificationFeedServiceRuntimeModule) DataFabricModules(co.cask.cdap.data.runtime.DataFabricModules) AppFabricServiceRuntimeModule(co.cask.cdap.app.guice.AppFabricServiceRuntimeModule) ServiceStoreModules(co.cask.cdap.app.guice.ServiceStoreModules) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule)

Aggregations

PrivateModule (com.google.inject.PrivateModule)28 Injector (com.google.inject.Injector)17 AbstractModule (com.google.inject.AbstractModule)16 Module (com.google.inject.Module)10 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)10 Guice.createInjector (com.google.inject.Guice.createInjector)6 DatasetDefinitionRegistry (co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry)5 ConfigModule (co.cask.cdap.common.guice.ConfigModule)5 DefaultDatasetDefinitionRegistry (co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry)5 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)4 Binding (com.google.inject.Binding)4 Key (com.google.inject.Key)4 Singleton (com.google.inject.Singleton)4 Named (com.google.inject.name.Named)4 Element (com.google.inject.spi.Element)4 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)3 RemoteDatasetFramework (co.cask.cdap.data2.datafabric.dataset.RemoteDatasetFramework)3 DatasetDefinitionRegistryFactory (co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory)3 LineageStoreReader (co.cask.cdap.data2.metadata.lineage.LineageStoreReader)3 LineageStoreWriter (co.cask.cdap.data2.metadata.lineage.LineageStoreWriter)3