use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class Relay2RpcDispatcherTest method testNotificationAndRpcRelay2Transit.
/**
* Tests that notifications are routed to all sites.
*/
public void testNotificationAndRpcRelay2Transit() throws Exception {
a.connect(LON_CLUSTER);
b.connect(LON_CLUSTER);
rpca.start();
rpcb.start();
Util.waitUntilAllChannelsHaveSameView(30000, 1000, a, b);
x.connect(SFO_CLUSTER);
y.connect(SFO_CLUSTER);
rpcx.start();
rpcy.start();
Util.waitUntilAllChannelsHaveSameView(30000, 1000, x, y);
assert a.getView().size() == 2;
assert x.getView().size() == 2;
RELAY2 ar = a.getProtocolStack().findProtocol(RELAY2.class);
RELAY2 xr = x.getProtocolStack().findProtocol(RELAY2.class);
assert ar != null && xr != null;
JChannel a_bridge = null, x_bridge = null;
for (int i = 0; i < 20; i++) {
a_bridge = ar.getBridge(SFO);
x_bridge = xr.getBridge(LON);
if (a_bridge != null && x_bridge != null && a_bridge.getView().size() == 2 && x_bridge.getView().size() == 2)
break;
Util.sleep(500);
}
assert a_bridge != null && x_bridge != null;
System.out.println("A's bridge channel: " + a_bridge.getView());
System.out.println("X's bridge channel: " + x_bridge.getView());
assert a_bridge.getView().size() == 2 : "bridge view is " + a_bridge.getView();
assert x_bridge.getView().size() == 2 : "bridge view is " + x_bridge.getView();
Route route = getRoute(x, LON);
System.out.println("Route at sfo to lon: " + route);
assert route != null;
assertSiteView(a, Arrays.asList(LON, SFO));
assert getCurrentSites(b) == null;
assertSiteView(x, Arrays.asList(LON, SFO));
assert getCurrentSites(y) == null;
System.out.println("B: sending message 0 to the site master of SFO");
Address sm_sfo = new SiteMaster(SFO);
MethodCall call = new MethodCall(ServerObject.class.getMethod("foo"));
System.out.println("B: call foo method on A");
Object rsp = rpcb.callRemoteMethod(a.getAddress(), call, new RequestOptions(ResponseMode.GET_ALL, 5000));
System.out.println("RSP is: " + rsp);
System.out.println("B: call foo method on SFO master site");
rsp = rpcb.callRemoteMethod(sm_sfo, call, new RequestOptions(ResponseMode.GET_ALL, 15000));
System.out.println("RSP is: " + rsp);
System.out.println("B: call foo method on all members in site LON");
RspList<Integer> rsps = rpcb.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 5000));
System.out.println("RSPs are: \n" + rsps);
assert rsps.size() == 2;
assert rsps.containsKey(a.getAddress()) && rsps.containsKey(b.getAddress());
View bridge_view = xr.getBridgeView(BRIDGE_CLUSTER);
System.out.println("bridge_view = " + bridge_view);
route = getRoute(x, LON);
System.out.println("Route at sfo to lon: " + route);
assert route != null;
}
use of org.jgroups.blocks.RequestOptions 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.RequestOptions 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.RequestOptions 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());
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class MessageDispatcherUnitTest method testNullMessageToAll.
public void testNullMessageToAll() throws Exception {
da.setRequestHandler(new MyHandler(null));
b = createChannel().name("B");
long stop, start = System.currentTimeMillis();
db = new MessageDispatcher(b, new MyHandler(null));
stop = System.currentTimeMillis();
b.connect("MessageDispatcherUnitTest");
Assert.assertEquals(2, b.getView().size());
System.out.println("view: " + b.getView());
System.out.println("casting message");
start = System.currentTimeMillis();
RspList<byte[]> rsps = da.castMessage(null, new BytesMessage(null, buf), new RequestOptions(ResponseMode.GET_ALL, 0));
stop = System.currentTimeMillis();
System.out.println("rsps:\n" + rsps);
System.out.println("call took " + (stop - start) + " ms");
assert rsps != null;
assert 2 == rsps.size();
Rsp<byte[]> rsp = rsps.get(a.getAddress());
assert rsp != null;
Object ret = rsp.getValue();
assert ret == null;
rsp = rsps.get(b.getAddress());
assert rsp != null;
ret = rsp.getValue();
assert ret == null;
}
Aggregations