use of org.apache.kafka.streams.errors.LogAndFailExceptionHandler in project kafka by apache.
the class RecordQueueTest method shouldPassPartitionTimeToTimestampExtractor.
@Test
public void shouldPassPartitionTimeToTimestampExtractor() {
final PartitionTimeTrackingTimestampExtractor timestampExtractor = new PartitionTimeTrackingTimestampExtractor();
final RecordQueue queue = new RecordQueue(new TopicPartition("topic", 1), mockSourceNodeWithMetrics, timestampExtractor, new LogAndFailExceptionHandler(), context, new LogContext());
assertTrue(queue.isEmpty());
assertEquals(0, queue.size());
assertEquals(RecordQueue.UNKNOWN, queue.headRecordTimestamp());
// add three 3 out-of-order records with timestamp 2, 1, 3, 4
final List<ConsumerRecord<byte[], byte[]>> list1 = Arrays.asList(new ConsumerRecord<>("topic", 1, 2, 0L, TimestampType.CREATE_TIME, 0, 0, recordKey, recordValue, new RecordHeaders(), Optional.empty()), new ConsumerRecord<>("topic", 1, 1, 0L, TimestampType.CREATE_TIME, 0, 0, recordKey, recordValue, new RecordHeaders(), Optional.empty()), new ConsumerRecord<>("topic", 1, 3, 0L, TimestampType.CREATE_TIME, 0, 0, recordKey, recordValue, new RecordHeaders(), Optional.empty()), new ConsumerRecord<>("topic", 1, 4, 0L, TimestampType.CREATE_TIME, 0, 0, recordKey, recordValue, new RecordHeaders(), Optional.empty()));
assertEquals(RecordQueue.UNKNOWN, timestampExtractor.partitionTime);
queue.addRawRecords(list1);
// no (known) timestamp has yet been passed to the timestamp extractor
assertEquals(RecordQueue.UNKNOWN, timestampExtractor.partitionTime);
queue.poll();
assertEquals(2L, timestampExtractor.partitionTime);
queue.poll();
assertEquals(2L, timestampExtractor.partitionTime);
queue.poll();
assertEquals(3L, timestampExtractor.partitionTime);
}
use of org.apache.kafka.streams.errors.LogAndFailExceptionHandler in project apache-kafka-on-k8s by banzaicloud.
the class GlobalStateTaskTest method before.
@Before
public void before() {
final Set<String> storeNames = Utils.mkSet("t1-store", "t2-store");
final Map<String, SourceNode> sourceByTopics = new HashMap<>();
sourceByTopics.put(topic1, sourceOne);
sourceByTopics.put(topic2, sourceTwo);
final Map<String, String> storeToTopic = new HashMap<>();
storeToTopic.put("t1-store", topic1);
storeToTopic.put("t2-store", topic2);
topology = ProcessorTopology.with(Utils.mkList(sourceOne, sourceTwo, processorOne, processorTwo), sourceByTopics, Collections.<StateStore>emptyList(), storeToTopic);
offsets.put(t1, 50L);
offsets.put(t2, 100L);
stateMgr = new GlobalStateManagerStub(storeNames, offsets);
globalStateTask = new GlobalStateUpdateTask(topology, context, stateMgr, new LogAndFailExceptionHandler(), logContext);
}
use of org.apache.kafka.streams.errors.LogAndFailExceptionHandler in project kafka by apache.
the class GlobalStateTaskTest method before.
@Before
public void before() {
final Set<String> storeNames = Utils.mkSet("t1-store", "t2-store");
final Map<String, SourceNode<?, ?>> sourceByTopics = new HashMap<>();
sourceByTopics.put(topic1, sourceOne);
sourceByTopics.put(topic2, sourceTwo);
final Map<String, String> storeToTopic = new HashMap<>();
storeToTopic.put("t1-store", topic1);
storeToTopic.put("t2-store", topic2);
topology = ProcessorTopologyFactories.with(asList(sourceOne, sourceTwo, processorOne, processorTwo), sourceByTopics, Collections.emptyList(), storeToTopic);
offsets.put(t1, 50L);
offsets.put(t2, 100L);
stateMgr = new GlobalStateManagerStub(storeNames, offsets, testDirectory);
globalStateTask = new GlobalStateUpdateTask(logContext, topology, context, stateMgr, new LogAndFailExceptionHandler());
}
Aggregations