use of co.cask.cdap.common.guice.NamespaceClientUnitTestModule in project cdap by caskdata.
the class HBaseQueueTest method init.
@BeforeClass
public static void init() throws Exception {
hConf = TEST_HBASE.getConfiguration();
// Customize test configuration
cConf = CConfiguration.create();
cConf.set(Constants.Zookeeper.QUORUM, TEST_HBASE.getZkConnectionString());
cConf.set(TxConstants.Service.CFG_DATA_TX_BIND_PORT, Integer.toString(Networks.getRandomPort()));
cConf.set(Constants.Dataset.TABLE_PREFIX, TABLE_PREFIX);
cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
cConf.setLong(QueueConstants.QUEUE_CONFIG_UPDATE_FREQUENCY, 10000L);
// Test with fewer splits than default (16).
// Fewer splits make the forceEvict runs faster, which makes all queue tests run faster
cConf.setInt(QueueConstants.ConfigKeys.QUEUE_TABLE_PRESPLITS, 4);
cConf.setLong(TxConstants.Manager.CFG_TX_TIMEOUT, 100000000L);
cConf.setLong(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, 100000000L);
injector = Guice.createInjector(new DataFabricModules().getDistributedModules(), new ConfigModule(cConf, hConf), new ZKClientModule(), new LocationRuntimeModule().getDistributedModules(), new NamespaceClientUnitTestModule().getModule(), new DiscoveryRuntimeModule().getDistributedModules(), new TransactionMetricsModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DataSetsModules().getInMemoryModules(), new SystemDatasetRuntimeModule().getDistributedModules(), new AbstractModule() {
@Override
protected void configure() {
bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class).in(Scopes.SINGLETON);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
}
});
//create HBase namespace
hbaseAdmin = TEST_HBASE.getHBaseAdmin();
ddlExecutor = new HBaseDDLExecutorFactory(cConf, hbaseAdmin.getConfiguration()).get();
tableUtil = injector.getInstance(HBaseTableUtil.class);
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NAMESPACE_ID));
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NAMESPACE_ID1));
ConfigurationTable configTable = new ConfigurationTable(hConf);
configTable.write(ConfigurationTable.Type.DEFAULT, cConf);
zkClientService = injector.getInstance(ZKClientService.class);
zkClientService.startAndWait();
txService = injector.getInstance(TransactionService.class);
Thread t = new Thread() {
@Override
public void run() {
txService.start();
}
};
t.start();
// The TransactionManager should be started by the txService.
// We just want a reference to that so that we can ask for tx snapshot
txSystemClient = injector.getInstance(TransactionSystemClient.class);
queueClientFactory = injector.getInstance(QueueClientFactory.class);
queueAdmin = injector.getInstance(QueueAdmin.class);
executorFactory = injector.getInstance(TransactionExecutorFactory.class);
}
use of co.cask.cdap.common.guice.NamespaceClientUnitTestModule in project cdap by caskdata.
the class BaseHiveExploreServiceTest method createInMemoryModules.
private static List<Module> createInMemoryModules(CConfiguration configuration, Configuration hConf, TemporaryFolder tmpFolder) throws IOException {
configuration.set(Constants.CFG_DATA_INMEMORY_PERSISTENCE, Constants.InMemoryPersistenceType.MEMORY.name());
configuration.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
configuration.set(Constants.Explore.LOCAL_DATA_DIR, tmpFolder.newFolder("hive").getAbsolutePath());
configuration.set(TxConstants.Manager.CFG_TX_SNAPSHOT_LOCAL_DIR, tmpFolder.newFolder("tx").getAbsolutePath());
configuration.setBoolean(TxConstants.Manager.CFG_DO_PERSIST, true);
return ImmutableList.of(new ConfigModule(configuration, hConf), new IOModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new NonCustomLocationUnitTestModule().getModule(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getInMemoryModules(), new MetricsClientRuntimeModule().getInMemoryModules(), new ExploreRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new StreamServiceRuntimeModule().getInMemoryModules(), new ViewAdminModules().getInMemoryModules(), new StreamAdminModules().getInMemoryModules(), new NotificationServiceRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new NamespaceClientUnitTestModule().getModule(), new AbstractModule() {
@Override
protected void configure() {
bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, Names.named(Constants.Stream.STREAM_HANDLER));
handlerBinder.addBinding().to(StreamHandler.class);
handlerBinder.addBinding().to(StreamFetchHandler.class);
handlerBinder.addBinding().to(StreamViewHttpHandler.class);
CommonHandlers.add(handlerBinder);
bind(StreamHttpService.class).in(Scopes.SINGLETON);
// Use LocalFileTransactionStateStorage, so that we can use transaction snapshots for assertions in test
install(Modules.override(new DataFabricModules().getInMemoryModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(TransactionStateStorage.class).annotatedWith(Names.named("persist")).to(LocalFileTransactionStateStorage.class).in(Scopes.SINGLETON);
bind(TransactionStateStorage.class).toProvider(TransactionStateStorageProvider.class).in(Singleton.class);
}
}));
}
});
}
use of co.cask.cdap.common.guice.NamespaceClientUnitTestModule in project cdap by caskdata.
the class HBaseMetricsTableTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
Injector injector = Guice.createInjector(new DataFabricModules().getDistributedModules(), new ConfigModule(conf, TEST_HBASE.getConfiguration()), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules(), new TransactionMetricsModule(), new LocationRuntimeModule().getDistributedModules(), new NamespaceClientUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getDistributedModules(), new DataSetsModules().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AbstractModule() {
@Override
protected void configure() {
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
});
dsFramework = injector.getInstance(DatasetFramework.class);
tableUtil = injector.getInstance(HBaseTableUtil.class);
ddlExecutor = new HBaseDDLExecutorFactory(conf, TEST_HBASE.getHBaseAdmin().getConfiguration()).get();
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
}
Aggregations