@Test public void assertHasNotShardingInfoInOfflineServers() { when(jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)).thenReturn(Arrays.asList("host0@-@0", "host0@-@1")); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(0))).thenReturn("host0@-@0"); when(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(1))).thenReturn("host0@-@1"); when(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(2))).thenReturn("host0@-@0"); assertFalse(shardingService.hasShardingInfoInOfflineServers()); }
public boolean hasShardingInfoInOfflineServers() { List<String> onlineInstances = jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT); int shardingTotalCount = configService.load(true).getShardingTotalCount(); for (int i = 0; i < shardingTotalCount; i++) { if (!onlineInstances.contains(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(i)))) { return true; } } return false; }
ShardingService { public boolean hasShardingInfoInOfflineServers() { List<String> onlineInstances = jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT); int shardingTotalCount = configService.load(true).getShardingTotalCount(); for (int i = 0; i < shardingTotalCount; i++) { if (!onlineInstances.contains(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(i)))) { return true; } } return false; } }
ShardingService { public boolean hasShardingInfoInOfflineServers() { List<String> onlineInstances = jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT); int shardingTotalCount = configService.load(true).getShardingTotalCount(); for (int i = 0; i < shardingTotalCount; i++) { if (!onlineInstances.contains(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(i)))) { return true; } } return false; } ShardingService(final CoordinatorRegistryCenter regCenter, final String jobName); }
ShardingService { public boolean hasShardingInfoInOfflineServers() { List<String> onlineInstances = jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT); int shardingTotalCount = configService.load(true).getShardingTotalCount(); for (int i = 0; i < shardingTotalCount; i++) { if (!onlineInstances.contains(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(i)))) { return true; } } return false; } ShardingService(final CoordinatorRegistryCenter regCenter, final String jobName); void setReshardingFlag(); boolean isNeedSharding(); void shardingIfNecessary(); List<Integer> getShardingItems(final String jobInstanceId); List<Integer> getLocalShardingItems(); boolean hasShardingInfoInOfflineServers(); }
ShardingService { public boolean hasShardingInfoInOfflineServers() { List<String> onlineInstances = jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT); int shardingTotalCount = configService.load(true).getShardingTotalCount(); for (int i = 0; i < shardingTotalCount; i++) { if (!onlineInstances.contains(jobNodeStorage.getJobNodeData(ShardingNode.getInstanceNode(i)))) { return true; } } return false; } ShardingService(final CoordinatorRegistryCenter regCenter, final String jobName); void setReshardingFlag(); boolean isNeedSharding(); void shardingIfNecessary(); List<Integer> getShardingItems(final String jobInstanceId); List<Integer> getLocalShardingItems(); boolean hasShardingInfoInOfflineServers();  }