use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class DataSetServiceModules method getStandaloneModules.
@Override
public Module getStandaloneModules() {
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().getStandaloneModules());
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"));
Multibinder.newSetBinder(binder(), DatasetMetricsReporter.class).addBinding().to(LevelDBDatasetMetricsReporter.class);
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);
bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
expose(DatasetOpExecutorService.class);
bind(DatasetOpExecutor.class).to(LocalDatasetOpExecutor.class);
expose(DatasetOpExecutor.class);
bind(DatasetTypeService.class).annotatedWith(Names.named(NOAUTH_DATASET_TYPE_SERVICE)).to(DefaultDatasetTypeService.class);
bind(DatasetTypeService.class).to(AuthorizationDatasetTypeService.class);
expose(DatasetTypeService.class);
}
});
}
};
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class DataSetsModules method getInMemoryModules.
@Override
public Module getInMemoryModules() {
return new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(MetadataStore.class).to(NoOpMetadataStore.class);
expose(MetadataStore.class);
bind(DatasetFramework.class).annotatedWith(Names.named(BASE_DATASET_FRAMEWORK)).to(InMemoryDatasetFramework.class).in(Scopes.SINGLETON);
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);
}
};
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class LocalRouteStoreTest method beforeClass.
@BeforeClass
public static void beforeClass() throws DatasetManagementException, IOException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
txManager = new TransactionManager(new Configuration());
txManager.startAndWait();
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocationRuntimeModule().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AbstractModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
bind(NamespaceQueryAdmin.class).to(InMemoryNamespaceClient.class).in(Scopes.SINGLETON);
}
});
datasetFramework = injector.getInstance(DatasetFramework.class);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class JobQueueDatasetTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException, DatasetManagementException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
txManager = new TransactionManager(new Configuration());
txManager.startAndWait();
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocationRuntimeModule().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AbstractModule() {
@Override
protected void configure() {
// Add the app-fabric Dataset module, which is where the JobQueueDataset is defined
MapBinder<String, DatasetModule> datasetModuleBinder = MapBinder.newMapBinder(binder(), String.class, DatasetModule.class, Constants.Dataset.Manager.DefaultDatasetModules.class);
datasetModuleBinder.addBinding("app-fabric").toInstance(new AppFabricDatasetModule());
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
bind(NamespaceQueryAdmin.class).to(InMemoryNamespaceClient.class).in(Scopes.SINGLETON);
}
});
DatasetFramework datasetFramework = injector.getInstance(DatasetFramework.class);
DatasetsUtil.createIfNotExists(datasetFramework, Schedulers.JOB_QUEUE_DATASET_ID, JobQueueDataset.class.getName(), DatasetProperties.EMPTY);
jobQueue = datasetFramework.getDataset(Schedulers.JOB_QUEUE_DATASET_ID, new HashMap<String, String>(), null);
txExecutor = new DynamicTransactionExecutorFactory(new InMemoryTxSystemClient(txManager)).createExecutor(Collections.<TransactionAware>singleton(jobQueue));
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class DistributedProgramRunnableModule method getCoreModules.
private List<Module> getCoreModules(final ProgramId programId, String txClientId) {
return new ArrayList<>(Arrays.<Module>asList(new ConfigModule(cConf, hConf), new IOModule(), new ZKClientModule(), new KafkaClientModule(), new MetricsClientRuntimeModule().getDistributedModules(), new MessagingClientModule(), new LocationRuntimeModule().getDistributedModules(), new LoggingModules().getDistributedModules(), new DiscoveryRuntimeModule().getDistributedModules(), new DataFabricModules(txClientId).getDistributedModules(), new DataSetsModules().getDistributedModules(), new ViewAdminModules().getDistributedModules(), new StreamAdminModules().getDistributedModules(), new NotificationFeedClientModule(), new AuditModule().getDistributedModules(), new NamespaceClientRuntimeModule().getDistributedModules(), new AuthorizationEnforcementModule().getDistributedModules(), new SecureStoreModules().getDistributedModules(), new AbstractModule() {
@Override
protected void configure() {
// For Binding queue stuff
bind(QueueReaderFactory.class).in(Scopes.SINGLETON);
// For binding DataSet transaction stuff
install(new DataFabricFacadeModule());
bind(ProgramStateWriter.class).to(MessagingProgramStateWriter.class);
bind(RuntimeStore.class).to(RemoteRuntimeStore.class);
// For binding StreamWriter
install(createStreamFactoryModule());
// don't need to perform any impersonation from within user programs
bind(UGIProvider.class).to(CurrentUGIProvider.class).in(Scopes.SINGLETON);
// bind PrivilegesManager to a remote implementation, so it does not need to instantiate the authorizer
bind(PrivilegesManager.class).to(RemotePrivilegesManager.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
// Bind ProgramId to the passed in instance programId so that we can retrieve it back later when needed.
// For example see ProgramDiscoveryExploreClient.
// Also binding to instance is fine here as the programId is guaranteed to not change throughout the
// lifecycle of this program runnable
bind(ProgramId.class).toInstance(programId);
// bind explore client to ProgramDiscoveryExploreClient which is aware of the programId
bind(ExploreClient.class).to(ProgramDiscoveryExploreClient.class).in(Scopes.SINGLETON);
// Bind the ArtifactManager implementation
install(new FactoryModuleBuilder().implement(ArtifactManager.class, RemoteArtifactManager.class).build(ArtifactManagerFactory.class));
// Bind the PluginFinder implementation
bind(PluginFinder.class).to(RemotePluginFinder.class);
}
}));
}
Aggregations