@Test public void assertRemoveWithJobName() { when(regCenter.isExisted("/test_job")).thenReturn(true); when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2")); jobOperateAPI.remove("test_job", null); verify(regCenter).getChildrenKeys("/test_job/servers"); verify(regCenter).remove("/test_job/servers/ip1"); verify(regCenter).remove("/test_job/servers/ip2"); assertFalse(regCenter.isExisted("/test_job/servers/ip1")); assertFalse(regCenter.isExisted("/test_job/servers/ip2")); assertTrue(regCenter.isExisted("/test_job")); }
@Override public void remove(final String jobName, final String serverIp) { shutdown(jobName, serverIp); if (null != jobName && null != serverIp) { regCenter.remove(new JobNodePath(jobName).getServerNodePath(serverIp)); } else if (null != jobName) { JobNodePath jobNodePath = new JobNodePath(jobName); List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath()); for (String each : servers) { regCenter.remove(jobNodePath.getServerNodePath(each)); } } else if (null != serverIp) { List<String> jobNames = regCenter.getChildrenKeys("/"); for (String each : jobNames) { regCenter.remove(new JobNodePath(each).getServerNodePath(serverIp)); } } }
JobOperateAPIImpl implements JobOperateAPI { @Override public void remove(final String jobName, final String serverIp) { shutdown(jobName, serverIp); if (null != jobName && null != serverIp) { regCenter.remove(new JobNodePath(jobName).getServerNodePath(serverIp)); } else if (null != jobName) { JobNodePath jobNodePath = new JobNodePath(jobName); List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath()); for (String each : servers) { regCenter.remove(jobNodePath.getServerNodePath(each)); } } else if (null != serverIp) { List<String> jobNames = regCenter.getChildrenKeys("/"); for (String each : jobNames) { regCenter.remove(new JobNodePath(each).getServerNodePath(serverIp)); } } } }
JobOperateAPIImpl implements JobOperateAPI { @Override public void remove(final String jobName, final String serverIp) { shutdown(jobName, serverIp); if (null != jobName && null != serverIp) { regCenter.remove(new JobNodePath(jobName).getServerNodePath(serverIp)); } else if (null != jobName) { JobNodePath jobNodePath = new JobNodePath(jobName); List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath()); for (String each : servers) { regCenter.remove(jobNodePath.getServerNodePath(each)); } } else if (null != serverIp) { List<String> jobNames = regCenter.getChildrenKeys("/"); for (String each : jobNames) { regCenter.remove(new JobNodePath(each).getServerNodePath(serverIp)); } } } JobOperateAPIImpl(final CoordinatorRegistryCenter regCenter); }
JobOperateAPIImpl implements JobOperateAPI { @Override public void remove(final String jobName, final String serverIp) { shutdown(jobName, serverIp); if (null != jobName && null != serverIp) { regCenter.remove(new JobNodePath(jobName).getServerNodePath(serverIp)); } else if (null != jobName) { JobNodePath jobNodePath = new JobNodePath(jobName); List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath()); for (String each : servers) { regCenter.remove(jobNodePath.getServerNodePath(each)); } } else if (null != serverIp) { List<String> jobNames = regCenter.getChildrenKeys("/"); for (String each : jobNames) { regCenter.remove(new JobNodePath(each).getServerNodePath(serverIp)); } } } JobOperateAPIImpl(final CoordinatorRegistryCenter regCenter); @Override void trigger(final String jobName); @Override void disable(final String jobName, final String serverIp); @Override void enable(final String jobName, final String serverIp); @Override void shutdown(final String jobName, final String serverIp); @Override void remove(final String jobName, final String serverIp); }
JobOperateAPIImpl implements JobOperateAPI { @Override public void remove(final String jobName, final String serverIp) { shutdown(jobName, serverIp); if (null != jobName && null != serverIp) { regCenter.remove(new JobNodePath(jobName).getServerNodePath(serverIp)); } else if (null != jobName) { JobNodePath jobNodePath = new JobNodePath(jobName); List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath()); for (String each : servers) { regCenter.remove(jobNodePath.getServerNodePath(each)); } } else if (null != serverIp) { List<String> jobNames = regCenter.getChildrenKeys("/"); for (String each : jobNames) { regCenter.remove(new JobNodePath(each).getServerNodePath(serverIp)); } } } JobOperateAPIImpl(final CoordinatorRegistryCenter regCenter); @Override void trigger(final String jobName); @Override void disable(final String jobName, final String serverIp); @Override void enable(final String jobName, final String serverIp); @Override void shutdown(final String jobName, final String serverIp); @Override void remove(final String jobName, final String serverIp);  }