You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2017/09/27 01:51:56 UTC
aurora git commit: Use a more efficient query for instance ID
collision detection
Repository: aurora
Updated Branches:
refs/heads/master 79ff364bc -> 474320bce
Use a more efficient query for instance ID collision detection
Reviewed at https://reviews.apache.org/r/62604/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/474320bc
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/474320bc
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/474320bc
Branch: refs/heads/master
Commit: 474320bced278b462a6a0d3f0bbeb5d64a54c9a2
Parents: 79ff364
Author: Bill Farner <wf...@apache.org>
Authored: Tue Sep 26 18:51:52 2017 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Tue Sep 26 18:51:52 2017 -0700
----------------------------------------------------------------------
.../apache/aurora/scheduler/state/StateManagerImpl.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/474320bc/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java b/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
index 6b780ec..9989ed4 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
@@ -30,9 +30,9 @@ import com.google.common.base.Suppliers;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
-import com.google.common.collect.Sets;
import org.apache.aurora.common.util.Clock;
import org.apache.aurora.gen.AssignedTask;
@@ -119,13 +119,10 @@ public class StateManagerImpl implements StateManager {
Set<IScheduledTask> scheduledTasks = FluentIterable.from(instanceIds)
.transform(instanceId -> createTask(instanceId, task)).toSet();
- Iterable<IScheduledTask> existingTasks = storeProvider.getTaskStore().fetchTasks(
- Query.jobScoped(task.getJob()).active());
+ Iterable<IScheduledTask> collision = storeProvider.getTaskStore().fetchTasks(
+ Query.instanceScoped(task.getJob(), instanceIds).active());
- Set<Integer> existingInstanceIds =
- FluentIterable.from(existingTasks).transform(Tasks::getInstanceId).toSet();
-
- if (!Sets.intersection(existingInstanceIds, instanceIds).isEmpty()) {
+ if (!Iterables.isEmpty(collision)) {
throw new IllegalArgumentException("Instance ID collision detected.");
}