use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by cdapio.
the class DatasetOpExecutorServiceTest method setUp.
@Before
public void setUp() throws Exception {
Configuration hConf = new Configuration();
CConfiguration cConf = CConfiguration.create();
File datasetDir = new File(TMP_FOLDER.newFolder(), "datasetUser");
Assert.assertTrue(datasetDir.mkdirs());
cConf.set(Constants.Dataset.Manager.OUTPUT_DIR, datasetDir.getAbsolutePath());
cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, "localhost");
cConf.set(Constants.Dataset.Executor.ADDRESS, "localhost");
cConf.setInt(Constants.Dataset.Executor.PORT, Networks.getRandomPort());
Injector injector = Guice.createInjector(new ConfigModule(cConf, hConf), RemoteAuthenticatorModules.getNoOpModule(), new IOModule(), new ZKClientModule(), new KafkaClientModule(), new InMemoryDiscoveryModule(), new NonCustomLocationUnitTestModule(), new DataFabricModules().getInMemoryModules(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getInMemoryModules(), new TransactionMetricsModule(), new ExploreClientModule(), new NamespaceAdminTestModule(), new AuthenticationContextModules().getMasterModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AbstractModule() {
@Override
protected void configure() {
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(MetadataServiceClient.class).to(NoOpMetadataServiceClient.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
dsOpExecService = injector.getInstance(DatasetOpExecutorService.class);
dsOpExecService.startAndWait();
managerService = injector.getInstance(DatasetService.class);
managerService.startAndWait();
dsFramework = injector.getInstance(DatasetFramework.class);
// find host
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
endpointStrategy = new RandomEndpointStrategy(() -> discoveryClient.discover(Constants.Service.DATASET_MANAGER));
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespaceAdmin.create(NamespaceMeta.DEFAULT);
namespaceAdmin.create(new NamespaceMeta.Builder().setName(bob.getParent()).build());
}
use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by cdapio.
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);
CommonNettyHttpServiceFactory commonNettyHttpServiceFactory = injector.getInstance(CommonNettyHttpServiceFactory.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, commonNettyHttpServiceFactory, 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, commonNettyHttpServiceFactory, 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.common.guice.InMemoryDiscoveryModule 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);
bind(MetricsSystemClient.class).toInstance(new NoOpMetricsSystemClient());
expose(MetricsSystemClient.class);
}
});
tetheringStore = new TetheringStore(injector.getInstance(TransactionRunner.class));
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
profileService = injector.getInstance(ProfileService.class);
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule 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 SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new ProvisionerModule(), new AuthorizationEnforcementModule().getNoOpModules(), 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.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.
the class RuntimeClientServerTest method beforeTest.
@Before
public void beforeTest() throws Exception {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.setBoolean(Constants.RuntimeMonitor.COMPRESSION_ENABLED, compression);
cConf.setBoolean(Constants.AppFabric.SPARK_EVENT_LOGS_ENABLED, true);
cConf.set(TEST_TOPIC_KEY, TEST_TOPIC);
cConf.set(Constants.RuntimeMonitor.TOPICS_CONFIGS, Constants.Logging.TMS_TOPIC_PREFIX + ":1," + TEST_TOPIC_KEY);
Injector injector = Guice.createInjector(new ConfigModule(cConf), RemoteAuthenticatorModules.getNoOpModule(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AuthorizationEnforcementModule().getNoOpModules(), new RuntimeServerModule() {
@Override
protected void bindRequestValidator() {
bind(RuntimeRequestValidator.class).toInstance((programRunId, request) -> new ProgramRunInfo(ProgramRunStatus.STOPPING, null));
}
@Override
protected void bindLogProcessor() {
bind(RemoteExecutionLogProcessor.class).toInstance(payloads -> {
// For testing purpose, we just store logs to a list
payloads.forEachRemaining(bytes -> logEntries.add(new String(bytes, StandardCharsets.UTF_8)));
});
}
}, new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
}
});
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
messagingService.createTopic(new TopicMetadata(NamespaceId.SYSTEM.topic("topic")));
runtimeServer = injector.getInstance(RuntimeServer.class);
runtimeServer.startAndWait();
runtimeClient = injector.getInstance(RuntimeClient.class);
locationFactory = injector.getInstance(LocationFactory.class);
}
Aggregations