use of org.apache.bookkeeper.feature.SettableFeature 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.SettableFeature in project distributedlog by twitter.
the class TestWriteLimiter method testDisabledFeature.
@Test
public void testDisabledFeature() throws Exception {
// Disable darkmode, but should still ignore limits because of the feature.
SettableFeature feature = new SettableFeature("test", 10000);
SimplePermitLimiter streamLimiter = createPermitLimiter(false, 1, feature);
SimplePermitLimiter globalLimiter = createPermitLimiter(false, Integer.MAX_VALUE, feature);
WriteLimiter limiter = new WriteLimiter("test", streamLimiter, globalLimiter);
limiter.acquire();
limiter.acquire();
assertPermits(streamLimiter, 2, globalLimiter, 2);
limiter.release();
limiter.release();
assertPermits(streamLimiter, 0, globalLimiter, 0);
}
use of org.apache.bookkeeper.feature.SettableFeature in project distributedlog by twitter.
the class TestWriteLimiter method testUnsetDisableFeatureBeforePermitsExceeded.
@Test
public void testUnsetDisableFeatureBeforePermitsExceeded() throws Exception {
SettableFeature feature = new SettableFeature("test", 0);
SimplePermitLimiter streamLimiter = createPermitLimiter(false, 1, feature);
SimplePermitLimiter globalLimiter = createPermitLimiter(false, Integer.MAX_VALUE, feature);
WriteLimiter limiter = new WriteLimiter("test", streamLimiter, globalLimiter);
limiter.acquire();
try {
limiter.acquire();
fail("should have thrown stream limit exception");
} catch (OverCapacityException ex) {
}
assertPermits(streamLimiter, 1, globalLimiter, 1);
feature.set(10000);
limiter.acquire();
assertPermits(streamLimiter, 2, globalLimiter, 2);
}
Aggregations