use of org.apache.catalina.tribes.transport.ReceiverBase in project tomcat by apache.
the class TestMulticastPackages method setUp.
@Before
public void setUp() throws Exception {
channel1 = new GroupChannel();
channel1.addInterceptor(new MessageDispatchInterceptor());
channel2 = new GroupChannel();
channel2.addInterceptor(new MessageDispatchInterceptor());
ThroughputInterceptor tint = new ThroughputInterceptor();
tint.setInterval(500);
ThroughputInterceptor tint2 = new ThroughputInterceptor();
tint2.setInterval(500);
// channel1.addInterceptor(tint);
channel2.addInterceptor(tint2);
listener1 = new Listener();
ReceiverBase rb1 = (ReceiverBase) channel1.getChannelReceiver();
ReceiverBase rb2 = (ReceiverBase) channel2.getChannelReceiver();
rb1.setUdpPort(50000);
rb2.setUdpPort(50000);
channel2.addChannelListener(listener1);
TesterUtil.addRandomDomain(new ManagedChannel[] { channel1, channel2 });
channel1.start(Channel.DEFAULT);
channel2.start(Channel.DEFAULT);
}
use of org.apache.catalina.tribes.transport.ReceiverBase in project tomcat by apache.
the class TestUdpPackages method testDataSendNO_ACK.
@Test
public void testDataSendNO_ACK() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
ReceiverBase rb1 = (ReceiverBase) channel1.getChannelReceiver();
ReceiverBase rb2 = (ReceiverBase) channel2.getChannelReceiver();
rb1.setUdpRxBufSize(1024 * 1024 * 10);
rb2.setUdpRxBufSize(1024 * 1024 * 10);
rb1.setUdpTxBufSize(1024 * 1024 * 10);
rb2.setUdpTxBufSize(1024 * 1024 * 10);
System.err.println("Starting NO_ACK");
Thread[] threads = new Thread[threadCount];
for (int x = 0; x < threads.length; x++) {
threads[x] = new Thread() {
@Override
public void run() {
try {
long start = System.currentTimeMillis();
for (int i = 0; i < msgCount; i++) {
int cnt = counter.getAndAdd(1);
channel1.send(new Member[] { channel2.getLocalMember(false) }, Data.createRandomData(1024, cnt), Channel.SEND_OPTIONS_UDP);
// Thread.currentThread().sleep(10);
}
System.out.println("Thread[" + this.getName() + "] sent " + msgCount + " messages in " + (System.currentTimeMillis() - start) + " ms.");
} catch (Exception x) {
x.printStackTrace();
}
}
};
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
// sleep for 50 sec, let the other messages in
long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < 25000 && msgCount * threadCount != listener1.count.get()) {
Thread.sleep(500);
}
System.err.println("Finished NO_ACK [" + listener1.count + "]");
System.out.println("Sent " + counter.get() + " messages. Received " + listener1.count + " Highest msg received:" + listener1.maxIdx);
System.out.print("Missing messages:");
printMissingMsgs(listener1.nrs, counter.get());
Assert.assertEquals("Checking success messages.", msgCount * threadCount, listener1.count.get());
}
use of org.apache.catalina.tribes.transport.ReceiverBase in project tomcat by apache.
the class TestUdpPackages method setUp.
@Before
public void setUp() throws Exception {
channel1 = new GroupChannel();
channel1.addInterceptor(new MessageDispatchInterceptor());
channel2 = new GroupChannel();
channel2.addInterceptor(new MessageDispatchInterceptor());
ThroughputInterceptor tint = new ThroughputInterceptor();
tint.setInterval(500);
ThroughputInterceptor tint2 = new ThroughputInterceptor();
tint2.setInterval(500);
// channel1.addInterceptor(tint);
channel2.addInterceptor(tint2);
listener1 = new Listener();
ReceiverBase rb1 = (ReceiverBase) channel1.getChannelReceiver();
ReceiverBase rb2 = (ReceiverBase) channel2.getChannelReceiver();
rb1.setUdpPort(50000);
rb2.setUdpPort(50000);
channel2.addChannelListener(listener1);
TesterUtil.addRandomDomain(new ManagedChannel[] { channel1, channel2 });
channel1.start(Channel.DEFAULT);
channel2.start(Channel.DEFAULT);
}
use of org.apache.catalina.tribes.transport.ReceiverBase in project tomcat by apache.
the class TestOrderInterceptor method setUp.
@Before
public void setUp() throws Exception {
System.out.println("Setup");
channels = new GroupChannel[channelCount];
orderitcs = new OrderInterceptor[channelCount];
mangleitcs = new MangleOrderInterceptor[channelCount];
test = new TestListener[channelCount];
threads = new Thread[channelCount];
for (int i = 0; i < channelCount; i++) {
channels[i] = new GroupChannel();
((ReceiverBase) channels[i].getChannelReceiver()).setHost("localhost");
orderitcs[i] = new OrderInterceptor();
mangleitcs[i] = new MangleOrderInterceptor();
orderitcs[i].setExpire(Long.MAX_VALUE);
channels[i].addInterceptor(orderitcs[i]);
channels[i].addInterceptor(mangleitcs[i]);
test[i] = new TestListener(i);
channels[i].addChannelListener(test[i]);
final int j = i;
threads[i] = new Thread() {
@Override
public void run() {
try {
channels[j].start(Channel.DEFAULT);
Thread.sleep(50);
} catch (Exception x) {
x.printStackTrace();
}
}
};
}
TesterUtil.addRandomDomain(channels);
for (int i = 0; i < channelCount; i++) {
threads[i].start();
}
int totalSleep = 0;
for (int i = 0; i < channelCount; i++) {
Member[] m = channels[i].getMembers();
while (m == null || m.length < channelCount - 1) {
totalSleep += 50;
if (totalSleep > 60000) {
Assert.fail("Cluster took more than 60s to start");
}
Thread.sleep(50);
m = channels[i].getMembers();
}
}
}
use of org.apache.catalina.tribes.transport.ReceiverBase in project tomcat by apache.
the class TestStandardSessionIntegration method doTestInvalidate.
private void doTestInvalidate(boolean useClustering) throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Tomcat.addServlet(ctx, "bug56578", new Bug56578Servlet());
ctx.addServletMappingDecoded("/bug56578", "bug56578");
if (useClustering) {
SimpleTcpCluster cluster = new SimpleTcpCluster();
((ReceiverBase) ((GroupChannel) cluster.getChannel()).getChannelReceiver()).setHost("localhost");
tomcat.getEngine().setCluster(cluster);
ctx.setDistributable(true);
ctx.setManager(ctx.getCluster().createManager(""));
}
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/bug56578");
Assert.assertEquals("PASS", res.toString());
}
Aggregations