in src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java [215:239]
public String shouldRunAsSingleOn() {
if ( !isRunOnSingle() ) {
return null;
}
final String[] ids = QuartzJobExecutor.SLING_IDS.get();
boolean schedule = false;
if ( ids != null ) {
int index = 0;
try {
final MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(getKey().getBytes("UTF-8"));
index = new BigInteger(1, m.digest()).mod(BigInteger.valueOf(ids.length)).intValue();
} catch ( final IOException | NoSuchAlgorithmException ex ) {
// although this should never happen (MD5 and UTF-8 are always available) we consider
// this an error case
LoggerFactory.getLogger(getClass().getName()).error("Unable to distribute scheduled " + this, ex);
return "";
}
final String myId = SLING_ID;
schedule = myId != null && myId.equals(ids[index]);
return schedule ? null : ids[index];
}
return "";
}