Search in sources :

Example 6 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 7 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();
                    return;
                }
            }
        };
    }
    for (int x = 0; x < threads.length; x++) {
        threads[x].start();
    }
    for (int x = 0; x < threads.length; x++) {
        threads[x].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());
    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)

Aggregations

ReceiverBase (org.apache.catalina.tribes.transport.ReceiverBase)7 Member (org.apache.catalina.tribes.Member)4 Test (org.junit.Test)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 GroupChannel (org.apache.catalina.tribes.group.GroupChannel)3 MessageDispatchInterceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor)3 ThroughputInterceptor (org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor)3 ChannelListener (org.apache.catalina.tribes.ChannelListener)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ManagedChannel (org.apache.catalina.tribes.ManagedChannel)1 DomainFilterInterceptor (org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor)1 FragmentationInterceptor (org.apache.catalina.tribes.group.interceptors.FragmentationInterceptor)1 GzipInterceptor (org.apache.catalina.tribes.group.interceptors.GzipInterceptor)1 OrderInterceptor (org.apache.catalina.tribes.group.interceptors.OrderInterceptor)1 StaticMembershipInterceptor (org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor)1 TcpFailureDetector (org.apache.catalina.tribes.group.interceptors.TcpFailureDetector)1 McastService (org.apache.catalina.tribes.membership.McastService)1 MemberImpl (org.apache.catalina.tribes.membership.MemberImpl)1