public final class AverageAllocationJobShardingStrategy extends Object implements JobShardingStrategy
If the job server number and sharding count cannot be divided, the redundant sharding item that cannot be divided will be added to the server with small sequence number in turn. For example: 1. If there are 3 job servers and the total sharding count is 9, each job server is divided into: 1=[0,1,2], 2=[3,4,5], 3=[6,7,8]; 2. If there are 3 job servers and the total sharding count is 8, each job server is divided into: 1=[0,1,6], 2=[2,3,7], 3=[4,5]; 3. If there are 3 job servers and the total sharding count is 10, each job server is divided into: 1=[0,1,2,9], 2=[3,4,5], 3=[6,7,8].
| 构造器和说明 |
|---|
AverageAllocationJobShardingStrategy() |
public Map<JobInstance,List<Integer>> sharding(List<JobInstance> jobInstances, String jobName, int shardingTotalCount)
JobShardingStrategysharding 在接口中 JobShardingStrategyjobInstances - all job instances which participate in shardingjobName - job nameshardingTotalCount - sharding total countCopyright © 2020 The Apache Software Foundation. All rights reserved.