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);
}
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;
}
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;
}
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");
}
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);
}
Aggregations