for (Map.Entry<Integer, List<Integer>> entry : taskAndInputIndices.entrySet()) {
int destTaskIndex = entry.getKey();
List<Integer> inputIndices = entry.getValue();
for(int i=0; i<inputIndices.size(); ++i) {
Integer inputIndex = inputIndices.get(i);
TezEvent tezEventToSend = inputIndicesWithEvents.get(inputIndex);
if (tezEventToSend == null) {
if (isFirstEvent) {
isFirstEvent = false;
// this is the first item - reuse the event object
if (isDataMovementEvent) {
((DataMovementEvent) event).setTargetIndex(inputIndex);
} else {
((InputFailedEvent) event).setTargetIndex(inputIndex);
}
tezEventToSend = tezEvent;
} else {
// create new event object for this input index
Event e;
if (isDataMovementEvent) {
DataMovementEvent dmEvent = (DataMovementEvent) event;
e = DataMovementEvent.create(dmEvent.getSourceIndex(),
inputIndex, dmEvent.getVersion(), dmEvent.getUserPayload());
} else {
InputFailedEvent ifEvent = ((InputFailedEvent) event);
e = InputFailedEvent.create(inputIndex, ifEvent.getVersion());
}
tezEventToSend = new TezEvent(e, tezEvent.getSourceInfo());
}
tezEventToSend.setDestinationInfo(destinationMetaInfo);
// cache the event object per input because are unique per input index
inputIndicesWithEvents.put(inputIndex, tezEventToSend);
}
Task destTask = destinationVertex.getTask(destTaskIndex);
if (destTask == null) {