createdOn = (String) jobProperties.get(org.apache.sling.event.jobs.Job.PROPERTY_JOB_CREATED_INSTANCE);
}
if ( createdOn == null ) {
createdOn = Environment.APPLICATION_ID;
}
final InstanceDescription createdOnInstance = this.instanceMap.get(createdOn);
if ( potentialTargets != null && potentialTargets.size() > 0 ) {
if ( createdOnInstance != null ) {
// create a list with local targets first.
final List<InstanceDescription> localTargets = new ArrayList<InstanceDescription>();
for(final InstanceDescription desc : potentialTargets) {
if ( desc.getClusterView().getId().equals(createdOnInstance.getClusterView().getId()) ) {
if ( !this.jobManagerConfiguration.disableDistribution() || desc.isLeader() ) {
localTargets.add(desc);
}
}
}
if ( localTargets.size() > 0 ) {
potentialTargets.clear();
potentialTargets.addAll(localTargets);
logger.debug("Potential targets filtered for {} : {}", jobTopic, potentialTargets);
}
}
// check prefer run on creation instance
if ( queueInfo.queueConfiguration.isPreferRunOnCreationInstance() ) {
InstanceDescription creationDesc = null;
for(final InstanceDescription desc : potentialTargets) {
if ( desc.getSlingId().equals(createdOn) ) {
creationDesc = desc;
break;
}