Class StoreChangelogReader
- java.lang.Object
-
- org.apache.kafka.streams.processor.internals.StoreChangelogReader
-
- All Implemented Interfaces:
ChangelogReader,ChangelogRegister
public class StoreChangelogReader extends java.lang.Object implements ChangelogReader
ChangelogReader is created and maintained by the stream thread and used for both updating standby tasks and restoring active tasks. It manages the restore consumer, including its assigned partitions, when to pause / resume these partitions, etc.The reader also maintains the source of truth for restoration state: only active tasks restoring changelog could be completed, while standby tasks updating changelog would always be in restoring state after being initialized.
-
-
Constructor Summary
Constructors Constructor Description StoreChangelogReader(org.apache.kafka.common.utils.Time time, StreamsConfig config, org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.admin.Admin adminClient, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> restoreConsumer, StateRestoreListener stateRestoreListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all partitionsjava.util.Set<org.apache.kafka.common.TopicPartition>completedChangelogs()voidenforceRestoreActive()Transit to restore active changelogs modebooleanisEmpty()voidregister(org.apache.kafka.common.TopicPartition partition, ProcessorStateManager stateManager)Since it is shared for multiple tasks and hence multiple state managers, the registration would take its corresponding state manager as well for restoring.voidrestore()Restore all registered state stores by reading from their changelogsjava.lang.StringtoString()voidtransitToUpdateStandby()Transit to update standby changelogs modevoidunregister(java.util.Collection<org.apache.kafka.common.TopicPartition> revokedChangelogs)Unregisters and removes the passed in partitions from the set of changelogs
-
-
-
Constructor Detail
-
StoreChangelogReader
public StoreChangelogReader(org.apache.kafka.common.utils.Time time, StreamsConfig config, org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.admin.Admin adminClient, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> restoreConsumer, StateRestoreListener stateRestoreListener)
-
-
Method Detail
-
enforceRestoreActive
public void enforceRestoreActive()
Description copied from interface:ChangelogReaderTransit to restore active changelogs mode- Specified by:
enforceRestoreActivein interfaceChangelogReader
-
transitToUpdateStandby
public void transitToUpdateStandby()
Description copied from interface:ChangelogReaderTransit to update standby changelogs mode- Specified by:
transitToUpdateStandbyin interfaceChangelogReader
-
register
public void register(org.apache.kafka.common.TopicPartition partition, ProcessorStateManager stateManager)Since it is shared for multiple tasks and hence multiple state managers, the registration would take its corresponding state manager as well for restoring.- Specified by:
registerin interfaceChangelogRegister- Parameters:
partition- the state store's changelog partition for restoringstateManager- the state manager used for restoring (one per task)
-
completedChangelogs
public java.util.Set<org.apache.kafka.common.TopicPartition> completedChangelogs()
- Specified by:
completedChangelogsin interfaceChangelogReader- Returns:
- the changelog partitions that have been completed restoring
-
restore
public void restore()
Description copied from interface:ChangelogReaderRestore all registered state stores by reading from their changelogs- Specified by:
restorein interfaceChangelogReader
-
unregister
public void unregister(java.util.Collection<org.apache.kafka.common.TopicPartition> revokedChangelogs)
Description copied from interface:ChangelogRegisterUnregisters and removes the passed in partitions from the set of changelogs- Specified by:
unregisterin interfaceChangelogRegister- Parameters:
revokedChangelogs- the set of partitions to remove
-
clear
public void clear()
Description copied from interface:ChangelogReaderClear all partitions- Specified by:
clearin interfaceChangelogReader
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceChangelogReader- Returns:
- whether the changelog reader has just been cleared or is uninitialized
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-