use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LevelDBMetricsTableTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DiscoveryRuntimeModule().getStandaloneModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule());
dsFramework = injector.getInstance(DatasetFramework.class);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LevelDBTableServiceTest method init.
@BeforeClass
public static void init() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
injector = Guice.createInjector(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getStandaloneModules(), new DataSetsModules().getStandaloneModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getStandaloneModules(), new AuthenticationContextModules().getMasterModule());
service = injector.getInstance(LevelDBTableService.class);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class GatewayTestBase method startGateway.
public static Injector startGateway(final CConfiguration conf) throws Exception {
// Set up our Guice injections
injector = Guice.createInjector(Modules.override(new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Named(Constants.Router.ADDRESS)
public final InetAddress providesHostname(CConfiguration cConf) {
return Networks.resolve(cConf.get(Constants.Router.ADDRESS), new InetSocketAddress("localhost", 0).getAddress());
}
}, new SecurityModules().getInMemoryModules(), new NotificationServiceRuntimeModule().getInMemoryModules(), new AppFabricTestModule(conf)).with(new AbstractModule() {
@Override
protected void configure() {
install(new StreamServiceRuntimeModule().getStandaloneModules());
// It's a bit hacky to add it here. Need to refactor these
// bindings out as it overlaps with
// AppFabricServiceModule
bind(LogReader.class).to(MockLogReader.class).in(Scopes.SINGLETON);
bind(StreamConsumerStateStoreFactory.class).to(LevelDBStreamConsumerStateStoreFactory.class).in(Singleton.class);
bind(StreamAdmin.class).to(FileStreamAdmin.class).in(Singleton.class);
bind(StreamConsumerFactory.class).to(LevelDBStreamFileConsumerFactory.class).in(Singleton.class);
bind(StreamFileWriterFactory.class).to(LocationStreamFileWriterFactory.class).in(Singleton.class);
bind(PrivilegesManager.class).to(NoOpAuthorizer.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
}));
txService = injector.getInstance(TransactionManager.class);
txService.startAndWait();
dsOpService = injector.getInstance(DatasetOpExecutor.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
metricsQueryService = injector.getInstance(MetricsQueryService.class);
metricsQueryService.startAndWait();
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
notificationService = injector.getInstance(NotificationService.class);
notificationService.startAndWait();
streamService = injector.getInstance(StreamService.class);
streamService.startAndWait();
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespaceAdmin.create(TEST_NAMESPACE_META1);
namespaceAdmin.create(TEST_NAMESPACE_META2);
// Restart handlers to check if they are resilient across restarts.
router = injector.getInstance(NettyRouter.class);
router.startAndWait();
Map<String, Integer> serviceMap = Maps.newHashMap();
for (Map.Entry<Integer, String> entry : router.getServiceLookup().getServiceMap().entrySet()) {
serviceMap.put(entry.getValue(), entry.getKey());
}
port = serviceMap.get(Constants.Service.GATEWAY);
return injector;
}
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 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));
}
}
}
}
Aggregations