Class LeaderAction
java.lang.Object
io.debezium.connector.spanner.task.leader.LeaderAction
This class contains all the logic for the leader task functionality.
Upon startup, the leader first checks if the sync topic is empty. If so, it assumes the
connector is operating from a fresh start and sends an initial change stream query to receive
back a list of initial change stream tokens.
Then, it waits for all survived tasks to send a list of REBALANCE_ANSWER messages.
Then, it rebalances change stream partitions from obsolete to new (survived) tasks.
Finally, it generates a new epoch message with the new assignment of partitions and writes
it into the sync topic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final io.debezium.util.Clockprivate static final Durationprivate final KafkaConsumerAdminServiceprivate final LeaderServiceprivate Threadprivate static final org.slf4j.Loggerprivate final Durationprivate final TaskPartitionRebalancerprivate final TaskSyncContextHolderprivate final TaskSyncPublisher -
Constructor Summary
ConstructorsConstructorDescriptionLeaderAction(TaskSyncContextHolder taskSyncContextHolder, KafkaConsumerAdminService kafkaAdminService, LeaderService leaderService, TaskPartitionRebalancer taskPartitonRebalancer, TaskSyncPublisher taskSyncPublisher, Consumer<Throwable> errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionprivate ThreadcreateLeaderThread(long rebalanceGenerationId) private voidnewEpoch(long rebalanceGenerationId) private TaskSyncContextvoidstart(long rebalanceGenerationId) voidstop(long rebalanceGenerationId)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
EPOCH_OFFSET_UPDATE_DURATION
-
taskSyncContextHolder
-
kafkaAdminService
-
leaderService
-
taskPartitonRebalancer
-
taskSyncPublisher
-
leaderThread
-
errorHandler
-
sleepInterval
-
clock
private final io.debezium.util.Clock clock
-
-
Constructor Details
-
LeaderAction
public LeaderAction(TaskSyncContextHolder taskSyncContextHolder, KafkaConsumerAdminService kafkaAdminService, LeaderService leaderService, TaskPartitionRebalancer taskPartitonRebalancer, TaskSyncPublisher taskSyncPublisher, Consumer<Throwable> errorHandler)
-
-
Method Details
-
createLeaderThread
-
publishEpochOffset
- Throws:
InterruptedException
-
start
public void start(long rebalanceGenerationId) -
stop
public void stop(long rebalanceGenerationId) -
newEpoch
- Throws:
InterruptedException
-