use of org.apache.bookkeeper.feature.Feature in project distributedlog by twitter.
the class TestDynamicConfigurationFeatureProvider method testLoadFeaturesFromOverlay.
/**
* {@link https://issues.apache.org/jira/browse/DL-40}
*/
@DistributedLogAnnotations.FlakyTest
@Ignore
@Test(timeout = 60000)
public void testLoadFeaturesFromOverlay() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
writer.setProperty("feature_2", "5000");
writer.save();
PropertiesWriter overlayWriter = new PropertiesWriter();
overlayWriter.setProperty("feature_2", "6000");
overlayWriter.setProperty("feature_4", "6000");
overlayWriter.save();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setDynamicConfigReloadIntervalSec(Integer.MAX_VALUE).setFileFeatureProviderBaseConfigPath(writer.getFile().toURI().toURL().getPath()).setFileFeatureProviderOverlayConfigPath(overlayWriter.getFile().toURI().toURL().getPath());
DynamicConfigurationFeatureProvider provider = new DynamicConfigurationFeatureProvider("", conf, NullStatsLogger.INSTANCE);
provider.start();
ensureConfigReloaded();
Feature feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(10000, feature1.availability());
Feature feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(6000, feature2.availability());
Feature feature3 = provider.getFeature("feature_3");
assertFalse(feature3.isAvailable());
assertEquals(0, feature3.availability());
Feature feature4 = provider.getFeature("feature_4");
assertTrue(feature4.isAvailable());
assertEquals(6000, feature4.availability());
Feature feature5 = provider.getFeature("unknown_feature");
assertFalse(feature5.isAvailable());
assertEquals(0, feature5.availability());
provider.stop();
}
use of org.apache.bookkeeper.feature.Feature in project distributedlog by twitter.
the class TestDynamicConfigurationFeatureProvider method testLoadFeaturesFromBase.
@Test(timeout = 60000)
public void testLoadFeaturesFromBase() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
writer.setProperty("feature_2", "5000");
writer.save();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setDynamicConfigReloadIntervalSec(Integer.MAX_VALUE).setFileFeatureProviderBaseConfigPath(writer.getFile().toURI().toURL().getPath());
DynamicConfigurationFeatureProvider provider = new DynamicConfigurationFeatureProvider("", conf, NullStatsLogger.INSTANCE);
provider.start();
ensureConfigReloaded();
Feature feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(10000, feature1.availability());
Feature feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(5000, feature2.availability());
Feature feature3 = provider.getFeature("feature_3");
assertFalse(feature3.isAvailable());
assertEquals(0, feature3.availability());
Feature feature4 = provider.getFeature("unknown_feature");
assertFalse(feature4.isAvailable());
assertEquals(0, feature4.availability());
provider.stop();
}
use of org.apache.bookkeeper.feature.Feature in project distributedlog by twitter.
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));
}
use of org.apache.bookkeeper.feature.Feature in project distributedlog by twitter.
the class TestDynamicConfigurationFeatureProvider method testReloadFeaturesFromOverlay.
@Test(timeout = 60000)
public void testReloadFeaturesFromOverlay() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
writer.setProperty("feature_2", "5000");
writer.save();
PropertiesWriter overlayWriter = new PropertiesWriter();
overlayWriter.setProperty("feature_2", "6000");
overlayWriter.setProperty("feature_4", "6000");
overlayWriter.save();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setDynamicConfigReloadIntervalSec(Integer.MAX_VALUE).setFileFeatureProviderBaseConfigPath(writer.getFile().toURI().toURL().getPath()).setFileFeatureProviderOverlayConfigPath(overlayWriter.getFile().toURI().toURL().getPath());
DynamicConfigurationFeatureProvider provider = new DynamicConfigurationFeatureProvider("", conf, NullStatsLogger.INSTANCE);
provider.start();
ensureConfigReloaded();
Feature feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(10000, feature1.availability());
Feature feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(6000, feature2.availability());
Feature feature3 = provider.getFeature("feature_3");
assertFalse(feature3.isAvailable());
assertEquals(0, feature3.availability());
Feature feature4 = provider.getFeature("feature_4");
assertTrue(feature4.isAvailable());
assertEquals(6000, feature4.availability());
Feature feature5 = provider.getFeature("unknown_feature");
assertFalse(feature5.isAvailable());
assertEquals(0, feature5.availability());
// dynamic load config
provider.getFeatureConf().setProperty("feature_1", 3000);
provider.getFeatureConf().setProperty("feature_2", 7000);
provider.getFeatureConf().setProperty("feature_3", 8000);
provider.getFeatureConf().setProperty("feature_4", 9000);
provider.onReload(provider.getFeatureConf());
feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(3000, feature1.availability());
feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(7000, feature2.availability());
feature3 = provider.getFeature("feature_3");
assertTrue(feature3.isAvailable());
assertEquals(8000, feature3.availability());
feature4 = provider.getFeature("feature_4");
assertTrue(feature4.isAvailable());
assertEquals(9000, feature4.availability());
provider.stop();
}
Aggregations