Search in sources :

Example 1 with LogAndSkipOnInvalidTimestamp

use of org.apache.kafka.streams.processor.LogAndSkipOnInvalidTimestamp in project apache-kafka-on-k8s by banzaicloud.

the class RecordQueueTest method shouldDropOnNegativeTimestamp.

@Test
public void shouldDropOnNegativeTimestamp() {
    final List<ConsumerRecord<byte[], byte[]>> records = Collections.singletonList(new ConsumerRecord<>("topic", 1, 1, -1L, TimestampType.CREATE_TIME, 0L, 0, 0, recordKey, recordValue));
    final RecordQueue queue = new RecordQueue(new TopicPartition(topics[0], 1), new MockSourceNode<>(topics, intDeserializer, intDeserializer), new LogAndSkipOnInvalidTimestamp(), new LogAndContinueExceptionHandler(), null, new LogContext());
    queue.addRawRecords(records);
    assertEquals(0, queue.size());
}
Also used : TopicPartition(org.apache.kafka.common.TopicPartition) LogAndSkipOnInvalidTimestamp(org.apache.kafka.streams.processor.LogAndSkipOnInvalidTimestamp) LogContext(org.apache.kafka.common.utils.LogContext) LogAndContinueExceptionHandler(org.apache.kafka.streams.errors.LogAndContinueExceptionHandler) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) Test(org.junit.Test)

Example 2 with LogAndSkipOnInvalidTimestamp

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

the class RecordQueueTest method shouldDropOnNegativeTimestamp.

@Test
public void shouldDropOnNegativeTimestamp() {
    final List<ConsumerRecord<byte[], byte[]>> records = Collections.singletonList(new ConsumerRecord<>("topic", 1, 1, -1L, TimestampType.CREATE_TIME, 0, 0, recordKey, recordValue, new RecordHeaders(), Optional.empty()));
    final RecordQueue queue = new RecordQueue(new TopicPartition("topic", 1), mockSourceNodeWithMetrics, new LogAndSkipOnInvalidTimestamp(), new LogAndContinueExceptionHandler(), new InternalMockProcessorContext(), new LogContext());
    queue.addRawRecords(records);
    assertEquals(0, queue.size());
}
Also used : RecordHeaders(org.apache.kafka.common.header.internals.RecordHeaders) TopicPartition(org.apache.kafka.common.TopicPartition) LogAndSkipOnInvalidTimestamp(org.apache.kafka.streams.processor.LogAndSkipOnInvalidTimestamp) LogContext(org.apache.kafka.common.utils.LogContext) InternalMockProcessorContext(org.apache.kafka.test.InternalMockProcessorContext) LogAndContinueExceptionHandler(org.apache.kafka.streams.errors.LogAndContinueExceptionHandler) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) Test(org.junit.Test)

Aggregations

ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)2 TopicPartition (org.apache.kafka.common.TopicPartition)2 LogContext (org.apache.kafka.common.utils.LogContext)2 LogAndContinueExceptionHandler (org.apache.kafka.streams.errors.LogAndContinueExceptionHandler)2 LogAndSkipOnInvalidTimestamp (org.apache.kafka.streams.processor.LogAndSkipOnInvalidTimestamp)2 Test (org.junit.Test)2 RecordHeaders (org.apache.kafka.common.header.internals.RecordHeaders)1 InternalMockProcessorContext (org.apache.kafka.test.InternalMockProcessorContext)1