use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class TestKeyIdentifierCodec method setup.
@BeforeClass
public static void setup() throws Exception {
Injector injector = Guice.createInjector(new IOModule(), new ConfigModule(), new FileBasedSecurityModule(), new DiscoveryRuntimeModule().getInMemoryModules());
CConfiguration conf = injector.getInstance(CConfiguration.class);
keyIdentifierCodec = injector.getInstance(KeyIdentifierCodec.class);
keyLength = conf.getInt(Constants.Security.TOKEN_DIGEST_KEY_LENGTH);
keyAlgo = conf.get(Constants.Security.TOKEN_DIGEST_ALGO);
keyGenerator = KeyGenerator.getInstance(keyAlgo);
keyGenerator.init(keyLength);
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class UpgradeTool method createInjector.
@VisibleForTesting
Injector createInjector() throws Exception {
return Guice.createInjector(new ConfigModule(cConf, hConf), new LocationRuntimeModule().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules(), new MessagingClientModule(), Modules.override(new DataSetsModules().getDistributedModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class).in(Scopes.SINGLETON);
// the DataSetsModules().getDistributedModules() binds to RemoteDatasetFramework so override that to
// the same InMemoryDatasetFramework
bind(DatasetFramework.class).annotatedWith(Names.named(DataSetsModules.BASE_DATASET_FRAMEWORK)).to(DatasetFramework.class);
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
// CDAP-5954 Upgrade tool does not need to record lineage and metadata changes for now.
bind(LineageWriter.class).to(NoOpLineageWriter.class);
}
}), new ViewAdminModules().getDistributedModules(), new StreamAdminModules().getDistributedModules(), new NotificationFeedClientModule(), new TwillModule(), new ExploreClientModule(), new ProgramRunnerRuntimeModule().getDistributedModules(), new ServiceStoreModules().getDistributedModules(), new SystemDatasetRuntimeModule().getDistributedModules(), // don't need real notifications for upgrade, so use the in-memory implementations
new NotificationServiceRuntimeModule().getInMemoryModules(), new KafkaClientModule(), new NamespaceStoreModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getMasterModule(), new SecureStoreModules().getDistributedModules(), new DataFabricModules(UpgradeTool.class.getName()).getDistributedModules(), new AppFabricServiceRuntimeModule().getDistributedModules(), new AbstractModule() {
@Override
protected void configure() {
// the DataFabricDistributedModule needs MetricsCollectionService binding and since Upgrade tool does not do
// anything with Metrics we just bind it to NoOpMetricsCollectionService
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
bind(MetricDatasetFactory.class).to(DefaultMetricDatasetFactory.class).in(Scopes.SINGLETON);
bind(MetricStore.class).to(DefaultMetricStore.class);
}
@Provides
@Singleton
@Named("datasetInstanceManager")
@SuppressWarnings("unused")
public DatasetInstanceManager getDatasetInstanceManager(TransactionSystemClientService txClient, TransactionExecutorFactory txExecutorFactory, @Named("datasetMDS") DatasetFramework framework) {
return new DatasetInstanceManager(txClient, txExecutorFactory, framework);
}
// This is needed because the LocalApplicationManager
// expects a dsframework injection named datasetMDS
@Provides
@Singleton
@Named("datasetMDS")
@SuppressWarnings("unused")
public DatasetFramework getInDsFramework(DatasetFramework dsFramework) {
return dsFramework;
}
});
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class ExternalAuthenticationServerTestBase method setup.
protected void setup() throws Exception {
Assert.assertNotNull("CConfiguration needs to be set by derived classes", configuration);
// Intentionally set "security.auth.server.announce.address" and "security.auth.server.announce.address" to invalid
// values verify that they are not used by external authentication server
configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_ADDRESS_DEPRECATED, "invalid.address");
configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_URLS, "invalid.urls");
Module securityModule = Modules.override(new SecurityModules().getInMemoryModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(AuditLogHandler.class).annotatedWith(Names.named(ExternalAuthenticationServer.NAMED_EXTERNAL_AUTH)).toInstance(new AuditLogHandler(TEST_AUDIT_LOGGER));
}
});
Injector injector = Guice.createInjector(new IOModule(), securityModule, new ConfigModule(getConfiguration(configuration), HBaseConfiguration.create(), sConfiguration), new DiscoveryRuntimeModule().getInMemoryModules());
server = injector.getInstance(ExternalAuthenticationServer.class);
tokenCodec = injector.getInstance(AccessTokenCodec.class);
discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
if (configuration.getBoolean(Constants.Security.SSL.EXTERNAL_ENABLED)) {
port = configuration.getInt(Constants.Security.AuthenticationServer.SSL_PORT);
} else {
port = configuration.getInt(Constants.Security.AUTH_SERVER_BIND_PORT);
}
startExternalAuthenticationServer();
server.startAndWait();
LOG.info("Auth server running on port {}", port);
TimeUnit.SECONDS.sleep(3);
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class SharedResourceCacheTest method startUp.
@BeforeClass
public static void startUp() throws Exception {
HBaseTestingUtility testUtil = new HBaseTestingUtility();
zkCluster = testUtil.startMiniZKCluster();
zkConnectString = testUtil.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM) + ":" + zkCluster.getClientPort();
LOG.info("Running ZK cluster at " + zkConnectString);
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.Zookeeper.QUORUM, zkConnectString);
injector1 = Guice.createInjector(new ConfigModule(cConf, testUtil.getConfiguration()), new ZKClientModule());
injector2 = Guice.createInjector(new ConfigModule(cConf, testUtil.getConfiguration()), new ZKClientModule());
}
use of co.cask.cdap.common.guice.ConfigModule 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());
}
Aggregations