use of org.apache.distributedlog.util.SimplePermitLimiter in project bookkeeper by apache.
the class TestWriteLimiter method testDarkmodeGlobalOverStreamUnder.
@Test(timeout = 60000)
public void testDarkmodeGlobalOverStreamUnder() throws Exception {
SimplePermitLimiter streamLimiter = createPermitLimiter(true, 2);
SimplePermitLimiter globalLimiter = createPermitLimiter(true, 1);
WriteLimiter limiter = new WriteLimiter("test", streamLimiter, globalLimiter);
limiter.acquire();
limiter.acquire();
assertPermits(streamLimiter, 2, globalLimiter, 2);
limiter.release();
assertPermits(streamLimiter, 1, globalLimiter, 1);
limiter.release();
assertPermits(streamLimiter, 0, globalLimiter, 0);
}
use of org.apache.distributedlog.util.SimplePermitLimiter in project bookkeeper by apache.
the class TestWriteLimiter method testUnsetDisableFeatureBeforePermitsExceeded.
@Test(timeout = 60000)
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