use of org.infinispan.remoting.transport.impl.FilterMapResponseCollector in project infinispan by infinispan.
the class RpcManagerTimeoutTest method testTimeoutWithResponseFilter.
@Test(expectedExceptions = TimeoutException.class)
public void testTimeoutWithResponseFilter() {
RpcManager rpcManager = advancedCache(0, CACHE_NAME).getRpcManager();
final List<Address> members = rpcManager.getMembers();
// wait for the responses from the last two members.
ResponseFilter filter = new ResponseFilter() {
private int expectedResponses = 2;
@Override
public boolean isAcceptable(Response response, Address sender) {
if (sender.equals(members.get(2)) || sender.equals(members.get(3))) {
expectedResponses--;
}
return true;
}
@Override
public boolean needMoreResponses() {
return expectedResponses > 0;
}
};
doTest(new FilterMapResponseCollector(filter, true, 2), false);
}
use of org.infinispan.remoting.transport.impl.FilterMapResponseCollector in project infinispan by infinispan.
the class JGroupsTransport method performSyncRemoteInvocation.
private CompletableFuture<Map<Address, Response>> performSyncRemoteInvocation(Collection<Address> targets, ReplicableCommand command, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean ignoreLeavers, boolean sendStaggeredRequest, boolean broadcast, Address singleTarget) {
CompletionStage<Map<Address, Response>> request;
if (sendStaggeredRequest) {
FilterMapResponseCollector collector = new FilterMapResponseCollector(responseFilter, false, targets.size());
request = invokeCommandStaggered(targets, command, collector, deliverOrder, timeout, TimeUnit.MILLISECONDS);
} else {
if (singleTarget != null) {
ResponseCollector<Map<Address, Response>> collector = ignoreLeavers ? SingletonMapResponseCollector.ignoreLeavers() : SingletonMapResponseCollector.validOnly();
request = invokeCommand(singleTarget, command, collector, deliverOrder, timeout, TimeUnit.MILLISECONDS);
} else {
ResponseCollector<Map<Address, Response>> collector;
if (mode == ResponseMode.WAIT_FOR_VALID_RESPONSE) {
collector = new FilterMapResponseCollector(responseFilter, false, targets.size());
} else if (responseFilter != null) {
collector = new FilterMapResponseCollector(responseFilter, true, targets.size());
} else {
collector = MapResponseCollector.ignoreLeavers(ignoreLeavers, targets.size());
}
if (broadcast) {
request = invokeCommandOnAll(command, collector, deliverOrder, timeout, TimeUnit.MILLISECONDS);
} else {
request = invokeCommand(targets, command, collector, deliverOrder, timeout, TimeUnit.MILLISECONDS);
}
}
}
return request.toCompletableFuture();
}
Aggregations