Database Reference
In-Depth Information
The wiley.streaming.curator.LeaderSelectionTest uses the
UnreliableLeader class to start three different leaders that then take
over processing events from each other when one crashes:
Thread[] thread = new Thread[3];
for(int i=0;i<thread.length;i++) {
UnreliableLeader l = new UnreliableLeader(
"localhost","server"+i);
thread[i] = new Thread(l);
thread[i].run();
}
for(int i=0;i<thread.length;i++) {
thread[i].join();
}
The output from this example looks something like this:
server0 is about to start waiting for leadership
server0: processing event
server0: processing event
server0: processing event
server0: processing event
server0: crashing
server1 is about to start waiting for leadership
server1: crashing
server2 is about to start waiting for leadership
server2: processing event
server2: processing event
server2: processing event
server2: crashing
Conclusion
This chapter has introduced the concepts behind maintaining shared state
and coordinating between distributed processes. These tasks have been
handled in an ad hoc manner by many distributed systems over the years,
most typically by using a relational database. The relational database option
generally works, but it introduces the potential for error when trying to
implement a do-it-yourself distributed lock manager or other system.
Search WWH ::




Custom Search