use of io.cdap.cdap.internal.guice.AppFabricTestModule in project cdap by caskdata.
the class RouterResource method before.
@Override
protected void before() {
CConfiguration cConf = CConfiguration.create();
Injector injector = Guice.createInjector(new CoreSecurityRuntimeModule().getStandaloneModules(), new ExternalAuthenticationModule(), new InMemoryDiscoveryModule(), new AppFabricTestModule(cConf));
DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
TokenValidator mockValidator = new MockTokenValidator("failme");
UserIdentityExtractor extractor = new MockAccessTokenIdentityExtractor(mockValidator);
SConfiguration sConf = injector.getInstance(SConfiguration.class);
cConf.set(Constants.Router.ADDRESS, hostname);
cConf.setInt(Constants.Router.ROUTER_PORT, 0);
for (Map.Entry<String, String> entry : additionalConfig.entrySet()) {
cConf.set(entry.getKey(), entry.getValue());
}
router = new NettyRouter(cConf, sConf, InetAddresses.forString(hostname), new RouterServiceLookup(cConf, (DiscoveryServiceClient) discoveryService, new RouterPathLookup()), mockValidator, extractor, discoveryServiceClient);
router.startAndWait();
}
use of io.cdap.cdap.internal.guice.AppFabricTestModule in project cdap by caskdata.
the class ProvisioningServiceTest method setupClass.
@BeforeClass
public static void setupClass() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new AppFabricTestModule(cConf));
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
messagingService = injector.getInstance(MessagingService.class);
provisionerStore = injector.getInstance(ProvisionerStore.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
provisioningService = injector.getInstance(ProvisioningService.class);
provisioningService.startAndWait();
transactionRunner = injector.getInstance(TransactionRunner.class);
}
use of io.cdap.cdap.internal.guice.AppFabricTestModule in project cdap by caskdata.
the class LocalMRJobInfoFetcherTest method startMetricsService.
public static Injector startMetricsService(CConfiguration conf) throws Exception {
Injector injector = Guice.createInjector(new AppFabricTestModule(conf));
injector.getInstance(TransactionManager.class).startAndWait();
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
injector.getInstance(DatasetOpExecutorService.class).startAndWait();
injector.getInstance(DatasetService.class).startAndWait();
return injector;
}
use of io.cdap.cdap.internal.guice.AppFabricTestModule in project cdap by caskdata.
the class AppFabricTestHelper method getInjector.
public static synchronized Injector getInjector(CConfiguration conf, @Nullable SConfiguration sConf, Module overrides) {
if (injector == null) {
services = new ArrayList<>();
configuration = conf;
if (!CConfigurationUtil.isOverridden(configuration, Constants.CFG_LOCAL_DATA_DIR)) {
configuration.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder("data").getAbsolutePath());
}
configuration.set(Constants.AppFabric.REST_PORT, Integer.toString(Networks.getRandomPort()));
configuration.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, true);
// Speed up tests
configuration.setLong(Constants.Scheduler.EVENT_POLL_DELAY_MILLIS, 100L);
configuration.setLong(Constants.AppFabric.STATUS_EVENT_POLL_DELAY_MILLIS, 100L);
injector = Guice.createInjector(Modules.override(new AppFabricTestModule(configuration, sConf)).with(overrides));
startService(injector, MessagingService.class);
startService(injector, TransactionManager.class);
metadataStorage = injector.getInstance(MetadataStorage.class);
try {
metadataStorage.createIndex();
} catch (IOException e) {
throw new RuntimeException("Unable to create the metadata tables.", e);
}
startService(injector, MetadataService.class);
// Register the tables before services will need to use them
try {
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
} catch (IOException e) {
throw new RuntimeException("Failed to create the system tables", e);
}
startService(injector, DatasetOpExecutorService.class);
startService(injector, DatasetService.class);
startService(injector, MetricsCollectionService.class);
startService(injector, MetadataSubscriberService.class);
startService(injector, ProgramNotificationSubscriberService.class);
Scheduler programScheduler = startService(injector, Scheduler.class);
// Wait for the scheduler to be functional.
if (programScheduler instanceof CoreSchedulerService) {
try {
((CoreSchedulerService) programScheduler).waitUntilFunctional(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return injector;
}
use of io.cdap.cdap.internal.guice.AppFabricTestModule in project cdap by caskdata.
the class StorageProviderNamespaceAdminTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.setBoolean(Constants.Explore.EXPLORE_ENABLED, true);
Injector injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf)).with(new AbstractModule() {
@Override
protected void configure() {
// use the DefaultNamespacePathLocator here to test proper namespace creation in storage handler and
// not the NamespacedLocationFactoryTestClient
bind(NamespacePathLocator.class).to(DefaultNamespacePathLocator.class);
}
}));
namespacePathLocator = injector.getInstance(NamespacePathLocator.class);
storageProviderNamespaceAdmin = injector.getInstance(StorageProviderNamespaceAdmin.class);
// start the dataset service for namespace store to work
transactionManager = injector.getInstance(TransactionManager.class);
transactionManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
// we don't use namespace admin here but the store because namespaceadmin will try to create the
// home directory for namespace which we don't want. We just want to store the namespace meta in store
// to look up during the delete.
namespaceStore = injector.getInstance(NamespaceStore.class);
}
Aggregations