Search in sources :

Example 11 with SimplePermitLimiter

use of com.twitter.distributedlog.util.SimplePermitLimiter 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);
}
Also used : SimplePermitLimiter(com.twitter.distributedlog.util.SimplePermitLimiter) SettableFeature(org.apache.bookkeeper.feature.SettableFeature) OverCapacityException(com.twitter.distributedlog.exceptions.OverCapacityException) Test(org.junit.Test)

Aggregations

SimplePermitLimiter (com.twitter.distributedlog.util.SimplePermitLimiter)11 Test (org.junit.Test)10 OverCapacityException (com.twitter.distributedlog.exceptions.OverCapacityException)5 SettableFeature (org.apache.bookkeeper.feature.SettableFeature)5 DynamicDistributedLogConfiguration (com.twitter.distributedlog.config.DynamicDistributedLogConfiguration)1 Future (com.twitter.util.Future)1 ArrayList (java.util.ArrayList)1 FixedValueFeature (org.apache.bookkeeper.feature.FixedValueFeature)1 NullStatsLogger (org.apache.bookkeeper.stats.NullStatsLogger)1