* Construct and show the application.
*/
public CoordinationDemo() {
+ // Default constructor
}
public void init() {
status = "Start failed:"+x.getMessage();
error = x;
startstatus = "failed";
- try { channel.stop(GroupChannel.DEFAULT);}catch(Exception ignore){}
+ try { channel.stop(Channel.DEFAULT);}catch(Exception ignore){
+ // Ignore
+ }
channel = null;
interceptor = null;
}
int type = event.getEventType();
boolean display = VIEW_EVENTS[type];
if ( display ) parent.printScreen();
- try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){}
+ try { Thread.sleep(SLEEP_TIME); }catch ( Exception x){
+ // Ignore
+ }
}
};
channel.addInterceptor(interceptor);
for ( int i=0; i<resp.length; i++ ) {
System.out.println("Received a response message from ["+resp[i].getSource().getName()+"] with data ["+resp[i].getMessage()+"]");
}
- Thread.sleep(pause);
- }catch(Exception x){}
+ Thread.sleep(pause);
+ }catch(Exception x){
+ // Ignore
+ }
}
}
try {
result = new Integer(object);
} catch (NumberFormatException ex) {
+ // Ignore
}
// Try a setFoo ( boolean )
} else if ("java.lang.Boolean".equals(paramType.getName())
- //public static class LoadMessage implements Serializable {
- public static class LoadMessage extends ByteMessage implements Serializable {
+ public static class LoadMessage extends ByteMessage {
public static byte[] outdata = new byte[size];
public static Random r = new Random(System.currentTimeMillis());
protected byte[] message = getMessage();
public LoadMessage() {
+ // Default constructor
}
public byte[] getMessage() {
/**
* Invoked if accept returns true.
- * No of for now
+ * No op for now
* @param msg - the message received
* @param source - the sending member
*/
public void messageReceived(Serializable msg, Member source) {
+ // NOOP
}
/**
* Invoked when a member is added to the group
*/
public void memberAdded(Member member) {
+ // NOOP
}
/**
MemberImpl mbr;
private static int testOptions = Channel.SEND_OPTIONS_DEFAULT;
public TestNioSender() {
-
+ // Default constructor
}
public synchronized int inc() {
protected void tearDown() throws Exception {
super.tearDown();
- try {channel.stop(Channel.DEFAULT);}catch (Exception ignore){}
+ try {channel.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
}
public void testDoubleFullStart() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
- if ( channel != null ) try {channel.stop(Channel.DEFAULT);}catch ( Exception ignore) {}
+ if ( channel != null ) try {channel.stop(Channel.DEFAULT);}catch ( Exception ignore) { /* Ignore */ }
channel = null;
}
}
public static class TestInterceptor extends ChannelInterceptorBase {
-
+ // Just use base class
}
import java.io.Serializable;
import java.util.Random;
import java.util.Arrays;
+
+import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelListener;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.group.GroupChannel;
channel2.addInterceptor(new MessageDispatch15Interceptor());
listener1 = new Listener();
channel2.addChannelListener(listener1);
- channel1.start(GroupChannel.DEFAULT);
- channel2.start(GroupChannel.DEFAULT);
+ channel1.start(Channel.DEFAULT);
+ channel2.start(Channel.DEFAULT);
}
protected void tearDown() throws Exception {
super.tearDown();
- channel1.stop(GroupChannel.DEFAULT);
- channel2.stop(GroupChannel.DEFAULT);
+ channel1.stop(Channel.DEFAULT);
+ channel2.stop(Channel.DEFAULT);
}
public void testDataSendNO_ACK() throws Exception {
public void run() {
try {
long start = System.currentTimeMillis();
- for (int i = 0; i < msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(),GroupChannel.SEND_OPTIONS_ASYNCHRONOUS);
+ for (int i = 0; i < msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(),Channel.SEND_OPTIONS_ASYNCHRONOUS);
System.out.println("Thread["+this.getName()+"] sent "+msgCount+" messages in "+(System.currentTimeMillis()-start)+" ms.");
}catch ( Exception x ) {
x.printStackTrace();
}
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),GroupChannel.SEND_OPTIONS_ASYNCHRONOUS);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_ASYNCHRONOUS);
//sleep for 50 sec, let the other messages in
long start = System.currentTimeMillis();
while ( (System.currentTimeMillis()-start)<5000 && msgCount!=listener1.count) Thread.sleep(500);
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),GroupChannel.SEND_OPTIONS_USE_ACK);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_USE_ACK);
Thread.sleep(250);
System.err.println("Finished ACK");
assertEquals("Checking success messages.",msgCount,listener1.count);
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),GroupChannel.SEND_OPTIONS_SYNCHRONIZED_ACK|GroupChannel.SEND_OPTIONS_USE_ACK);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK);
Thread.sleep(250);
System.err.println("Finished SYNC_ACK");
assertEquals("Checking success messages.",msgCount,listener1.count);
rb1.setUdpPort(50000);
rb2.setUdpPort(50000);
channel2.addChannelListener(listener1);
- channel1.start(GroupChannel.DEFAULT);
- channel2.start(GroupChannel.DEFAULT);
+ channel1.start(Channel.DEFAULT);
+ channel2.start(Channel.DEFAULT);
}
protected void tearDown() throws Exception {
super.tearDown();
- channel1.stop(GroupChannel.DEFAULT);
- channel2.stop(GroupChannel.DEFAULT);
+ channel1.stop(Channel.DEFAULT);
+ channel2.stop(Channel.DEFAULT);
}
public void testSingleDataSendNO_ACK() throws Exception {
}
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_MULTICAST);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_MULTICAST);
//sleep for 50 sec, let the other messages in
long start = System.currentTimeMillis();
while ( (System.currentTimeMillis()-start)<5000 && msgCount!=listener1.count.get()) Thread.sleep(500);
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
Thread.sleep(250);
System.err.println("Finished ACK");
assertEquals("Checking success messages.",msgCount,listener1.count.get());
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_SYNCHRONIZED_ACK|GroupChannel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_MULTICAST);
Thread.sleep(250);
System.err.println("Finished SYNC_ACK");
assertEquals("Checking success messages.",msgCount,listener1.count.get());
import java.io.Serializable;
import java.util.Random;
import java.util.Arrays;
+
+import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelListener;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.group.GroupChannel;
channel2 = new GroupChannel();
listener1 = new Listener();
channel2.addChannelListener(listener1);
- channel1.start(GroupChannel.DEFAULT);
- channel2.start(GroupChannel.DEFAULT);
+ channel1.start(Channel.DEFAULT);
+ channel2.start(Channel.DEFAULT);
}
protected void tearDown() throws Exception {
super.tearDown();
- channel1.stop(GroupChannel.DEFAULT);
- channel2.stop(GroupChannel.DEFAULT);
+ channel1.stop(Channel.DEFAULT);
+ channel2.stop(Channel.DEFAULT);
}
public void testDataSendSYNCACK() throws Exception {
int errC=0, nerrC=0;
for (int i=0; i<msgCount; i++) {
boolean error = Data.r.nextBoolean();
- channel1.send(channel1.getMembers(),Data.createRandomData(error),GroupChannel.SEND_OPTIONS_SYNCHRONIZED_ACK|GroupChannel.SEND_OPTIONS_USE_ACK);
+ channel1.send(channel1.getMembers(),Data.createRandomData(error),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK);
if ( error ) errC++; else nerrC++;
}
System.err.println("Finished SYNC_ACK");
printStats(System.err);
}
throw new IllegalArgumentException();
- } else {
- noErrCnt++;
- if ( (noErrCnt % 100) == 0) {
- printStats(System.err);
- }
+ }
+ noErrCnt++;
+ if ( (noErrCnt % 100) == 0) {
+ printStats(System.err);
}
}
}
rb1.setUdpPort(50000);
rb2.setUdpPort(50000);
channel2.addChannelListener(listener1);
- channel1.start(GroupChannel.DEFAULT);
- channel2.start(GroupChannel.DEFAULT);
+ channel1.start(Channel.DEFAULT);
+ channel2.start(Channel.DEFAULT);
}
protected void tearDown() throws Exception {
super.tearDown();
- channel1.stop(GroupChannel.DEFAULT);
- channel2.stop(GroupChannel.DEFAULT);
+ channel1.stop(Channel.DEFAULT);
+ channel2.stop(Channel.DEFAULT);
}
public void testSingleDataSendNO_ACK() throws Exception {
}
public void testDataSendASYNC() throws Exception {
System.err.println("Starting ASYNC");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_UDP);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_ASYNCHRONOUS|Channel.SEND_OPTIONS_UDP);
//sleep for 50 sec, let the other messages in
long start = System.currentTimeMillis();
while ( (System.currentTimeMillis()-start)<5000 && msgCount!=listener1.count.get()) Thread.sleep(500);
public void testDataSendACK() throws Exception {
System.err.println("Starting ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
Thread.sleep(250);
System.err.println("Finished ACK");
assertEquals("Checking success messages.",msgCount,listener1.count.get());
public void testDataSendSYNCACK() throws Exception {
System.err.println("Starting SYNC_ACK");
- for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),GroupChannel.SEND_OPTIONS_SYNCHRONIZED_ACK|GroupChannel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
+ for (int i=0; i<msgCount; i++) channel1.send(new Member[] {channel2.getLocalMember(false)},Data.createRandomData(1024),Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK|Channel.SEND_OPTIONS_UDP);
Thread.sleep(250);
System.err.println("Finished SYNC_ACK");
assertEquals("Checking success messages.",msgCount,listener1.count.get());
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());
+ while ( member == null && (cnt++ < 100 ) ) try {Thread.sleep(100); member = coordinators[0].getCoordinator();}catch ( Exception x){ /* Ignore */ }
+ for (int i=0; i<channelCount; i++ ) assertEquals(member,coordinators[i].getCoordinator());
System.out.println("Coordinator[1] is:"+member);
}
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());
+ for (int i = 1; i < channelCount; i++) if ( i != dead ) assertEquals(member, coordinators[i].getCoordinator());
System.out.println("Coordinator[2b] is:" + member);
}
}
Thread.sleep(5000);
for ( int i=0; i<test.length; i++ ) {
- super.assertEquals(false,test[i].fail);
+ assertEquals(false,test[i].fail);
}
}
}
Thread.sleep(5000);
for ( int i=0; i<test.length; i++ ) {
- super.assertEquals(false,test[i].fail);
+ assertEquals(false,test[i].fail);
}
}
}
public void clear() {
+ // NOOP
}
public void sendMessages(long delay, long sleep) throws Exception {
for (int i = 0; i < channels.length; i++) {
try {
channels[i].stop(Channel.DEFAULT);
- } catch (Exception ignore) {}
+ } catch (Exception ignore) {
+ // Ignore
+ }
}
super.tearDown();
}
for (int i = 0; i < channels.length; i++) {
try {
channels[i].stop(Channel.DEFAULT);
- } catch (Exception ignore) {}
+ } catch (Exception ignore) {
+ // Ignore
+ }
}
super.tearDown();
}
channel1.send(channel1.getMembers(), msg, 0);
assertEquals("Message send should have failed.",true,false);
} catch ( ChannelException x ) {
-
+ // Ignore
}
assertEquals("Expecting member count to not be equal",mbrlist1.members.size()+1,mbrlist2.members.size());
channel1.stop(Channel.DEFAULT);
protected void tearDown() throws Exception {
tcpFailureDetector1 = null;
tcpFailureDetector2 = null;
- try { channel1.stop(Channel.DEFAULT);}catch (Exception ignore){}
+ try { channel1.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
channel1 = null;
- try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){}
+ try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
channel2 = null;
super.tearDown();
}
try {
Thread.sleep(1000);
printStats(start, mb, count, df, total);
- }catch ( Exception x ) {}
+ }catch ( Exception x ) {
+ // Ignore
+ }
}
}
};
public static void main(String[] args) throws Exception {
int size = 43800;
- if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){}
+ if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){ /* Ignore */ }
XByteBuffer xbuf = new XByteBuffer(43800,true);
ServerSocket srvSocket = new ServerSocket(9999);
System.out.println("Listening on 9999");
try {
Thread.sleep(1000);
printStats(start, mb, count, df, total);
- }catch ( Exception x ) {}
+ }catch ( Exception x ) { /* Ignore */ }
}
}
};
public static void main(String[] args) throws Exception {
int size = 43800;
- if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){}
+ if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){ /* Ignore */ }
ServerSocket srvSocket = new ServerSocket(9999);
System.out.println("Listening on 9999");
try {
Thread.sleep(1000);
printStats(start, mb, count, df, total);
- }catch ( Exception x ) {}
+ }catch ( Exception x ) { /* Ignore */ }
}
}
};