Search in sources :

Example 1 with CommitCallback

use of org.apache.kafka.streams.processor.CommitCallback in project kafka by apache.

the class ProcessorStateManagerTest method shouldThrowOnFailureToWritePositionCheckpointFile.

@Test
public void shouldThrowOnFailureToWritePositionCheckpointFile() throws IOException {
    final ProcessorStateManager stateMgr = getStateManager(Task.TaskType.ACTIVE);
    final CommitCallback persistentCheckpoint = mock(CommitCallback.class);
    persistentCheckpoint.onCommit();
    final IOException ioException = new IOException("asdf");
    expectLastCall().andThrow(ioException);
    replay(persistentCheckpoint);
    stateMgr.registerStore(persistentStore, persistentStore.stateRestoreCallback, persistentCheckpoint);
    final ProcessorStateException processorStateException = assertThrows(ProcessorStateException.class, stateMgr::checkpoint);
    assertThat(processorStateException.getMessage(), containsString("process-state-manager-test Exception caught while trying to checkpoint store," + " changelog partition test-application-My-Topology-persistentStore-changelog-1"));
    assertThat(processorStateException.getCause(), is(ioException));
}
Also used : CommitCallback(org.apache.kafka.streams.processor.CommitCallback) IOException(java.io.IOException) ProcessorStateException(org.apache.kafka.streams.errors.ProcessorStateException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 ProcessorStateException (org.apache.kafka.streams.errors.ProcessorStateException)1 CommitCallback (org.apache.kafka.streams.processor.CommitCallback)1 Test (org.junit.Test)1