use of org.jgroups.JChannel in project JGroups by belaban.
the class DNSDiscoveryTester method runTestAndCheckIfViewWasReceived.
public boolean runTestAndCheckIfViewWasReceived(String dnsQuery, String recordType) throws Exception {
List<JChannel> channels = new ArrayList<>();
CountDownLatch waitForViewToForm = new CountDownLatch(1);
for (int i = 0; i < numberOfTestedInstances; ++i) {
DNS_PING ping = new DNS_PING();
ping.dns_resolver = dnsResolverBuilder.build();
ping.dns_query = dnsQuery;
ping.dns_record_type = recordType;
ping.dns_address = "fake.com";
Protocol[] protocols = { new TCP().setBindAddress(InetAddress.getLoopbackAddress()).setBindPort(portStart).setPortRange(1), ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(timeout) };
JChannel c = new JChannel(protocols).name(String.valueOf(i + 1));
channels.add(c);
c.setReceiver(new Receiver() {
@Override
public void viewAccepted(View view) {
if (view.getMembers().size() == numberOfTestedInstances) {
waitForViewToForm.countDown();
}
}
});
c.connect("TEST");
}
boolean viewReceived = waitForViewToForm.await(timeout, unit);
channels.forEach(JChannel::close);
return viewReceived;
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class STABLE_Test method testStableWithDontLoopback.
public void testStableWithDontLoopback() throws Exception {
byte[] payload = new byte[5000];
for (int i = 0; i < 10; i++) {
Message msg = new BytesMessage(null, payload).setFlag(Message.TransientFlag.DONT_LOOPBACK);
b.send(msg);
// prevents batches, which trigger STABLE msgs in non-10000 increments
Util.sleep(200);
}
Util.waitUntil(5000, 500, () -> Stream.of(r1, r3).allMatch(r -> r.size() == 10));
assert r2.size() == 0;
Util.waitUntilTrue(5000, 500, () -> Stream.of(a, b, c).map(c -> ((NAKACK2) c.getProtocolStack().findProtocol(NAKACK2.class)).getWindow(b.getAddress())).allMatch(t -> t.getHighestReceived() == 10 && t.getHighestDelivered() == 10 && t.getLow() == 10));
for (JChannel ch : List.of(a, b, c)) {
NAKACK2 n = ch.getProtocolStack().findProtocol(NAKACK2.class);
Table<Message> t = n.getWindow(b.getAddress());
assert t.getHighestReceived() == 10 && t.getHighestDelivered() == 10 && t.getLow() == 10 : String.format("table for %s is %s (low is probably 0)", ch.getName(), t);
}
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class STABLE_Test method create.
protected static JChannel create(String name) throws Exception {
JChannel ch = new JChannel(Util.getTestStack()).name(name);
STABLE stable = ch.getProtocolStack().findProtocol(STABLE.class);
// disabled periodical stable
stable.setDesiredAverageGossip(0).setMaxBytes(10000);
ch.getProtocolStack().getTransport().getDiagnosticsHandler().setEnabled(true);
return ch;
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class TLSTest method create.
private JChannel create(String name) throws Exception {
TCP transport = new TCP();
transport.setBindAddress(InetAddress.getLoopbackAddress());
transport.setBindPort(9600);
transport.setSocketFactory(sslContexts.containsKey(name) ? new DefaultSocketFactory(sslContexts.get(name)) : new DefaultSocketFactory());
TCPPING ping = new TCPPING();
ping.setInitialHosts2(Collections.singletonList(new IpAddress(transport.getBindAddress(), transport.getBindPort())));
return new JChannel(transport, ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS()).name(name);
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class NAKACK_RetransmitTest method startRetransmission.
protected static void startRetransmission(JChannel... channels) throws Exception {
for (JChannel ch : channels) {
NAKACK2 nak = ch.getProtocolStack().findProtocol(NAKACK2.class);
START_RETRANSMISSION.invoke(nak);
}
}
Aggregations