in kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/listener/AbstractDistributeOnceElasticJobListener.java [54:79]
public final void beforeJobExecuted(final ShardingContexts shardingContexts) {
Set<Integer> shardingItems = shardingContexts.getShardingItemParameters().keySet();
if (shardingItems.isEmpty()) {
return;
}
guaranteeService.registerStart(shardingItems);
while (!guaranteeService.isRegisterStartSuccess(shardingItems)) {
BlockUtils.waitingShortTime();
}
if (guaranteeService.isAllStarted()) {
guaranteeService.executeInLeaderForLastStarted(this, shardingContexts);
return;
}
long before = timeService.getCurrentMillis();
try {
synchronized (startedWait) {
startedWait.wait(startedTimeoutMilliseconds);
}
} catch (final InterruptedException ex) {
Thread.interrupted();
}
if (timeService.getCurrentMillis() - before >= startedTimeoutMilliseconds) {
guaranteeService.clearAllStartedInfo();
handleTimeout(startedTimeoutMilliseconds);
}
}