use of io.pravega.segmentstore.storage.ThrottleSourceListener in project pravega by pravega.
the class BookKeeperLogTests method testDebugLogWrapper.
/**
* Tests {@link BookKeeperLogFactory#createDebugLogWrapper}.
*/
@Test
public void testDebugLogWrapper() throws Exception {
@Cleanup val wrapper = this.factory.get().createDebugLogWrapper(0);
val readOnly = wrapper.asReadOnly();
val writeSettings = readOnly.getWriteSettings();
Assert.assertEquals(BookKeeperConfig.MAX_APPEND_LENGTH, writeSettings.getMaxWriteLength());
Assert.assertEquals((int) BookKeeperConfig.BK_WRITE_TIMEOUT.getDefaultValue(), writeSettings.getMaxWriteTimeout().toMillis());
Assert.assertEquals((int) BookKeeperConfig.MAX_OUTSTANDING_BYTES.getDefaultValue(), writeSettings.getMaxOutstandingBytes());
AssertExtensions.assertThrows("registerQueueStateChangeListener should not be implemented.", () -> readOnly.registerQueueStateChangeListener(new ThrottleSourceListener() {
@Override
public void notifyThrottleSourceChanged() {
}
@Override
public boolean isClosed() {
return false;
}
}), ex -> ex instanceof UnsupportedOperationException);
}
use of io.pravega.segmentstore.storage.ThrottleSourceListener in project pravega by pravega.
the class InMemoryDurableDataLogTests method testRegisterQueueStateListener.
@Override
@Test
public void testRegisterQueueStateListener() {
@Cleanup val log = createDurableDataLog();
// Following should have no effect.
log.registerQueueStateChangeListener(new ThrottleSourceListener() {
@Override
public void notifyThrottleSourceChanged() {
}
@Override
public boolean isClosed() {
return false;
}
});
}
use of io.pravega.segmentstore.storage.ThrottleSourceListener in project pravega by pravega.
the class CacheUtilizationProviderTests method testCleanupListeners.
/**
* Tests the {@link CacheUtilizationProvider#registerCleanupListener} and {@link CacheUtilizationProvider#notifyCleanupListeners}
*/
@Test
public void testCleanupListeners() {
val usedBytes = new AtomicLong();
val cup = new CacheUtilizationProvider(POLICY, usedBytes::get);
TestCleanupListener l1 = new TestCleanupListener();
TestCleanupListener l2 = new TestCleanupListener();
cup.registerCleanupListener(l1);
cup.registerCleanupListener(l2);
cup.notifyCleanupListeners();
Assert.assertEquals("Expected cleanup listener to be invoked the first time.", 1, l1.getCallCount());
Assert.assertEquals("Expected cleanup listener to be invoked the first time.", 1, l2.getCallCount());
l2.setClosed(true);
cup.notifyCleanupListeners();
Assert.assertEquals("Expected cleanup listener to be invoked the second time.", 2, l1.getCallCount());
Assert.assertEquals("Not expected cleanup listener to be invoked the second time.", 1, l2.getCallCount());
// This should have no effect.
cup.registerCleanupListener(l2);
// Now verify with errors.
cup.registerCleanupListener(new ThrottleSourceListener() {
@Override
public void notifyThrottleSourceChanged() {
throw new IntentionalException();
}
@Override
public boolean isClosed() {
return false;
}
});
cup.notifyCleanupListeners();
Assert.assertEquals("Expected cleanup listener to be invoked the third time.", 3, l1.getCallCount());
Assert.assertEquals("Not expected cleanup listener to be invoked the third time.", 1, l2.getCallCount());
}
Aggregations