@Test public void assertGetLocalShardingItemsWithEnabledServer() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(serverService.isAvailableServer("127.0.0.1")).thenReturn(true); when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeData("sharding/0/instance")).thenReturn("127.0.0.1@-@0"); when(jobNodeStorage.getJobNodeData("sharding/1/instance")).thenReturn("127.0.0.1@-@1"); when(jobNodeStorage.getJobNodeData("sharding/2/instance")).thenReturn("127.0.0.1@-@0"); assertThat(shardingService.getLocalShardingItems(), is(Arrays.asList(0, 2))); JobRegistry.getInstance().shutdown("test_job"); }
public List<Integer> getLocalShardingItems() { if (JobRegistry.getInstance().isShutdown(jobName) || !serverService.isAvailableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())) { return Collections.emptyList(); } return getShardingItems(JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()); }
ShardingService { public List<Integer> getLocalShardingItems() { if (JobRegistry.getInstance().isShutdown(jobName) || !serverService.isAvailableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())) { return Collections.emptyList(); } return getShardingItems(JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()); } }
ShardingService { public List<Integer> getLocalShardingItems() { if (JobRegistry.getInstance().isShutdown(jobName) || !serverService.isAvailableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())) { return Collections.emptyList(); } return getShardingItems(JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()); } ShardingService(final CoordinatorRegistryCenter regCenter, final String jobName); }
ShardingService { public List<Integer> getLocalShardingItems() { if (JobRegistry.getInstance().isShutdown(jobName) || !serverService.isAvailableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())) { return Collections.emptyList(); } return getShardingItems(JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()); } 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 List<Integer> getLocalShardingItems() { if (JobRegistry.getInstance().isShutdown(jobName) || !serverService.isAvailableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())) { return Collections.emptyList(); } return getShardingItems(JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()); } ShardingService(final CoordinatorRegistryCenter regCenter, final String jobName); void setReshardingFlag(); boolean isNeedSharding(); void shardingIfNecessary(); List<Integer> getShardingItems(final String jobInstanceId); List<Integer> getLocalShardingItems(); boolean hasShardingInfoInOfflineServers();  }