while (groupIterator.hasNext()) {
final ExecutionGroupVertex groupVertex = groupIterator.next();
for (int i = 0; i < groupVertex.getCurrentNumberOfGroupMembers(); ++i) {
final ExecutionVertex vertex = groupVertex.getGroupMember(i);
if (vertex.getExecutionState() == ExecutionState.SCHEDULED
&& vertex.getAllocatedResource() != null) {
// In local mode, we do not consider any topology, only the instance type
if (vertex.getAllocatedResource().getInstanceType().equals(
allocatedResource.getInstanceType())) {
resourceToBeReplaced = vertex.getAllocatedResource();
break;
}
}
}
if (resourceToBeReplaced != null) {
break;
}
}
// For some reason, we don't need this instance
if (resourceToBeReplaced == null) {
LOG.error("Instance " + allocatedResource.getInstance() + " is not required for job"
+ eg.getJobID());
try {
getInstanceManager().releaseAllocatedResource(jobID, eg.getJobConfiguration(),
allocatedResource);
} catch (InstanceException e) {
LOG.error(e);
}
return;
}
// Replace the selected instance
final Iterator<ExecutionVertex> it = resourceToBeReplaced.assignedVertices();
while (it.hasNext()) {
final ExecutionVertex vertex = it.next();
vertex.setAllocatedResource(allocatedResource);
vertex.updateExecutionState(ExecutionState.ASSIGNED);
}
}
}
// Deploy the assigned vertices