ShardingNode { public Integer getItemByRunningItemPath(final String path) { if (!isRunningItemPath(path)) { return null; } return Integer.parseInt(path.substring(jobNodePath.getFullPath(ROOT).length() + 1, path.lastIndexOf(RUNNING_APPENDIX) - 1)); } ShardingNode(final String jobName); static String getInstanceNode(final int item); static String getRunningNode(final int item); Integer getItemByRunningItemPath(final String path); static final String ROOT; }
@Test public void assertGetItemWhenNotRunningItemPath() { assertNull(shardingNode.getItemByRunningItemPath("/test_job/sharding/0/completed")); }
@Test public void assertGetItemByRunningItemPath() { assertThat(shardingNode.getItemByRunningItemPath("/test_job/sharding/0/running"), is(0)); }