Interface Candidate
- All Known Implementing Classes:
- AbstractCandidate,- DefaultCandidate
public interface Candidate
Interface that defines the contract for candidates to participate
 in a leader election. The callback methods 
onGranted(Context)
 and onRevoked(Context) are invoked when leadership is
 granted and revoked.- Author:
- Patrick Peralta, Janne Valkealahti
- 
Method Summary
- 
Method Details- 
getRoleString getRole()Gets the role.- Returns:
- a string indicating the name of the leadership role this candidate is participating in; other candidates present in the system with the same name will contend for leadership
 
- 
getIdString getId()Gets the identifier.- Returns:
- a unique ID for this candidate; no other candidate for leader election should return the same id
 
- 
onGrantedCallback method invoked when this candidate is elected leader. Implementations may chose to launch a background thread to perform leadership roles and return immediately. Another option is for implementations to perform all leadership work in the thread invoking this method. In the latter case, the method must respond to thread interrupts by throwingInterruptedException. When the thread is interrupted, this indicates that this candidate is no longer leader.- Parameters:
- ctx- leadership context
- Throws:
- InterruptedException- when this candidate is no longer leader
 
- 
onRevokedCallback method invoked when this candidate is no longer leader. Implementations should use this to shut down any resources (threads, network connections, etc) used to perform leadership work.- Parameters:
- ctx- leadership context
 
 
-