Class StoreChangelogReader
- java.lang.Object
-
- org.apache.kafka.streams.processor.internals.StoreChangelogReader
-
- All Implemented Interfaces:
ChangelogReader
,ChangelogRegister
public class StoreChangelogReader extends 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, Admin adminClient, Consumer<byte[],byte[]> restoreConsumer, StateRestoreListener stateRestoreListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear all partitionsSet<TopicPartition>
completedChangelogs()
void
enforceRestoreActive()
Transit to restore active changelogs modeboolean
isEmpty()
void
register(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.void
restore()
Restore all registered state stores by reading from their changelogsString
toString()
void
transitToUpdateStandby()
Transit to update standby changelogs modevoid
unregister(Collection<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, Admin adminClient, Consumer<byte[],byte[]> restoreConsumer, StateRestoreListener stateRestoreListener)
-
-
Method Detail
-
enforceRestoreActive
public void enforceRestoreActive()
Description copied from interface:ChangelogReader
Transit to restore active changelogs mode- Specified by:
enforceRestoreActive
in interfaceChangelogReader
-
transitToUpdateStandby
public void transitToUpdateStandby()
Description copied from interface:ChangelogReader
Transit to update standby changelogs mode- Specified by:
transitToUpdateStandby
in interfaceChangelogReader
-
register
public void register(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:
register
in interfaceChangelogRegister
- Parameters:
partition
- the state store's changelog partition for restoringstateManager
- the state manager used for restoring (one per task)
-
completedChangelogs
public Set<TopicPartition> completedChangelogs()
- Specified by:
completedChangelogs
in interfaceChangelogReader
- Returns:
- the changelog partitions that have been completed restoring
-
restore
public void restore()
Description copied from interface:ChangelogReader
Restore all registered state stores by reading from their changelogs- Specified by:
restore
in interfaceChangelogReader
-
unregister
public void unregister(Collection<TopicPartition> revokedChangelogs)
Description copied from interface:ChangelogRegister
Unregisters and removes the passed in partitions from the set of changelogs- Specified by:
unregister
in interfaceChangelogRegister
- Parameters:
revokedChangelogs
- the set of partitions to remove
-
clear
public void clear()
Description copied from interface:ChangelogReader
Clear all partitions- Specified by:
clear
in interfaceChangelogReader
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceChangelogReader
- Returns:
- whether the changelog reader has just been cleared or is uninitialized
-
-