Search in sources :

Example 11 with CommitLogReader

use of cz.o2.proxima.direct.commitlog.CommitLogReader in project proxima-platform by O2-Czech-Republic.

the class LocalKafkaCommitLogDescriptorTest method testObserveOffsetsWithLogRoll.

@Test(timeout = 10000)
public void testObserveOffsetsWithLogRoll() throws InterruptedException {
    String topic = Utils.topic(storageUri);
    Map<TopicPartition, Long> endOffsets = IntStream.range(0, 3).mapToObj(i -> new TopicPartition(topic, i)).collect(Collectors.toMap(Function.identity(), e -> 2L));
    Map<TopicPartition, Long> beginningOffsets = IntStream.range(0, 3).mapToObj(i -> new TopicPartition(topic, i)).collect(Collectors.toMap(Function.identity(), e -> 0L));
    final LocalKafkaCommitLogDescriptor descriptor = new LocalKafkaCommitLogDescriptor() {

        @Override
        public Accessor createAccessor(DirectDataOperator direct, AttributeFamilyDescriptor family) {
            AtomicInteger invokedCount = new AtomicInteger();
            return new Accessor(family.getEntity(), family.getStorageUri(), family.getCfg(), id) {

                @Override
                <K, V> KafkaConsumer<K, V> mockKafkaConsumer(String name, ConsumerGroup group, ElementSerializer<K, V> serializer, @Nullable Collection<Partition> assignedPartitions, @Nullable ConsumerRebalanceListener listener) {
                    KafkaConsumer<K, V> mock = super.mockKafkaConsumer(name, group, serializer, assignedPartitions, listener);
                    doAnswer(invocationOnMock -> {
                        if (invokedCount.incrementAndGet() > 2) {
                            return endOffsets;
                        }
                        return beginningOffsets;
                    }).when(mock).beginningOffsets(any());
                    doAnswer(invocationOnMock -> endOffsets).when(mock).endOffsets(any());
                    return mock;
                }
            };
        }
    };
    final Accessor accessor = descriptor.createAccessor(direct, createTestFamily(entity, storageUri, partitionsCfg(3)));
    final CommitLogReader reader = Optionals.get(accessor.getCommitLogReader(context()));
    final CountDownLatch latch = new CountDownLatch(1);
    final CommitLogObserver observer = new CommitLogObserver() {

        @Override
        public boolean onNext(StreamElement ingest, OnNextContext context) {
            context.confirm();
            return false;
        }

        @Override
        public boolean onError(Throwable error) {
            throw new RuntimeException(error);
        }

        @Override
        public void onCompleted() {
            latch.countDown();
        }
    };
    try (final ObserveHandle handle = reader.observeBulkOffsets(reader.fetchOffsets(Position.OLDEST, reader.getPartitions()).values(), true, observer)) {
        latch.await();
    }
}
Also used : Arrays(java.util.Arrays) LocalKafkaLogReader(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaLogReader) LocalKafkaWriter(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaWriter) Partition(cz.o2.proxima.storage.Partition) EntityDescriptor(cz.o2.proxima.repository.EntityDescriptor) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) CachedView(cz.o2.proxima.direct.view.CachedView) StreamElement(cz.o2.proxima.storage.StreamElement) WatermarkEstimator(cz.o2.proxima.time.WatermarkEstimator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Pair(cz.o2.proxima.util.Pair) Serde(org.apache.kafka.common.serialization.Serde) UnaryFunction(cz.o2.proxima.functional.UnaryFunction) Duration(java.time.Duration) Map(java.util.Map) Serdes(org.apache.kafka.common.serialization.Serdes) URI(java.net.URI) WatermarkEstimatorFactory(cz.o2.proxima.time.WatermarkEstimatorFactory) Optionals(cz.o2.proxima.util.Optionals) WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) TopicPartition(org.apache.kafka.common.TopicPartition) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) UUID(java.util.UUID) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) Collectors(java.util.stream.Collectors) RebalanceInProgressException(org.apache.kafka.common.errors.RebalanceInProgressException) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) CommitLogObservers(cz.o2.proxima.direct.commitlog.CommitLogObservers) Objects(java.util.Objects) CountDownLatch(java.util.concurrent.CountDownLatch) ConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ConfigRepository(cz.o2.proxima.repository.ConfigRepository) Stream(java.util.stream.Stream) KeyValue(cz.o2.proxima.direct.randomaccess.KeyValue) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) DirectDataOperator(cz.o2.proxima.direct.core.DirectDataOperator) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Context(cz.o2.proxima.direct.core.Context) IntStream(java.util.stream.IntStream) TestUtils.createTestFamily(cz.o2.proxima.util.TestUtils.createTestFamily) KeyPartitioner(cz.o2.proxima.storage.commitlog.KeyPartitioner) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) HashMap(java.util.HashMap) OnlineAttributeWriter(cz.o2.proxima.direct.core.OnlineAttributeWriter) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) ConfigFactory(com.typesafe.config.ConfigFactory) Watermarks(cz.o2.proxima.time.Watermarks) Factory(cz.o2.proxima.functional.Factory) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) WatermarkIdlePolicy(cz.o2.proxima.time.WatermarkIdlePolicy) Before(org.junit.Before) Properties(java.util.Properties) Repository(cz.o2.proxima.repository.Repository) Iterator(java.util.Iterator) AttributeDescriptor(cz.o2.proxima.repository.AttributeDescriptor) MoreObjects(com.google.common.base.MoreObjects) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) Test(org.junit.Test) AttributeFamilyDescriptor(cz.o2.proxima.repository.AttributeFamilyDescriptor) Offset(cz.o2.proxima.direct.commitlog.Offset) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) AtomicLong(java.util.concurrent.atomic.AtomicLong) AttributeDescriptorBase(cz.o2.proxima.repository.AttributeDescriptorBase) Partitioner(cz.o2.proxima.storage.commitlog.Partitioner) Assert(org.junit.Assert) Comparator(java.util.Comparator) Collections(java.util.Collections) Position(cz.o2.proxima.storage.commitlog.Position) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) StreamElement(cz.o2.proxima.storage.StreamElement) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) CountDownLatch(java.util.concurrent.CountDownLatch) ConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener) AttributeFamilyDescriptor(cz.o2.proxima.repository.AttributeFamilyDescriptor) DirectDataOperator(cz.o2.proxima.direct.core.DirectDataOperator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TopicPartition(org.apache.kafka.common.TopicPartition) AtomicLong(java.util.concurrent.atomic.AtomicLong) Collection(java.util.Collection) Nullable(javax.annotation.Nullable) Test(org.junit.Test)

Example 12 with CommitLogReader

use of cz.o2.proxima.direct.commitlog.CommitLogReader in project proxima-platform by O2-Czech-Republic.

the class LocalKafkaCommitLogDescriptorTest method testObserveCancelled.

@Test(timeout = 10000)
public void testObserveCancelled() throws InterruptedException {
    Accessor accessor = kafka.createAccessor(direct, createTestFamily(entity, storageUri, partitionsCfg(3)));
    CommitLogReader reader = Optionals.get(accessor.getCommitLogReader(context()));
    final CountDownLatch latch = new CountDownLatch(1);
    final ObserveHandle handle = reader.observe("test", Position.NEWEST, new CommitLogObserver() {

        @Override
        public boolean onNext(StreamElement ingest, OnNextContext context) {
            return true;
        }

        @Override
        public void onCompleted() {
            fail("This should not be called");
        }

        @Override
        public boolean onError(Throwable error) {
            throw new RuntimeException(error);
        }

        @Override
        public void onCancelled() {
            latch.countDown();
        }
    });
    handle.close();
    latch.await();
}
Also used : CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) StreamElement(cz.o2.proxima.storage.StreamElement) CountDownLatch(java.util.concurrent.CountDownLatch) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) Test(org.junit.Test)

Example 13 with CommitLogReader

use of cz.o2.proxima.direct.commitlog.CommitLogReader in project proxima-platform by O2-Czech-Republic.

the class LocalKafkaCommitLogDescriptorTest method testBatchObserveWithLogRoll.

@Test(timeout = 10000)
public void testBatchObserveWithLogRoll() throws InterruptedException {
    String topic = Utils.topic(storageUri);
    Map<TopicPartition, Long> endOffsets = IntStream.range(0, 3).mapToObj(i -> new TopicPartition(topic, i)).collect(Collectors.toMap(Function.identity(), e -> 2L));
    Map<TopicPartition, Long> beginningOffsets = IntStream.range(0, 3).mapToObj(i -> new TopicPartition(topic, i)).collect(Collectors.toMap(Function.identity(), e -> 0L));
    final LocalKafkaCommitLogDescriptor descriptor = new LocalKafkaCommitLogDescriptor() {

        @Override
        public Accessor createAccessor(DirectDataOperator direct, AttributeFamilyDescriptor family) {
            AtomicInteger invokedCount = new AtomicInteger();
            return new Accessor(family.getEntity(), family.getStorageUri(), family.getCfg(), id) {

                @Override
                <K, V> KafkaConsumer<K, V> mockKafkaConsumer(String name, ConsumerGroup group, ElementSerializer<K, V> serializer, @Nullable Collection<Partition> assignedPartitions, @Nullable ConsumerRebalanceListener listener) {
                    KafkaConsumer<K, V> mock = super.mockKafkaConsumer(name, group, serializer, assignedPartitions, listener);
                    doAnswer(invocationOnMock -> {
                        if (invokedCount.incrementAndGet() > 2) {
                            return endOffsets;
                        }
                        return beginningOffsets;
                    }).when(mock).beginningOffsets(any());
                    doAnswer(invocationOnMock -> endOffsets).when(mock).endOffsets(any());
                    return mock;
                }
            };
        }
    };
    final Accessor accessor = descriptor.createAccessor(direct, createTestFamily(entity, storageUri, partitionsCfg(3)));
    final CommitLogReader reader = Optionals.get(accessor.getCommitLogReader(context()));
    final CountDownLatch latch = new CountDownLatch(1);
    final CommitLogObserver observer = new CommitLogObserver() {

        @Override
        public boolean onNext(StreamElement ingest, OnNextContext context) {
            context.confirm();
            return false;
        }

        @Override
        public boolean onError(Throwable error) {
            throw new RuntimeException(error);
        }

        @Override
        public void onCompleted() {
            latch.countDown();
        }
    };
    try (final ObserveHandle handle = reader.observeBulk("dummy", Position.OLDEST, true, observer)) {
        latch.await();
    }
}
Also used : Arrays(java.util.Arrays) LocalKafkaLogReader(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaLogReader) LocalKafkaWriter(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaWriter) Partition(cz.o2.proxima.storage.Partition) EntityDescriptor(cz.o2.proxima.repository.EntityDescriptor) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) CachedView(cz.o2.proxima.direct.view.CachedView) StreamElement(cz.o2.proxima.storage.StreamElement) WatermarkEstimator(cz.o2.proxima.time.WatermarkEstimator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Pair(cz.o2.proxima.util.Pair) Serde(org.apache.kafka.common.serialization.Serde) UnaryFunction(cz.o2.proxima.functional.UnaryFunction) Duration(java.time.Duration) Map(java.util.Map) Serdes(org.apache.kafka.common.serialization.Serdes) URI(java.net.URI) WatermarkEstimatorFactory(cz.o2.proxima.time.WatermarkEstimatorFactory) Optionals(cz.o2.proxima.util.Optionals) WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) TopicPartition(org.apache.kafka.common.TopicPartition) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) UUID(java.util.UUID) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) Collectors(java.util.stream.Collectors) RebalanceInProgressException(org.apache.kafka.common.errors.RebalanceInProgressException) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) CommitLogObservers(cz.o2.proxima.direct.commitlog.CommitLogObservers) Objects(java.util.Objects) CountDownLatch(java.util.concurrent.CountDownLatch) ConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ConfigRepository(cz.o2.proxima.repository.ConfigRepository) Stream(java.util.stream.Stream) KeyValue(cz.o2.proxima.direct.randomaccess.KeyValue) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) DirectDataOperator(cz.o2.proxima.direct.core.DirectDataOperator) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Context(cz.o2.proxima.direct.core.Context) IntStream(java.util.stream.IntStream) TestUtils.createTestFamily(cz.o2.proxima.util.TestUtils.createTestFamily) KeyPartitioner(cz.o2.proxima.storage.commitlog.KeyPartitioner) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) HashMap(java.util.HashMap) OnlineAttributeWriter(cz.o2.proxima.direct.core.OnlineAttributeWriter) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) ConfigFactory(com.typesafe.config.ConfigFactory) Watermarks(cz.o2.proxima.time.Watermarks) Factory(cz.o2.proxima.functional.Factory) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) WatermarkIdlePolicy(cz.o2.proxima.time.WatermarkIdlePolicy) Before(org.junit.Before) Properties(java.util.Properties) Repository(cz.o2.proxima.repository.Repository) Iterator(java.util.Iterator) AttributeDescriptor(cz.o2.proxima.repository.AttributeDescriptor) MoreObjects(com.google.common.base.MoreObjects) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) Test(org.junit.Test) AttributeFamilyDescriptor(cz.o2.proxima.repository.AttributeFamilyDescriptor) Offset(cz.o2.proxima.direct.commitlog.Offset) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) AtomicLong(java.util.concurrent.atomic.AtomicLong) AttributeDescriptorBase(cz.o2.proxima.repository.AttributeDescriptorBase) Partitioner(cz.o2.proxima.storage.commitlog.Partitioner) Assert(org.junit.Assert) Comparator(java.util.Comparator) Collections(java.util.Collections) Position(cz.o2.proxima.storage.commitlog.Position) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) StreamElement(cz.o2.proxima.storage.StreamElement) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) CountDownLatch(java.util.concurrent.CountDownLatch) ConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener) AttributeFamilyDescriptor(cz.o2.proxima.repository.AttributeFamilyDescriptor) DirectDataOperator(cz.o2.proxima.direct.core.DirectDataOperator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TopicPartition(org.apache.kafka.common.TopicPartition) AtomicLong(java.util.concurrent.atomic.AtomicLong) Collection(java.util.Collection) Nullable(javax.annotation.Nullable) Test(org.junit.Test)

Example 14 with CommitLogReader

use of cz.o2.proxima.direct.commitlog.CommitLogReader in project proxima-platform by O2-Czech-Republic.

the class LocalKafkaCommitLogDescriptorTest method testBulkObserveWithExceptionAndRetry.

@Test(timeout = 10000)
public void testBulkObserveWithExceptionAndRetry() throws InterruptedException {
    Accessor accessor = kafka.createAccessor(direct, createTestFamily(entity, storageUri, partitionsCfg(3)));
    LocalKafkaWriter writer = accessor.newWriter();
    CommitLogReader reader = Optionals.get(accessor.getCommitLogReader(context()));
    AtomicInteger restarts = new AtomicInteger();
    StreamElement update = StreamElement.upsert(entity, attr, UUID.randomUUID().toString(), "key", attr.getName(), System.currentTimeMillis(), new byte[] { 1, 2 });
    final int numRetries = 3;
    final CountDownLatch latch = new CountDownLatch(numRetries);
    final CommitLogObserver observer = CommitLogObservers.withNumRetriedExceptions("test", numRetries, new CommitLogObserver() {

        @Override
        public boolean onError(Throwable error) {
            latch.countDown();
            return true;
        }

        @Override
        public boolean onNext(StreamElement ingest, OnNextContext confirm) {
            restarts.incrementAndGet();
            throw new RuntimeException("FAIL!");
        }
    });
    reader.observe("test", observer);
    Executors.newCachedThreadPool().execute(() -> {
        while (true) {
            try {
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException ex) {
                break;
            }
            writer.write(update, (succ, e) -> assertTrue(succ));
        }
    });
    latch.await();
    assertEquals(3, restarts.get());
}
Also used : LocalKafkaWriter(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaWriter) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) StreamElement(cz.o2.proxima.storage.StreamElement) CountDownLatch(java.util.concurrent.CountDownLatch) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Example 15 with CommitLogReader

use of cz.o2.proxima.direct.commitlog.CommitLogReader in project proxima-platform by O2-Czech-Republic.

the class LocalKafkaCommitLogDescriptorTest method testBulkObservePartitionsResetOffsetsSuccess.

@Test(timeout = 10000)
public void testBulkObservePartitionsResetOffsetsSuccess() throws InterruptedException {
    Accessor accessor = kafka.createAccessor(direct, createTestFamily(entity, storageUri, partitionsCfg(3)));
    LocalKafkaWriter writer = accessor.newWriter();
    CommitLogReader reader = Optionals.get(accessor.getCommitLogReader(context()));
    AtomicInteger restarts = new AtomicInteger();
    AtomicReference<Throwable> exc = new AtomicReference<>();
    AtomicReference<StreamElement> input = new AtomicReference<>();
    AtomicReference<CountDownLatch> latch = new AtomicReference<>(new CountDownLatch(2));
    StreamElement update = StreamElement.upsert(entity, attr, UUID.randomUUID().toString(), "key", attr.getName(), System.currentTimeMillis(), new byte[] { 1, 2 });
    final ObserveHandle handle = reader.observePartitions(reader.getPartitions(), Position.NEWEST, new CommitLogObserver() {

        @Override
        public void onRepartition(OnRepartitionContext context) {
            restarts.incrementAndGet();
        }

        @Override
        public boolean onNext(StreamElement ingest, OnNextContext context) {
            input.set(ingest);
            context.confirm();
            latch.get().countDown();
            return true;
        }

        @Override
        public boolean onError(Throwable error) {
            exc.set(error);
            throw new RuntimeException(error);
        }
    });
    handle.waitUntilReady();
    writer.write(update, (succ, e) -> {
        assertTrue(succ);
        latch.get().countDown();
    });
    latch.get().await();
    latch.set(new CountDownLatch(1));
    handle.resetOffsets(reader.getPartitions().stream().map(p -> (PartitionWithTopic) p).map(p -> new TopicOffset(new PartitionWithTopic(p.getTopic(), p.getId()), 0, Watermarks.MIN_WATERMARK)).collect(Collectors.toList()));
    latch.get().await();
    assertEquals(1L, (long) (Long) handle.getCommittedOffsets().stream().mapToLong(o -> ((TopicOffset) o).getOffset()).sum());
}
Also used : Arrays(java.util.Arrays) LocalKafkaLogReader(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaLogReader) LocalKafkaWriter(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaWriter) Partition(cz.o2.proxima.storage.Partition) EntityDescriptor(cz.o2.proxima.repository.EntityDescriptor) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) CachedView(cz.o2.proxima.direct.view.CachedView) StreamElement(cz.o2.proxima.storage.StreamElement) WatermarkEstimator(cz.o2.proxima.time.WatermarkEstimator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Pair(cz.o2.proxima.util.Pair) Serde(org.apache.kafka.common.serialization.Serde) UnaryFunction(cz.o2.proxima.functional.UnaryFunction) Duration(java.time.Duration) Map(java.util.Map) Serdes(org.apache.kafka.common.serialization.Serdes) URI(java.net.URI) WatermarkEstimatorFactory(cz.o2.proxima.time.WatermarkEstimatorFactory) Optionals(cz.o2.proxima.util.Optionals) WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) TopicPartition(org.apache.kafka.common.TopicPartition) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) UUID(java.util.UUID) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) Collectors(java.util.stream.Collectors) RebalanceInProgressException(org.apache.kafka.common.errors.RebalanceInProgressException) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) CommitLogObservers(cz.o2.proxima.direct.commitlog.CommitLogObservers) Objects(java.util.Objects) CountDownLatch(java.util.concurrent.CountDownLatch) ConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ConfigRepository(cz.o2.proxima.repository.ConfigRepository) Stream(java.util.stream.Stream) KeyValue(cz.o2.proxima.direct.randomaccess.KeyValue) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) DirectDataOperator(cz.o2.proxima.direct.core.DirectDataOperator) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Context(cz.o2.proxima.direct.core.Context) IntStream(java.util.stream.IntStream) TestUtils.createTestFamily(cz.o2.proxima.util.TestUtils.createTestFamily) KeyPartitioner(cz.o2.proxima.storage.commitlog.KeyPartitioner) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) HashMap(java.util.HashMap) OnlineAttributeWriter(cz.o2.proxima.direct.core.OnlineAttributeWriter) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) ConfigFactory(com.typesafe.config.ConfigFactory) Watermarks(cz.o2.proxima.time.Watermarks) Factory(cz.o2.proxima.functional.Factory) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) WatermarkIdlePolicy(cz.o2.proxima.time.WatermarkIdlePolicy) Before(org.junit.Before) Properties(java.util.Properties) Repository(cz.o2.proxima.repository.Repository) Iterator(java.util.Iterator) AttributeDescriptor(cz.o2.proxima.repository.AttributeDescriptor) MoreObjects(com.google.common.base.MoreObjects) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) Test(org.junit.Test) AttributeFamilyDescriptor(cz.o2.proxima.repository.AttributeFamilyDescriptor) Offset(cz.o2.proxima.direct.commitlog.Offset) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) AtomicLong(java.util.concurrent.atomic.AtomicLong) AttributeDescriptorBase(cz.o2.proxima.repository.AttributeDescriptorBase) Partitioner(cz.o2.proxima.storage.commitlog.Partitioner) Assert(org.junit.Assert) Comparator(java.util.Comparator) Collections(java.util.Collections) Position(cz.o2.proxima.storage.commitlog.Position) LocalKafkaWriter(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.LocalKafkaWriter) ObserveHandle(cz.o2.proxima.direct.commitlog.ObserveHandle) OnNextContext(cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) StreamElement(cz.o2.proxima.storage.StreamElement) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Accessor(cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor) CommitLogObserver(cz.o2.proxima.direct.commitlog.CommitLogObserver) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicLong(java.util.concurrent.atomic.AtomicLong) Test(org.junit.Test)

Aggregations

CommitLogReader (cz.o2.proxima.direct.commitlog.CommitLogReader)80 Test (org.junit.Test)70 StreamElement (cz.o2.proxima.storage.StreamElement)67 CommitLogObserver (cz.o2.proxima.direct.commitlog.CommitLogObserver)63 CountDownLatch (java.util.concurrent.CountDownLatch)58 ObserveHandle (cz.o2.proxima.direct.commitlog.ObserveHandle)45 ArrayList (java.util.ArrayList)41 EntityDescriptor (cz.o2.proxima.repository.EntityDescriptor)34 AttributeDescriptor (cz.o2.proxima.repository.AttributeDescriptor)33 List (java.util.List)31 UUID (java.util.UUID)29 ConfigFactory (com.typesafe.config.ConfigFactory)28 DirectDataOperator (cz.o2.proxima.direct.core.DirectDataOperator)28 Offset (cz.o2.proxima.direct.commitlog.Offset)27 Collections (java.util.Collections)27 Collectors (java.util.stream.Collectors)27 OnNextContext (cz.o2.proxima.direct.commitlog.CommitLogObserver.OnNextContext)26 AtomicReference (java.util.concurrent.atomic.AtomicReference)26 Repository (cz.o2.proxima.repository.Repository)25 Accessor (cz.o2.proxima.direct.kafka.LocalKafkaCommitLogDescriptor.Accessor)24