public class DynamoDBLockBasedLeaderDecider extends Object implements LeaderDecider
METRIC_OPERATION_LEADER_DECIDER, METRIC_OPERATION_LEADER_DECIDER_IS_LEADER| Constructor and Description |
|---|
DynamoDBLockBasedLeaderDecider() |
| Modifier and Type | Method and Description |
|---|---|
static DynamoDBLockBasedLeaderDecider |
create(CoordinatorStateDAO coordinatorStateDao,
String workerId,
MetricsFactory metricsFactory,
long leaseDurationInMillis,
long heartbeatPeriodInMillis) |
void |
initialize()
Performs initialization tasks for decider if any.
|
Boolean |
isLeader(String workerId)
Check the lockItem in storage and if the current worker is not leader worker, then tries to acquire lock and
returns true if it was able to acquire lock else false.
|
void |
releaseLeadershipIfHeld()
If the current worker is the leader, then releases the leadership else does nothing.
|
void |
shutdown()
Shuts down the leader decider, releasing any held lock and closing the lock client.
|
public static DynamoDBLockBasedLeaderDecider create(CoordinatorStateDAO coordinatorStateDao, String workerId, MetricsFactory metricsFactory, long leaseDurationInMillis, long heartbeatPeriodInMillis)
public void initialize()
LeaderDeciderinitialize in interface LeaderDeciderpublic Boolean isLeader(String workerId)
isLeader in interface LeaderDeciderworkerId - ID of the workerpublic void shutdown()
This method releases the leadership lock if held and then closes the underlying DynamoDB lock client to stop its background heartbeat thread. This ensures that no locks are kept alive after shutdown.
shutdown in interface LeaderDeciderpublic void releaseLeadershipIfHeld()
LeaderDeciderreleaseLeadershipIfHeld in interface LeaderDeciderCopyright © 2026. All rights reserved.