DataInputStream input,
MapOutputLocation mapOutputLoc,
Path filename, int reduce)
throws IOException, InterruptedException {
// Read the shuffle header and validate header
TaskAttemptID mapId = null;
long decompressedLength = -1;
long compressedLength = -1;
int forReduce = -1;
boolean found = false;
try {
ShuffleHeader header = new ShuffleHeader();
header.readFields(input);
// Special case where the map output was not found
if (header.found == false) {
LOG.warn("getMapOutput: Header for " + mapOutputLoc + " indicates" +
"the map output can't be found, indicating a serious error.");
return new MapOutputStatus(null,
CopyOutputErrorType.SERIOUS_ERROR,
ErrorRootCause.DATA_CORRUPTION);
}
mapId = TaskAttemptID.forName(header.mapId);
compressedLength = header.compressedLength;
decompressedLength = header.uncompressedLength;
forReduce = header.forReduce;
} catch (IllegalArgumentException e) {
LOG.warn(getName() + " Invalid map id (maybe protocol mismatch)", e);
return new MapOutputStatus(null, CopyOutputErrorType.SERIOUS_ERROR,
ErrorRootCause.DATA_CORRUPTION);
}
if (mapId == null) {
LOG.warn("Missing header " + FROM_MAP_TASK + " in response for " +
connection.getURL());
return new MapOutputStatus(null, CopyOutputErrorType.SERIOUS_ERROR,
ErrorRootCause.DATA_CORRUPTION);
}
TaskAttemptID expectedMapId = mapOutputLoc.getTaskAttemptId();
if (!mapId.equals(expectedMapId)) {
LOG.warn(getName() + " data from wrong map:" + mapId +
" arrived to reduce task " + reduce +
", where as expected map output should be from " + expectedMapId);
return new MapOutputStatus(null, CopyOutputErrorType.SERIOUS_ERROR,