Search in sources :

Example 51 with JChannel

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

the class TCPGOSSIP_Test method createTcpgossipChannel.

protected JChannel createTcpgossipChannel(String name) throws Exception {
    TCPGOSSIP gossip = new TCPGOSSIP();
    List<InetSocketAddress> initial_hosts = new ArrayList<>();
    initial_hosts.add(new InetSocketAddress(bind_addr, gossip_router_port));
    gossip.setInitialHosts(initial_hosts);
    JChannel ch = new JChannel(new TCP().setSockConnTimeout(300).setBindAddress(bind_addr), gossip, new MERGE3().setMinInterval(1000).setMaxInterval(3000), new FD_ALL3().setTimeout(5000).setInterval(1500), new VERIFY_SUSPECT(), new NAKACK2().useMcastXmit(false), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(1000));
    if (name != null)
        ch.setName(name);
    return ch;
}
Also used : JChannel(org.jgroups.JChannel) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) GMS(org.jgroups.protocols.pbcast.GMS) NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) STABLE(org.jgroups.protocols.pbcast.STABLE)

Example 52 with JChannel

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

the class TCPGOSSIP_Test method testConnectThreeChannelsWithGRAlreadyDown.

public void testConnectThreeChannelsWithGRAlreadyDown() throws Exception {
    JChannel third = null;
    try {
        coordinator = createTcpgossipChannel("A");
        channel = createTcpgossipChannel("B");
        // kill router
        gossipRouter.stop();
        // cannot discover others since GR is down
        coordinator.connect("testConnectThreeChannelsWithGRAlreadyDown");
        channel.connect("testConnectThreeChannelsWithGRAlreadyDown");
        third = createTcpgossipChannel("C");
        third.connect("testConnectThreeChannelsWithGRAlreadyDown");
        // restart and....
        gossipRouter.start();
        Util.waitUntilAllChannelsHaveSameView(60000, 1000, coordinator, channel, third);
        // confirm they found each other
        View view = channel.getView();
        assert channel.getView().size() == 3;
        assert third.getView().size() == 3;
        assert view.containsMember(channel.getAddress());
        assert view.containsMember(coordinator.getAddress());
    } finally {
        Util.close(third);
    }
}
Also used : JChannel(org.jgroups.JChannel) View(org.jgroups.View)

Example 53 with JChannel

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

the class InfinispanStackMerge3Test method main.

public static void main(String[] args) throws Exception {
    Map<String, List<Long>> results = new HashMap<>();
    for (Supplier<TP> transport : TRANSPORTS) {
        results.put(transport.get().getClass().getSimpleName(), new LinkedList<>());
        for (int run = 0; run < RUNS; run++) {
            JChannel[] channels = new JChannel[MEMBERS];
            // Setup
            for (int member = 0; member < MEMBERS; member++) channels[member] = createChannel(transport.get(), String.valueOf(member + 1));
            Util.waitUntilAllChannelsHaveSameView(10_000, 500, channels);
            System.out.printf("-- run #%d: cluster formed:\n%s\n", run + 1, printViews(channels));
            // Partition
            Stream.of(channels).forEach(channel -> {
                GMS gms = channel.getProtocolStack().findProtocol(GMS.class);
                View view = View.create(channel.getAddress(), gms.getViewId().getId() + 1, channel.getAddress());
                gms.installView(view);
            });
            System.out.printf("-- injected partition (waiting for merge):\n%s\n", printViews(channels));
            // Merge
            long timeBeforeMerge = System.currentTimeMillis();
            Util.waitUntilAllChannelsHaveSameView(360_000, 100, channels);
            long timeAfterMerge = System.currentTimeMillis();
            System.out.printf("-- run #%d: %s cluster merged in %d ms:\n%s\n", run + 1, transport.get().getClass().getSimpleName(), timeAfterMerge - timeBeforeMerge, printViews(channels));
            // Cleanup
            Stream.of(channels).forEach(JChannel::close);
            results.get(transport.get().getClass().getSimpleName()).add(timeAfterMerge - timeBeforeMerge);
        }
    }
    printStats(results);
}
Also used : JChannel(org.jgroups.JChannel) GMS(org.jgroups.protocols.pbcast.GMS) View(org.jgroups.View)

Example 54 with JChannel

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

the class RemoteGetStressTest method createChannel.

protected static JChannel createChannel(String name) throws Exception {
    SHARED_LOOPBACK sl = new SHARED_LOOPBACK();
    sl.getThreadPool().setMinThreads(1).setMaxThreads(5);
    Protocol[] protocols = { sl, new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS(), new UFC(), new MFC().setMaxCredits(2000000).setMinThreshold(0.4), new FRAG2().setFragSize(8000) };
    return new JChannel(protocols).name(name);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) STABLE(org.jgroups.protocols.pbcast.STABLE) Protocol(org.jgroups.stack.Protocol) GMS(org.jgroups.protocols.pbcast.GMS)

Example 55 with JChannel

use of org.jgroups.JChannel in project wildfly by wildfly.

the class RelayConfigurationBuilder method accept.

@Override
public void accept(RELAY2 protocol) {
    String localSite = this.siteName;
    List<RemoteSiteConfiguration> remoteSites = this.getRemoteSites();
    List<String> sites = new ArrayList<>(remoteSites.size() + 1);
    sites.add(localSite);
    // Collect bridges, eliminating duplicates
    Map<String, RelayConfig.BridgeConfig> bridges = new HashMap<>();
    for (final RemoteSiteConfiguration remoteSite : remoteSites) {
        String siteName = remoteSite.getName();
        sites.add(siteName);
        String clusterName = remoteSite.getClusterName();
        RelayConfig.BridgeConfig bridge = new RelayConfig.BridgeConfig(clusterName) {

            @Override
            public JChannel createChannel() throws Exception {
                JChannel channel = (JChannel) remoteSite.getChannelFactory().createChannel(siteName);
                // Don't use FORK in bridge stack
                channel.getProtocolStack().removeProtocol(FORK.class);
                return channel;
            }
        };
        bridges.put(clusterName, bridge);
    }
    protocol.site(localSite);
    for (String site : sites) {
        RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
        protocol.addSite(site, siteConfig);
        if (site.equals(localSite)) {
            for (RelayConfig.BridgeConfig bridge : bridges.values()) {
                siteConfig.addBridge(bridge);
            }
        }
    }
}
Also used : JChannel(org.jgroups.JChannel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelayConfig(org.jgroups.protocols.relay.config.RelayConfig) RemoteSiteConfiguration(org.wildfly.clustering.jgroups.spi.RemoteSiteConfiguration)

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