TreeMap<TaskAttemptID, String> taskAttemptSortedMap = new TreeMap<TaskAttemptID, String>();
for (String s : allPeers) {
byte[] data = zk.getData(constructKey(taskId.getJobID(), "peers", s),
this, null);
TaskAttemptID thatTask = new TaskAttemptID();
boolean result = getValueFromBytes(data, thatTask);
if (result) {
taskAttemptSortedMap.put(thatTask, s);
}
}
for (Map.Entry<TaskAttemptID, String> entry : taskAttemptSortedMap
.entrySet()) {
TaskAttemptID thatTask = entry.getKey();
String s = entry.getValue();
LOG.debug("TASK mapping from zookeeper: " + thatTask + " ID:"
+ thatTask.getTaskID().getId() + " : " + s);
sortedMap.put(thatTask.getTaskID().getId(), s);
}
} catch (Exception e) {
LOG.error(e);
throw new RuntimeException("All peer names could not be retrieved!");
}