use of org.apache.kafka.test.NoOpProcessorContext in project kafka by apache.
the class StreamTaskTest method shouldWrapKafkaExceptionsWithStreamsExceptionAndAddContextWhenPunctuating.
@SuppressWarnings("unchecked")
@Test
public void shouldWrapKafkaExceptionsWithStreamsExceptionAndAddContextWhenPunctuating() throws Exception {
final ProcessorNode punctuator = new ProcessorNode("test", new AbstractProcessor() {
@Override
public void init(final ProcessorContext context) {
context.schedule(1);
}
@Override
public void process(final Object key, final Object value) {
//
}
@Override
public void punctuate(final long timestamp) {
throw new KafkaException("KABOOM!");
}
}, Collections.<String>emptySet());
punctuator.init(new NoOpProcessorContext());
try {
task.punctuate(punctuator, 1);
fail("Should've thrown StreamsException");
} catch (StreamsException e) {
final String message = e.getMessage();
assertTrue("message=" + message + " should contain processor", message.contains("processor=test"));
assertThat(((ProcessorContextImpl) task.processorContext()).currentNode(), nullValue());
}
}
use of org.apache.kafka.test.NoOpProcessorContext 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);
}
use of org.apache.kafka.test.NoOpProcessorContext in project kafka by apache.
the class GlobalStateTaskTest method before.
@Before
public void before() {
sourceOne = new MockSourceNode<>(new String[] { "t1" }, new StringDeserializer(), new StringDeserializer());
sourceTwo = new MockSourceNode<>(new String[] { "t2" }, new IntegerDeserializer(), new IntegerDeserializer());
processorNodes = Arrays.asList(sourceOne, sourceTwo, new MockProcessorNode<>(-1), new MockProcessorNode<>(-1));
final Set<String> storeNames = Utils.mkSet("t1-store", "t2-store");
final Map<String, SourceNode> sourceByTopics = new HashMap<>();
sourceByTopics.put("t1", sourceOne);
sourceByTopics.put("t2", sourceTwo);
final Map<String, String> storeToTopic = new HashMap<>();
storeToTopic.put("t1-store", "t1");
storeToTopic.put("t2-store", "t2");
final ProcessorTopology topology = new ProcessorTopology(processorNodes, sourceByTopics, Collections.<String, SinkNode>emptyMap(), Collections.<StateStore>emptyList(), storeToTopic, Collections.<StateStore>emptyList());
context = new NoOpProcessorContext();
t1 = new TopicPartition("t1", 1);
t2 = new TopicPartition("t2", 1);
offsets = new HashMap<>();
offsets.put(t1, 50L);
offsets.put(t2, 100L);
stateMgr = new GlobalStateManagerStub(storeNames, offsets);
globalStateTask = new GlobalStateUpdateTask(topology, context, stateMgr);
}
Aggregations