public class TierTopicConsumer extends Object implements Runnable
register(kafka.tier.TopicIdPartition, kafka.tier.topic.TierTopicConsumer.ClientCtx)
and deregister(kafka.tier.TopicIdPartition)
materialization of tier partition
states.Modifier and Type | Class and Description |
---|---|
static interface |
TierTopicConsumer.ClientCtx |
Constructor and Description |
---|
TierTopicConsumer(TierTopicManagerConfig config,
org.apache.kafka.storage.internals.log.LogDirFailureChannel logDirFailureChannel,
TierStateFetcher tierStateFetcher,
org.apache.kafka.common.metrics.Metrics metrics,
org.apache.kafka.common.utils.Time time) |
TierTopicConsumer(TierTopicManagerConfig config,
Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> primaryConsumerSupplier,
Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> catchupConsumerSupplier,
Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> discoverConsumerSupplier,
TierTopicManagerCommitter committer,
TierStateFetcher tierStateFetcher,
Optional<org.apache.kafka.common.metrics.Metrics> metrics,
org.apache.kafka.common.utils.Time time) |
Modifier and Type | Method and Description |
---|---|
void |
cancelTracked(AbstractTierMetadata metadata)
Cancel materialization tracking for provided metadata.
|
void |
cleanup() |
void |
deregister(TopicIdPartition partition)
Deregister this topic partition and stop materialization.
|
void |
deregister(TopicIdPartition partition,
String expectedClientCtxId)
Deregister this topic partition and stop materialization only if id of the registered ClientCtx
matches the specified ClientCtx id.
|
void |
doWork() |
void |
initialize(InitializedTierTopic tierTopic)
Start consuming the tier topic.
|
boolean |
isReady() |
void |
register(Map<TopicIdPartition,TierTopicConsumer.ClientCtx> partitionsToRegister)
Register topic partitions to be materialized.
|
void |
register(TopicIdPartition partition,
TierTopicConsumer.ClientCtx clientCtx)
Register topic partition to be materialized.
|
void |
run() |
void |
shutdown() |
Map<Integer,OffsetAndEpoch> |
snapshotPositions()
Takes and returns a snapshot of the current positions for all tier topic partitions.
|
void |
start() |
void |
trackMaterialization(AbstractTierMetadata metadata,
CompletableFuture<TierPartitionState.AppendResult> future)
Track materialization of provided metadata.
|
void |
writePositions(Map<Integer,OffsetAndEpoch> positions) |
public TierTopicConsumer(TierTopicManagerConfig config, org.apache.kafka.storage.internals.log.LogDirFailureChannel logDirFailureChannel, TierStateFetcher tierStateFetcher, org.apache.kafka.common.metrics.Metrics metrics, org.apache.kafka.common.utils.Time time)
public TierTopicConsumer(TierTopicManagerConfig config, Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> primaryConsumerSupplier, Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> catchupConsumerSupplier, Supplier<org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> discoverConsumerSupplier, TierTopicManagerCommitter committer, TierStateFetcher tierStateFetcher, Optional<org.apache.kafka.common.metrics.Metrics> metrics, org.apache.kafka.common.utils.Time time)
public void register(TopicIdPartition partition, TierTopicConsumer.ClientCtx clientCtx)
partition
- Topic partition to registerclientCtx
- Client context for this registrationpublic void register(Map<TopicIdPartition,TierTopicConsumer.ClientCtx> partitionsToRegister)
register(TopicIdPartition, ClientCtx)
but allows registration for multiple topic partitions atomically, to ensure all topic partitions can begin
materialization at the same time.partitionsToRegister
- Topic partitions to registerpublic void deregister(TopicIdPartition partition)
partition
- Topic partition to deregisterpublic void deregister(TopicIdPartition partition, String expectedClientCtxId)
partition
- Topic partition to deregister.expectedClientCtxId
- Expected id of the ClientCtx associated with the topic partition to deregister.public void trackMaterialization(AbstractTierMetadata metadata, CompletableFuture<TierPartitionState.AppendResult> future)
metadata
- Metadata to track materialization forfuture
- Corresponding future; the future is completed after successful materialization of the metadata. It
may be completed exceptionally if the partition is no longer being materialized or if we ran into
unexpected state.public void cancelTracked(AbstractTierMetadata metadata)
metadata
- Metadata to cancel materialization tracking forpublic void initialize(InitializedTierTopic tierTopic)
tierTopic
- An instance of InitializedTierTopic
.public void start()
public Map<Integer,OffsetAndEpoch> snapshotPositions()
public void writePositions(Map<Integer,OffsetAndEpoch> positions)
public boolean isReady()
public void shutdown()
public void cleanup()
public void doWork()