public class DefaultCandidate extends AbstractCandidate
Candidate for leadership.
This implementation simply logs when it is elected and when its leadership is revoked.| Constructor and Description |
|---|
DefaultCandidate()
Instantiate a default candidate.
|
DefaultCandidate(String id,
String role)
Instantiate a default candidate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
onGranted(Context ctx)
Callback method invoked when this candidate is elected leader.
|
void |
onRevoked(Context ctx)
Callback method invoked when this candidate is no longer leader.
|
String |
toString() |
void |
yieldLeadership()
Voluntarily yield leadership if held.
|
getId, getRolepublic void onGranted(Context ctx)
CandidateInterruptedException. When the thread
is interrupted, this indicates that this candidate is no
longer leader.onGranted in interface CandidateonGranted in class AbstractCandidatectx - leadership contextpublic void onRevoked(Context ctx)
CandidateonRevoked in interface CandidateonRevoked in class AbstractCandidatectx - leadership contextpublic void yieldLeadership()
onGranted(Context) method is called by the
leader initiator.