use of org.apache.kafka.test.NoOpReadOnlyStore in project kafka by apache.
the class GlobalStateManagerImplTest method shouldNotCloseStoresIfCloseAlreadyCalled.
@Test
public void shouldNotCloseStoresIfCloseAlreadyCalled() throws Exception {
stateManager.initialize(context);
initializeConsumer(1, 1, t1);
stateManager.register(new NoOpReadOnlyStore("t1-store") {
@Override
public void close() {
if (!isOpen()) {
throw new RuntimeException("store already closed");
}
super.close();
}
}, false, stateRestoreCallback);
stateManager.close(Collections.<TopicPartition, Long>emptyMap());
stateManager.close(Collections.<TopicPartition, Long>emptyMap());
}
use of org.apache.kafka.test.NoOpReadOnlyStore in project kafka by apache.
the class GlobalStateManagerImplTest method shouldAttemptToCloseAllStoresEvenWhenSomeException.
@Test
public void shouldAttemptToCloseAllStoresEvenWhenSomeException() throws Exception {
stateManager.initialize(context);
initializeConsumer(1, 1, t1);
initializeConsumer(1, 1, t2);
final NoOpReadOnlyStore store = new NoOpReadOnlyStore("t1-store") {
@Override
public void close() {
super.close();
throw new RuntimeException("KABOOM!");
}
};
stateManager.register(store, false, stateRestoreCallback);
stateManager.register(store2, false, stateRestoreCallback);
try {
stateManager.close(Collections.<TopicPartition, Long>emptyMap());
} catch (ProcessorStateException e) {
// expected
}
assertFalse(store.isOpen());
assertFalse(store2.isOpen());
}
use of org.apache.kafka.test.NoOpReadOnlyStore in project kafka by apache.
the class GlobalStateManagerImplTest method shouldThrowProcessorStateStoreExceptionIfStoreCloseFailed.
@Test(expected = ProcessorStateException.class)
public void shouldThrowProcessorStateStoreExceptionIfStoreCloseFailed() throws Exception {
stateManager.initialize(context);
initializeConsumer(1, 1, t1);
stateManager.register(new NoOpReadOnlyStore(store1.name()) {
@Override
public void close() {
throw new RuntimeException("KABOOM!");
}
}, false, stateRestoreCallback);
stateManager.close(Collections.<TopicPartition, Long>emptyMap());
}
use of org.apache.kafka.test.NoOpReadOnlyStore in project kafka by apache.
the class GlobalStateManagerImplTest method shouldThrowProcessorStateStoreExceptionIfStoreFlushFailed.
@Test(expected = ProcessorStateException.class)
public void shouldThrowProcessorStateStoreExceptionIfStoreFlushFailed() throws Exception {
stateManager.initialize(context);
final TheStateRestoreCallback stateRestoreCallback = new TheStateRestoreCallback();
// register the stores
initializeConsumer(1, 1, t1);
stateManager.register(new NoOpReadOnlyStore(store1.name()) {
@Override
public void flush() {
throw new RuntimeException("KABOOM!");
}
}, false, stateRestoreCallback);
stateManager.flush(context);
}
use of org.apache.kafka.test.NoOpReadOnlyStore in project kafka by apache.
the class GlobalStateManagerImplTest method before.
@Before
public void before() throws IOException {
final Map<String, String> storeToTopic = new HashMap<>();
storeToTopic.put("t1-store", "t1");
storeToTopic.put("t2-store", "t2");
final Map<StateStore, ProcessorNode> storeToProcessorNode = new HashMap<>();
store1 = new NoOpReadOnlyStore<>("t1-store");
storeToProcessorNode.put(store1, new MockProcessorNode(-1));
store2 = new NoOpReadOnlyStore("t2-store");
storeToProcessorNode.put(store2, new MockProcessorNode(-1));
topology = new ProcessorTopology(Collections.<ProcessorNode>emptyList(), Collections.<String, SourceNode>emptyMap(), Collections.<String, SinkNode>emptyMap(), Collections.<StateStore>emptyList(), storeToTopic, Arrays.<StateStore>asList(store1, store2));
context = new NoOpProcessorContext();
stateDirPath = TestUtils.tempDirectory().getPath();
stateDirectory = new StateDirectory("appId", stateDirPath, time);
consumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
stateManager = new GlobalStateManagerImpl(topology, consumer, stateDirectory);
checkpointFile = new File(stateManager.baseDir(), ProcessorStateManager.CHECKPOINT_FILE_NAME);
}
Aggregations