Search in sources :

Example 11 with GroupChannel

use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.

the class TestDomainFilterInterceptor method setUp.

@Before
public void setUp() throws Exception {
    for (int i = 0; i < channels.length; i++) {
        channels[i] = new GroupChannel();
        channels[i].getMembershipService().setPayload(("Channel-" + (i + 1)).getBytes("ASCII"));
        listeners[i] = new TestMbrListener(("Listener-" + (i + 1)));
        channels[i].addMembershipListener(listeners[i]);
        DomainFilterInterceptor filter = new DomainFilterInterceptor();
        filter.setDomain(UUIDGenerator.randomUUID(false));
        channels[i].addInterceptor(filter);
    }
}
Also used : GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Before(org.junit.Before)

Example 12 with GroupChannel

use of org.apache.catalina.tribes.group.GroupChannel in project tomcat by apache.

the class TestTcpFailureDetector method setUp.

@Before
public void setUp() throws Exception {
    channel1 = new GroupChannel();
    channel2 = new GroupChannel();
    ((ReceiverBase) channel1.getChannelReceiver()).setHost("localhost");
    ((ReceiverBase) channel2.getChannelReceiver()).setHost("localhost");
    channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
    channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
    mbrlist1 = new TestMbrListener("Channel-1");
    mbrlist2 = new TestMbrListener("Channel-2");
    tcpFailureDetector1 = new TcpFailureDetector();
    tcpFailureDetector2 = new TcpFailureDetector();
    channel1.addInterceptor(tcpFailureDetector1);
    channel2.addInterceptor(tcpFailureDetector2);
    channel1.addMembershipListener(mbrlist1);
    channel2.addMembershipListener(mbrlist2);
    TesterUtil.addRandomDomain(new ManagedChannel[] { channel1, channel2 });
}
Also used : ReceiverBase(org.apache.catalina.tribes.transport.ReceiverBase) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Before(org.junit.Before)

Example 13 with GroupChannel

use of org.apache.catalina.tribes.group.GroupChannel in project tomcat70 by apache.

the class NioReceiver method start.

/**
 * start cluster receiver
 * @throws IOException
 * @see org.apache.catalina.tribes.ChannelReceiver#start()
 */
@Override
public void start() throws IOException {
    super.start();
    try {
        setPool(new RxTaskPool(getMaxThreads(), getMinThreads(), this));
    } catch (Exception x) {
        log.fatal("ThreadPool can initilzed. Listener not started", x);
        if (x instanceof IOException)
            throw (IOException) x;
        else
            throw new IOException(x.getMessage());
    }
    try {
        getBind();
        bind();
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel) getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel) getChannel()).getName() + "]";
        }
        Thread t = new Thread(this, "NioReceiver" + channelName);
        t.setDaemon(true);
        t.start();
    } catch (Exception x) {
        log.fatal("Unable to start cluster receiver", x);
        if (x instanceof IOException)
            throw (IOException) x;
        else
            throw new IOException(x.getMessage());
    }
}
Also used : GroupChannel(org.apache.catalina.tribes.group.GroupChannel) RxTaskPool(org.apache.catalina.tribes.transport.RxTaskPool) IOException(java.io.IOException) CancelledKeyException(java.nio.channels.CancelledKeyException) IOException(java.io.IOException) ClosedSelectorException(java.nio.channels.ClosedSelectorException)

Example 14 with GroupChannel

use of org.apache.catalina.tribes.group.GroupChannel in project tomcat70 by apache.

the class TcpPingInterceptor method start.

@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if (thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel) getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel) getChannel()).getName() + "]";
        }
        thread.setName("TcpPingInterceptor.PingThread" + channelName + "-" + cnt.addAndGet(1));
        thread.start();
    }
    // acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while (next != null) {
        if (next instanceof TcpFailureDetector)
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector) next);
        if (next instanceof StaticMembershipInterceptor)
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor) next);
        next = next.getNext();
    }
}
Also used : GroupChannel(org.apache.catalina.tribes.group.GroupChannel) ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor) WeakReference(java.lang.ref.WeakReference)

Example 15 with GroupChannel

use of org.apache.catalina.tribes.group.GroupChannel in project tomcat70 by apache.

the class BioReceiver method start.

@Override
public void start() throws IOException {
    super.start();
    try {
        setPool(new RxTaskPool(getMaxThreads(), getMinThreads(), this));
    } catch (Exception x) {
        log.fatal("ThreadPool can initilzed. Listener not started", x);
        if (x instanceof IOException)
            throw (IOException) x;
        else
            throw new IOException(x.getMessage());
    }
    try {
        getBind();
        bind();
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel) getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel) getChannel()).getName() + "]";
        }
        Thread t = new Thread(this, "BioReceiver" + channelName);
        t.setDaemon(true);
        t.start();
    } catch (Exception x) {
        log.fatal("Unable to start cluster receiver", x);
        if (x instanceof IOException)
            throw (IOException) x;
        else
            throw new IOException(x.getMessage());
    }
}
Also used : GroupChannel(org.apache.catalina.tribes.group.GroupChannel) RxTaskPool(org.apache.catalina.tribes.transport.RxTaskPool) IOException(java.io.IOException) IOException(java.io.IOException)

Aggregations

GroupChannel (org.apache.catalina.tribes.group.GroupChannel)28 Before (org.junit.Before)16 ReceiverBase (org.apache.catalina.tribes.transport.ReceiverBase)9 ChannelListener (org.apache.catalina.tribes.ChannelListener)8 MessageDispatchInterceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor)8 TcpFailureDetector (org.apache.catalina.tribes.group.interceptors.TcpFailureDetector)6 ThroughputInterceptor (org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor)6 MessageDispatch15Interceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor)5 McastService (org.apache.catalina.tribes.membership.McastService)5 ClusterSessionListener (org.apache.catalina.ha.session.ClusterSessionListener)4 JvmRouteBinderValve (org.apache.catalina.ha.session.JvmRouteBinderValve)4 SimpleTcpCluster (org.apache.catalina.ha.tcp.SimpleTcpCluster)4 Member (org.apache.catalina.tribes.Member)4 StaticMembershipInterceptor (org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor)4 ReplicationTransmitter (org.apache.catalina.tribes.transport.ReplicationTransmitter)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 lombok.val (lombok.val)2 DeltaManager (org.apache.catalina.ha.session.DeltaManager)2