use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LevelDBKVTableTest method getDefinition.
@Override
protected DatasetDefinition<? extends NoTxKeyValueTable, ? extends DatasetAdmin> getDefinition() throws IOException {
final String dataDir = tmpFolder.newFolder().getAbsolutePath();
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_DATA_LEVELDB_DIR, dataDir);
bind(CConfiguration.class).toInstance(conf);
bind(LevelDBTableService.class).toInstance(service);
}
});
LevelDBKVTableDefinition def = new LevelDBKVTableDefinition("foo");
injector.injectMembers(def);
return def;
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class MessageTableRegionObserver method reloadPruneState.
private void reloadPruneState(RegionCoprocessorEnvironment env) {
if (pruneEnable == null) {
// If prune enable has never been initialized, try to do so now
initializePruneState(env);
} else {
CConfiguration conf = topicMetadataCache.getCConfiguration();
if (conf != null) {
boolean newPruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE);
if (newPruneEnable != pruneEnable) {
// pruning enable has been changed, resetting prune state
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Transaction Invalid List pruning feature is set to %s now for region %s.", newPruneEnable, env.getRegion().getRegionInfo().getRegionNameAsString()));
}
resetPruneState();
initializePruneState(env);
}
}
}
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class RouterMainTest method testGuiceInjection.
@Test
public void testGuiceInjection() throws Exception {
CConfiguration cConf = CConfiguration.create();
Injector injector = RouterMain.createGuiceInjector(cConf);
Assert.assertNotNull(injector);
NettyRouter router = injector.getInstance(NettyRouter.class);
Assert.assertNotNull(router);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class HBaseQueueRegionObserver method initializePruneState.
private void initializePruneState(RegionCoprocessorEnvironment env) {
CConfiguration conf = configCache.getCConf();
if (conf != null) {
pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE);
if (Boolean.TRUE.equals(pruneEnable)) {
String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE);
long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong(TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL));
compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval);
if (LOG.isDebugEnabled()) {
TableName tableName = env.getRegionInfo().getTable();
LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s:%s. Compaction state " + "will be recorded in table %s", tableName.getNamespaceAsString(), tableName.getNameAsString(), pruneTable));
}
}
}
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class HBaseQueueDebugger method createInjector.
private static Injector createInjector(boolean disableAuthorization) throws Exception {
CConfiguration cConf = CConfiguration.create();
if (disableAuthorization && cConf.getBoolean(Constants.Security.Authorization.ENABLED)) {
System.out.println(String.format("Disabling authorization for %s.", HBaseQueueDebugger.class.getSimpleName()));
cConf.setBoolean(Constants.Security.Authorization.ENABLED, false);
}
// Note: login has to happen before any objects that need Kerberos credentials are instantiated.
SecurityUtil.loginForMasterService(cConf);
return Guice.createInjector(new ConfigModule(cConf, HBaseConfiguration.create()), new IOModule(), new ZKClientModule(), new LocationRuntimeModule().getDistributedModules(), new DiscoveryRuntimeModule().getDistributedModules(), new ViewAdminModules().getDistributedModules(), new StreamAdminModules().getDistributedModules(), new NotificationFeedClientModule(), new TwillModule(), new ExploreClientModule(), new DataFabricModules(HBaseQueueDebugger.class.getName()).getDistributedModules(), new ServiceStoreModules().getDistributedModules(), new DataSetsModules().getDistributedModules(), new AppFabricServiceRuntimeModule().getDistributedModules(), new ProgramRunnerRuntimeModule().getDistributedModules(), new SystemDatasetRuntimeModule().getDistributedModules(), new NotificationServiceRuntimeModule().getDistributedModules(), new MetricsClientRuntimeModule().getDistributedModules(), new MetricsStoreModule(), new KafkaClientModule(), new NamespaceStoreModule().getDistributedModules(), new AuthorizationModule(), new AuthorizationEnforcementModule().getMasterModule(), new SecureStoreModules().getDistributedModules(), new MessagingClientModule(), new AbstractModule() {
@Override
protected void configure() {
bind(QueueClientFactory.class).to(HBaseQueueClientFactory.class).in(Singleton.class);
bind(QueueAdmin.class).to(HBaseQueueAdmin.class).in(Singleton.class);
bind(HBaseTableUtil.class).toProvider(HBaseTableUtilFactory.class);
bind(Store.class).annotatedWith(Names.named("defaultStore")).to(DefaultStore.class).in(Singleton.class);
// This is needed because the LocalApplicationManager
// expects a dsframework injection named datasetMDS
bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).to(DatasetFramework.class).in(Singleton.class);
}
});
}
Aggregations