Search in sources :

Example 31 with Protocol

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

the class FlowControlUnitTest method replaceMFC.

protected static void replaceMFC(int max_queue_size, JChannel... channels) throws Exception {
    for (JChannel ch : channels) {
        ProtocolStack stack = ch.getProtocolStack();
        MFC_NB mfc_nb = new MFC_NB().setMaxCredits(MAX_CREDITS).setMinThreshold(0.2);
        mfc_nb.setMaxQueueSize(max_queue_size);
        mfc_nb.frag_size = 1500;
        mfc_nb.init();
        stack.replaceProtocol(stack.findProtocol(MFC.class), mfc_nb);
        View view = ch.getView();
        // needs to setup received and sent hashmaps
        mfc_nb.handleViewChange(view.getMembers());
        for (Protocol p = mfc_nb; p != null; p = p.getDownProtocol()) p.setAddress(ch.getAddress());
        mfc_nb.start();
    }
}
Also used : ProtocolStack(org.jgroups.stack.ProtocolStack) Protocol(org.jgroups.stack.Protocol)

Example 32 with Protocol

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

the class NAKACK2_RetransmissionTest method setup.

@BeforeMethod
protected void setup() throws Exception {
    receiver = new MockProtocol();
    nak = new NAKACK2().useMcastXmit(false);
    transport = new MockTransport();
    ProtocolStack stack = new ProtocolStack();
    stack.addProtocols(transport, nak, receiver);
    stack.init();
    nak.down(new Event(Event.BECOME_SERVER));
    for (Protocol p = nak; p != null; p = p.getDownProtocol()) p.setAddress(A);
    Digest digest = new Digest(view.getMembersRaw(), new long[] { 0, 0, 0, 0 });
    nak.down(new Event(Event.SET_DIGEST, digest));
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) ProtocolStack(org.jgroups.stack.ProtocolStack) Protocol(org.jgroups.stack.Protocol) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with Protocol

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

the class RpcDispatcherTest method setProps.

protected static void setProps(JChannel... channels) {
    for (JChannel ch : channels) {
        Protocol prot = ch.getProtocolStack().findProtocol(FRAG2.class);
        if (prot != null) {
            ((FRAG2) prot).setFragSize(12000);
        }
        prot = ch.getProtocolStack().findProtocol(FRAG.class);
        if (prot != null) {
            ((FRAG) prot).setFragSize(12000);
        }
        prot = ch.getProtocolStack().getTransport();
        if (prot != null)
            ((TP) prot).getBundler().setMaxSize(14000);
    }
}
Also used : FRAG2(org.jgroups.protocols.FRAG2) FRAG(org.jgroups.protocols.FRAG) Protocol(org.jgroups.stack.Protocol) TP(org.jgroups.protocols.TP)

Example 34 with Protocol

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

the class JmxConfigurator method unregisterChannel.

public static void unregisterChannel(JChannel c, MBeanServer server, ObjectName prefix, String clusterName) throws Exception {
    if (clusterName != null)
        clusterName = ObjectName.quote(clusterName);
    ProtocolStack stack = c.getProtocolStack();
    List<Protocol> protocols = stack.getProtocols();
    for (Protocol p : protocols) {
        if (p.getClass().isAnnotationPresent(MBean.class)) {
            try {
                String obj_name = getProtocolRegistrationName(clusterName, prefix, p);
                unregister(p, server, obj_name);
            } catch (MBeanRegistrationException e) {
                log.warn("MBean unregistration failed: " + e.getCause());
            }
        }
    }
    unregister(c, server, getChannelRegistrationName(prefix, clusterName));
}
Also used : ProtocolStack(org.jgroups.stack.ProtocolStack) Protocol(org.jgroups.stack.Protocol)

Example 35 with Protocol

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

the class JmxConfigurator method registerChannel.

/**
 * Registers an already created channel with the given MBeanServer. Wraps instance of JChannel
 * with DynamicMBean and delegates all calls to the actual JChannel wrapped.<br/>
 * Optionally, this method will also wrap each protocol in the given channel with DynamicMBean
 * and register it as well.
 * @param channel The channel
 * @param server The MBeanServer
 * @param domain Has to be a JMX ObjectName of the domain, e.g. DefaultDomain:name=JGroups
 * @param register_protocols Whether or not to register the protocols, too
 */
public static void registerChannel(JChannel channel, MBeanServer server, String domain, String cluster_name, boolean register_protocols) throws Exception {
    if (channel == null)
        throw new NullPointerException("channel cannot be null");
    if (cluster_name == null)
        cluster_name = channel.getClusterName();
    if (cluster_name == null)
        cluster_name = "null";
    cluster_name = ObjectName.quote(cluster_name);
    if (register_protocols) {
        ProtocolStack stack = channel.getProtocolStack();
        List<Protocol> protocols = stack.getProtocols();
        for (Protocol p : protocols) {
            if (p.getClass().isAnnotationPresent(MBean.class)) {
                String jmx_name = getProtocolRegistrationName(cluster_name, domain, p);
                register(p, server, jmx_name);
            }
        }
    }
    register(channel, server, getChannelRegistrationName(domain, cluster_name));
}
Also used : ProtocolStack(org.jgroups.stack.ProtocolStack) 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