use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class HBaseQueueRegionObserver 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 = configCache.getCConf();
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.getRegionInfo().getRegionNameAsString()));
}
resetPruneState();
initializePruneState(env);
}
}
}
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class SystemArgumentsTest method testRetryStrategies.
@Test
public void testRetryStrategies() throws InterruptedException {
CConfiguration cConf = CConfiguration.create();
Map<String, String> args = Collections.emptyMap();
// Get default, expect exponential back-off behavior, until the max delay
RetryStrategy strategy = SystemArguments.getRetryStrategy(args, ProgramType.CUSTOM_ACTION, cConf);
long startTime = System.currentTimeMillis();
Assert.assertEquals(1000L, strategy.nextRetry(1, startTime));
Assert.assertEquals(2000L, strategy.nextRetry(2, startTime));
Assert.assertEquals(4000L, strategy.nextRetry(3, startTime));
Assert.assertEquals(8000L, strategy.nextRetry(4, startTime));
Assert.assertEquals(16000L, strategy.nextRetry(5, startTime));
Assert.assertEquals(30000L, strategy.nextRetry(6, startTime));
Assert.assertEquals(30000L, strategy.nextRetry(7, startTime));
// It should give up (returning -1) when exceeding the max retries
Assert.assertEquals(-1L, strategy.nextRetry(1001, startTime));
// Override the strategy type and max retry time
args = ImmutableMap.of("system." + Constants.Retry.TYPE, RetryStrategyType.FIXED_DELAY.toString(), "system." + Constants.Retry.MAX_TIME_SECS, "5");
strategy = SystemArguments.getRetryStrategy(args, ProgramType.CUSTOM_ACTION, cConf);
startTime = System.currentTimeMillis();
// Expects the delay doesn't change
Assert.assertEquals(1000L, strategy.nextRetry(1, startTime));
Assert.assertEquals(1000L, strategy.nextRetry(2, startTime));
Assert.assertEquals(1000L, strategy.nextRetry(3, startTime));
Assert.assertEquals(1000L, strategy.nextRetry(4, startTime));
// Should give up (returning -1) after passing the max retry time
Assert.assertEquals(-1L, strategy.nextRetry(1, startTime - 6000));
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class NamespaceHttpHandlerTest method testDeleteDatasetsOnly.
@Test
public void testDeleteDatasetsOnly() throws Exception {
CConfiguration cConf = getInjector().getInstance(CConfiguration.class);
// test deleting non-existent namespace
assertResponseCode(200, createNamespace(NAME));
assertResponseCode(200, getNamespace(NAME));
NamespacedLocationFactory namespacedLocationFactory = getInjector().getInstance(NamespacedLocationFactory.class);
Location nsLocation = namespacedLocationFactory.get(new NamespaceId(NAME));
Assert.assertTrue(nsLocation.exists());
DatasetFramework dsFramework = getInjector().getInstance(DatasetFramework.class);
deploy(AppWithServices.class, Constants.Gateway.API_VERSION_3_TOKEN, NAME);
deploy(AppWithDataset.class, Constants.Gateway.API_VERSION_3_TOKEN, NAME);
DatasetId myDataset = new DatasetId(NAME, "myds");
Assert.assertTrue(dsFramework.hasInstance(myDataset));
Id.Program program = Id.Program.from(NAME_ID, "AppWithServices", ProgramType.SERVICE, "NoOpService");
startProgram(program);
boolean resetEnabled = cConf.getBoolean(Constants.Dangerous.UNRECOVERABLE_RESET);
cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, false);
// because reset is not enabled
assertResponseCode(403, deleteNamespaceData(NAME));
Assert.assertTrue(nsLocation.exists());
cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, resetEnabled);
// because service is running
assertResponseCode(409, deleteNamespaceData(NAME));
Assert.assertTrue(nsLocation.exists());
stopProgram(program);
assertResponseCode(200, deleteNamespaceData(NAME));
Assert.assertTrue(nsLocation.exists());
Assert.assertTrue(getAppList(NAME).size() == 2);
Assert.assertTrue(getAppDetails(NAME, "AppWithServices").get("name").getAsString().equals("AppWithServices"));
Assert.assertTrue(getAppDetails(NAME, AppWithDataset.class.getSimpleName()).get("name").getAsString().equals(AppWithDataset.class.getSimpleName()));
assertResponseCode(200, getNamespace(NAME));
Assert.assertFalse(dsFramework.hasInstance(myDataset));
assertResponseCode(200, deleteNamespace(NAME));
assertResponseCode(404, getNamespace(NAME));
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class DatasetOpExecutorServiceTest method setUp.
@Before
public void setUp() throws Exception {
Configuration hConf = new Configuration();
CConfiguration cConf = CConfiguration.create();
File datasetDir = new File(TMP_FOLDER.newFolder(), "datasetUser");
Assert.assertTrue(datasetDir.mkdirs());
cConf.set(Constants.Dataset.Manager.OUTPUT_DIR, datasetDir.getAbsolutePath());
cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, "localhost");
cConf.set(Constants.Dataset.Executor.ADDRESS, "localhost");
cConf.setInt(Constants.Dataset.Executor.PORT, Networks.getRandomPort());
Injector injector = Guice.createInjector(new ConfigModule(cConf, hConf), new IOModule(), new ZKClientModule(), new KafkaClientModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new NonCustomLocationUnitTestModule().getModule(), new DataFabricModules().getInMemoryModules(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getInMemoryModules(), new TransactionMetricsModule(), new ExploreClientModule(), new NamespaceClientRuntimeModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AbstractModule() {
@Override
protected void configure() {
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
managerService = injector.getInstance(DatasetService.class);
managerService.startAndWait();
dsFramework = injector.getInstance(DatasetFramework.class);
// find host
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
endpointStrategy = new RandomEndpointStrategy(discoveryClient.discover(Constants.Service.DATASET_MANAGER));
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespaceAdmin.create(NamespaceMeta.DEFAULT);
namespaceAdmin.create(new NamespaceMeta.Builder().setName(bob.getParent()).build());
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LevelDBKVTableTest method init.
@BeforeClass
public static void init() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
conf.set(Constants.CFG_DATA_LEVELDB_DIR, tmpFolder.newFolder().getAbsolutePath());
service = new LevelDBTableService();
service.setConfiguration(conf);
}
Aggregations