/** * 获取当前作业服务器运行时分片上下文. * * @return 当前作业服务器运行时分片上下文 */ public JobExecutionMultipleShardingContext getJobExecutionShardingContext() { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); List<Integer> shardingItems = shardingService.getLocalHostShardingItems(); if (configService.isFailover()) { List<Integer> failoverItems = failoverService.getLocalHostFailoverItems(); if (!failoverItems.isEmpty()) { result.setShardingItems(failoverItems); } else { shardingItems.removeAll(failoverService.getLocalHostTakeOffItems()); result.setShardingItems(shardingItems); } } else { result.setShardingItems(shardingItems); } boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; }