Map<ByteArray, byte[]> transforms = pipelineData.getTransforms();
final AtomicBoolean isResponseProcessed = new AtomicBoolean(false);
for (Map.Entry<Node, List<ByteArray>> entry: pipelineData.getNodeToKeysMap().entrySet()) {
final Node node = entry.getKey();
final Collection<ByteArray> keys = entry.getValue();
NonblockingStoreCallback callback = new NonblockingStoreCallback() {
public void requestComplete(Object result, long requestTime) {
if (logger.isTraceEnabled())
logger.trace(pipeline.getOperation().getSimpleName()
+ " response received (" + requestTime + " ms.) from node "
+ node.getId());
Response<Iterable<ByteArray>, Object> response = new Response<Iterable<ByteArray>, Object>(node,
keys,
result,
requestTime);
responses.put(node.getId(), response);
latch.countDown();
// TODO: There is inconsistency between the exceptions are treated here in the
// completion callback and in the application thread.
// They need a cleanup to make them consistent. Thought about handling
// them here, but it is the selector thread that is calling this completion method,
// handleResponseError has some synchronization, not sure about the effect, so reserving
// it for later.
// isResponseProcessed just reduces the time window during
// which a exception can go uncounted. When the parallel
// requests timeout and it is trying Serial timeout
// exceptions are lost and the node is never marked down.
// This reduces the window where an exception is lost
if (isResponseProcessed.get() && response.getValue() instanceof Exception)
if (response.getValue() instanceof InvalidMetadataException) {
pipelineData.reportException((InvalidMetadataException) response.getValue());
logger.warn("Received invalid metadata problem after a successful "
+ pipeline.getOperation().getSimpleName()
+ " call on node " + node.getId() + ", store '"
+ pipelineData.getStoreName() + "'");
} else {
handleResponseError(response, pipeline, failureDetector);
}
}
};
if (logger.isTraceEnabled())
logger.trace("Submitting " + pipeline.getOperation().getSimpleName()
+ " request on node " + node.getId());
NonblockingStore store = nonblockingStores.get(node.getId());
store.submitGetAllRequest(keys, transforms, callback, timeoutMs);
}
try {
latch.await(timeoutMs, TimeUnit.MILLISECONDS);