use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class SingleHopClientExecutor method submitBulkOp.
/**
* execute bulk op (putAll or removeAll) on multiple PR servers, returning a map of the results.
* Results are either a VersionedObjectList or a BulkOpPartialResultsException
*
* @param callableTasks
* @param cms
* @param region
* @param failedServers
* @return the per-server results
*/
static Map<ServerLocation, Object> submitBulkOp(List callableTasks, ClientMetadataService cms, LocalRegion region, Map<ServerLocation, RuntimeException> failedServers) {
if (callableTasks != null && !callableTasks.isEmpty()) {
Map<ServerLocation, Object> resultMap = new HashMap<ServerLocation, Object>();
boolean anyPartialResults = false;
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();
RuntimeException rte = null;
final boolean isDebugEnabled = logger.isDebugEnabled();
while (futureItr.hasNext() && !execService.isShutdown() && !execService.isTerminated()) {
Future fut = (Future) futureItr.next();
SingleHopOperationCallable task = (SingleHopOperationCallable) taskItr.next();
ServerLocation server = task.getServer();
try {
VersionedObjectList versions = (VersionedObjectList) fut.get();
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#got result from {}:{}", server, versions);
}
resultMap.put(server, versions);
} catch (InterruptedException e) {
InternalGemFireException ige = new InternalGemFireException(e);
// only to make this server as failed server, not to throw right now
failedServers.put(server, ige);
if (rte == null) {
rte = ige;
}
} catch (ExecutionException ee) {
if (ee.getCause() instanceof ServerOperationException) {
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#ExecutionException from server {}", server, ee);
}
ServerOperationException soe = (ServerOperationException) ee.getCause();
// only to make this server as failed server, not to throw right now
failedServers.put(server, soe);
if (rte == null) {
rte = soe;
}
} else if (ee.getCause() instanceof ServerConnectivityException) {
if (logger.isDebugEnabled()) {
logger.debug("submitBulkOp#ExecutionException for server {}", server, ee);
}
cms = region.getCache().getClientMetadataService();
cms.removeBucketServerLocation(server);
cms.scheduleGetPRMetaData(region, false);
failedServers.put(server, (ServerConnectivityException) ee.getCause());
} else {
Throwable t = ee.getCause();
if (t instanceof PutAllPartialResultException) {
resultMap.put(server, t);
anyPartialResults = true;
failedServers.put(server, (PutAllPartialResultException) t);
} else {
RuntimeException other_rte = executionThrowable(ee.getCause());
failedServers.put(server, other_rte);
if (rte == null) {
rte = other_rte;
}
}
}
}
// catch
}
// so the partial results can be processed
if (rte != null && !anyPartialResults) {
throw rte;
}
}
return resultMap;
}
return null;
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class SerializationHelper method readServerLocationList.
public static ArrayList readServerLocationList(DataInput in) throws IOException, ClassNotFoundException {
int size = in.readInt();
if (size < 0) {
return null;
}
ArrayList serverLocations = new ArrayList(size);
for (int i = 0; i < size; i++) {
ServerLocation next = new ServerLocation();
InternalDataSerializer.invokeFromData(next, in);
serverLocations.add(next);
}
return serverLocations;
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class ClientReplacementRequest method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.currentServer = new ServerLocation();
InternalDataSerializer.invokeFromData(this.currentServer, in);
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class SerializationHelper method writeBucketServerLocations.
private static void writeBucketServerLocations(Collection<BucketServerLocation66> bucketServerLocations, DataOutput out) throws IOException {
if (bucketServerLocations == null) {
out.writeInt(-1);
return;
}
int length = bucketServerLocations.size();
out.writeInt(length);
for (Iterator itr = bucketServerLocations.iterator(); itr.hasNext(); ) {
ServerLocation next = (ServerLocation) itr.next();
InternalDataSerializer.invokeToData(next, out);
}
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class SerializationHelper method readServerLocationSet.
public static HashSet readServerLocationSet(DataInput in) throws IOException, ClassNotFoundException {
int size = in.readInt();
if (size < 0) {
return null;
}
HashSet serverLocations = new HashSet(size);
for (int i = 0; i < size; i++) {
ServerLocation next = new ServerLocation();
InternalDataSerializer.invokeFromData(next, in);
serverLocations.add(next);
}
return serverLocations;
}
Aggregations