Search in sources :

Example 16 with ReceiverBase

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);
}
Also used : ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) ChannelListener(org.apache.catalina.tribes.ChannelListener) MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) ThroughputInterceptor(org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor) Before(org.junit.Before)

Example 17 with ReceiverBase

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());
}
Also used : ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Member(org.apache.catalina.tribes.Member) Test(org.junit.Test)

Example 18 with ReceiverBase

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);
}
Also used : ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) ChannelListener(org.apache.catalina.tribes.ChannelListener) MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) ThroughputInterceptor(org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor) Before(org.junit.Before)

Example 19 with ReceiverBase

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();
        }
    }
}
Also used : ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Member(org.apache.catalina.tribes.Member) ChannelException(org.apache.catalina.tribes.ChannelException) Before(org.junit.Before)

Example 20 with ReceiverBase

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());
}
Also used : Context(org.apache.catalina.Context) Tomcat(org.apache.catalina.startup.Tomcat) ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) ByteChunk(org.apache.tomcat.util.buf.ByteChunk)

Aggregations

ReceiverBase (org.apache.catalina.tribes.transport.ReceiverBase)20 Member (org.apache.catalina.tribes.Member)11 GroupChannel (org.apache.catalina.tribes.group.GroupChannel)9 Before (org.junit.Before)8 Test (org.junit.Test)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 ThroughputInterceptor (org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor)6 ChannelListener (org.apache.catalina.tribes.ChannelListener)4 MessageDispatchInterceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor)4 ManagedChannel (org.apache.catalina.tribes.ManagedChannel)3 MessageDispatch15Interceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor)3 McastService (org.apache.catalina.tribes.membership.McastService)3 ReplicationTransmitter (org.apache.catalina.tribes.transport.ReplicationTransmitter)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ChannelException (org.apache.catalina.tribes.ChannelException)2 DomainFilterInterceptor (org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor)2 FragmentationInterceptor (org.apache.catalina.tribes.group.interceptors.FragmentationInterceptor)2 GzipInterceptor (org.apache.catalina.tribes.group.interceptors.GzipInterceptor)2 OrderInterceptor (org.apache.catalina.tribes.group.interceptors.OrderInterceptor)2