use of org.jgroups.blocks.RpcDispatcher in project JGroups by belaban.
the class Deadlock2Test method testTwoChannels.
/**
* Tests the deadlock resolution using two different channels. The deadlock detection
* is turned on. It implements the following scenario:
*
* Channel1 Channel2
* | |
* + -------------------------------> outerMethod()
* | RPC
* | |
* | |
* | |
* | <-- innerMethod() <-----------------+ ---------+
* | | |
* | | <-- innerMethod()
*
* If there is a deadlock, JUnit will timeout and fail the test.
*/
public void testTwoChannels() throws Throwable {
ServerObject obj1, obj2 = null;
c1 = createChannel();
obj1 = new ServerObject("obj1");
RpcDispatcher disp1 = new RpcDispatcher(c1, obj1);
obj1.setRpcDispatcher(disp1);
c2 = createChannel();
obj2 = new ServerObject("obj2");
RpcDispatcher disp2 = new RpcDispatcher(c2, obj2);
obj2.setRpcDispatcher(disp2);
makeUnique(c1, c2);
c1.connect(name);
c2.connect(name);
Address localAddress2 = c2.getAddress();
// call a point-to-point method on Member 2 that triggers a nested distributed RPC
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on " + localAddress2);
Object retval = disp1.callRemoteMethod(localAddress2, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod(): " + retval);
}
use of org.jgroups.blocks.RpcDispatcher in project JGroups by belaban.
the class Deadlock2Test method testOneChannel.
/**
* Tests the deadlock resolution using self-calls on a single channel. The deadlock detection is turned on so
* the method call should go straight through. If there is a problem, the test will time out.
*/
public void testOneChannel() throws Exception {
c1 = createChannel();
makeUnique(c1);
ServerObject serverObject = new ServerObject("obj1");
RpcDispatcher disp = new RpcDispatcher(c1, serverObject);
serverObject.setRpcDispatcher(disp);
c1.connect(name);
Address localAddress = c1.getAddress();
// call the nested group method on itself
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on all members");
RspList<String> rspList = disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod(): " + rspList);
Assert.assertEquals(1, rspList.size());
assert "outerMethod[innerMethod]".equals(rspList.getValue(localAddress));
assert rspList.isReceived(localAddress);
assert !rspList.isSuspected(localAddress);
}
use of org.jgroups.blocks.RpcDispatcher in project JGroups by belaban.
the class Deadlock2Test method testTwoChannelsWithInitialMulticast.
public void testTwoChannelsWithInitialMulticast() throws Exception {
ServerObject obj1, obj2 = null;
c1 = createChannel();
obj1 = new ServerObject("obj1");
RpcDispatcher disp1 = new RpcDispatcher(c1, obj1);
obj1.setRpcDispatcher(disp1);
c2 = createChannel();
obj2 = new ServerObject("obj2");
RpcDispatcher disp2 = new RpcDispatcher(c2, obj2);
obj2.setRpcDispatcher(disp2);
makeUnique(c1, c2);
c1.connect(name);
c2.connect(name);
List<Address> dests = new ArrayList<>();
dests.add(c1.getAddress());
dests.add(c2.getAddress());
// call a point-to-point method on Member 2 that triggers a nested distributed RPC
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on all members");
RspList<String> rsps = disp1.callRemoteMethods(dests, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod():\n" + rsps);
Assert.assertEquals(2, rsps.size());
}
Aggregations