aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Allow null lock token in saveJobUpdate.
Date Fri, 19 Sep 2014 18:09:00 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master b2914f123 -> 012aca3d2


Allow null lock token in saveJobUpdate.

Reviewed at https://reviews.apache.org/r/25831/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/012aca3d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/012aca3d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/012aca3d

Branch: refs/heads/master
Commit: 012aca3d2a5667f9cfd6a1b9b0b91c982d34bb94
Parents: b2914f1
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Fri Sep 19 11:08:35 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Fri Sep 19 11:08:35 2014 -0700

----------------------------------------------------------------------
 .../scheduler/storage/JobUpdateStore.java       |   6 +-
 .../scheduler/storage/db/DBJobUpdateStore.java  |   7 +-
 .../scheduler/storage/log/LogStorage.java       |   3 +-
 .../storage/log/SnapshotStoreImpl.java          |  26 ++--
 .../storage/log/WriteAheadStorage.java          |   4 +-
 .../updater/JobUpdateControllerImpl.java        |   5 +-
 .../storage/db/DBJobUpdateStoreTest.java        | 123 +++++++++----------
 .../scheduler/storage/log/LogStorageTest.java   |  18 ++-
 .../storage/log/SnapshotStoreImplTest.java      |  29 +++--
 .../aurora/scheduler/updater/JobUpdaterIT.java  |   2 +-
 10 files changed, 127 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/storage/JobUpdateStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/JobUpdateStore.java b/src/main/java/org/apache/aurora/scheduler/storage/JobUpdateStore.java
index 920ff3e..cb74d62 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/JobUpdateStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/JobUpdateStore.java
@@ -98,9 +98,11 @@ public interface JobUpdateStore {
      * without having at least one {@link IJobUpdateEvent} present in the store will return
empty.
      *
      * @param update Update to save.
-     * @param lockToken UUID identifying the lock associated with this update.
+     * @param lockToken Optional UUID identifying the lock associated with this update.
+     *                  The {@code lockToken} can be absent when terminal updates are re-inserted
+     *                  during snapshot restore.
      */
-    void saveJobUpdate(IJobUpdate update, String lockToken);
+    void saveJobUpdate(IJobUpdate update, Optional<String> lockToken);
 
     /**
      * Saves a new job update event.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStore.java
index cb2e768..4db336c 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStore.java
@@ -62,15 +62,16 @@ public class DBJobUpdateStore implements JobUpdateStore.Mutable {
   }
 
   @Override
-  public void saveJobUpdate(IJobUpdate update, String lockToken) {
+  public void saveJobUpdate(IJobUpdate update, Optional<String> lockToken) {
     requireNonNull(update);
-    requireNonNull(lockToken);
 
     jobKeyMapper.merge(update.getSummary().getJobKey().newBuilder());
     detailsMapper.insert(update.newBuilder());
 
     String updateId = update.getSummary().getUpdateId();
-    detailsMapper.insertLockToken(updateId, lockToken);
+    if (lockToken.isPresent()) {
+      detailsMapper.insertLockToken(updateId, lockToken.get());
+    }
 
     // Insert optional instance update overrides.
     Set<IRange> instanceOverrides =

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
index d3bf1f2..816f450 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
@@ -27,6 +27,7 @@ import java.util.logging.Logger;
 import javax.inject.Inject;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
 import com.google.inject.BindingAnnotation;
 import com.twitter.common.application.ShutdownRegistry;
 import com.twitter.common.base.Closure;
@@ -462,7 +463,7 @@ public class LogStorage implements NonVolatileStorage, DistributedSnapshotStore
       case SAVE_JOB_UPDATE:
         writeBehindJobUpdateStore.saveJobUpdate(
             IJobUpdate.build(op.getSaveJobUpdate().getJobUpdate()),
-            op.getSaveJobUpdate().getLockToken());
+            Optional.fromNullable(op.getSaveJobUpdate().getLockToken()));
         break;
 
       case SAVE_JOB_UPDATE_EVENT:

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
b/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
index 8331c29..66ff567 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImpl.java
@@ -20,6 +20,7 @@ import java.util.logging.Logger;
 
 import javax.inject.Inject;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import com.twitter.common.inject.TimedInterceptor.Timed;
 import com.twitter.common.util.BuildInfo;
@@ -220,17 +221,22 @@ public class SnapshotStoreImpl implements SnapshotStore<Snapshot>
{
               JobUpdateDetails details = storedDetails.getDetails();
               updateStore.saveJobUpdate(
                   IJobUpdate.build(details.getUpdate()),
-                  storedDetails.getLockToken());
-
-              for (JobUpdateEvent updateEvent : details.getUpdateEvents()) {
-                updateStore.saveJobUpdateEvent(
-                    IJobUpdateEvent.build(updateEvent),
-                    details.getUpdate().getSummary().getUpdateId());
+                  Optional.fromNullable(storedDetails.getLockToken()));
+
+              if (details.getUpdateEventsSize() > 0) {
+                for (JobUpdateEvent updateEvent : details.getUpdateEvents()) {
+                  updateStore.saveJobUpdateEvent(
+                      IJobUpdateEvent.build(updateEvent),
+                      details.getUpdate().getSummary().getUpdateId());
+                }
               }
-              for (JobInstanceUpdateEvent instanceEvent : details.getInstanceEvents()) {
-                updateStore.saveJobInstanceUpdateEvent(
-                    IJobInstanceUpdateEvent.build(instanceEvent),
-                    details.getUpdate().getSummary().getUpdateId());
+
+              if (details.getInstanceEventsSize() > 0) {
+                for (JobInstanceUpdateEvent instanceEvent : details.getInstanceEvents())
{
+                  updateStore.saveJobInstanceUpdateEvent(
+                      IJobInstanceUpdateEvent.build(instanceEvent),
+                      details.getUpdate().getSummary().getUpdateId());
+                }
               }
             }
           }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java
b/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java
index 2b0a6a1..ce42ad2 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java
@@ -281,10 +281,10 @@ class WriteAheadStorage extends ForwardingStore implements
   }
 
   @Override
-  public void saveJobUpdate(IJobUpdate update, String lockToken) {
+  public void saveJobUpdate(IJobUpdate update, Optional<String> lockToken) {
     requireNonNull(update);
 
-    write(Op.saveJobUpdate(new SaveJobUpdate(update.newBuilder(), lockToken)));
+    write(Op.saveJobUpdate(new SaveJobUpdate(update.newBuilder(), lockToken.orNull())));
     jobUpdateStore.saveJobUpdate(update, lockToken);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
index 3e8182d..348bdbf 100644
--- a/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
@@ -146,7 +146,10 @@ class JobUpdateControllerImpl implements JobUpdateController {
           throw new UpdateStateException(e.getMessage(), e);
         }
 
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, lock.getToken());
+        storeProvider.getJobUpdateStore().saveJobUpdate(
+            update,
+            Optional.of(requireNonNull(lock.getToken())));
+
         recordAndChangeJobUpdateStatus(
             storeProvider.getJobUpdateStore(),
             storeProvider.getTaskStore(),

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
index 9041b42..1cbb7ab 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
@@ -63,6 +63,12 @@ import static org.apache.aurora.gen.JobUpdateAction.INSTANCE_ROLLBACK_FAILED;
 import static org.apache.aurora.gen.JobUpdateAction.INSTANCE_ROLLING_BACK;
 import static org.apache.aurora.gen.JobUpdateAction.INSTANCE_UPDATED;
 import static org.apache.aurora.gen.JobUpdateAction.INSTANCE_UPDATING;
+import static org.apache.aurora.gen.JobUpdateStatus.ABORTED;
+import static org.apache.aurora.gen.JobUpdateStatus.ERROR;
+import static org.apache.aurora.gen.JobUpdateStatus.ROLLED_BACK;
+import static org.apache.aurora.gen.JobUpdateStatus.ROLLING_FORWARD;
+import static org.apache.aurora.gen.JobUpdateStatus.ROLL_BACK_PAUSED;
+import static org.apache.aurora.gen.JobUpdateStatus.ROLL_FORWARD_PAUSED;
 import static org.junit.Assert.assertEquals;
 
 public class DBJobUpdateStoreTest {
@@ -70,7 +76,7 @@ public class DBJobUpdateStoreTest {
   private static final IJobKey JOB = JobKeys.from("testRole", "testEnv", "job");
   private static final long CREATED_MS = 111L;
   private static final IJobUpdateEvent FIRST_EVENT =
-      makeJobUpdateEvent(JobUpdateStatus.ROLLING_FORWARD, CREATED_MS);
+      makeJobUpdateEvent(ROLLING_FORWARD, CREATED_MS);
 
   private Storage storage;
 
@@ -95,10 +101,10 @@ public class DBJobUpdateStoreTest {
     assertEquals(Optional.<IJobUpdate>absent(), getUpdate(updateId1));
     assertEquals(Optional.<IJobUpdate>absent(), getUpdate(updateId2));
 
-    saveUpdate(update1, "lock1");
+    saveUpdate(update1, Optional.of("lock1"));
     assertUpdate(update1);
 
-    saveUpdate(update2, "lock2");
+    saveUpdate(update2, Optional.<String>absent());
     assertUpdate(update2);
   }
 
@@ -108,7 +114,7 @@ public class DBJobUpdateStoreTest {
     builder.getInstructions().getDesiredState().setInstances(ImmutableSet.<Range>of());
 
     // Save with empty desired state instances.
-    saveUpdate(IJobUpdate.build(builder), "lock");
+    saveUpdate(IJobUpdate.build(builder), Optional.of("lock"));
   }
 
   @Test
@@ -122,7 +128,7 @@ public class DBJobUpdateStoreTest {
     IJobUpdate expected = IJobUpdate.build(builder);
 
     // Save with empty overrides.
-    saveUpdate(expected, "lock");
+    saveUpdate(expected, Optional.of("lock"));
     assertUpdate(expected);
   }
 
@@ -138,7 +144,7 @@ public class DBJobUpdateStoreTest {
 
     // Save with null overrides.
     builder.getInstructions().getSettings().setUpdateOnlyTheseInstances(null);
-    saveUpdate(IJobUpdate.build(builder), "lock");
+    saveUpdate(IJobUpdate.build(builder), Optional.of("lock"));
     assertUpdate(expected);
   }
 
@@ -147,30 +153,30 @@ public class DBJobUpdateStoreTest {
     String updateId = "u1";
     IJobUpdate update = makeJobUpdate(JOB, updateId);
 
-    saveUpdate(update, "lock1");
-    saveUpdate(update, "lock2");
+    saveUpdate(update, Optional.of("lock1"));
+    saveUpdate(update, Optional.of("lock2"));
   }
 
   @Test
   public void testSaveJobEvents() {
     String updateId = "u3";
     IJobUpdate update = makeJobUpdate(JOB, updateId);
-    IJobUpdateEvent event1 = makeJobUpdateEvent(JobUpdateStatus.ROLLING_FORWARD, 124L);
-    IJobUpdateEvent event2 = makeJobUpdateEvent(JobUpdateStatus.ROLL_FORWARD_PAUSED, 125L);
+    IJobUpdateEvent event1 = makeJobUpdateEvent(ROLLING_FORWARD, 124L);
+    IJobUpdateEvent event2 = makeJobUpdateEvent(ROLL_FORWARD_PAUSED, 125L);
 
-    saveUpdate(update, "lock1");
+    saveUpdate(update, Optional.of("lock1"));
     assertUpdate(update);
     assertEquals(ImmutableList.of(FIRST_EVENT), getUpdateDetails(updateId).get().getUpdateEvents());
 
     saveJobEvent(event1, updateId);
     assertEquals(
-        populateExpected(update, JobUpdateStatus.ROLLING_FORWARD, CREATED_MS, 124L),
+        populateExpected(update, ROLLING_FORWARD, CREATED_MS, 124L),
         getUpdateDetails(updateId).get().getUpdate());
     assertEquals(event1, getUpdateDetails(updateId).get().getUpdateEvents().get(1));
 
     saveJobEvent(event2, updateId);
     assertEquals(
-        populateExpected(update, JobUpdateStatus.ROLL_FORWARD_PAUSED, CREATED_MS, 125L),
+        populateExpected(update, ROLL_FORWARD_PAUSED, CREATED_MS, 125L),
         getUpdateDetails(updateId).get().getUpdate());
     assertEquals(event1, getUpdateDetails(updateId).get().getUpdateEvents().get(1));
     assertEquals(event2, getUpdateDetails(updateId).get().getUpdateEvents().get(2));
@@ -183,13 +189,13 @@ public class DBJobUpdateStoreTest {
     IJobInstanceUpdateEvent event1 = makeJobInstanceEvent(0, 125L, INSTANCE_UPDATED);
     IJobInstanceUpdateEvent event2 = makeJobInstanceEvent(1, 126L, INSTANCE_ROLLING_BACK);
 
-    saveUpdate(update, "lock");
+    saveUpdate(update, Optional.of("lock"));
     assertUpdate(update);
     assertEquals(0, getUpdateDetails(updateId).get().getInstanceEvents().size());
 
     saveJobInstanceEvent(event1, updateId);
     assertEquals(
-        populateExpected(update, JobUpdateStatus.ROLLING_FORWARD, CREATED_MS, 125L),
+        populateExpected(update, ROLLING_FORWARD, CREATED_MS, 125L),
         getUpdateDetails(updateId).get().getUpdate());
     assertEquals(
         event1,
@@ -197,7 +203,7 @@ public class DBJobUpdateStoreTest {
 
     saveJobInstanceEvent(event2, updateId);
     assertEquals(
-        populateExpected(update, JobUpdateStatus.ROLLING_FORWARD, CREATED_MS, 126L),
+        populateExpected(update, ROLLING_FORWARD, CREATED_MS, 126L),
         getUpdateDetails(updateId).get().getUpdate());
     assertEquals(event1, getUpdateDetails(updateId).get().getInstanceEvents().get(0));
     assertEquals(event2, getUpdateDetails(updateId).get().getInstanceEvents().get(1));
@@ -205,7 +211,7 @@ public class DBJobUpdateStoreTest {
 
   @Test(expected = StorageException.class)
   public void testSaveJobEventWithoutUpdateFails() {
-    saveJobEvent(makeJobUpdateEvent(JobUpdateStatus.ROLLING_FORWARD, 123L), "u2");
+    saveJobEvent(makeJobUpdateEvent(ROLLING_FORWARD, 123L), "u2");
   }
 
   @Test(expected = StorageException.class)
@@ -216,14 +222,8 @@ public class DBJobUpdateStoreTest {
   @Test
   public void testSaveJobUpdateStateIgnored() {
     String updateId = "u1";
-
-    IJobUpdate update = populateExpected(
-        makeJobUpdate(JOB, updateId),
-        JobUpdateStatus.ABORTED,
-        567L,
-        567L);
-
-    saveUpdate(update, "lock1");
+    IJobUpdate update = populateExpected(makeJobUpdate(JOB, updateId), ABORTED, 567L, 567L);
+    saveUpdate(update, Optional.of("lock1"));
 
     // Assert state fields were ignored.
     assertUpdate(update);
@@ -237,7 +237,7 @@ public class DBJobUpdateStoreTest {
       public void execute(MutableStoreProvider storeProvider) {
         IJobUpdate update = makeJobUpdate(JOB, updateId);
         storeProvider.getLockStore().saveLock(makeLock(update.getSummary().getJobKey(), "lock1"));
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, "lock1");
+        storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock1"));
       }
     });
     assertEquals(Optional.<IJobUpdateDetails>absent(), getUpdateDetails(updateId));
@@ -252,21 +252,21 @@ public class DBJobUpdateStoreTest {
     IJobUpdateDetails details2 =
         makeJobDetails(makeJobUpdate(JobKeys.from("role", "env", "name2"), updateId2));
 
-    saveUpdate(details1.getUpdate(), "lock1");
-    saveUpdate(details2.getUpdate(), "lock2");
+    saveUpdate(details1.getUpdate(), Optional.of("lock1"));
+    saveUpdate(details2.getUpdate(), Optional.of("lock2"));
 
     details1 = updateJobDetails(populateExpected(details1.getUpdate()), FIRST_EVENT);
     details2 = updateJobDetails(populateExpected(details2.getUpdate()), FIRST_EVENT);
     assertEquals(Optional.of(details1), getUpdateDetails(updateId1));
     assertEquals(Optional.of(details2), getUpdateDetails(updateId2));
 
-    IJobUpdateEvent jEvent11 = makeJobUpdateEvent(JobUpdateStatus.ROLLING_FORWARD, 456L);
-    IJobUpdateEvent jEvent12 = makeJobUpdateEvent(JobUpdateStatus.ERROR, 457L);
+    IJobUpdateEvent jEvent11 = makeJobUpdateEvent(ROLLING_FORWARD, 456L);
+    IJobUpdateEvent jEvent12 = makeJobUpdateEvent(ERROR, 457L);
     IJobInstanceUpdateEvent iEvent11 = makeJobInstanceEvent(1, 451L, INSTANCE_UPDATED);
     IJobInstanceUpdateEvent iEvent12 = makeJobInstanceEvent(2, 452L, INSTANCE_UPDATING);
 
-    IJobUpdateEvent jEvent21 = makeJobUpdateEvent(JobUpdateStatus.ROLL_FORWARD_PAUSED, 567L);
-    IJobUpdateEvent jEvent22 = makeJobUpdateEvent(JobUpdateStatus.ABORTED, 568L);
+    IJobUpdateEvent jEvent21 = makeJobUpdateEvent(ROLL_FORWARD_PAUSED, 567L);
+    IJobUpdateEvent jEvent22 = makeJobUpdateEvent(ABORTED, 568L);
     IJobInstanceUpdateEvent iEvent21 = makeJobInstanceEvent(3, 561L, INSTANCE_UPDATED);
     IJobInstanceUpdateEvent iEvent22 = makeJobInstanceEvent(4, 562L, INSTANCE_UPDATING);
 
@@ -281,11 +281,11 @@ public class DBJobUpdateStoreTest {
     saveJobInstanceEvent(iEvent22, updateId2);
 
     details1 = updateJobDetails(
-        populateExpected(details1.getUpdate(), JobUpdateStatus.ERROR, CREATED_MS, 457L),
+        populateExpected(details1.getUpdate(), ERROR, CREATED_MS, 457L),
         ImmutableList.of(FIRST_EVENT, jEvent11, jEvent12), ImmutableList.of(iEvent11, iEvent12));
 
     details2 = updateJobDetails(
-        populateExpected(details2.getUpdate(), JobUpdateStatus.ABORTED, CREATED_MS, 568L),
+        populateExpected(details2.getUpdate(), ABORTED, CREATED_MS, 568L),
         ImmutableList.of(FIRST_EVENT, jEvent21, jEvent22), ImmutableList.of(iEvent21, iEvent22));
 
     assertEquals(Optional.of(details1), getUpdateDetails(updateId1));
@@ -302,16 +302,15 @@ public class DBJobUpdateStoreTest {
   public void testTruncateJobUpdates() {
     String updateId = "u5";
     IJobUpdate update = makeJobUpdate(JOB, updateId);
-    IJobUpdateEvent updateEvent = IJobUpdateEvent.build(
-        new JobUpdateEvent(JobUpdateStatus.ROLLING_FORWARD, 123L));
+    IJobUpdateEvent updateEvent = IJobUpdateEvent.build(new JobUpdateEvent(ROLLING_FORWARD,
123L));
     IJobInstanceUpdateEvent instanceEvent = IJobInstanceUpdateEvent.build(
         new JobInstanceUpdateEvent(0, 125L, INSTANCE_ROLLBACK_FAILED));
 
-    saveUpdate(update, "lock");
+    saveUpdate(update, Optional.of("lock"));
     saveJobEvent(updateEvent, updateId);
     saveJobInstanceEvent(instanceEvent, updateId);
     assertEquals(
-        populateExpected(update, JobUpdateStatus.ROLLING_FORWARD, CREATED_MS, 125L),
+        populateExpected(update, ROLLING_FORWARD, CREATED_MS, 125L),
         getUpdate(updateId).get());
     assertEquals(2, getUpdateDetails(updateId).get().getUpdateEvents().size());
     assertEquals(1, getUpdateDetails(updateId).get().getInstanceEvents().size());
@@ -326,7 +325,7 @@ public class DBJobUpdateStoreTest {
     storage.write(new MutateWork.NoResult.Quiet() {
       @Override
       public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, "lock");
+        storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock"));
       }
     });
   }
@@ -334,22 +333,22 @@ public class DBJobUpdateStoreTest {
   @Test(expected = StorageException.class)
   public void testSaveTwoUpdatesForOneJob() {
     final IJobUpdate update = makeJobUpdate(JOB, "updateId");
-    saveUpdate(update, "lock1");
-    saveUpdate(update, "lock2");
+    saveUpdate(update, Optional.of("lock1"));
+    saveUpdate(update, Optional.of("lock2"));
   }
 
   @Test(expected = StorageException.class)
   public void testSaveTwoUpdatesSameJobKey() {
     final IJobUpdate update1 = makeJobUpdate(JOB, "update1");
     final IJobUpdate update2 = makeJobUpdate(JOB, "update2");
-    saveUpdate(update1, "lock1");
-    saveUpdate(update2, "lock1");
+    saveUpdate(update1, Optional.of("lock1"));
+    saveUpdate(update2, Optional.of("lock1"));
   }
 
   @Test
   public void testLockCleared() {
     final IJobUpdate update = makeJobUpdate(JOB, "update1");
-    saveUpdate(update, "lock1");
+    saveUpdate(update, Optional.of("lock1"));
 
     storage.write(new MutateWork.NoResult.Quiet() {
       @Override
@@ -374,7 +373,7 @@ public class DBJobUpdateStoreTest {
         getSummaries(new JobUpdateQuery().setUpdateId("update1")));
 
     // If the lock has been released for this job, we can start another update.
-    saveUpdate(makeJobUpdate(JOB, "update2"), "lock2");
+    saveUpdate(makeJobUpdate(JOB, "update2"), Optional.of("lock2"));
   }
 
   private static final Optional<String> NO_TOKEN = Optional.absent();
@@ -386,13 +385,13 @@ public class DBJobUpdateStoreTest {
       public void execute(MutableStoreProvider storeProvider) {
         final IJobUpdate update1 = makeJobUpdate(JobKeys.from("role", "env", "name1"), "update1");
         final IJobUpdate update2 = makeJobUpdate(JobKeys.from("role", "env", "name2"), "update2");
-        saveUpdate(update1, "lock1");
+        saveUpdate(update1, Optional.of("lock1"));
         assertEquals(
             Optional.of("lock1"),
             storeProvider.getJobUpdateStore().getLockToken("update1"));
         assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken("update2"));
 
-        saveUpdate(update2, "lock2");
+        saveUpdate(update2, Optional.of("lock2"));
         assertEquals(
             Optional.of("lock1"),
             storeProvider.getJobUpdateStore().getLockToken("update1"));
@@ -424,13 +423,13 @@ public class DBJobUpdateStoreTest {
     IJobKey job4 = JobKeys.from(role1, "env", "name4");
     IJobKey job5 = JobKeys.from("role", "env", "name5");
     IJobUpdateSummary s1 =
-        saveSummary(job1, "u1", 1230L, JobUpdateStatus.ROLLED_BACK, "user", "lock1");
-    IJobUpdateSummary s2 = saveSummary(job2, "u2", 1231L, JobUpdateStatus.ABORTED, "user",
"lock2");
-    IJobUpdateSummary s3 = saveSummary(job3, "u3", 1239L, JobUpdateStatus.ERROR, "user2",
"lock3");
+        saveSummary(job1, "u1", 1230L, ROLLED_BACK, "user", Optional.of("lock1"));
+    IJobUpdateSummary s2 =  saveSummary(job2, "u2", 1231L, ABORTED, "user", Optional.of("lock2"));
+    IJobUpdateSummary s3 = saveSummary(job3, "u3", 1239L, ERROR, "user2", Optional.of("lock3"));
     IJobUpdateSummary s4 =
-        saveSummary(job4, "u4", 1234L, JobUpdateStatus.ROLL_BACK_PAUSED, "user3", "lock4");
+        saveSummary(job4, "u4", 1234L, ROLL_BACK_PAUSED, "user3", Optional.of("lock4"));
     IJobUpdateSummary s5 =
-        saveSummary(job5, "u5", 1235L, JobUpdateStatus.ROLLING_FORWARD, "user4", "lock5");
+        saveSummary(job5, "u5", 1235L, ROLLING_FORWARD, "user4", Optional.of("lock5"));
 
     // Test empty query returns all.
     assertEquals(ImmutableList.of(s1, s2, s4, s5, s3), getSummaries(new JobUpdateQuery()));
@@ -453,14 +452,11 @@ public class DBJobUpdateStoreTest {
 
     // Test query by one status.
     assertEquals(ImmutableList.of(s3), getSummaries(new JobUpdateQuery().setUpdateStatuses(
-        ImmutableSet.of(JobUpdateStatus.ERROR))));
+        ImmutableSet.of(ERROR))));
 
     // Test query by multiple statuses.
     assertEquals(ImmutableList.of(s1, s2, s3), getSummaries(new JobUpdateQuery().setUpdateStatuses(
-        ImmutableSet.of(
-            JobUpdateStatus.ERROR,
-            JobUpdateStatus.ABORTED,
-            JobUpdateStatus.ROLLED_BACK))));
+        ImmutableSet.of(ERROR, ABORTED, ROLLED_BACK))));
 
     // Test query by empty statuses.
     assertEquals(
@@ -492,7 +488,7 @@ public class DBJobUpdateStoreTest {
 
     assertEquals(Optional.<IJobUpdateInstructions>absent(), getUpdateInstructions(updateId));
 
-    saveUpdate(update, "lock1");
+    saveUpdate(update, Optional.of("lock1"));
     assertEquals(Optional.of(makeJobUpdateInstructions()), getUpdateInstructions(updateId));
   }
 
@@ -556,11 +552,14 @@ public class DBJobUpdateStoreTest {
         .setUser("fake user"));
   }
 
-  private void saveUpdate(final IJobUpdate update, final String lockToken) {
+  private void saveUpdate(final IJobUpdate update, final Optional<String> lockToken)
{
     storage.write(new MutateWork.NoResult.Quiet() {
       @Override
       public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getLockStore().saveLock(makeLock(update.getSummary().getJobKey(), lockToken));
+        if (lockToken.isPresent()) {
+          storeProvider.getLockStore().saveLock(
+              makeLock(update.getSummary().getJobKey(), lockToken.get()));
+        }
         storeProvider.getJobUpdateStore().saveJobUpdate(update, lockToken);
         storeProvider.getJobUpdateStore().saveJobUpdateEvent(
             FIRST_EVENT,
@@ -597,7 +596,7 @@ public class DBJobUpdateStoreTest {
   }
 
   private IJobUpdate populateExpected(IJobUpdate update) {
-    return populateExpected(update, JobUpdateStatus.ROLLING_FORWARD, CREATED_MS, CREATED_MS);
+    return populateExpected(update, ROLLING_FORWARD, CREATED_MS, CREATED_MS);
   }
 
   private IJobUpdate populateExpected(
@@ -666,7 +665,7 @@ public class DBJobUpdateStoreTest {
       Long modifiedTimestampMs,
       JobUpdateStatus status,
       String user,
-      String lockToken) {
+      Optional<String> lockToken) {
 
     IJobUpdateSummary summary = IJobUpdateSummary.build(new JobUpdateSummary()
         .setUpdateId(updateId)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
index ccc2f68..8fbade1 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
@@ -750,10 +750,21 @@ public class LogStorageTest extends EasyMockTest {
   }
 
   @Test
-  public void testSaveUpdate() throws Exception {
+  public void testSaveUpdateWithLockToken() throws Exception {
+    saveAndAssertJobUpdate("id1", Optional.of("token"));
+  }
+
+  @Test
+  public void testSaveUpdateWithNullLockToken() throws Exception {
+    saveAndAssertJobUpdate("id2", Optional.<String>absent());
+  }
+
+  private void saveAndAssertJobUpdate(final String updateId, final Optional<String>
lockToken)
+      throws Exception {
+
     final IJobUpdate update = IJobUpdate.build(new JobUpdate()
         .setSummary(new JobUpdateSummary()
-            .setUpdateId(UPDATE_ID)
+            .setUpdateId(updateId)
             .setJobKey(JOB_KEY.newBuilder())
             .setUser("user"))
         .setInstructions(new JobUpdateInstructions()
@@ -764,7 +775,6 @@ public class LogStorageTest extends EasyMockTest {
                 .setTask(new TaskConfig())
                 .setInstances(ImmutableSet.of(new Range(0, 3)))))
             .setSettings(new JobUpdateSettings())));
-    final String lockToken = "token";
 
     new MutationFixture() {
       @Override
@@ -772,7 +782,7 @@ public class LogStorageTest extends EasyMockTest {
         storageUtil.expectWriteOperation();
         storageUtil.jobUpdateStore.saveJobUpdate(update, lockToken);
         streamMatcher.expectTransaction(
-            Op.saveJobUpdate(new SaveJobUpdate(update.newBuilder(), lockToken)))
+            Op.saveJobUpdate(new SaveJobUpdate(update.newBuilder(), lockToken.orNull())))
             .andReturn(position);
       }
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
index 6de7e19..d07220a 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplTest.java
@@ -101,12 +101,16 @@ public class SnapshotStoreImplTest extends EasyMockTest {
     SchedulerMetadata metadata = new SchedulerMetadata()
         .setFrameworkId(frameworkId)
         .setVersion(CURRENT_API_VERSION);
-    final String updateId = "updateId";
-    IJobUpdateDetails updateDetails = IJobUpdateDetails.build(new JobUpdateDetails()
-        .setUpdate(new JobUpdate().setSummary(new JobUpdateSummary().setUpdateId(updateId)))
+    final String updateId1 = "updateId1";
+    final String updateId2 = "updateId2";
+    IJobUpdateDetails updateDetails1 = IJobUpdateDetails.build(new JobUpdateDetails()
+        .setUpdate(new JobUpdate().setSummary(new JobUpdateSummary().setUpdateId(updateId1)))
         .setUpdateEvents(ImmutableList.of(new JobUpdateEvent().setStatus(JobUpdateStatus.ERROR)))
         .setInstanceEvents(ImmutableList.of(new JobInstanceUpdateEvent().setTimestampMs(123L))));
 
+    IJobUpdateDetails updateDetails2 = IJobUpdateDetails.build(new JobUpdateDetails()
+        .setUpdate(new JobUpdate().setSummary(new JobUpdateSummary().setUpdateId(updateId2))));
+
     storageUtil.expectOperations();
     expect(storageUtil.taskStore.fetchTasks(Query.unscoped())).andReturn(tasks);
     expect(storageUtil.quotaStore.fetchQuotas())
@@ -121,7 +125,8 @@ public class SnapshotStoreImplTest extends EasyMockTest {
     String lockToken = "token";
     expect(storageUtil.jobUpdateStore.fetchAllJobUpdateDetails())
         .andReturn(ImmutableSet.of(
-            new StoredJobUpdateDetails(updateDetails.newBuilder(), lockToken)));
+            new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
+            new StoredJobUpdateDetails(updateDetails2.newBuilder(), null)));
 
     expectDataWipe();
     storageUtil.taskStore.saveTasks(tasks);
@@ -132,13 +137,16 @@ public class SnapshotStoreImplTest extends EasyMockTest {
         IJobConfiguration.build(job.getJobConfiguration()));
     storageUtil.schedulerStore.saveFrameworkId(frameworkId);
     storageUtil.lockStore.saveLock(lock);
-    storageUtil.jobUpdateStore.saveJobUpdate(updateDetails.getUpdate(), lockToken);
+    storageUtil.jobUpdateStore.saveJobUpdate(
+        updateDetails1.getUpdate(), Optional.fromNullable(lockToken));
     storageUtil.jobUpdateStore.saveJobUpdateEvent(
-        Iterables.getOnlyElement(updateDetails.getUpdateEvents()),
-        updateId);
+        Iterables.getOnlyElement(updateDetails1.getUpdateEvents()),
+        updateId1);
     storageUtil.jobUpdateStore.saveJobInstanceUpdateEvent(
-        Iterables.getOnlyElement(updateDetails.getInstanceEvents()),
-        updateId);
+        Iterables.getOnlyElement(updateDetails1.getInstanceEvents()),
+        updateId1);
+    storageUtil.jobUpdateStore.saveJobUpdate(
+        updateDetails2.getUpdate(), Optional.<String>absent());
 
     control.replay();
 
@@ -151,7 +159,8 @@ public class SnapshotStoreImplTest extends EasyMockTest {
         .setSchedulerMetadata(metadata)
         .setLocks(ImmutableSet.of(lock.newBuilder()))
         .setJobUpdateDetails(ImmutableSet.of(
-            new StoredJobUpdateDetails(updateDetails.newBuilder(), lockToken)));
+            new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
+            new StoredJobUpdateDetails(updateDetails2.newBuilder(), null)));
 
     assertEquals(expected, snapshotStore.createSnapshot());
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/012aca3d/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java b/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
index d90c87c..f7c7205 100644
--- a/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
@@ -659,7 +659,7 @@ public class JobUpdaterIT extends EasyMockTest {
       throw Throwables.propagate(e);
     }
 
-    store.saveJobUpdate(update, lock.getToken());
+    store.saveJobUpdate(update, Optional.of(lock.getToken()));
     store.saveJobUpdateEvent(
         IJobUpdateEvent.build(
             new JobUpdateEvent()


Mime
View raw message