use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class ProcessorStateManagerTest method shouldThrowProcessorStateExceptionOnFlushIfStoreThrowsAnException.
@Test
public void shouldThrowProcessorStateExceptionOnFlushIfStoreThrowsAnException() {
final RuntimeException exception = new RuntimeException("KABOOM!");
final ProcessorStateManager stateManager = getStateManager(Task.TaskType.ACTIVE);
final MockKeyValueStore stateStore = new MockKeyValueStore(persistentStoreName, true) {
@Override
public void flush() {
throw exception;
}
};
stateManager.registerStore(stateStore, stateStore.stateRestoreCallback, null);
final ProcessorStateException thrown = assertThrows(ProcessorStateException.class, stateManager::flush);
assertEquals(exception, thrown.getCause());
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class ProcessorStateManagerTest method shouldThrowProcessorStateExceptionOnCloseIfStoreThrowsAnException.
@Test
public void shouldThrowProcessorStateExceptionOnCloseIfStoreThrowsAnException() {
final RuntimeException exception = new RuntimeException("KABOOM!");
final ProcessorStateManager stateManager = getStateManager(Task.TaskType.ACTIVE);
final MockKeyValueStore stateStore = new MockKeyValueStore(persistentStoreName, true) {
@Override
public void close() {
throw exception;
}
};
stateManager.registerStore(stateStore, stateStore.stateRestoreCallback, null);
final ProcessorStateException thrown = assertThrows(ProcessorStateException.class, stateManager::close);
assertEquals(exception, thrown.getCause());
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class ProcessorStateManagerTest method shouldThrowIfRestoreCallbackThrows.
@Test
public void shouldThrowIfRestoreCallbackThrows() {
final ProcessorStateManager stateMgr = getStateManager(Task.TaskType.ACTIVE);
stateMgr.registerStore(persistentStore, (key, value) -> {
throw new RuntimeException("KABOOM!");
}, null);
final StateStoreMetadata storeMetadata = stateMgr.storeMetadata(persistentStorePartition);
try {
stateMgr.restore(storeMetadata, singletonList(consumerRecord));
fail("should have thrown processor state exception when IO exception happens");
} catch (final ProcessorStateException e) {
// pass
}
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class ProcessorStateManagerTest method shouldFlushGoodStoresEvenSomeThrowsException.
@Test
public void shouldFlushGoodStoresEvenSomeThrowsException() {
final AtomicBoolean flushedStore = new AtomicBoolean(false);
final MockKeyValueStore stateStore1 = new MockKeyValueStore(persistentStoreName, true) {
@Override
public void flush() {
throw new RuntimeException("KABOOM!");
}
};
final MockKeyValueStore stateStore2 = new MockKeyValueStore(persistentStoreTwoName, true) {
@Override
public void flush() {
flushedStore.set(true);
}
};
final ProcessorStateManager stateManager = getStateManager(Task.TaskType.ACTIVE);
stateManager.registerStore(stateStore1, stateStore1.stateRestoreCallback, null);
stateManager.registerStore(stateStore2, stateStore2.stateRestoreCallback, null);
try {
stateManager.flush();
} catch (final ProcessorStateException expected) {
/* ignore */
}
Assert.assertTrue(flushedStore.get());
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class RocksDBStore method putAll.
@Override
public void putAll(final List<KeyValue<Bytes, byte[]>> entries) {
try (final WriteBatch batch = new WriteBatch()) {
dbAccessor.prepareBatch(entries, batch);
StoreQueryUtils.updatePosition(position, context);
write(batch);
} catch (final RocksDBException e) {
throw new ProcessorStateException("Error while batch writing to store " + name, e);
}
}
Aggregations