SchedulerState { public synchronized void addTask(Protos.TaskID taskId, NodeTask node) { this.tasks.put(taskId, node); updateStateStore(); } SchedulerState(MyriadStateStore stateStore); synchronized void addNodes(Collection<NodeTask> nodes); synchronized void addTask(Protos.TaskID taskId, NodeTask node); synchronized void updateTask(Protos.TaskStatus taskStatus); synchronized void makeTaskPending(Protos.TaskID taskId); synchronized void makeTaskStaging(Protos.TaskID taskId); synchronized void makeTaskActive(Protos.TaskID taskId); synchronized void makeTaskLost(Protos.TaskID taskId); synchronized void makeTaskKillable(Protos.TaskID taskId); synchronized NodeTask getTask(Protos.TaskID taskId); synchronized Set<Protos.TaskID> getKillableTaskIds(); synchronized Set<Protos.TaskID> getKillableTaskIds(String taskPrefix); synchronized void removeTask(Protos.TaskID taskId); synchronized Set<Protos.TaskID> getPendingTaskIds(); synchronized Collection<Protos.TaskID> getPendingTaskIDsForProfile(ServiceResourceProfile serviceProfile); synchronized Set<Protos.TaskID> getPendingTaskIds(String taskPrefix); synchronized Set<Protos.TaskID> getActiveTaskIds(); synchronized Set<Protos.TaskID> getActiveTaskIds(String taskPrefix); synchronized Set<NodeTask> getActiveTasks(); Set<NodeTask> getActiveTasksByType(String taskPrefix); Set<NodeTask> getStagingTasks(); Set<NodeTask> getStagingTasksByType(String taskPrefix); Set<NodeTask> getPendingTasksByType(String taskPrefix); synchronized Set<NodeTask> getTasks(Set<Protos.TaskID> taskIds); synchronized Collection<Protos.TaskID> getActiveTaskIDsForProfile(ServiceResourceProfile serviceProfile); synchronized NodeTask getNodeTask(SlaveID slaveId, String taskPrefix); synchronized Set<NodeTask> getNodeTasks(SlaveID slaveId); Set<Protos.TaskID> getStagingTaskIds(); synchronized Collection<Protos.TaskID> getStagingTaskIDsForProfile(ServiceResourceProfile serviceProfile); Set<Protos.TaskID> getStagingTaskIds(String taskPrefix); Set<Protos.TaskID> getLostTaskIds(); Set<Protos.TaskID> getLostTaskIds(String taskPrefix); synchronized Collection<Protos.TaskStatus> getTaskStatuses(); synchronized boolean hasTask(Protos.TaskID taskID); synchronized Optional<Protos.FrameworkID> getFrameworkID(); synchronized void setFrameworkId(Protos.FrameworkID newFrameworkId);  }
@Test public void testAddTask() throws Exception { SchedulerState sState = initialize(); TaskID idOne = TaskID.newBuilder().setValue("Task1").build(); TaskID idTwo = TaskID.newBuilder().setValue("Task2").build(); sState.addTask(idOne, taskOne); sState.addTask(idTwo, taskTwo); assertEquals("zero", sState.getTask(idOne).getProfile().getName()); assertEquals("low", sState.getTask(idTwo).getProfile().getName()); }