Search in sources :

Example 1 with Protocol

use of org.jgroups.stack.Protocol in project hibernate-orm by hibernate.

the class TestDisconnectHandler method getFD.

private Protocol getFD() {
    Protocol protocol = getProtocolStack().findProtocol(FD_ALL.class, FD_ALL2.class, FD_SOCK.class, FD_HOST.class);
    log.trace("Found protocol " + protocol);
    return protocol;
}
Also used : Protocol(org.jgroups.stack.Protocol)

Example 2 with Protocol

use of org.jgroups.stack.Protocol in project hibernate-orm by hibernate.

the class TestDisconnectHandler method down.

@Override
public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.SET_LOCAL_ADDRESS:
            localAddress = (Address) evt.getArg();
            log.trace("Set address " + localAddress);
            break;
        case Event.CONNECT:
        case Event.CONNECT_WITH_STATE_TRANSFER:
        case Event.CONNECT_USE_FLUSH:
        case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
            log.trace("Connecting on " + localAddress);
            // we need to pass the message from below GMS (let's say regular FD* protocols
            connected.add(getFD());
            break;
        case Event.DISCONNECT:
            log.trace("Disconnecting on " + localAddress);
            connected.remove(getFD());
            // reduce view ack collection timeout to minimum, since we don't want to wait anymore
            GMS gms = (GMS) getProtocolStack().findProtocol(GMS.class);
            gms.setViewAckCollectionTimeout(1);
            for (Protocol other : connected) {
                executor.execute(() -> {
                    log.trace("Suspecting " + localAddress + " on " + other);
                    Event suspectEvent = new Event(Event.SUSPECT, localAddress);
                    other.up(suspectEvent);
                    other.down(suspectEvent);
                });
            }
            break;
    }
    return super.down(evt);
}
Also used : Event(org.jgroups.Event) GMS(org.jgroups.protocols.pbcast.GMS) Protocol(org.jgroups.stack.Protocol)

Example 3 with Protocol

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

the class LockServiceTest method setProp.

protected void setProp(Class<? extends Protocol> clazz, String prop_name, Object value, JChannel... channels) {
    for (JChannel ch : channels) {
        Protocol prot = ch.getProtocolStack().findProtocol(clazz);
        prot.setValue(prop_name, value);
    }
}
Also used : JChannel(org.jgroups.JChannel) Protocol(org.jgroups.stack.Protocol)

Example 4 with Protocol

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

the class SASLTest method createChannel.

private static JChannel createChannel(String channelName, String mech, String username) throws Exception {
    SASL sasl = new SASL();
    sasl.setMech(mech);
    sasl.setClientCallbackHandler(new MyCallbackHandler(username));
    sasl.setServerCallbackHandler(new MyCallbackHandler(username));
    sasl.setTimeout(5000);
    if (System.getProperty("java.vendor").contains("IBM")) {
        sasl.sasl_props.put("com.ibm.security.sasl.digest.realm", REALM);
    } else {
        sasl.sasl_props.put("com.sun.security.sasl.digest.realm", REALM);
    }
    sasl.setLevel("trace");
    GMS gms = new GMS();
    gms.setJoinTimeout(3000);
    return new JChannel(new Protocol[] { new SHARED_LOOPBACK(), new PING(), new MERGE3(), new NAKACK2(), new UNICAST3(), new STABLE(), sasl, gms }).name(channelName);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) STABLE(org.jgroups.protocols.pbcast.STABLE) GMS(org.jgroups.protocols.pbcast.GMS) Protocol(org.jgroups.stack.Protocol)

Example 5 with Protocol

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

the class SASL_SimpleAuthorizingCallbackTest method createChannel.

private JChannel createChannel(String channelName, String mech, String principal) throws Exception {
    Properties properties = new Properties();
    properties.put("sasl.local.principal", principal);
    properties.put("sasl.credentials.properties", credentialsFile.getAbsolutePath());
    properties.put("sasl.role", "mycluster");
    properties.put("sasl.roles.properties", rolesFile.getAbsolutePath());
    properties.put("sasl.realm", REALM);
    SASL sasl = new SASL();
    sasl.setMech(mech);
    sasl.setClientCallbackHandler(new SimpleAuthorizingCallbackHandler(properties));
    sasl.setServerCallbackHandler(new SimpleAuthorizingCallbackHandler(properties));
    sasl.setTimeout(5000);
    if (System.getProperty("java.vendor").contains("IBM")) {
        sasl.sasl_props.put("com.ibm.security.sasl.digest.realm", REALM);
    } else {
        sasl.sasl_props.put("com.sun.security.sasl.digest.realm", REALM);
    }
    return new JChannel(new Protocol[] { new SHARED_LOOPBACK(), new PING(), new NAKACK2(), new UNICAST3(), new STABLE(), sasl, new GMS() }).name(channelName);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) SimpleAuthorizingCallbackHandler(org.jgroups.auth.sasl.SimpleAuthorizingCallbackHandler) STABLE(org.jgroups.protocols.pbcast.STABLE) Properties(java.util.Properties) Protocol(org.jgroups.stack.Protocol) GMS(org.jgroups.protocols.pbcast.GMS)

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