sparrowzoo opened a new issue #1549:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1549


    public void shardingIfNecessary() {
           List<JobInstance> availableJobInstances = 
instanceService.getAvailableJobInstances();
           if (!isNeedSharding() || availableJobInstances.isEmpty()) {
               return;
           }
           
           if (!leaderService.isLeaderUntilBlock()) {
               //分片确认已经结束
               blockUntilShardingCompleted();
               return;
           }
           //等待所有任务节点结束/running 临时节点(存在假死的可能)
           waitingOtherShardingItemCompleted();
           LiteJobConfiguration liteJobConfig = configService.load(false);
           int shardingTotalCount = 
liteJobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount();
           log.debug("Job '{}' sharding begin.", jobName);
           jobNodeStorage.fillEphemeralJobNode(ShardingNode.PROCESSING, "");
           resetShardingInfo(shardingTotalCount);
           JobShardingStrategy jobShardingStrategy = 
JobShardingStrategyFactory.getStrategy(liteJobConfig.getJobShardingStrategyClass());
           jobNodeStorage.executeInTransaction(new 
PersistShardingInfoTransactionExecutionCallback(jobShardingStrategy.sharding(availableJobInstances,
 jobName, shardingTotalCount)));
           log.debug("Job '{}' sharding complete.", jobName);
       }
   
   
    private void waitingOtherShardingItemCompleted() {
           while (executionService.hasRunningItems()) {
               log.debug("Job '{}' sleep short time until other job 
completed.", jobName);
               BlockUtils.waitingShortTime();
           }
       }


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to