use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testGetReadAheadBatchSize.
@Test(timeout = 20000)
public void testGetReadAheadBatchSize() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
// get default value
assertEquals(BKDL_READAHEAD_BATCHSIZE_DEFAULT, dynConf.getReadAheadBatchSize());
// get value from old key of default config
defaultConfig.setProperty(BKDL_READAHEAD_BATCHSIZE_OLD, BKDL_READAHEAD_BATCHSIZE_DEFAULT + 1);
assertEquals(BKDL_READAHEAD_BATCHSIZE_DEFAULT + 1, dynConf.getReadAheadBatchSize());
// get value from new key of default config
defaultConfig.setProperty(BKDL_READAHEAD_BATCHSIZE, BKDL_READAHEAD_BATCHSIZE_DEFAULT + 2);
assertEquals(BKDL_READAHEAD_BATCHSIZE_DEFAULT + 2, dynConf.getReadAheadBatchSize());
// get value from old key of dynamic config
dynConf.setProperty(BKDL_READAHEAD_BATCHSIZE_OLD, BKDL_READAHEAD_BATCHSIZE_DEFAULT + 3);
assertEquals(BKDL_READAHEAD_BATCHSIZE_DEFAULT + 3, dynConf.getReadAheadBatchSize());
// get value from new key of default config
dynConf.setProperty(BKDL_READAHEAD_BATCHSIZE, BKDL_READAHEAD_BATCHSIZE_DEFAULT + 4);
assertEquals(BKDL_READAHEAD_BATCHSIZE_DEFAULT + 4, dynConf.getReadAheadBatchSize());
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testGetQuorumConfig.
@Test(timeout = 20000)
public void testGetQuorumConfig() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
// get default value
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// Test Ensemble Size
// get value from old key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_ENSEMBLE_SIZE_OLD, BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 1);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 1, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from new key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_ENSEMBLE_SIZE, BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 2);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 2, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from old key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_ENSEMBLE_SIZE_OLD, BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 3);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 3, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from new key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_ENSEMBLE_SIZE, BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// Test Write Quorum Size
// get value from old key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_OLD, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 1);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 1, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from new key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 2);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 2, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from old key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_OLD, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 3);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 3, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// get value from new key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT);
// Test Ack Quorum Size
// get value from old key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_OLD, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 1);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 1);
// get value from new key of default config
defaultConfig.setProperty(BKDL_BOOKKEEPER_ACK_QUORUM_SIZE, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 2);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 2);
// get value from old key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_OLD, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 3);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 3);
// get value from new key of dynamic config
dynConf.setProperty(BKDL_BOOKKEEPER_ACK_QUORUM_SIZE, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 4);
assertQuorumConfig(dynConf.getQuorumConfig(), BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_WRITE_QUORUM_SIZE_DEFAULT + 4, BKDL_BOOKKEEPER_ACK_QUORUM_SIZE_DEFAULT + 4);
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testIsDurableWriteEnabled.
@Test(timeout = 20000)
public void testIsDurableWriteEnabled() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
assertTrue(dynConf.isDurableWriteEnabled());
defaultConfig.setProperty(BKDL_IS_DURABLE_WRITE_ENABLED, false);
assertFalse(dynConf.isDurableWriteEnabled());
dynConf.setProperty(BKDL_IS_DURABLE_WRITE_ENABLED, true);
assertTrue(dynConf.isDurableWriteEnabled());
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestConfigurationFeatureProvider method testConfigurationFeatureProvider.
@Test(timeout = 60000)
public void testConfigurationFeatureProvider() throws Exception {
String rootScope = "dl";
ConcurrentBaseConfiguration featureConf = new ConcurrentBaseConfiguration();
ConcurrentMap<String, SettableFeature> features = new ConcurrentHashMap<String, SettableFeature>();
ConfigurationFeatureProvider featureProvider = new ConfigurationFeatureProvider(rootScope, featureConf, features);
String featureName1 = "feature1";
String fullFeatureName1 = rootScope + "." + featureName1;
int availability1 = 1234;
featureConf.setProperty(fullFeatureName1, availability1);
Feature feature1 = featureProvider.getFeature(featureName1);
assertEquals(availability1, feature1.availability());
assertTrue(features.containsKey(fullFeatureName1));
assertTrue(feature1 == features.get(fullFeatureName1));
String subScope = "subscope";
String featureName2 = "feature2";
String fullFeatureName2 = rootScope + "." + subScope + "." + featureName2;
int availability2 = 4321;
featureConf.setProperty(fullFeatureName2, availability2);
Feature feature2 = featureProvider.scope(subScope).getFeature(featureName2);
assertEquals(availability2, feature2.availability());
assertTrue(features.containsKey(fullFeatureName2));
assertTrue(feature2 == features.get(fullFeatureName2));
}
Aggregations