RunningService { public Collection<TaskContext> getRunningTasks(final String jobName) { Set<TaskContext> taskContexts = new CopyOnWriteArraySet<>(); Collection<TaskContext> result = RUNNING_TASKS.putIfAbsent(jobName, taskContexts); return null == result ? taskContexts : result; } RunningService(final CoordinatorRegistryCenter regCenter); void start(); void add(final TaskContext taskContext); void updateIdle(final TaskContext taskContext, final boolean isIdle); void remove(final String jobName); void remove(final TaskContext taskContext); boolean isJobRunning(final String jobName); boolean isTaskRunning(final MetaInfo metaInfo); Collection<TaskContext> getRunningTasks(final String jobName); Map<String, Set<TaskContext>> getAllRunningTasks(); Set<TaskContext> getAllRunningDaemonTasks(); void addMapping(final String taskId, final String hostname); String popMapping(final String taskId); void clear();  }
@Test public void assertAddWithoutData() { assertThat(runningService.getRunningTasks("test_job").size(), is(1)); assertThat(runningService.getRunningTasks("test_job").iterator().next(), is(taskContext)); assertThat(runningService.getRunningTasks("test_job_t").size(), is(1)); assertThat(runningService.getRunningTasks("test_job_t").iterator().next(), is(taskContextT)); }