use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class StateManagerUtilTest method shouldStillWipeStateStoresIfCloseThrowsException.
@Test
public void shouldStillWipeStateStoresIfCloseThrowsException() throws IOException {
final File randomFile = new File("/random/path");
mockStatic(Utils.class);
expect(stateManager.taskId()).andReturn(taskId);
expect(stateDirectory.lock(taskId)).andReturn(true);
stateManager.close();
expectLastCall().andThrow(new ProcessorStateException("Close failed"));
expect(stateManager.baseDir()).andReturn(randomFile);
Utils.delete(randomFile);
stateDirectory.unlock(taskId);
expectLastCall();
ctrl.checkOrder(true);
ctrl.replay();
replayAll();
assertThrows(ProcessorStateException.class, () -> StateManagerUtil.closeStateManager(logger, "logPrefix:", false, true, stateManager, stateDirectory, TaskType.ACTIVE));
ctrl.verify();
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class StateManagerUtilTest method testCloseStateManagerWithStateStoreWipeOutRethrowWrappedIOException.
@Test
public void testCloseStateManagerWithStateStoreWipeOutRethrowWrappedIOException() throws IOException {
final File unknownFile = new File("/unknown/path");
mockStatic(Utils.class);
expect(stateManager.taskId()).andReturn(taskId);
expect(stateDirectory.lock(taskId)).andReturn(true);
stateManager.close();
expectLastCall();
expect(stateManager.baseDir()).andReturn(unknownFile);
Utils.delete(unknownFile);
expectLastCall().andThrow(new IOException("Deletion failed"));
stateDirectory.unlock(taskId);
expectLastCall();
ctrl.checkOrder(true);
ctrl.replay();
replayAll();
final ProcessorStateException thrown = assertThrows(ProcessorStateException.class, () -> StateManagerUtil.closeStateManager(logger, "logPrefix:", false, true, stateManager, stateDirectory, TaskType.ACTIVE));
assertEquals(IOException.class, thrown.getCause().getClass());
ctrl.verify();
}
use of org.apache.kafka.streams.errors.ProcessorStateException in project kafka by apache.
the class StandbyTaskTest method shouldNotFlushAndThrowOnCloseDirty.
@Test
public void shouldNotFlushAndThrowOnCloseDirty() {
EasyMock.expect(stateManager.changelogOffsets()).andStubReturn(Collections.emptyMap());
stateManager.close();
EasyMock.expectLastCall().andThrow(new ProcessorStateException("KABOOM!")).anyTimes();
stateManager.flush();
EasyMock.expectLastCall().andThrow(new AssertionError("Flush should not be called")).anyTimes();
stateManager.checkpoint();
EasyMock.expectLastCall().andThrow(new AssertionError("Checkpoint should not be called")).anyTimes();
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet()).anyTimes();
EasyMock.replay(stateManager);
final MetricName metricName = setupCloseTaskMetric();
task = createStandbyTask();
task.initializeIfNeeded();
task.suspend();
task.closeDirty();
assertEquals(Task.State.CLOSED, task.state());
final double expectedCloseTaskMetric = 1.0;
verifyCloseTaskMetric(expectedCloseTaskMetric, streamsMetrics, metricName);
EasyMock.verify(stateManager);
}
Aggregations