use of org.apache.geode.cache.client.internal.GetAllOp.GetAllOpImpl in project geode by apache.
the class SingleHopClientExecutor method submitGetAll.
static Map<ServerLocation, Object> submitGetAll(Map<ServerLocation, HashSet> serverToFilterMap, List callableTasks, ClientMetadataService cms, LocalRegion region) {
if (callableTasks != null && !callableTasks.isEmpty()) {
Map<ServerLocation, Object> resultMap = new HashMap<ServerLocation, Object>();
List futures = null;
try {
futures = execService.invokeAll(callableTasks);
} catch (RejectedExecutionException rejectedExecutionEx) {
throw rejectedExecutionEx;
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
}
if (futures != null) {
Iterator futureItr = futures.iterator();
Iterator taskItr = callableTasks.iterator();
while (futureItr.hasNext() && !execService.isShutdown() && !execService.isTerminated()) {
Future fut = (Future) futureItr.next();
SingleHopOperationCallable task = (SingleHopOperationCallable) taskItr.next();
List keys = ((GetAllOpImpl) task.getOperation()).getKeyList();
ServerLocation server = task.getServer();
try {
VersionedObjectList valuesFromServer = (VersionedObjectList) fut.get();
valuesFromServer.setKeys(keys);
for (VersionedObjectList.Iterator it = valuesFromServer.iterator(); it.hasNext(); ) {
VersionedObjectList.Entry entry = it.next();
Object key = entry.getKey();
Object value = entry.getValue();
if (!entry.isKeyNotOnServer()) {
if (value instanceof Throwable) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GetAll_0_CAUGHT_THE_FOLLOWING_EXCEPTION_ATTEMPTING_TO_GET_VALUE_FOR_KEY_1, new Object[] { value, key }), (Throwable) value);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#got result from {}: {}", server, valuesFromServer);
}
resultMap.put(server, valuesFromServer);
} catch (InterruptedException e) {
throw new InternalGemFireException(e.getMessage());
} catch (ExecutionException ee) {
if (ee.getCause() instanceof ServerOperationException) {
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#ExecutionException.ServerOperationException : Caused by :{}", ee.getCause());
}
throw (ServerOperationException) ee.getCause();
} else if (ee.getCause() instanceof ServerConnectivityException) {
if (logger.isDebugEnabled()) {
logger.debug("GetAllOp#ExecutionException.ServerConnectivityException : Caused by :{} The failed server is: {}", ee.getCause(), server);
}
try {
cms = region.getCache().getClientMetadataService();
} catch (CacheClosedException e) {
return null;
}
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData((LocalRegion) region, false);
resultMap.put(server, ee.getCause());
} else {
throw executionThrowable(ee.getCause());
}
}
}
return resultMap;
}
}
return null;
}
Aggregations