Methods Summary |
---|
public static void | main(java.lang.String[] args)
TestSuite suite = new TestSuite();
suite.addTestSuite(TestNonBlockingCoordinator.class);
suite.run(new TestResult());
|
protected void | setUp()
System.out.println("Setup");
super.setUp();
channels = new GroupChannel[channelCount];
coordinators = new NonBlockingCoordinator[channelCount];
threads = new Thread[channelCount];
for ( int i=0; i<channelCount; i++ ) {
channels[i] = new GroupChannel();
coordinators[i] = new NonBlockingCoordinator();
channels[i].addInterceptor(coordinators[i]);
channels[i].addInterceptor(new TcpFailureDetector());
final int j = i;
threads[i] = new Thread() {
public void run() {
try {
channels[j].start(Channel.DEFAULT);
Thread.sleep(50);
} catch (Exception x) {
x.printStackTrace();
}
}
};
}
for ( int i=0; i<channelCount; i++ ) threads[i].start();
for ( int i=0; i<channelCount; i++ ) threads[i].join();
Thread.sleep(1000);
|
protected void | tearDown()
System.out.println("tearDown");
super.tearDown();
for ( int i=0; i<channelCount; i++ ) {
channels[i].stop(Channel.DEFAULT);
}
|
public void | testCoord1()
for (int i=1; i<channelCount; i++ )
assertEquals("Message count expected to be equal.",channels[i-1].getMembers().length,channels[i].getMembers().length);
Member member = coordinators[0].getCoordinator();
int cnt = 0;
while ( member == null && (cnt++ < 100 ) ) try {Thread.sleep(100); member = coordinators[0].getCoordinator();}catch ( Exception x){}
for (int i=0; i<channelCount; i++ ) super.assertEquals(member,coordinators[i].getCoordinator());
System.out.println("Coordinator[1] is:"+member);
|
public void | testCoord2()
Member member = coordinators[1].getCoordinator();
System.out.println("Coordinator[2a] is:" + member);
int index = -1;
for ( int i=0; i<channelCount; i++ ) {
if ( channels[i].getLocalMember(false).equals(member) ) {
System.out.println("Shutting down:" + channels[i].getLocalMember(true).toString());
channels[i].stop(Channel.DEFAULT);
index = i;
}
}
int dead = index;
Thread.sleep(1000);
if ( index == 0 ) index = 1; else index = 0;
System.out.println("Member count:"+channels[index].getMembers().length);
member = coordinators[index].getCoordinator();
for (int i = 1; i < channelCount; i++) if ( i != dead ) super.assertEquals(member, coordinators[i].getCoordinator());
System.out.println("Coordinator[2b] is:" + member);
|