TaskStorageQueryAdapter: Rename some methods and tweak javadocs for clarity

This commit is contained in:
Gian Merlino 2013-01-31 08:16:56 -08:00
parent 779c54d8f2
commit 65576cbade
3 changed files with 10 additions and 10 deletions

View File

@ -50,10 +50,11 @@ public class TaskStorageQueryAdapter
} }
/** /**
* Returns all recursive task statuses for a particular task from the same task group. Includes that task, * Returns all recursive task statuses for a particular task, staying within the same task group. Includes that
* plus any tasks it spawned, and so on. Excludes spawned tasks that ended up in a different task group. * task, plus any tasks it spawned, and so on. Does not include spawned tasks that ended up in a different task
* group. Does not include this task's parents or siblings.
*/ */
public Map<String, Optional<TaskStatus>> getGroupRecursiveStatuses(final String taskid) public Map<String, Optional<TaskStatus>> getSameGroupChildStatuses(final String taskid)
{ {
final Optional<Task> taskOptional = storage.getTask(taskid); final Optional<Task> taskOptional = storage.getTask(taskid);
final Optional<TaskStatus> statusOptional = storage.getStatus(taskid); final Optional<TaskStatus> statusOptional = storage.getStatus(taskid);
@ -64,7 +65,7 @@ public class TaskStorageQueryAdapter
if(taskOptional.isPresent() && statusOptional.isPresent()) { if(taskOptional.isPresent() && statusOptional.isPresent()) {
for(final Task nextTask : statusOptional.get().getNextTasks()) { for(final Task nextTask : statusOptional.get().getNextTasks()) {
if(nextTask.getGroupId().equals(taskOptional.get().getGroupId())) { if(nextTask.getGroupId().equals(taskOptional.get().getGroupId())) {
resultBuilder.putAll(getGroupRecursiveStatuses(nextTask.getId())); resultBuilder.putAll(getSameGroupChildStatuses(nextTask.getId()));
} }
} }
} }
@ -73,12 +74,11 @@ public class TaskStorageQueryAdapter
} }
/** /**
* Like {@link #getGroupRecursiveStatuses}, but flattens all recursive statuses for the same task group into a * Like {@link #getSameGroupChildStatuses}, but flattens the recursive statuses into a single, merged status.
* single, merged status.
*/ */
public Optional<TaskStatus> getGroupMergedStatus(final String taskid) public Optional<TaskStatus> getSameGroupMergedStatus(final String taskid)
{ {
final Map<String, Optional<TaskStatus>> statuses = getGroupRecursiveStatuses(taskid); final Map<String, Optional<TaskStatus>> statuses = getSameGroupChildStatuses(taskid);
int nSuccesses = 0; int nSuccesses = 0;
int nFailures = 0; int nFailures = 0;

View File

@ -112,7 +112,7 @@ public class IndexerCoordinatorResource
@Produces("application/json") @Produces("application/json")
public Response doStatus(@PathParam("taskid") String taskid) public Response doStatus(@PathParam("taskid") String taskid)
{ {
final Optional<TaskStatus> status = taskStorageQueryAdapter.getGroupMergedStatus(taskid); final Optional<TaskStatus> status = taskStorageQueryAdapter.getSameGroupMergedStatus(taskid);
if (!status.isPresent()) { if (!status.isPresent()) {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).build();
} else { } else {

View File

@ -416,7 +416,7 @@ public class TaskQueueTest
Assert.assertTrue("id1 isSuccess", ts.getStatus("id1").get().isSuccess()); Assert.assertTrue("id1 isSuccess", ts.getStatus("id1").get().isSuccess());
Assert.assertTrue( Assert.assertTrue(
"id1 isSuccess (merged)", "id1 isSuccess (merged)",
new TaskStorageQueryAdapter(ts).getGroupMergedStatus("id1").get().isSuccess() new TaskStorageQueryAdapter(ts).getSameGroupMergedStatus("id1").get().isSuccess()
); );
Assert.assertTrue("id2 isRunnable", ts.getStatus("id2").get().isRunnable()); Assert.assertTrue("id2 isRunnable", ts.getStatus("id2").get().isRunnable());
} }