Search in sources :

Example 16 with Protocol

use of org.jgroups.stack.Protocol in project JGroups by belaban.

the class RemoteGetStressTest method createChannel.

protected static JChannel createChannel(String name) throws Exception {
    SHARED_LOOPBACK sl = new SHARED_LOOPBACK();
    sl.getThreadPool().setMinThreads(1).setMaxThreads(5);
    Protocol[] protocols = { sl, new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS(), new UFC(), new MFC().setMaxCredits(2000000).setMinThreshold(0.4), new FRAG2().setFragSize(8000) };
    return new JChannel(protocols).name(name);
}
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 17 with Protocol

use of org.jgroups.stack.Protocol in project JGroups by belaban.

the class StateTransferTest method replaceStateTransferProtocolWith.

protected static void replaceStateTransferProtocolWith(JChannel ch, Class<? extends Protocol> state_transfer_class) throws Exception {
    ProtocolStack stack = ch.getProtocolStack();
    if (stack.findProtocol(state_transfer_class) != null)
        // protocol of the right class is already in stack
        return;
    Protocol prot = stack.findProtocol(STATE_TRANSFER.class, StreamingStateTransfer.class);
    Protocol new_state_transfer_protcol = state_transfer_class.getDeclaredConstructor().newInstance();
    if (prot != null) {
        stack.replaceProtocol(prot, new_state_transfer_protcol);
    } else {
        // no state transfer protocol found in stack
        Protocol flush = stack.findProtocol(FLUSH.class);
        if (flush != null)
            stack.insertProtocol(new_state_transfer_protcol, ProtocolStack.Position.BELOW, FLUSH.class);
        else
            stack.insertProtocolAtTop(new_state_transfer_protcol);
    }
}
Also used : ProtocolStack(org.jgroups.stack.ProtocolStack) Protocol(org.jgroups.stack.Protocol)

Example 18 with Protocol

use of org.jgroups.stack.Protocol in project JGroups by belaban.

the class SHUFFLE method down.

public Object down(Message msg) {
    Protocol dn_prot = down_prot;
    if (dn_prot == null)
        return null;
    if (!down)
        return dn_prot.down(msg);
    add(down_msgs, msg, down_lock, dn_prot::down);
    return null;
}
Also used : Protocol(org.jgroups.stack.Protocol)

Example 19 with Protocol

use of org.jgroups.stack.Protocol in project JGroups by belaban.

the class SHUFFLE method up.

public Object up(Message msg) {
    Protocol up_protocol = up_prot;
    if (up_protocol == null)
        return null;
    if (!up)
        return up_protocol.up(msg);
    add(up_msgs, msg, up_lock, m -> up_protocol.up(msg));
    return null;
}
Also used : Protocol(org.jgroups.stack.Protocol)

Example 20 with Protocol

use of org.jgroups.stack.Protocol in project JGroups by belaban.

the class Relay2Test method testAddRelay2ToAnAlreadyConnectedChannel.

/**
 * Test that RELAY2 can be added to an already connected channel.
 */
public void testAddRelay2ToAnAlreadyConnectedChannel() throws Exception {
    // Create and connect a channel.
    a = new JChannel();
    a.connect(SFO_CLUSTER);
    System.out.println("Channel " + a.getName() + " is connected. View: " + a.getView());
    // Add RELAY2 protocol to the already connected channel.
    RELAY2 relayToInject = createRELAY2(SFO);
    // Util.setField(Util.getField(relayToInject.getClass(), "local_addr"), relayToInject, a.getAddress());
    a.getProtocolStack().insertProtocolAtTop(relayToInject);
    for (Protocol p = relayToInject; p != null; p = p.getDownProtocol()) p.setAddress(a.getAddress());
    relayToInject.setProtocolStack(a.getProtocolStack());
    relayToInject.configure();
    relayToInject.handleView(a.getView());
    // Check for RELAY2 presence
    RELAY2 ar = a.getProtocolStack().findProtocol(RELAY2.class);
    assert ar != null;
    waitUntilRoute(SFO, true, 10000, 500, a);
    assert !ar.printRoutes().equals("n/a (not site master)") : "This member should be site master";
    Route route = getRoute(a, SFO);
    System.out.println("Route at sfo to sfo: " + route);
    assert route != null;
}
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