parent
97ec512b00
commit
3fa2b995c6
2 changed files with 28 additions and 26 deletions
|
@ -40,19 +40,20 @@ public class BackwardRecordEmitter
|
||||||
) {
|
) {
|
||||||
final Map<TopicPartition, Long> partitionsOffsets =
|
final Map<TopicPartition, Long> partitionsOffsets =
|
||||||
offsetsSeek.getPartitionsOffsets(consumer);
|
offsetsSeek.getPartitionsOffsets(consumer);
|
||||||
log.info("partition offsets: {}", partitionsOffsets);
|
log.debug("partition offsets: {}", partitionsOffsets);
|
||||||
var waitingOffsets =
|
var waitingOffsets =
|
||||||
offsetsSeek.waitingOffsets(consumer, partitionsOffsets.keySet());
|
offsetsSeek.waitingOffsets(consumer, partitionsOffsets.keySet());
|
||||||
log.info("waittin offsets {} {}",
|
log.debug("waittin offsets {} {}",
|
||||||
waitingOffsets.getBeginOffsets(),
|
waitingOffsets.getBeginOffsets(),
|
||||||
waitingOffsets.getEndOffsets()
|
waitingOffsets.getEndOffsets()
|
||||||
);
|
);
|
||||||
while (!sink.isCancelled() && !waitingOffsets.beginReached()) {
|
while (!sink.isCancelled() && !waitingOffsets.beginReached()) {
|
||||||
for (Map.Entry<TopicPartition, Long> entry : partitionsOffsets.entrySet()) {
|
for (Map.Entry<TopicPartition, Long> entry : partitionsOffsets.entrySet()) {
|
||||||
final Long lowest = waitingOffsets.getBeginOffsets().get(entry.getKey().partition());
|
final Long lowest = waitingOffsets.getBeginOffsets().get(entry.getKey().partition());
|
||||||
|
if (lowest != null) {
|
||||||
consumer.assign(Collections.singleton(entry.getKey()));
|
consumer.assign(Collections.singleton(entry.getKey()));
|
||||||
final long offset = Math.max(lowest, entry.getValue() - msgsPerPartition);
|
final long offset = Math.max(lowest, entry.getValue() - msgsPerPartition);
|
||||||
log.info("Polling {} from {}", entry.getKey(), offset);
|
log.debug("Polling {} from {}", entry.getKey(), offset);
|
||||||
consumer.seek(entry.getKey(), offset);
|
consumer.seek(entry.getKey(), offset);
|
||||||
ConsumerRecords<Bytes, Bytes> records = consumer.poll(POLL_TIMEOUT_MS);
|
ConsumerRecords<Bytes, Bytes> records = consumer.poll(POLL_TIMEOUT_MS);
|
||||||
final List<ConsumerRecord<Bytes, Bytes>> partitionRecords =
|
final List<ConsumerRecord<Bytes, Bytes>> partitionRecords =
|
||||||
|
@ -61,8 +62,8 @@ public class BackwardRecordEmitter
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Collections.reverse(partitionRecords);
|
Collections.reverse(partitionRecords);
|
||||||
|
|
||||||
log.info("{} records polled", records.count());
|
log.debug("{} records polled", records.count());
|
||||||
log.info("{} records sent", partitionRecords.size());
|
log.debug("{} records sent", partitionRecords.size());
|
||||||
for (ConsumerRecord<Bytes, Bytes> msg : partitionRecords) {
|
for (ConsumerRecord<Bytes, Bytes> msg : partitionRecords) {
|
||||||
if (!sink.isCancelled() && !waitingOffsets.beginReached()) {
|
if (!sink.isCancelled() && !waitingOffsets.beginReached()) {
|
||||||
sink.next(msg);
|
sink.next(msg);
|
||||||
|
@ -77,6 +78,7 @@ public class BackwardRecordEmitter
|
||||||
Math.max(offset, entry.getValue() - msgsPerPartition)
|
Math.max(offset, entry.getValue() - msgsPerPartition)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (waitingOffsets.beginReached()) {
|
if (waitingOffsets.beginReached()) {
|
||||||
log.info("begin reached after partitions");
|
log.info("begin reached after partitions");
|
||||||
} else if (sink.isCancelled()) {
|
} else if (sink.isCancelled()) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ kafka:
|
||||||
- name: local
|
- name: local
|
||||||
bootstrapServers: b-1.kad-msk.uxahxx.c6.kafka.eu-west-1.amazonaws.com:9092
|
bootstrapServers: b-1.kad-msk.uxahxx.c6.kafka.eu-west-1.amazonaws.com:9092
|
||||||
# zookeeper: localhost:2181
|
# zookeeper: localhost:2181
|
||||||
# schemaRegistry: http://localhost:8083
|
schemaRegistry: http://kad-ecs-application-lb-857515197.eu-west-1.elb.amazonaws.com:9000/api/schema-registry
|
||||||
# -
|
# -
|
||||||
# name: secondLocal
|
# name: secondLocal
|
||||||
# zookeeper: zookeeper1:2181
|
# zookeeper: zookeeper1:2181
|
||||||
|
|
Loading…
Add table
Reference in a new issue