Search in sources :

Example 6 with Protocol

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);
}
Also used : HashMap(java.util.HashMap) AfterMethod(org.testng.annotations.AfterMethod) Method(java.lang.reflect.Method) Protocol(org.jgroups.stack.Protocol) Test(org.testng.annotations.Test)

Example 7 with Protocol

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);
}
Also used : Protocol(org.jgroups.stack.Protocol) Test(org.testng.annotations.Test)

Example 8 with Protocol

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");
}
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 9 with Protocol

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);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) STABLE(org.jgroups.protocols.pbcast.STABLE) Protocol(org.jgroups.stack.Protocol) GMS(org.jgroups.protocols.pbcast.GMS)

Example 10 with Protocol

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);
    }
}
Also used : Protocol(org.jgroups.stack.Protocol)

Aggregations

Protocol (org.jgroups.stack.Protocol)87 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)18 JChannel (org.jgroups.JChannel)17 GMS (org.jgroups.protocols.pbcast.GMS)17 STABLE (org.jgroups.protocols.pbcast.STABLE)13 ProtocolStack (org.jgroups.stack.ProtocolStack)12 ArrayList (java.util.ArrayList)9 Test (org.testng.annotations.Test)9 Property (org.jgroups.annotations.Property)6 HashMap (java.util.HashMap)5 ForkProtocol (org.jgroups.fork.ForkProtocol)5 ForkProtocolStack (org.jgroups.fork.ForkProtocolStack)5 InetAddress (java.net.InetAddress)4 ProtocolConfiguration (org.jgroups.conf.ProtocolConfiguration)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)3 Message (org.jgroups.Message)3 FORK (org.jgroups.protocols.FORK)3 UNICAST3 (org.jgroups.protocols.UNICAST3)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 Method (java.lang.reflect.Method)2