Search in sources :

Example 1 with ProductionExceptionHandler

use of org.apache.kafka.streams.errors.ProductionExceptionHandler in project apache-kafka-on-k8s by banzaicloud.

the class StreamTaskTest method shouldFlushRecordCollectorOnFlushState.

@Test
public void shouldFlushRecordCollectorOnFlushState() {
    final AtomicBoolean flushed = new AtomicBoolean(false);
    final StreamsMetrics streamsMetrics = new MockStreamsMetrics(new Metrics());
    final StreamTask streamTask = new StreamTask(taskId00, partitions, topology, consumer, changelogReader, config, streamsMetrics, stateDirectory, null, time, producer) {

        @Override
        RecordCollector createRecordCollector(final LogContext logContext, final ProductionExceptionHandler exHandler) {
            return new NoOpRecordCollector() {

                @Override
                public void flush() {
                    flushed.set(true);
                }
            };
        }
    };
    streamTask.flushState();
    assertTrue(flushed.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Metrics(org.apache.kafka.common.metrics.Metrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) LogContext(org.apache.kafka.common.utils.LogContext) ProductionExceptionHandler(org.apache.kafka.streams.errors.ProductionExceptionHandler) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Test(org.junit.Test)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 LogContext (org.apache.kafka.common.utils.LogContext)1 StreamsMetrics (org.apache.kafka.streams.StreamsMetrics)1 ProductionExceptionHandler (org.apache.kafka.streams.errors.ProductionExceptionHandler)1 NoOpRecordCollector (org.apache.kafka.test.NoOpRecordCollector)1 Test (org.junit.Test)1