public GroupedSearchResults search(AQuery query, int firstResult, int count, AGroup groupBy, int groupSize, AFilter filter, ASort sort) throws RpcException {
int requests = requestsInProgress.incrementAndGet();
try {
if ( requests > maxSimultaneousRequests) {
throw new RpcException("There are too many requests in progress( current: " + requests + ", max: " + maxSimultaneousRequests
+ "). Server call skipped.");
}
try {
if (super.checkConnection()) {
GroupedSearchResults res = remoteSearcher.search(query, firstResult, count, groupBy, groupSize,filter, sort);
super.connectionSuccess();
return res;
} else {
throw new RpcException("The recconection policy requested not to contact the server. Server call skipped.");
}
} catch (RemoteException e) {
logger.error("search: exception caught.", e);
super.connectionFailure();
throw new RpcException(e);
}
} finally {
requestsInProgress.decrementAndGet();
}
}