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();
}
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);
}
}
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);
}
}
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);
}
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;
}
}
Aggregations