* must be run on the local node.
* NOTE: we may want to revisit this final assumption, perhaps delaying
* such tasks, or coming up with some other policy
*/
private boolean handoffTask(String objName, Identity identity) {
Node handoffNode = null;
try {
handoffNode = nodeMappingService.getNode(identity);
} catch (UnknownIdentityException uie) {
// this should be a rare case, but in the event that there isn't
// a mapping available, there's really nothing to be done except
// just run the task locally, and in a separate thread try to get
// the assignment taken care of
if (logger.isLoggable(Level.INFO)) {
logger.logThrow(Level.INFO, uie, "No mapping exists for " +
"identity {0} so task {1} will run locally",
identity.getName(), objName);
}
assignNode(identity);
return false;
}
// since the call to get an assigned node can actually return a
// failed node, check for this case first
if (!handoffNode.isAlive()) {
// since the mapped node is down, run the task locally
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, "Mapping for identity {0} was to " +
"node {1} which has failed so task {2} will " +
"run locally", identity.getName(),
handoffNode.getId(), objName);
}
return false;
}
long newNodeId = handoffNode.getId();
if (newNodeId == nodeId) {
// a timing issue caused us to try handing-off to ourselves, so
// just return from here
return false;
}