public abstract class AbstractLeaderElectionService extends Object implements LeaderElectionService
AbstractLeaderElectionService
provides a generic implementation of the LeaderElection
handling.Constructor and Description |
---|
AbstractLeaderElectionService() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
confirmLeadership(String contenderID,
UUID leaderSessionID,
String leaderAddress)
Confirms the leadership with the
leaderSessionID and leaderAddress for the
LeaderContender that is associated with the contenderID . |
LeaderElection |
createLeaderElection(String contenderID)
Creates a new
LeaderElection instance that is registered to this LeaderElectionService instance. |
protected abstract boolean |
hasLeadership(String contenderID,
UUID leaderSessionID)
Checks whether the
LeaderElectionService has the leadership acquired for the contenderID and leaderSessionID . |
protected abstract void |
register(String contenderID,
LeaderContender contender)
|
protected abstract void |
remove(String contenderID)
Removes the
LeaderContender from the LeaderElectionService that is associated
with the contenderID . |
public LeaderElection createLeaderElection(String contenderID)
LeaderElectionService
LeaderElection
instance that is registered to this LeaderElectionService
instance.createLeaderElection
in interface LeaderElectionService
contenderID
- a unique identifier that refers to the stored leader information that the
newly created LeaderElection
manages.protected abstract void register(String contenderID, LeaderContender contender) throws Exception
LeaderContender
under the contenderID
with the underlying
LeaderElectionService
. Leadership changes are starting to be reported to the LeaderContender
.Exception
protected abstract void remove(String contenderID)
LeaderContender
from the LeaderElectionService
that is associated
with the contenderID
.protected abstract void confirmLeadership(String contenderID, UUID leaderSessionID, String leaderAddress)
leaderSessionID
and leaderAddress
for the
LeaderContender
that is associated with the contenderID
.protected abstract boolean hasLeadership(String contenderID, UUID leaderSessionID)
LeaderElectionService
has the leadership acquired for the contenderID
and leaderSessionID
.true
if the service has leadership with the passed leaderSessionID
acquired; false
otherwise.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.