aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Accumulate read/write timing in MemStorage for top-level operations only.
Date Tue, 25 Feb 2014 21:36:07 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master cbb56ab8b -> d37a833ee


Accumulate read/write timing in MemStorage for top-level operations only.

Bugs closed: AURORA-135

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


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

Branch: refs/heads/master
Commit: d37a833ee8065f0cafbb8ff17886b5ceafc2536d
Parents: cbb56ab
Author: Bill Farner <wfarner@apache.org>
Authored: Tue Feb 25 13:34:25 2014 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue Feb 25 13:34:25 2014 -0800

----------------------------------------------------------------------
 .../scheduler/storage/ForwardingStore.java      |  5 --
 .../scheduler/storage/ReadWriteLockManager.java | 67 ++++++++++++--------
 .../aurora/scheduler/storage/Storage.java       | 59 ++++++++---------
 .../scheduler/storage/log/LogStorage.java       |  1 -
 .../scheduler/storage/mem/MemStorage.java       | 64 ++++++++++---------
 .../thrift/SchedulerThriftInterface.java        |  7 +-
 .../storage/ReadWriteLockManagerTest.java       | 40 ++++++------
 .../scheduler/storage/log/LogStorageTest.java   | 12 +++-
 .../thrift/SchedulerThriftInterfaceTest.java    |  3 +-
 .../aurora/scheduler/thrift/ThriftIT.java       |  2 +
 10 files changed, 137 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java b/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
index ef7d2ce..34d39f2 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/ForwardingStore.java
@@ -106,11 +106,6 @@ public class ForwardingStore implements
   }
 
   @Override
-  public void snapshot() throws StorageException {
-    storage.snapshot();
-  }
-
-  @Override
   public void saveFrameworkId(String frameworkId) {
     schedulerStore.saveFrameworkId(frameworkId);
   }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java b/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
index a029914..d48b89e 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
@@ -19,6 +19,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import com.google.common.base.Preconditions;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * A lock manager that wraps a ReadWriteLock and detects ill-fated attempts to upgrade
  * a read-locked thread to a write-locked thread, which would otherwise deadlock.
@@ -26,12 +28,23 @@ import com.google.common.base.Preconditions;
 public class ReadWriteLockManager {
   private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
-  enum LockMode {
+  private enum LockMode {
     NONE,
     READ,
     WRITE
   }
 
+  public enum LockType {
+    READ(LockMode.READ),
+    WRITE(LockMode.WRITE);
+
+    private LockMode mode;
+
+    private LockType(LockMode mode) {
+      this.mode = mode;
+    }
+  }
+
   private static class LockState {
     private LockMode initialLockMode = LockMode.NONE;
     private int lockCount = 0;
@@ -66,44 +79,42 @@ public class ReadWriteLockManager {
   };
 
   /**
-   * Blocks until this thread has acquired a read lock.
+   * Blocks until this thread has acquired the requested lock.
    *
+   * @param type Type of lock to acquire.
    * @return {@code true} if the lock was newly-acquired, or {@code false} if this thread
previously
-   *         secured the write lock and has yet to release it.
+   *         secured the lock and has yet to release it.
    */
-  public boolean readLock() {
-    lock.readLock().lock();
-    return lockState.get().lockAcquired(LockMode.READ);
-  }
+  public boolean lock(LockType type) {
+    checkNotNull(type);
 
-  /**
-   * Releases this thread's read lock.
-   */
-  public void readUnlock() {
-    lock.readLock().unlock();
-    lockState.get().lockReleased(LockMode.READ);
+    if (LockType.READ == type) {
+      lock.readLock().lock();
+    } else {
+      Preconditions.checkState(lockState.get().initialLockMode != LockMode.READ,
+          "A read operation may not be upgraded to a write operation.");
+
+      lock.writeLock().lock();
+    }
+
+    return lockState.get().lockAcquired(type.mode);
   }
 
   /**
-   * Blocks until this thread has acquired a write lock.
+   * Releases this thread's lock of the given type.
    *
-   * @return {@code true} if the lock was newly-acquired, or {@code false} if this thread
previously
-   *         secured the write lock and has yet to release it.
+   * @param type Type of lock to release.
    */
-  public boolean writeLock() {
-    Preconditions.checkState(lockState.get().initialLockMode != LockMode.READ,
-        "A read operation may not be upgraded to a write operation.");
+  public void unlock(LockType type) {
+    checkNotNull(type);
 
-    lock.writeLock().lock();
-    return lockState.get().lockAcquired(LockMode.WRITE);
-  }
+    if (LockType.READ == type) {
+      lock.readLock().unlock();
+    } else {
+      lock.writeLock().unlock();
+    }
 
-  /**
-   * Releases this thread's write lock.
-   */
-  public void writeUnlock() {
-    lock.writeLock().unlock();
-    lockState.get().lockReleased(LockMode.WRITE);
+    lockState.get().lockReleased(type.mode);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/Storage.java b/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
index 9cc1d1e..4b33fe5 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
@@ -66,13 +66,13 @@ public interface Storage {
   }
 
   /**
-   * Encapsulates a read-only storage operation.
+   * A unit of work to perform against the storage system.
    *
-   * @param <T> The type of result this unit of work produces.
-   * @param <E> The type of exception this unit of work can throw.
+   * @param <S> Type of stores the work needs access to.
+   * @param <T> Return type of the operation.
+   * @param <E> Exception type thrown by the operation.
    */
-  interface Work<T, E extends Exception> {
-
+  interface StorageOperation<S extends StoreProvider, T, E extends Exception> {
     /**
      * Abstracts a unit of work that has a result, but may also throw a specific exception.
      *
@@ -80,14 +80,23 @@ public interface Storage {
      * @return the result of the successfully completed unit of work
      * @throws E if the unit of work could not be completed
      */
-    T apply(StoreProvider storeProvider) throws E;
+    T apply(S storeProvider) throws E;
+  }
+
+  /**
+   * Encapsulates a read-only storage operation.
+   *
+   * @param <T> The type of result this unit of work produces.
+   * @param <E> The type of exception this unit of work can throw.
+   */
+  abstract class Work<T, E extends Exception> implements StorageOperation<StoreProvider,
T, E> {
 
     /**
      * A convenient typedef for Work that throws no checked exceptions - it runs quietly.
      *
      * @param <T> The type of result this unit of work produces.
      */
-    interface Quiet<T> extends Work<T, RuntimeException> {
+    public abstract static class Quiet<T> extends Work<T, RuntimeException> {
       // typedef
     }
   }
@@ -98,31 +107,15 @@ public interface Storage {
    * @param <T> The type of result this unit of work produces.
    * @param <E> The type of exception this unit of work can throw.
    */
-  interface MutateWork<T, E extends Exception> {
-
-    NoResult.Quiet NOOP = new NoResult.Quiet() {
-      @Override
-      protected void execute(Storage.MutableStoreProvider storeProvider) {
-        // No-op.
-      }
-    };
-
-    /**
-     * Abstracts a unit of work that should either commit a set of changes to storage as
a side
-     * effect of successful completion or else commit no changes at all when an exception
is thrown.
-     *
-     * @param storeProvider A provider to give access to different available stores.
-     * @return the result of the successfully completed unit of work
-     * @throws E if the unit of work could not be completed
-     */
-    T apply(MutableStoreProvider storeProvider) throws E;
+  abstract class MutateWork<T, E extends Exception>
+      implements StorageOperation<MutableStoreProvider, T, E> {
 
     /**
      * A convenient typedef for Work that throws no checked exceptions - it runs quietly.
      *
      * @param <T> The type of result this unit of work produces.
      */
-    interface Quiet<T> extends MutateWork<T, RuntimeException> {
+    public abstract static class Quiet<T> extends MutateWork<T, RuntimeException>
{
       // typedef
     }
 
@@ -131,7 +124,7 @@ public interface Storage {
      *
      * @param <E> The type of exception this unit of work can throw.
      */
-    abstract class NoResult<E extends Exception> implements MutateWork<Void, E>
{
+    public abstract static class NoResult<E extends Exception> extends MutateWork<Void,
E> {
 
       @Override
       public final Void apply(MutableStoreProvider storeProvider) throws E {
@@ -215,12 +208,6 @@ public interface Storage {
   <T, E extends Exception> T write(MutateWork<T, E> work) throws StorageException,
E;
 
   /**
-   * Clean up the underlying storage by optimizing internal data structures. Does not change
-   * externally-visible state but might not run concurrently with write operations.
-   */
-  void snapshot() throws StorageException;
-
-  /**
    * A non-volatile storage that has additional methods to control its lifecycle.
    */
   interface NonVolatileStorage extends Storage {
@@ -243,6 +230,12 @@ public interface Storage {
     void start(MutateWork.NoResult.Quiet initializationLogic) throws StorageException;
 
     /**
+     * Clean up the underlying storage by optimizing internal data structures. Does not change
+     * externally-visible state but might not run concurrently with write operations.
+     */
+    void snapshot() throws StorageException;
+
+    /**
      * Prepares the underlying storage system for clean shutdown.
      */
     void stop();

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/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 fd1be9f..1842210 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
@@ -692,7 +692,6 @@ public class LogStorage extends ForwardingStore
     } catch (StreamAccessException e) {
       throw new StorageException("Failed to create a snapshot", e);
     }
-    super.snapshot();
   }
 
   private void log(Op op) {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
index 30d77cc..283976a 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
@@ -21,6 +21,7 @@ import javax.inject.Inject;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.twitter.common.inject.TimedInterceptor.Timed;
+import com.twitter.common.stats.SlidingStats;
 import com.twitter.common.stats.StatImpl;
 import com.twitter.common.stats.Stats;
 
@@ -29,6 +30,7 @@ import org.apache.aurora.scheduler.storage.JobStore;
 import org.apache.aurora.scheduler.storage.LockStore;
 import org.apache.aurora.scheduler.storage.QuotaStore;
 import org.apache.aurora.scheduler.storage.ReadWriteLockManager;
+import org.apache.aurora.scheduler.storage.ReadWriteLockManager.LockType;
 import org.apache.aurora.scheduler.storage.SchedulerStore;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.TaskStore;
@@ -49,6 +51,13 @@ public class MemStorage implements Storage {
   private final AtomicLong readLockWaitNanos = Stats.exportLong("read_lock_wait_nanos");
   private final AtomicLong writeLockWaitNanos = Stats.exportLong("write_lock_wait_nanos");
 
+  // We choose to not use the @Timed decorator for these stats since nested transactions
are normal
+  // and pollute the stats.
+  private final SlidingStats readStats =
+      new SlidingStats("mem_storage_consistent_read_operation", "nanos");
+  private final SlidingStats writeStats =
+      new SlidingStats("mem_storage_write_operation", "nanos");
+
   private final MutableStoreProvider storeProvider;
   private final ReadWriteLockManager lockManager = new ReadWriteLockManager();
 
@@ -120,52 +129,47 @@ public class MemStorage implements Storage {
         new MemAttributeStore());
   }
 
-  @Timed("mem_storage_consistent_read_operation")
-  @Override
-  public <T, E extends Exception> T consistentRead(Work<T, E> work) throws StorageException,
E {
+  private <S extends StoreProvider, T, E extends Exception> T doWork(
+      LockType lockType,
+      S stores,
+      StorageOperation<S, T, E> work,
+      SlidingStats stats,
+      AtomicLong lockWaitStat) throws StorageException, E {
+
     checkNotNull(work);
 
+    // Perform the work, and only record stats for top-level transactions.  This prevents
+    // over-counting when nested transactions are performed.
     long lockStartNanos = System.nanoTime();
-    boolean topLevelOperation = lockManager.readLock();
+    boolean topLevelOperation = lockManager.lock(lockType);
     if (topLevelOperation) {
-      readLockWaitNanos.addAndGet(System.nanoTime() - lockStartNanos);
+      lockWaitStat.addAndGet(System.nanoTime() - lockStartNanos);
     }
     try {
-      return work.apply(storeProvider);
+      return work.apply(stores);
     } finally {
-      lockManager.readUnlock();
+      lockManager.unlock(lockType);
+      if (topLevelOperation) {
+        stats.accumulate(System.nanoTime() - lockStartNanos);
+      }
     }
   }
 
-  @Timed("mem_storage_weakly_consistent_read_operation")
   @Override
-  public <T, E extends Exception> T weaklyConsistentRead(Work<T, E> work)
-      throws StorageException, E {
-
-    return work.apply(storeProvider);
+  public <T, E extends Exception> T consistentRead(Work<T, E> work) throws StorageException,
E {
+    return doWork(LockType.READ, storeProvider, work, readStats, readLockWaitNanos);
   }
 
-  @Timed("mem_storage_write_operation")
   @Override
-  public <T, E extends Exception> T write(MutateWork<T, E> work)
-      throws StorageException, E {
-
-    checkNotNull(work);
-
-    long lockStartNanos = System.nanoTime();
-    boolean topLevelOperation = lockManager.writeLock();
-    if (topLevelOperation) {
-      writeLockWaitNanos.addAndGet(System.nanoTime() - lockStartNanos);
-    }
-    try {
-      return work.apply(storeProvider);
-    } finally {
-      lockManager.writeUnlock();
-    }
+  public <T, E extends Exception> T write(MutateWork<T, E> work) throws StorageException,
E {
+    return doWork(LockType.WRITE, storeProvider, work, writeStats, writeLockWaitNanos);
   }
 
+  @Timed("mem_storage_weakly_consistent_read_operation")
   @Override
-  public void snapshot() {
-    // No-op.
+  public <T, E extends Exception> T weaklyConsistentRead(Work<T, E> work)
+      throws StorageException, E {
+
+    return work.apply(storeProvider);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index e6a32b8..dccae15 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -108,6 +108,7 @@ import org.apache.aurora.scheduler.storage.JobStore;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork;
+import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
 import org.apache.aurora.scheduler.storage.backup.Recovery;
 import org.apache.aurora.scheduler.storage.backup.Recovery.RecoveryException;
 import org.apache.aurora.scheduler.storage.backup.StorageBackup;
@@ -163,7 +164,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
       },
       Tasks.SCHEDULED_TO_INFO);
 
-  private final Storage storage;
+  private final NonVolatileStorage storage;
   private final SchedulerCore schedulerCore;
   private final LockManager lockManager;
   private final CapabilityValidator sessionValidator;
@@ -177,7 +178,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @Inject
   SchedulerThriftInterface(
-      Storage storage,
+      NonVolatileStorage storage,
       SchedulerCore schedulerCore,
       LockManager lockManager,
       CapabilityValidator sessionValidator,
@@ -202,7 +203,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @VisibleForTesting
   SchedulerThriftInterface(
-      Storage storage,
+      NonVolatileStorage storage,
       SchedulerCore schedulerCore,
       LockManager lockManager,
       CapabilityValidator sessionValidator,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/test/java/org/apache/aurora/scheduler/storage/ReadWriteLockManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/ReadWriteLockManagerTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/ReadWriteLockManagerTest.java
index 5dc7df1..06ce715 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/ReadWriteLockManagerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/ReadWriteLockManagerTest.java
@@ -31,6 +31,8 @@ import com.twitter.common.util.concurrent.ExecutorServiceShutdown;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.aurora.scheduler.storage.ReadWriteLockManager.LockType.READ;
+import static org.apache.aurora.scheduler.storage.ReadWriteLockManager.LockType.WRITE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -55,14 +57,14 @@ public class ReadWriteLockManagerTest extends TearDownTestCase {
 
   @Test
   public void testModeDowngrade() {
-    lockManager.writeLock();
-    lockManager.readLock();
+    lockManager.lock(WRITE);
+    lockManager.lock(READ);
   }
 
   @Test(expected = IllegalStateException.class)
   public void testModeUpgrade() {
-    lockManager.readLock();
-    lockManager.writeLock();
+    lockManager.lock(READ);
+    lockManager.lock(WRITE);
   }
 
   @Test
@@ -73,37 +75,37 @@ public class ReadWriteLockManagerTest extends TearDownTestCase {
     Future<String> slowReadResult = executor.submit(new Callable<String>() {
       @Override
       public String call() throws Exception {
-        lockManager.readLock();
+        lockManager.lock(READ);
         slowReadStarted.countDown();
         fastReadFinished.await();
-        lockManager.readUnlock();
+        lockManager.unlock(READ);
         return "slow";
       }
     });
 
     slowReadStarted.await();
-    lockManager.readLock();
-    lockManager.readUnlock();
+    lockManager.lock(READ);
+    lockManager.unlock(READ);
     fastReadFinished.countDown();
     assertEquals("slow", slowReadResult.get());
   }
 
   @Test
   public void testReentrantReadLock() {
-    assertTrue(lockManager.readLock());
-    assertFalse(lockManager.readLock());
-    lockManager.readUnlock();
-    lockManager.readUnlock();
-    assertTrue(lockManager.readLock());
+    assertTrue(lockManager.lock(READ));
+    assertFalse(lockManager.lock(READ));
+    lockManager.unlock(READ);
+    lockManager.unlock(READ);
+    assertTrue(lockManager.lock(READ));
   }
 
   @Test
   public void testReentrantWriteLock() {
-    assertTrue(lockManager.writeLock());
-    assertFalse(lockManager.writeLock());
-    lockManager.writeUnlock();
-    lockManager.writeUnlock();
-    assertTrue(lockManager.writeLock());
-    assertFalse(lockManager.readLock());
+    assertTrue(lockManager.lock(WRITE));
+    assertFalse(lockManager.lock(WRITE));
+    lockManager.unlock(WRITE);
+    lockManager.unlock(WRITE);
+    assertTrue(lockManager.lock(WRITE));
+    assertFalse(lockManager.lock(READ));
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/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 1f02e84..d6624f4 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
@@ -72,8 +72,10 @@ import org.apache.aurora.scheduler.log.Log.Position;
 import org.apache.aurora.scheduler.log.Log.Stream;
 import org.apache.aurora.scheduler.storage.AttributeStore;
 import org.apache.aurora.scheduler.storage.SnapshotStore;
+import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.ILock;
@@ -184,7 +186,7 @@ public class LogStorageTest extends EasyMockTest {
         createTransaction(Op.saveFrameworkId(new SaveFrameworkId(frameworkId2)));
     expect(entry1.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry1));
     expect(entry2.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry2));
-    expect(stream.readAll()).andReturn(Iterators.<Entry>forArray(entry1, entry2));
+    expect(stream.readAll()).andReturn(Iterators.forArray(entry1, entry2));
 
     final Capture<MutateWork<Void, RuntimeException>> recoveryWork = createCapture();
     expect(storageUtil.storage.write(capture(recoveryWork))).andAnswer(
@@ -229,7 +231,6 @@ public class LogStorageTest extends EasyMockTest {
             return null;
           }
         }).times(2);
-    storageUtil.storage.snapshot();
 
     control.replay();
 
@@ -271,7 +272,12 @@ public class LogStorageTest extends EasyMockTest {
       // Simulate NOOP initialization work
       // Creating a mock and expecting apply(storeProvider) does not work here for whatever
       // reason.
-      MutateWork.NoResult.Quiet initializationLogic = MutateWork.NOOP;
+      MutateWork.NoResult.Quiet initializationLogic = new NoResult.Quiet() {
+        @Override
+        protected void execute(Storage.MutableStoreProvider storeProvider) {
+          // No-op.
+        }
+      };
 
       final Capture<MutateWork.NoResult.Quiet> recoverAndInitializeWork = createCapture();
       storageUtil.storage.write(capture(recoverAndInitializeWork));

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index f0f0e39..4a2d39d 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -77,6 +77,7 @@ import org.apache.aurora.scheduler.state.LockManager.LockException;
 import org.apache.aurora.scheduler.state.MaintenanceController;
 import org.apache.aurora.scheduler.state.SchedulerCore;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
 import org.apache.aurora.scheduler.storage.backup.Recovery;
 import org.apache.aurora.scheduler.storage.backup.StorageBackup;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
@@ -161,7 +162,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
       @Override
       protected void configure() {
         bind(Clock.class).toInstance(new FakeClock());
-        bind(Storage.class).toInstance(storageUtil.storage);
+        bind(NonVolatileStorage.class).toInstance(storageUtil.storage);
         bind(SchedulerCore.class).toInstance(scheduler);
         bind(LockManager.class).toInstance(lockManager);
         bind(CapabilityValidator.class).toInstance(userValidator);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d37a833e/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
index 2254574..09a288a 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
@@ -40,6 +40,7 @@ import org.apache.aurora.scheduler.state.MaintenanceController;
 import org.apache.aurora.scheduler.state.SchedulerCore;
 import org.apache.aurora.scheduler.state.StateManager;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
 import org.apache.aurora.scheduler.storage.backup.Recovery;
 import org.apache.aurora.scheduler.storage.backup.StorageBackup;
 import org.apache.aurora.scheduler.storage.entities.IQuota;
@@ -153,6 +154,7 @@ public class ThriftIT extends EasyMockTest {
             bindMock(StateManager.class);
             storageTestUtil = new StorageTestUtil(ThriftIT.this);
             bind(Storage.class).toInstance(storageTestUtil.storage);
+            bind(NonVolatileStorage.class).toInstance(storageTestUtil.storage);
             bindMock(StorageBackup.class);
             bindMock(ThriftConfiguration.class);
             bind(QuotaManager.class).toInstance(quotaManager);


Mime
View raw message