Class DefaultCandidate
java.lang.Object
org.springframework.integration.leader.AbstractCandidate
org.springframework.integration.leader.DefaultCandidate
- All Implemented Interfaces:
- Candidate
Simple 
Candidate for leadership.
 This implementation simply logs when it is elected and when its leadership is revoked.- Since:
- 4.2
- Author:
- Janne Valkealahti, Artem Bilan
- 
Constructor SummaryConstructorsConstructorDescriptionInstantiate a default candidate.DefaultCandidate(String id, String role) Instantiate a default candidate.
- 
Method SummaryMethods inherited from class org.springframework.integration.leader.AbstractCandidategetId, getRole
- 
Constructor Details- 
DefaultCandidatepublic DefaultCandidate()Instantiate a default candidate.
- 
DefaultCandidateInstantiate a default candidate.- Parameters:
- id- the identifier
- role- the role
 
 
- 
- 
Method Details- 
onGrantedDescription copied from interface:CandidateCallback 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.- Specified by:
- onGrantedin interface- Candidate
- Specified by:
- onGrantedin class- AbstractCandidate
- Parameters:
- ctx- leadership context
 
- 
onRevokedDescription copied from interface:CandidateCallback 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.- Specified by:
- onRevokedin interface- Candidate
- Specified by:
- onRevokedin class- AbstractCandidate
- Parameters:
- ctx- leadership context
 
- 
yieldLeadershippublic void yieldLeadership()Voluntarily yield leadership if held. If leader context is not yet known this method does nothing. Leader context becomes available only afteronGranted(Context)method is called by the leader initiator.
- 
toString
 
-