use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class UNICAST_ConnectionTests method testMessageToNonExistingMember.
@Test(dataProvider = "configProvider")
public void testMessageToNonExistingMember(Class<? extends Protocol> unicast) throws Exception {
Map<String, Object> props = new HashMap<>(1);
props.put("max_retransmit_time", 5000);
setup(unicast, props);
Address target = Util.createRandomAddress("FakeAddress");
a.send(target, "hello");
Protocol prot = a.getProtocolStack().findProtocol(unicast);
Method hasSendConnectionTo = unicast.getMethod("hasSendConnectionTo", Address.class);
for (int i = 0; i < 10; i++) {
boolean result = (Boolean) hasSendConnectionTo.invoke(prot, target);
if (!result)
break;
Util.sleep(1000);
}
assert !(Boolean) hasSendConnectionTo.invoke(prot, target);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class UNICAST_DroppedAckTest method testNotEndlessXmits.
@Test(dataProvider = "configProvider")
public void testNotEndlessXmits(Class<? extends Protocol> unicast_class) throws Exception {
setup(unicast_class);
DISCARD discard_a = (DISCARD) a.getProtocolStack().findProtocol(DISCARD.class);
// drops the next 5 ACKs
discard_a.setDropDownUnicasts(5);
for (int i = 1; i <= 5; i++) b.send(a.getAddress(), i);
Protocol unicast_b = b.getProtocolStack().findProtocol(UNICAST3.class);
for (int i = 0; i < 10; i++) {
int num_unacked_msgs = numUnackedMessages(unicast_b);
System.out.println("num_unacked_msgs=" + num_unacked_msgs);
if (num_unacked_msgs == 0)
break;
Util.sleep(1000);
}
assert numUnackedMessages(unicast_b) == 0 : "num_unacked_msgs on B should be 0 but is " + numUnackedMessages(unicast_b);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class FCTest method setUp.
protected void setUp(Class<? extends Protocol> flow_control_class) throws Exception {
Protocol flow_control_prot = flow_control_class.newInstance();
flow_control_prot.setValue("min_credits", 1000).setValue("max_credits", 10000).setValue("max_block_time", 1000);
ch = new JChannel(new SHARED_LOOPBACK(), new SHARED_LOOPBACK_PING(), new NAKACK2().setValue("use_mcast_xmit", false), new UNICAST3(), new STABLE().setValue("max_bytes", 50000), new GMS().setValue("print_local_addr", false), flow_control_prot, new FRAG2().fragSize(800));
ch.connect("FCTest");
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class FragTest method createChannel.
protected static JChannel createChannel(String name, Class<? extends Protocol> clazz) throws Exception {
Protocol frag_prot = clazz.newInstance();
frag_prot.setValue("frag_size", FRAG_SIZE);
return new JChannel(new SHARED_LOOPBACK(), new SHARED_LOOPBACK_PING(), new NAKACK2().setValue("use_mcast_xmit", false), new UNICAST3(), new STABLE().setValue("max_bytes", 50000), new GMS().setValue("print_local_addr", false), new UFC(), new MFC(), frag_prot).name(name);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class FragTest method testMessageOrdering.
/**
* Tests potential ordering violation by sending small, unfragmented messages, followed by a large message
* which generates 3 fragments, followed by a final small message. Verifies that the message assembled from the
* 3 fragments is in the right place and not at the end. JIRA=https://issues.jboss.org/browse/JGRP-1648
*/
public void testMessageOrdering(Class<? extends Protocol> frag_clazz) throws Exception {
setup(frag_clazz);
OrderingReceiver receiver = new OrderingReceiver();
b.setReceiver(receiver);
Protocol frag = a.getProtocolStack().findProtocol(FRAG3.class, FRAG2.class, FRAG.class);
frag.setValue("frag_size", 5000);
Address dest = b.getAddress();
Message first = new Message(dest, new Payload(1, 10));
// frag_size is 5000, so FRAG{2} will create 3 fragments
Message big = new Message(dest, new Payload(2, 12000));
Message last = new Message(dest, new Payload(3, 10));
a.send(first);
a.send(big);
a.send(last);
List<Integer> list = receiver.getList();
for (int i = 0; i < 10; i++) {
if (list.size() == 3)
break;
Util.sleep(1000);
}
System.out.println("list = " + list);
assert list.size() == 3;
// assert that the ordering is [1 2 3], *not* [1 3 2]
for (int i = 0; i < list.size(); i++) {
assert list.get(i) == i + 1 : "element at index " + i + " is " + list.get(i) + ", was supposed to be " + (i + 1);
}
}
Aggregations