Search in sources :

Example 6 with ConcurrentBaseConfiguration

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());
}
Also used : ConcurrentBaseConfiguration(org.apache.distributedlog.common.config.ConcurrentBaseConfiguration) Test(org.junit.Test)

Example 7 with ConcurrentBaseConfiguration

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);
}
Also used : ConcurrentBaseConfiguration(org.apache.distributedlog.common.config.ConcurrentBaseConfiguration) Test(org.junit.Test)

Example 8 with ConcurrentBaseConfiguration

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());
}
Also used : ConcurrentBaseConfiguration(org.apache.distributedlog.common.config.ConcurrentBaseConfiguration) Test(org.junit.Test)

Example 9 with ConcurrentBaseConfiguration

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));
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SettableFeature(org.apache.bookkeeper.feature.SettableFeature) SettableFeature(org.apache.bookkeeper.feature.SettableFeature) Feature(org.apache.bookkeeper.feature.Feature) ConcurrentBaseConfiguration(org.apache.distributedlog.common.config.ConcurrentBaseConfiguration) Test(org.junit.Test)

Aggregations

ConcurrentBaseConfiguration (org.apache.distributedlog.common.config.ConcurrentBaseConfiguration)9 Test (org.junit.Test)8 ConcurrentConstConfiguration (org.apache.distributedlog.common.config.ConcurrentConstConfiguration)2 URI (java.net.URI)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 LedgerHandle (org.apache.bookkeeper.client.LedgerHandle)1 LedgerMetadata (org.apache.bookkeeper.client.LedgerMetadata)1 Feature (org.apache.bookkeeper.feature.Feature)1 SettableFeature (org.apache.bookkeeper.feature.SettableFeature)1 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)1 AsyncLogWriter (org.apache.distributedlog.api.AsyncLogWriter)1 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)1 Namespace (org.apache.distributedlog.api.namespace.Namespace)1 DynamicDistributedLogConfiguration (org.apache.distributedlog.config.DynamicDistributedLogConfiguration)1 BKNamespaceDriver (org.apache.distributedlog.impl.BKNamespaceDriver)1