Search in sources :

Example 66 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class GossipRouterTest method createTunnelChannel.

protected JChannel createTunnelChannel(String name, boolean include_failure_detection) throws Exception {
    TUNNEL tunnel = new TUNNEL().setValue("bind_addr", bind_addr).setValue("reconnect_interval", 1000);
    tunnel.setGossipRouterHosts(gossip_router_hosts);
    List<Protocol> protocols = new ArrayList<>();
    protocols.addAll(Arrays.asList(tunnel, new PING(), new MERGE3().setValue("min_interval", 1000).setValue("max_interval", 3000)));
    if (include_failure_detection) {
        List<Protocol> tmp = new ArrayList<>(2);
        tmp.add(new FD().setValue("timeout", 2000).setValue("max_tries", 2));
        tmp.add(new VERIFY_SUSPECT());
        protocols.addAll(tmp);
    }
    protocols.addAll(Arrays.asList(new NAKACK2().setValue("use_mcast_xmit", false), new UNICAST3(), new STABLE(), new GMS().joinTimeout(10)));
    JChannel ch = new JChannel(protocols);
    if (name != null)
        ch.setName(name);
    return ch;
}
Also used : JChannel(org.jgroups.JChannel) ArrayList(java.util.ArrayList) GMS(org.jgroups.protocols.pbcast.GMS) NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) STABLE(org.jgroups.protocols.pbcast.STABLE) Protocol(org.jgroups.stack.Protocol)

Example 67 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class LargeStateTransferTest method setThreadPoolSize.

private static void setThreadPoolSize(JChannel... channels) {
    for (JChannel channel : channels) {
        TP transport = channel.getProtocolStack().getTransport();
        transport.setThreadPoolMinThreads(2);
        transport.setThreadPoolMaxThreads(8);
    }
}
Also used : JChannel(org.jgroups.JChannel) TP(org.jgroups.protocols.TP)

Example 68 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class INJECT_VIEWTest method testInjectView.

public static void testInjectView() throws Exception {
    JChannel[] channels = null;
    try {
        channels = create(false, true, "testInjectView", "A", "B", "C");
        print(channels);
        View view = channels[channels.length - 1].getView();
        assert view.size() == channels.length : "view is " + view;
        String injectionViewString = "A=A/B;B=B/C;C=C";
        System.out.println("\ninjecting views: " + injectionViewString);
        for (JChannel channel : channels) {
            channel.getProtocolStack().addProtocol(new INJECT_VIEW());
        }
        for (JChannel channel : channels) {
            INJECT_VIEW iv = channel.getProtocolStack().findProtocol(INJECT_VIEW.class);
            iv.injectView(injectionViewString);
        }
        System.out.println("\nInjected views: " + injectionViewString);
        print(channels);
        System.out.println("\nchecking views: ");
        checkViews(channels, "A", "A", "B");
        System.out.println("\nA is OK");
        checkViews(channels, "B", "B", "C");
        System.out.println("\nB is OK");
        checkViews(channels, "C", "C");
        System.out.println("\nC is OK");
        System.out.println("\ndigests:");
        printDigests(channels);
        Address leader = determineLeader(channels, "A", "B", "C");
        long end_time = System.currentTimeMillis() + 30000;
        do {
            System.out.println("\n==== injecting merge events into " + leader + " ====");
            injectMergeEvent(channels, leader, "A", "B", "C");
            Util.sleep(1000);
            if (allChannelsHaveViewOf(channels, channels.length))
                break;
        } while (end_time > System.currentTimeMillis());
        System.out.println("\n");
        print(channels);
        assertAllChannelsHaveViewOf(channels, channels.length);
        System.out.println("\ndigests:");
        printDigests(channels);
    } finally {
        System.out.println("closing channels");
        close(channels);
        System.out.println("done");
    }
}
Also used : JChannel(org.jgroups.JChannel) Address(org.jgroups.Address) View(org.jgroups.View)

Example 69 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class INJECT_VIEWTest method create.

private static JChannel[] create(boolean use_flush_props, boolean simple_ids, String cluster_name, String... names) throws Exception {
    JChannel[] retval = new JChannel[names.length];
    for (int i = 0; i < retval.length; i++) {
        JChannel ch;
        Protocol[] props = use_flush_props ? getFlushProps() : getProps();
        if (simple_ids) {
            ch = new MyChannel(props);
            ((MyChannel) ch).setId(i + 1);
        } else
            ch = new JChannel(props);
        ch.setName(names[i]);
        retval[i] = ch;
        ch.connect(cluster_name);
        if (i == 0)
            Util.sleep(3000);
    }
    return retval;
}
Also used : JChannel(org.jgroups.JChannel) Protocol(org.jgroups.stack.Protocol)

Example 70 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class SUPERVISOR_Test method assertFailureDetectorRunning.

protected void assertFailureDetectorRunning(JChannel... channels) {
    for (JChannel ch : channels) {
        System.out.print("Checking " + ch.getName() + ": ");
        FD fd = (FD) ch.getProtocolStack().findProtocol(FD.class);
        assert fd.isMonitorRunning();
        System.out.println("running");
    }
}
Also used : JChannel(org.jgroups.JChannel)

Aggregations

JChannel (org.jgroups.JChannel)119 GMS (org.jgroups.protocols.pbcast.GMS)22 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)21 Protocol (org.jgroups.stack.Protocol)18 STABLE (org.jgroups.protocols.pbcast.STABLE)15 View (org.jgroups.View)14 Message (org.jgroups.Message)10 ArrayList (java.util.ArrayList)9 Address (org.jgroups.Address)7 IOException (java.io.IOException)6 Test (org.testng.annotations.Test)5 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)4 LockService (org.jgroups.blocks.locking.LockService)4 Test (org.junit.Test)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)3