Search in sources :

Example 26 with JChannel

use of org.jgroups.JChannel in project activemq-artemis by apache.

the class ActiveMQResourceAdapter method createBroadcastEndpointFactory.

protected BroadcastEndpointFactory createBroadcastEndpointFactory(final ConnectionFactoryProperties overrideProperties) {
    String discoveryAddress = overrideProperties.getDiscoveryAddress() != null ? overrideProperties.getDiscoveryAddress() : getDiscoveryAddress();
    if (discoveryAddress != null) {
        Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort();
        if (discoveryPort == null) {
            discoveryPort = ActiveMQClient.DEFAULT_DISCOVERY_PORT;
        }
        String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() != null ? overrideProperties.getDiscoveryLocalBindAddress() : raProperties.getDiscoveryLocalBindAddress();
        return new UDPBroadcastEndpointFactory().setGroupAddress(discoveryAddress).setGroupPort(discoveryPort).setLocalBindAddress(localBindAddress).setLocalBindPort(-1);
    }
    String jgroupsChannel = overrideProperties.getJgroupsChannelName() != null ? overrideProperties.getJgroupsChannelName() : getJgroupsChannelName();
    String jgroupsLocatorClassName = raProperties.getJgroupsChannelLocatorClass();
    if (jgroupsLocatorClassName != null) {
        String jchannelRefName = raProperties.getJgroupsChannelRefName();
        JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClassName, jchannelRefName);
        return new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel);
    }
    String jgroupsFileName = overrideProperties.getJgroupsFile() != null ? overrideProperties.getJgroupsFile() : getJgroupsFile();
    if (jgroupsFileName != null) {
        return new JGroupsFileBroadcastEndpointFactory().setChannelName(jgroupsChannel).setFile(jgroupsFileName);
    }
    return null;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) JChannel(org.jgroups.JChannel) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)

Example 27 with JChannel

use of org.jgroups.JChannel in project wildfly by wildfly.

the class ChannelServiceConfigurator method get.

@Override
public JChannel get() {
    try {
        JChannel channel = this.factory.get().createChannel(this.name);
        if (JGroupsLogger.ROOT_LOGGER.isTraceEnabled()) {
            JGroupsLogger.ROOT_LOGGER.tracef("JGroups channel %s created with configuration:%n %s", this.name, channel.getProtocolStack().printProtocolSpec(true));
        }
        channel.stats(this.statisticsEnabled);
        if (this.server != null) {
            try {
                JmxConfigurator.registerChannel(channel, this.server.get(), this.name);
            } catch (Exception e) {
                JGroupsLogger.ROOT_LOGGER.debug(e.getLocalizedMessage(), e);
            }
        }
        channel.connect(this.cluster.get());
        return channel;
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
Also used : JChannel(org.jgroups.JChannel) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 28 with JChannel

use of org.jgroups.JChannel in project cayenne by apache.

the class JavaGroupsBridge method startupExternal.

@Override
protected void startupExternal() throws Exception {
    // set of properties, trying to configure multicast address and port
    if (configURL != null) {
        channel = new JChannel(configURL);
    } else {
        String configString = buildConfigString();
        channel = new JChannel(configString);
    }
    // Important - discard messages from self
    channel.setOpt(Channel.LOCAL, Boolean.FALSE);
    channel.connect(externalSubject);
    if (receivesExternalEvents()) {
        adapter = new PullPushAdapter(channel, this);
    }
}
Also used : JChannel(org.jgroups.JChannel) PullPushAdapter(org.jgroups.blocks.PullPushAdapter)

Example 29 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class CounterServiceDemo method start.

void start(String props, String channel_name) throws Exception {
    ch = new JChannel(props);
    ch.setName(channel_name);
    ch.setReceiver(new Receiver() {

        public void viewAccepted(View view) {
            System.out.println("-- view: " + view);
        }
    });
    loop();
}
Also used : JChannel(org.jgroups.JChannel) Receiver(org.jgroups.Receiver) View(org.jgroups.View)

Example 30 with JChannel

use of org.jgroups.JChannel in project JGroups by belaban.

the class LockServiceDemo method start.

public void start() throws Exception {
    try {
        ch = new JChannel(props);
        if (name != null)
            ch.setName(name);
        lock_service = new LockService(ch);
        lock_service.addLockListener(this);
        ch.connect("lock-cluster");
        JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true);
        loop();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Util.close(ch);
    }
}
Also used : JChannel(org.jgroups.JChannel) LockService(org.jgroups.blocks.locking.LockService)

Aggregations

JChannel (org.jgroups.JChannel)119 GMS (org.jgroups.protocols.pbcast.GMS)22 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)21 Protocol (org.jgroups.stack.Protocol)18 STABLE (org.jgroups.protocols.pbcast.STABLE)15 View (org.jgroups.View)14 Message (org.jgroups.Message)10 ArrayList (java.util.ArrayList)9 Address (org.jgroups.Address)7 IOException (java.io.IOException)6 Test (org.testng.annotations.Test)5 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)4 LockService (org.jgroups.blocks.locking.LockService)4 Test (org.junit.Test)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)3