Database Reference
In-Depth Information
queue 2 consumed 2/Next Work Unit 3
Added item
queue 1 consumed 3/Next Work Unit 4
Added item
queue 2 consumed 4/Next Work Unit 5
Added item
queue 2 consumed 5/Next Work Unit 6
Added item
queue 1 consumed 6/Next Work Unit 7
Added item
queue 1 consumed 7/Next Work Unit 8
Added item
queue 2 consumed 8/Next Work Unit 9
Added item
queue 2 consumed 9/Next Work Unit 10
Added item
queue 2 consumed 10/Next Work Unit 11
Added item
queue 1 consumed 11/Next Work Unit 12
Leader Elections
Curator provides two recipes for implementing Leader Elections: a
LeaderSelector class and a LeaderLatch class. The LeaderSelector
class uses a callback mechanism to implement its functionality, whereas the
LeaderLatch class uses a process similar to the earlier Leader Election
example using the native Java API.
To use the LeaderSelector , the server trying to obtain leadership of
the process must implement the LeaderSelectorListener interface.
This interface specifies the takeLeadership method, which serves as the
main method for the server. Returning from this method relinquishes the
leadershipposition.Forexample,adummyunreliableservermightlooklike
this:
public class UnreliableLeader implements
LeaderSelectorListener {
String name = "";
boolean leader = false ;
String connect;
Search WWH ::




Custom Search