public class KafkaPoller extends Object implements Change.Source<KafkaPoller.Batch>
<http://www.wikidata.org> wikibase:kafka ( "topic:0" 1234 )
When the poller is started, the offsets are initialized from two things:
a) if the storage above if found, use that for initialization
b) if not, use the given timestamp to initialize
This also means if the Kafka offset is ever reset, the old offsets need to be manually
cleaned up. See KafkaOffsetsRepository.UPDATE_OFFSETS query for how to do it.
See https://wikitech.wikimedia.org/wiki/EventBus for more docs on events in Kafka.| Modifier and Type | Class and Description |
|---|---|
static class |
KafkaPoller.Batch |
| Constructor and Description |
|---|
KafkaPoller(org.apache.kafka.clients.consumer.Consumer<String,ChangeEvent> consumer,
WikibaseRepository.Uris uris,
Instant firstStartTime,
int batchSize,
Collection<String> topics,
KafkaOffsetsRepository kafkaOffsetsRepository,
boolean ignoreStoredOffsets,
com.codahale.metrics.MetricRegistry metricRegistry) |
| Modifier and Type | Method and Description |
|---|---|
static KafkaPoller |
buildKafkaPoller(String kafkaServers,
String consumerId,
Collection<String> clusterNames,
WikibaseRepository.Uris uris,
int batchSize,
Instant startTime,
boolean ignoreStoredOffsets,
KafkaOffsetsRepository kafkaOffsetsRepository,
com.codahale.metrics.MetricRegistry metricRegistry) |
void |
close() |
com.google.common.collect.ImmutableMap<org.apache.kafka.common.TopicPartition,Long> |
currentOffsets() |
KafkaPoller.Batch |
firstBatch()
Fetch the first batch.
|
KafkaPoller.Batch |
nextBatch(KafkaPoller.Batch lastBatch)
Fetches the next batch after lastBatch.
|
public KafkaPoller(org.apache.kafka.clients.consumer.Consumer<String,ChangeEvent> consumer, WikibaseRepository.Uris uris, Instant firstStartTime, int batchSize, Collection<String> topics, KafkaOffsetsRepository kafkaOffsetsRepository, boolean ignoreStoredOffsets, com.codahale.metrics.MetricRegistry metricRegistry)
@Nonnull public static KafkaPoller buildKafkaPoller(String kafkaServers, String consumerId, Collection<String> clusterNames, WikibaseRepository.Uris uris, int batchSize, Instant startTime, boolean ignoreStoredOffsets, KafkaOffsetsRepository kafkaOffsetsRepository, com.codahale.metrics.MetricRegistry metricRegistry)
public KafkaPoller.Batch firstBatch() throws RetryableException
Change.SourcefirstBatch in interface Change.Source<KafkaPoller.Batch>RetryableException - is the fetch fails in a retryable waypublic com.google.common.collect.ImmutableMap<org.apache.kafka.common.TopicPartition,Long> currentOffsets()
public KafkaPoller.Batch nextBatch(KafkaPoller.Batch lastBatch) throws RetryableException
Change.SourcenextBatch in interface Change.Source<KafkaPoller.Batch>RetryableException - is the fetch fails in a retryable waypublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2019. All rights reserved.