@Override public final void execute(final JobExecutionContext context) throws JobExecutionException { log.debug("Elastic job: job execute begin, job execution context:{}.", context); shardingService.shardingIfNecessary(); JobExecutionMultipleShardingContext shardingContext = executionContextService.getJobExecutionShardingContext(); if (executionService.misfireIfNecessary(shardingContext.getShardingItems())) { log.info( "Previous job is still running, new job will start after previous job completed. Misfired job had recorded."); return; } executionService.cleanPreviousExecutionInfo(); executeJobInternal(shardingContext); log.debug("Elastic job: execute normal completed, sharding context:{}.", shardingContext); while (!executionService.getMisfiredJobItems(shardingContext.getShardingItems()).isEmpty() && !stoped && !shardingService.isNeedSharding()) { log.debug("Elastic job: execute misfired job, sharding context:{}.", shardingContext); executionService.clearMisfire(shardingContext.getShardingItems()); executeJobInternal(shardingContext); log.debug("Elastic job: misfired job completed, sharding context:{}.", shardingContext); } if (configService.isFailover() && !stoped) { failoverService.failoverIfNecessary(); } log.debug("Elastic job: execute all completed, job execution context:{}.", context); }