You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/02/25 10:47:25 UTC

[GitHub] [shardingsphere-elasticjob] leehom opened a new issue #2056: 失效转移getLocalTakeOffItems逻辑问题

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


   分片完后,getLocalTakeOffItems,获取分配了的失效转移分片,然后从运行实例分片中移除
   >      public ShardingContexts getShardingContexts() {
           。。。
   >         // 分片
   >         shardingService.shardingIfNecessary();
   >         List<Integer> shardingItems = shardingService.getLocalShardingItems();
   >         // 重新上线?
   >         if (isFailover) {
   >             shardingItems.removeAll(failoverService.getLocalTakeOffItems());
   >         }
   >         shardingItems.removeAll(executionService.getDisabledItems(shardingItems));
   >         return executionContextService.getJobShardingContext(shardingItems);
   >     }
   目的防止运行实例在主节点分片后下线,然后又上线,该节点的分片很可能已转移给别的运行实例,因此需要进行移除,避免多节点运行相同的作业分片项,这里是不是应该直接**丢弃所有分片**,看失效转移处理
   >  class JobCrashedJobListener extends AbstractJobListener {
   >         @Override
   >         protected void dataChanged(final String path, final Type eventType, final String data) {
   >                 // 获取下线实例的失效转移中的分片
   >                 List<Integer> failoverItems = failoverService.getFailoveringItems(jobInstanceId);
   >                 if (!failoverItems.isEmpty()) {
   >                     for (int each : failoverItems) {
   >                         failoverService.setCrashedFailoverFlagDirectly(each);
   >                         failoverService.failoverIfNecessary();
   >                     }
   >                 } else {
   >                 	// 获取下线实例分配的分片
   >                     for (int each : shardingService.getCrashedShardingItems(jobInstanceId)) {
   >                         failoverService.setCrashedFailoverFlag(each);
   >                         failoverService.failoverIfNecessary();
   >                     }
   >                 }
   >             }
   >         }
   >     }
   在线实例循环分掉crashed实例所有的分片,下线实例重新上线可能还没分完,导致重复执行,另外,两种分片是不是可以合并再循环转移


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org