use of org.jgroups.JChannel in project JGroups by belaban.
the class ConfiguratorTest method testProgrammaticCreationAndVariableSubstitution.
/**
* Tests that vars are substituted correctly when creating a channel programmatically (https://issues.jboss.org/browse/JGRP-1908)
*/
public void testProgrammaticCreationAndVariableSubstitution() throws Exception {
System.setProperty(Global.EXTERNAL_PORT, "10000");
System.setProperty(Global.BIND_ADDR, "127.0.0.1");
JChannel channel = new JChannel(new SHARED_LOOPBACK()).name("A");
TP tp = channel.getProtocolStack().getTransport();
assert tp.getValue("external_port").equals(10000);
assert tp.getValue("bind_addr").equals(InetAddress.getByName("127.0.0.1"));
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class ForkProtocolStack method up.
public Object up(Message msg) {
FORK.ForkHeader hdr = msg.getHeader(FORK.ID);
if (hdr == null)
return null;
String forkId = hdr.getForkChannelId();
if (forkId == null)
throw new IllegalArgumentException("header has a null fork_channel_id");
JChannel fork_channel = get(forkId);
if (fork_channel == null) {
return this.unknownForkHandler.handleUnknownForkChannel(msg, forkId);
}
return fork_channel.up(msg);
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class PartitionedHashMap method start.
@ManagedOperation
public void start() throws Exception {
hash_function = new ConsistentHashFunction<>();
addMembershipListener((MembershipListener) hash_function);
ch = new JChannel(props);
Marshaller m = new CustomMarshaller();
disp = new RpcDispatcher(ch, this).setMarshaller(m).setMethodLookup(methods::get).setMembershipListener(this);
ch.connect(cluster_name);
local_addr = ch.getAddress();
view = ch.getView();
}
use of org.jgroups.JChannel in project fabric8 by jboss-fuse.
the class PingTestBase method doTestCluster.
protected void doTestCluster() throws Exception {
Util.waitUntilAllChannelsHaveSameSize(10000, 1000, channels);
// Tests unicasts from the first to the last
JChannel first = channels[0], last = channels[NUM - 1];
for (int i = 1; i <= 10; i++) {
first.send(last.getAddress(), i);
}
List<Integer> msgs = receivers[NUM - 1].getList();
Util.waitUntilListHasSize(msgs, 10, 10000, 1000);
System.out.println("msgs = " + msgs);
for (int i = 1; i < 10; i++) {
Assert.assertTrue(msgs.contains(i));
}
clearReceivers();
// Tests multicasts
for (int i = 0; i < NUM; i++) {
JChannel ch = channels[i];
int num = (i + 1) * 10;
for (int j = 0; j <= 5; j++) {
ch.send(null, num + j);
}
}
final int expected_size = NUM * 6;
final List<Integer> expected_numbers = new ArrayList<>(expected_size);
for (int i = 0; i < NUM; i++) {
int num = (i + 1) * 10;
for (int j = 0; j <= 5; j++) {
expected_numbers.add(num + j);
}
}
for (int i = 0; i < NUM; i++) {
List<Integer> list = receivers[i].getList();
Util.waitUntilListHasSize(list, expected_size, 10000, 1000);
System.out.println("list[" + i + "]: " + list);
}
for (int i = 0; i < NUM; i++) {
List<Integer> list = receivers[i].getList();
for (int num : expected_numbers) {
Assert.assertTrue(list.contains(num));
}
}
clearReceivers();
}
use of org.jgroups.JChannel in project fabric8 by jboss-fuse.
the class TestBase method setUp.
@Before
public void setUp() throws Exception {
for (int i = 0; i < NUM; i++) {
Protocol ping = createPing();
channels[i] = new JChannel(new TCP(), ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS());
channels[i].setName(Character.toString((char) ('A' + i)));
channels[i].connect(CLUSTER_NAME);
channels[i].setReceiver(receivers[i] = new MyReceiver());
}
}
Aggregations