use of org.jgroups.blocks.MethodCall in project JGroups by belaban.
the class FlowControlUnitTest method forward.
/**
* First callback called by B (on A); this will call receive(byte[])
* @param target The target to call. Null == multicast RPC
* @param num_bytes The number of bytes to send
*/
@Test(enabled = false)
public void forward(Address target, int num_bytes) throws Exception {
byte[] buffer = new byte[num_bytes];
if (target != null) {
// unicast
Object retval = da.callRemoteMethod(target, new MethodCall(RECEIVE, a.getAddress(), buffer), RequestOptions.SYNC().timeout(5000).flags(Message.Flag.OOB));
System.out.println("retval=" + retval);
int actual_bytes = (Integer) retval;
assert actual_bytes == num_bytes : "expected " + Util.printBytes(num_bytes) + ", but call returned " + Util.printBytes(actual_bytes);
} else {
// multicast
RspList<Object> rsps = da.callRemoteMethods(null, new MethodCall(RECEIVE, a.getAddress(), buffer), RequestOptions.SYNC().timeout(5000).flags(Message.Flag.OOB));
System.out.println("rsps:\n" + rsps);
assert rsps.size() == 2;
for (Map.Entry<Address, Rsp<Object>> entry : rsps.entrySet()) {
Rsp<Object> rsp = entry.getValue();
assert rsp.wasReceived() : " rsp from " + entry.getKey() + " was not received";
int actual_bytes = (Integer) rsp.getValue();
assert actual_bytes == num_bytes : "expected " + Util.printBytes(num_bytes) + ", but call returned " + Util.printBytes(actual_bytes);
}
}
}
Aggregations