}
List<Integer> missingList = new ArrayList<Integer>();
try {
List<Future> flist = new ArrayList<Future>();
for (MemberImpl member : members) {
Future future = operationService
.invokeOnTarget(SERVICE_NAME, new QueryOperation(name, predicate), member.getAddress());
flist.add(future);
}
for (Future future : flist) {
QueryResult queryResult = (QueryResult) future.get();
if (queryResult != null) {
final List<Integer> partitionIds = queryResult.getPartitionIds();
if (partitionIds != null) {
plist.addAll(partitionIds);
if (pagingPredicate == null) {
result.addAll(queryResult.getResult());
} else {
for (QueryResultEntry queryResultEntry : queryResult.getResult()) {
Object key = ss.toObject(queryResultEntry.getKeyData());
Object value = ss.toObject(queryResultEntry.getValueData());
result.add(new AbstractMap.SimpleImmutableEntry(key, value));
}
}
}
}
}
if (plist.size() == partitionCount) {
if (pagingPredicate != null) {
PagingPredicateAccessor.setPagingPredicateAnchor(pagingPredicate, ((SortedQueryResultSet) result).last());
}
return result;
}
for (int i = 0; i < partitionCount; i++) {
if (!plist.contains(i)) {
missingList.add(i);
}
}
} catch (Throwable t) {
missingList.clear();
for (int i = 0; i < partitionCount; i++) {
if (!plist.contains(i)) {
missingList.add(i);
}
}
}
try {
List<Future> futures = new ArrayList<Future>(missingList.size());
for (Integer pid : missingList) {
QueryPartitionOperation queryPartitionOperation = new QueryPartitionOperation(name, predicate);
queryPartitionOperation.setPartitionId(pid);
try {
Future f =
operationService.invokeOnPartition(SERVICE_NAME, queryPartitionOperation, pid);
futures.add(f);
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}