in twill-core/src/main/java/org/apache/twill/internal/AbstractTwillController.java [170:189]
private void validateInstanceIds(String runnable, Set<Integer> instanceIds) {
ResourceReport resourceReport = getResourceReport();
if (resourceReport == null) {
throw new IllegalStateException("Unable to get resource report since application has not started.");
}
Collection<TwillRunResources> runnableResources = resourceReport.getRunnableResources(runnable);
if (runnableResources == null) {
throw new RuntimeException("Unable to verify run resources for runnable " + runnable);
}
Set<Integer> existingInstanceIds = Sets.newHashSet();
for (TwillRunResources twillRunResources : runnableResources) {
existingInstanceIds.add(twillRunResources.getInstanceId());
}
LOG.info("Existing instance ids: {}", existingInstanceIds);
for (int instanceId : instanceIds) {
if (!existingInstanceIds.contains(instanceId)) {
throw new IllegalArgumentException("Unable to find instance id " + instanceId + " for " + runnable);
}
}
}