Database Reference
In-Depth Information
}
}
To see it in action, build a little test harness with three different servers
that all take leadership until they crash:
public class LeaderElectionTest {
@Test
public void test() throws Exception {
Thread one = new Thread( new
UnreliableServer("huey","localhost"
,"/ducks"));
Thread two = new Thread( new
UnreliableServer("dewey","localhost"
,"/ducks"));
Thread three = new Thread( new
UnreliableServer("louis","localhost"
,"/ducks"));
one.start();
two.start();
three.start();
//Wait for all the servers to finally die
one.join();
two.join();
three.join();
}
}
This is an example output from this process. Each time the child list
changes, the servers all check to see if they are leader. The one that is
leader starts processing until it “crashes.” This continues until all three
have crashed:
Starting huey
Starting dewey
Waiting for a change in the lock.
Waiting for a change in the lock.
 
Search WWH ::




Custom Search