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);
}
Aggregations