public MultiplexerStressTest() {
}
private void start() throws Exception {
CyclicBarrier barrier=new CyclicBarrier(7);
f1=new JChannelFactory();
f2=new JChannelFactory();
f3=new JChannelFactory();
f1.setMultiplexerConfig("stacks.xml");
f2.setMultiplexerConfig("stacks.xml");
f3.setMultiplexerConfig("stacks.xml");
c11=f1.createMultiplexerChannel("udp", "A");
c11.connect("X");
r11=new MyReceiver(barrier);
c11.setReceiver(r11);
c12=f1.createMultiplexerChannel("udp", "B");
c12.connect("X");
r12=new MyReceiver(barrier);
c12.setReceiver(r12);
c21=f2.createMultiplexerChannel("udp", "A");
c21.connect("X");
r21=new MyReceiver(barrier);
c21.setReceiver(r21);
c22=f2.createMultiplexerChannel("udp", "B");
c22.connect("X");
r22=new MyReceiver(barrier);
c22.setReceiver(r22);
c31=f3.createMultiplexerChannel("udp", "A");
c31.connect("X");
r31=new MyReceiver(barrier);
c31.setReceiver(r31);
c32=f3.createMultiplexerChannel("udp", "B");
c32.connect("X");
r32=new MyReceiver(barrier);
c32.setReceiver(r32);
long start, stop;
new MySender(barrier, c11).start();
new MySender(barrier, c12).start();
new MySender(barrier, c21).start();
new MySender(barrier, c22).start();
new MySender(barrier, c31).start();
new MySender(barrier, c32).start();
barrier.await(); // start the 6 sender threads
start=System.currentTimeMillis();
barrier.await(); // results from the 6 receivers
stop=System.currentTimeMillis();
System.out.println("Cluster A:\n" + printStats(stop-start,new MyReceiver[]{r11,r21,r31}));
System.out.println("Cluster B:\n" + printStats(stop-start,new MyReceiver[]{r12,r22,r32}));