use of org.apache.kafka.streams.processor.Punctuator in project apache-kafka-on-k8s by banzaicloud.
the class StreamTaskTest method shouldWrapKafkaExceptionsWithStreamsExceptionAndAddContextWhenPunctuatingWallClockTimeTime.
@Test
public void shouldWrapKafkaExceptionsWithStreamsExceptionAndAddContextWhenPunctuatingWallClockTimeTime() {
task = createStatelessTask(false);
task.initializeStateStores();
task.initializeTopology();
try {
task.punctuate(processorSystemTime, 1, PunctuationType.WALL_CLOCK_TIME, new Punctuator() {
@Override
public void punctuate(long timestamp) {
throw new KafkaException("KABOOM!");
}
});
fail("Should've thrown StreamsException");
} catch (final StreamsException e) {
final String message = e.getMessage();
assertTrue("message=" + message + " should contain processor", message.contains("processor '" + processorSystemTime.name() + "'"));
assertThat(task.processorContext.currentNode(), nullValue());
}
}
use of org.apache.kafka.streams.processor.Punctuator in project apache-kafka-on-k8s by banzaicloud.
the class StreamTaskTest method shouldNotThrowExceptionOnScheduleIfCurrentNodeIsNotNull.
@Test
public void shouldNotThrowExceptionOnScheduleIfCurrentNodeIsNotNull() {
task = createStatelessTask(false);
task.processorContext.setCurrentNode(processorStreamTime);
task.schedule(1, PunctuationType.STREAM_TIME, new Punctuator() {
@Override
public void punctuate(long timestamp) {
// no-op
}
});
}
use of org.apache.kafka.streams.processor.Punctuator in project apache-kafka-on-k8s by banzaicloud.
the class PunctuationQueueTest method testPunctuationInterval.
@Test
public void testPunctuationInterval() {
final TestProcessor processor = new TestProcessor();
final ProcessorNode<String, String> node = new ProcessorNode<>("test", processor, null);
final PunctuationQueue queue = new PunctuationQueue();
final Punctuator punctuator = new Punctuator() {
@Override
public void punctuate(long timestamp) {
node.processor().punctuate(timestamp);
}
};
final PunctuationSchedule sched = new PunctuationSchedule(node, 0L, 100L, punctuator);
final long now = sched.timestamp - 100L;
queue.schedule(sched);
ProcessorNodePunctuator processorNodePunctuator = new ProcessorNodePunctuator() {
@Override
public void punctuate(ProcessorNode node, long time, PunctuationType type, Punctuator punctuator) {
punctuator.punctuate(time);
}
};
queue.mayPunctuate(now, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(0, processor.punctuatedAt.size());
queue.mayPunctuate(now + 99L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(0, processor.punctuatedAt.size());
queue.mayPunctuate(now + 100L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(1, processor.punctuatedAt.size());
queue.mayPunctuate(now + 199L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(1, processor.punctuatedAt.size());
queue.mayPunctuate(now + 200L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(2, processor.punctuatedAt.size());
queue.mayPunctuate(now + 1001L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(3, processor.punctuatedAt.size());
queue.mayPunctuate(now + 1002L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(3, processor.punctuatedAt.size());
queue.mayPunctuate(now + 1100L, PunctuationType.STREAM_TIME, processorNodePunctuator);
assertEquals(4, processor.punctuatedAt.size());
}
Aggregations