Search in sources :

Example 61 with JChannel

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

the class Chat method start.

private void start(String props, String name) throws Exception {
    channel = new JChannel(props);
    if (name != null)
        channel.name(name);
    channel.setReceiver(this);
    channel.connect("ChatCluster");
    eventLoop();
    channel.close();
}
Also used : JChannel(org.jgroups.JChannel)

Example 62 with JChannel

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

the class ExecutionServiceDemo method start.

public void start() throws Exception {
    ch = new JChannel(props);
    if (name != null)
        ch.setName(name);
    execution_service = new ExecutionService(ch);
    runner = new ExecutionRunner(ch);
    ch.connect("executing-cluster");
    JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "execution-service", ch.getClusterName(), true);
    // Start a consumer
    queue.add(executor.submit(runner));
    random = new Random();
    printValues = false;
    try {
        loop();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Util.close(ch);
    }
}
Also used : JChannel(org.jgroups.JChannel) Random(java.util.Random) ExecutionRunner(org.jgroups.blocks.executor.ExecutionRunner) ExecutionService(org.jgroups.blocks.executor.ExecutionService)

Example 63 with JChannel

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

the class QuoteServer method start.

public void start() {
    try {
        channel = new JChannel(props);
        disp = (RpcDispatcher) new RpcDispatcher(channel, this).setMembershipListener(this).setStateListener(this);
        channel.connect(channel_name);
        System.out.println("\nQuote Server started at " + new Date());
        System.out.println("Joined channel '" + channel_name + "' (" + channel.getView().size() + " members)");
        channel.getState(null, 0);
        System.out.println("Ready to serve requests");
    } catch (Exception e) {
        log.error("QuoteServer.start() : " + e);
        System.exit(-1);
    }
}
Also used : RpcDispatcher(org.jgroups.blocks.RpcDispatcher) JChannel(org.jgroups.JChannel)

Example 64 with JChannel

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

the class ReplCache method start.

@ManagedOperation
public void start() throws Exception {
    if (hash_function_factory != null) {
        hash_function = hash_function_factory.create();
    }
    if (hash_function == null)
        hash_function = new ConsistentHashFunction<>();
    ch = new JChannel(props);
    disp = new RpcDispatcher(ch, this).setMethodLookup(methods::get).setMembershipListener(this);
    Marshaller marshaller = new CustomMarshaller();
    disp.setMarshaller(marshaller);
    ch.connect(cluster_name);
    local_addr = ch.getAddress();
    view = ch.getView();
    timer = ch.getProtocolStack().getTransport().getTimer();
    l2_cache.addChangeListener(this);
}
Also used : JChannel(org.jgroups.JChannel) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 65 with JChannel

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

the class RSVPTest method testSynchronousMulticastSend.

public void testSynchronousMulticastSend() throws Exception {
    for (JChannel ch : channels) assert ch.getView().size() == NUM : "channel " + ch.getAddress() + ": view  is " + ch.getView();
    // test with a multicast message:
    short value = (short) Math.abs((short) Util.random(10000));
    Message msg = new Message(null, value);
    msg.setFlag(Message.Flag.RSVP);
    DISCARD discard = channels[0].getProtocolStack().findProtocol(DISCARD.class);
    discard.setDropDownMulticasts(1);
    long start = System.currentTimeMillis();
    channels[0].send(msg);
    long diff = System.currentTimeMillis() - start;
    System.out.println("sending took " + diff + " ms");
    int cnt = 1;
    for (MyReceiver receiver : receivers) {
        System.out.println("receiver " + cnt++ + ": value=" + receiver.getValue());
    }
    for (MyReceiver receiver : receivers) {
        long tmp_value = receiver.getValue();
        assert tmp_value == value : "value is " + tmp_value + ", but should be " + value;
    }
}
Also used : JChannel(org.jgroups.JChannel) Message(org.jgroups.Message)

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