Search in sources :

Example 46 with JChannel

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

the class SYM_ENCRYPT_Test method create.

@Override
protected JChannel create(String name, Consumer<List<Protocol>> c) throws Exception {
    // Verify that the SecureRandom instance can be customized
    SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
    SYM_ENCRYPT encr;
    try {
        encr = new SYM_ENCRYPT().keystoreName("keystore/defaultStore.keystore").alias("myKey").storePassword(DEF_PWD).symAlgorithm(symAlgorithm()).symIvLength(symIvLength()).secureRandom(secureRandom);
    } catch (Throwable t) {
        encr = new SYM_ENCRYPT().keystoreName("defaultStore.keystore").alias("myKey").storePassword(DEF_PWD).symAlgorithm(symAlgorithm()).symIvLength(symIvLength()).secureRandom(secureRandom);
    }
    return new JChannel(new SHARED_LOOPBACK(), new SHARED_LOOPBACK_PING(), // omit MERGE3 from the stack -- nodes are leaving gracefully
    encr, new NAKACK2().useMcastXmit(false), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(2000)).name(name);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) SecureRandom(java.security.SecureRandom) STABLE(org.jgroups.protocols.pbcast.STABLE) GMS(org.jgroups.protocols.pbcast.GMS)

Example 47 with JChannel

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

the class BaseLeaveTest method testLeaveOfSingletonCoord.

/**
 * A single member (coord) leaves
 */
public void testLeaveOfSingletonCoord() throws Exception {
    setup(1);
    JChannel ch = channels[0];
    assert ch.getView().size() == 1;
    Util.close(ch);
    assert ch.getView() == null;
}
Also used : JChannel(org.jgroups.JChannel)

Example 48 with JChannel

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

the class ChannelTestBase method createChannel.

protected JChannel createChannel() throws Exception {
    JChannel ch = new JChannel(channel_conf);
    ch.getProtocolStack().getTransport().setBindAddress(bind_addr);
    return ch;
}
Also used : JChannel(org.jgroups.JChannel)

Example 49 with JChannel

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

the class ChannelTestBase method makeUnique.

protected void makeUnique(JChannel... channels) throws Exception {
    String mcast_addr = Util.getProperty(new String[] { Global.UDP_MCAST_ADDR, "jboss.partition.udpGroup" }, null, "mcast_addr", null);
    boolean is_udp = Stream.of(channels).anyMatch(ch -> ch.getProtocolStack().getTransport() instanceof UDP), is_tcp = Stream.of(channels).anyMatch(ch -> ch.getProtocolStack().getTransport() instanceof BasicTCP);
    if (is_udp) {
        InetAddress mcast = mcast_addr != null ? InetAddress.getByName(mcast_addr) : InetAddress.getByName(ResourceManager.getNextMulticastAddress());
        int mcast_port = ResourceManager.getNextMulticastPort(bind_addr);
        for (JChannel ch : channels) {
            UDP udp = (UDP) ch.getProtocolStack().getTransport();
            udp.setBindAddress(bind_addr);
            udp.setMulticastAddress(mcast).setMulticastPort(mcast_port);
        }
    } else if (is_tcp) {
        List<Integer> ports = ResourceManager.getNextTcpPorts(bind_addr, channels.length);
        Collection<InetSocketAddress> hosts = ports.stream().map(p -> new InetSocketAddress(bind_addr, p)).collect(Collectors.toList());
        for (int i = 0; i < channels.length; i++) {
            ProtocolStack stack = channels[i].getProtocolStack();
            TP tp = stack.getTransport();
            tp.setBindPort(ports.get(i));
            TCPPING ping = stack.findProtocol(TCPPING.class);
            if (ping == null)
                throw new IllegalStateException("TCP stack must consist of TCP:TCPPING - other configs are not supported");
            ping.setInitialHosts(hosts);
        }
    } else
        throw new IllegalStateException("Only UDP and TCP are supported as transport protocols");
}
Also used : UDP(org.jgroups.protocols.UDP) JChannel(org.jgroups.JChannel) InetSocketAddress(java.net.InetSocketAddress) BasicTCP(org.jgroups.protocols.BasicTCP) ProtocolStack(org.jgroups.stack.ProtocolStack) Collection(java.util.Collection) List(java.util.List) TP(org.jgroups.protocols.TP) InetAddress(java.net.InetAddress) TCPPING(org.jgroups.protocols.TCPPING)

Example 50 with JChannel

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

the class RpcDispatcherAnycastMultipleCallsTest method init.

@BeforeClass
void init() throws Exception {
    targets = new RpcDispatcherAnycastServerObject[NUM];
    final String GROUP = "RpcDispatcherAnycastMultipleCallsTest";
    JChannel first_channel = null;
    for (int i = 0; i < NUM; i++) {
        JChannel c = createChannel();
        if (first_channel == null)
            first_channel = c;
        targets[i] = new RpcDispatcherAnycastServerObject(c);
    }
    List<JChannel> channels = Stream.of(targets).map(RpcDispatcherAnycastServerObject::getChannel).collect(Collectors.toList());
    makeUnique(channels);
    for (JChannel ch : channels) ch.connect(GROUP);
}
Also used : JChannel(org.jgroups.JChannel) BeforeClass(org.testng.annotations.BeforeClass)

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