use of io.cdap.cdap.data.runtime.StorageModule in project cdap by caskdata.
the class TetheringProvisionerTest method testGuiceInjector.
@Test
public void testGuiceInjector() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new InMemoryDiscoveryModule(), new StorageModule(), new ProvisionerModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
bind(SecureStore.class).toInstance(FakeSecureStore.builder().build());
bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class);
}
});
ProvisionerProvider provisionerProvider = injector.getInstance(ProvisionerProvider.class);
Map<String, Provisioner> provisioners = provisionerProvider.loadProvisioners();
Assert.assertNotNull(provisioners.get(TetheringProvisioner.TETHERING_NAME));
ProvisionerConfigProvider configProvider = injector.getInstance(ProvisionerConfigProvider.class);
Map<String, ProvisionerConfig> configs = configProvider.loadProvisionerConfigs(provisioners.values());
Assert.assertNotNull(configs.get(TetheringProvisioner.TETHERING_NAME));
}
use of io.cdap.cdap.data.runtime.StorageModule in project cdap by caskdata.
the class TetheringServerHandlerTest method setup.
@BeforeClass
public static void setup() throws IOException {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
topicPrefix = cConf.get(Constants.Tethering.TOPIC_PREFIX);
injector = Guice.createInjector(new ConfigModule(cConf), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new StorageModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new PrivateModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
expose(MetricsCollectionService.class);
}
});
tetheringStore = new TetheringStore(injector.getInstance(TransactionRunner.class));
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of io.cdap.cdap.data.runtime.StorageModule 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(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new StorageModule(), new PrivateModule() {
@Override
protected void configure() {
bind(DatasetDefinitionRegistryFactory.class).to(DefaultDatasetDefinitionRegistryFactory.class).in(Scopes.SINGLETON);
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
expose(MetricsCollectionService.class);
expose(DatasetFramework.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
framework = injector.getInstance(DatasetFramework.class);
}
use of io.cdap.cdap.data.runtime.StorageModule in project cdap by caskdata.
the class RemoteDatasetFrameworkTest method before.
@Before
public void before() throws Exception {
cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, "localhost");
cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, true);
Configuration txConf = HBaseConfiguration.create();
CConfigurationUtil.copyTxProperties(cConf, txConf);
// ok to pass null, since the impersonator won't actually be called, if kerberos security is not enabled
Impersonator impersonator = new DefaultImpersonator(cConf, null);
// TODO: Refactor to use injector for everything
Injector injector = Guice.createInjector(new ConfigModule(cConf, txConf), RemoteAuthenticatorModules.getNoOpModule(), new InMemoryDiscoveryModule(), new AuthorizationTestModule(), new StorageModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new TransactionInMemoryModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Singleton.class);
bind(DatasetDefinitionRegistryFactory.class).to(DefaultDatasetDefinitionRegistryFactory.class).in(Scopes.SINGLETON);
// through the injector, we only need RemoteDatasetFramework in these tests
bind(RemoteDatasetFramework.class);
}
});
// Tx Manager to support working with datasets
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
TransactionRunner transactionRunner = injector.getInstance(TransactionRunner.class);
StructuredTableAdmin structuredTableAdmin = injector.getInstance(StructuredTableAdmin.class);
StoreDefinition.createAllTables(structuredTableAdmin);
InMemoryTxSystemClient txSystemClient = new InMemoryTxSystemClient(txManager);
TransactionSystemClientService txSystemClientService = new DelegatingTransactionSystemClientService(txSystemClient);
DiscoveryService discoveryService = injector.getInstance(DiscoveryService.class);
DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
AuthenticationContext authenticationContext = injector.getInstance(AuthenticationContext.class);
RemoteClientFactory remoteClientFactory = injector.getInstance(RemoteClientFactory.class);
framework = createFramework(authenticationContext, remoteClientFactory);
SystemDatasetInstantiatorFactory datasetInstantiatorFactory = new SystemDatasetInstantiatorFactory(locationFactory, framework, cConf);
DatasetAdminService datasetAdminService = new DatasetAdminService(framework, cConf, locationFactory, datasetInstantiatorFactory, impersonator);
ImmutableSet<HttpHandler> handlers = ImmutableSet.of(new DatasetAdminOpHTTPHandler(datasetAdminService));
opExecutorService = new DatasetOpExecutorService(cConf, SConfiguration.create(), discoveryService, metricsCollectionService, handlers);
opExecutorService.startAndWait();
DiscoveryExploreClient exploreClient = new DiscoveryExploreClient(discoveryServiceClient, authenticationContext);
ExploreFacade exploreFacade = new ExploreFacade(exploreClient, cConf);
AccessEnforcer accessEnforcer = injector.getInstance(AccessEnforcer.class);
DatasetTypeManager typeManager = new DatasetTypeManager(cConf, locationFactory, impersonator, transactionRunner);
DatasetInstanceManager instanceManager = new DatasetInstanceManager(transactionRunner);
DatasetTypeService noAuthTypeService = new DefaultDatasetTypeService(typeManager, namespaceQueryAdmin, namespacePathLocator, cConf, impersonator, txSystemClientService, transactionRunner, DEFAULT_MODULES);
DatasetTypeService typeService = new AuthorizationDatasetTypeService(noAuthTypeService, accessEnforcer, authenticationContext);
DatasetOpExecutor opExecutor = new RemoteDatasetOpExecutor(authenticationContext, remoteClientFactory);
DatasetInstanceService instanceService = new DatasetInstanceService(typeService, noAuthTypeService, instanceManager, opExecutor, exploreFacade, namespaceQueryAdmin, ownerAdmin, accessEnforcer, authenticationContext, new NoOpMetadataServiceClient());
instanceService.setAuditPublisher(inMemoryAuditPublisher);
service = new DatasetService(cConf, SConfiguration.create(), discoveryService, discoveryServiceClient, metricsCollectionService, new HashSet<>(), typeService, instanceService);
// Start dataset service, wait for it to be discoverable
service.startAndWait();
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryServiceClient.discover(Constants.Service.DATASET_MANAGER));
Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", service);
}
use of io.cdap.cdap.data.runtime.StorageModule in project cdap by caskdata.
the class NoSqlJobQueueTableTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException, TableAlreadyExistsException {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.Dataset.DATA_STORAGE_IMPLEMENTATION, Constants.Dataset.DATA_STORAGE_NOSQL);
txManager = new TransactionManager(new Configuration());
txManager.startAndWait();
Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new StorageModule(), new AbstractModule() {
@Override
protected void configure() {
bind(DatasetDefinitionRegistryFactory.class).to(DefaultDatasetDefinitionRegistryFactory.class).in(Scopes.SINGLETON);
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
bind(NamespaceQueryAdmin.class).to(InMemoryNamespaceAdmin.class).in(Scopes.SINGLETON);
bind(TransactionSystemClient.class).toInstance(new InMemoryTxSystemClient(txManager));
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
}
});
StructuredTableAdmin tableAdmin = injector.getInstance(StructuredTableAdmin.class);
transactionRunner = injector.getInstance(TransactionRunner.class);
StoreDefinition.JobQueueStore.create(tableAdmin);
StoreDefinition.AppMetadataStore.create(tableAdmin);
}
Aggregations