TaskQueue: Fix task ordering when bootstrapping

This commit is contained in:
Gian Merlino 2013-03-11 11:15:19 -07:00
parent 3fa46988f5
commit 0e4db00d54
1 changed files with 4 additions and 4 deletions

View File

@ -105,17 +105,17 @@ public class TaskQueue
} }
// Sort locks by version // Sort locks by version
final Ordering<TaskLock> byVersionOrdering = new Ordering<TaskLock>() final Ordering<Map.Entry<TaskLock, Task>> byVersionOrdering = new Ordering<Map.Entry<TaskLock, Task>>()
{ {
@Override @Override
public int compare(TaskLock left, TaskLock right) public int compare(Map.Entry<TaskLock, Task> left, Map.Entry<TaskLock, Task> right)
{ {
return left.getVersion().compareTo(right.getVersion()); return left.getKey().getVersion().compareTo(right.getKey().getVersion());
} }
}; };
// Acquire as many locks as possible, in version order // Acquire as many locks as possible, in version order
for(final Map.Entry<TaskLock, Task> taskAndLock : tasksByLock.entries()) { for(final Map.Entry<TaskLock, Task> taskAndLock : byVersionOrdering.sortedCopy(tasksByLock.entries())) {
final Task task = taskAndLock.getValue(); final Task task = taskAndLock.getValue();
final TaskLock savedTaskLock = taskAndLock.getKey(); final TaskLock savedTaskLock = taskAndLock.getKey();