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/11/13 21:22:20 UTC

[1/5] aurora git commit: Remove the internal SQL database

Repository: aurora
Updated Branches:
  refs/heads/master e0624b27b -> 942760466


http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java b/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
deleted file mode 100644
index 55b9a8b..0000000
--- a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.async;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ScheduledExecutorService;
-
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.easymock.EasyMock;
-import org.easymock.IExpectationSetters;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.expectLastCall;
-import static org.junit.Assert.assertEquals;
-
-public class GatingDelayExecutorTest extends EasyMockTest {
-
-  private static final Amount<Long, Time> ONE_SECOND = Amount.of(1L, Time.SECONDS);
-
-  private ScheduledExecutorService gatedExecutor;
-  private Runnable runnable;
-  private GatingDelayExecutor gatingExecutor;
-
-  @Before
-  public void setUp() {
-    gatedExecutor = createMock(ScheduledExecutorService.class);
-    runnable = createMock(Runnable.class);
-    gatingExecutor = new GatingDelayExecutor(gatedExecutor);
-  }
-
-  @Test
-  public void testGateOpen() {
-    gatedExecutor.execute(runnable);
-
-    control.replay();
-
-    // The gate was not closed, so the work is executed immediately.
-    gatingExecutor.execute(runnable);
-  }
-
-  private IExpectationSetters<?> invokeWorkWhenSubmitted() {
-    return expectLastCall().andAnswer(() -> {
-      ((Runnable) EasyMock.getCurrentArguments()[0]).run();
-      return null;
-    });
-  }
-
-  @Test
-  public void testGateIsThreadSpecific() throws InterruptedException {
-    gatedExecutor.execute(runnable);
-
-    control.replay();
-
-    CountDownLatch gateClosed = new CountDownLatch(1);
-    CountDownLatch unblock = new CountDownLatch(1);
-    Runnable closer = () -> gatingExecutor.closeDuring(() -> {
-      gateClosed.countDown();
-      try {
-        unblock.await();
-      } catch (InterruptedException e) {
-        throw Throwables.propagate(e);
-      }
-      return "hi";
-    });
-    new ThreadFactoryBuilder()
-        .setDaemon(true)
-        .setNameFormat("GateTest")
-        .build()
-        .newThread(closer)
-        .start();
-
-    gateClosed.await();
-    gatingExecutor.execute(runnable);
-    assertQueueSize(0);
-    unblock.countDown();
-  }
-
-  private void assertQueueSize(int size) {
-    assertEquals(size, gatingExecutor.getQueueSize());
-  }
-
-  @Test
-  public void testReentrantClose() {
-    gatedExecutor.execute(runnable);
-    expectLastCall().times(3);
-
-    control.replay();
-
-    gatingExecutor.execute(runnable);
-    assertQueueSize(0);
-
-    String result = gatingExecutor.closeDuring(() -> {
-      gatingExecutor.execute(runnable);
-      assertQueueSize(1);
-
-      String result1 = gatingExecutor.closeDuring(() -> {
-        gatingExecutor.execute(runnable);
-        assertQueueSize(2);
-        return "hello";
-      });
-      assertEquals("hello", result1);
-
-      return "hi";
-    });
-    assertEquals("hi", result);
-    assertQueueSize(0);
-  }
-
-  @Test
-  public void testExecute() {
-    gatedExecutor.execute(runnable);
-    invokeWorkWhenSubmitted();
-    runnable.run();
-    expectLastCall();
-
-    control.replay();
-
-    gatingExecutor.execute(runnable);
-  }
-
-  @Test
-  public void testExecuteAfterDelay() {
-    gatedExecutor.schedule(
-        runnable,
-        ONE_SECOND.getValue().longValue(),
-        ONE_SECOND.getUnit().getTimeUnit());
-    invokeWorkWhenSubmitted();
-    runnable.run();
-
-    control.replay();
-
-    gatingExecutor.execute(runnable, ONE_SECOND);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java b/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
deleted file mode 100644
index b8a419c..0000000
--- a/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.http;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-
-import com.google.inject.Module;
-import com.sun.jersey.api.client.ClientResponse;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class H2ConsoleModuleIT extends AbstractJettyTest {
-  @Override
-  protected Module getChildServletModule() {
-    return new H2ConsoleModule(true);
-  }
-
-  @Test
-  public void testConsoleBinding() {
-    replayAndStart();
-    ClientResponse response = getRequestBuilder(H2ConsoleModule.H2_PATH + "/")
-        .post(ClientResponse.class);
-    assertEquals(ClientResponse.Status.OK.getStatusCode(), response.getStatus());
-    assertEquals(MediaType.TEXT_HTML, response.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
index be91940..d3c7ac9 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
@@ -31,7 +31,6 @@ import com.google.inject.Module;
 import com.google.inject.name.Named;
 import com.google.inject.name.Names;
 import com.google.inject.util.Modules;
-import com.sun.jersey.api.client.ClientResponse;
 
 import org.apache.aurora.gen.AuroraAdmin;
 import org.apache.aurora.gen.JobKey;
@@ -39,18 +38,15 @@ import org.apache.aurora.gen.Response;
 import org.apache.aurora.gen.ResponseCode;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.http.AbstractJettyTest;
-import org.apache.aurora.scheduler.http.H2ConsoleModule;
 import org.apache.aurora.scheduler.http.api.ApiModule;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.thrift.aop.AnnotatedAuroraAdmin;
 import org.apache.aurora.scheduler.thrift.aop.MockDecoratedThrift;
-import org.apache.http.HttpResponse;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.shiro.authc.credential.CredentialsMatcher;
@@ -66,8 +62,6 @@ import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PATH;
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PERM;
 import static org.apache.aurora.scheduler.http.api.ApiModule.API_PATH;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
@@ -89,8 +83,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
       new UsernamePasswordCredentials("backupsvc", "s3cret!!1");
   private static final UsernamePasswordCredentials DEPLOY_SERVICE =
       new UsernamePasswordCredentials("deploysvc", "0_0-x_0");
-  private static final UsernamePasswordCredentials H2_USER =
-      new UsernamePasswordCredentials("dbuser", "pwd");
 
   private static final UsernamePasswordCredentials INCORRECT =
       new UsernamePasswordCredentials("root", "wrong");
@@ -110,7 +102,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
   private static final String ENG_ROLE = "eng";
   private static final String BACKUP_ROLE = "backup";
   private static final String DEPLOY_ROLE = "deploy";
-  private static final String H2_ROLE = "h2access";
   private static final Named SHIRO_AFTER_AUTH_FILTER_ANNOTATION = Names.named("shiro_post_filter");
 
   private Ini ini;
@@ -133,7 +124,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
     users.put(
         DEPLOY_SERVICE.getUserName(),
         COMMA_JOINER.join(DEPLOY_SERVICE.getPassword(), DEPLOY_ROLE));
-    users.put(H2_USER.getUserName(), COMMA_JOINER.join(H2_USER.getPassword(), H2_ROLE));
 
     Ini.Section roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);
     roles.put(ADMIN_ROLE, "*");
@@ -147,7 +137,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
             + ADS_STAGING_JOB.getEnvironment()
             + ":"
             + ADS_STAGING_JOB.getName());
-    roles.put(H2_ROLE, H2_PERM);
 
     auroraAdmin = createMock(AnnotatedAuroraAdmin.class);
     shiroAfterAuthFilter = createMock(Filter.class);
@@ -157,7 +146,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
   protected Module getChildServletModule() {
     return Modules.combine(
         new ApiModule(new ApiModule.Options()),
-        new H2ConsoleModule(true),
         new HttpSecurityModule(
             new IniShiroRealmModule(ini, credentialsMatcher),
             Key.get(Filter.class, SHIRO_AFTER_AUTH_FILTER_ANNOTATION)),
@@ -317,40 +305,4 @@ public class HttpSecurityIT extends AbstractJettyTest {
 
     assertEquals(OK, getAuthenticatedClient(BACKUP_SERVICE).listBackups());
   }
-
-  private HttpResponse callH2Console(Credentials credentials) throws Exception {
-    DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
-
-    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-    credentialsProvider.setCredentials(AuthScope.ANY, credentials);
-    defaultHttpClient.setCredentialsProvider(credentialsProvider);
-    return defaultHttpClient.execute(new HttpPost(formatUrl(H2_PATH + "/")));
-  }
-
-  @Test
-  public void testH2ConsoleUser() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.OK.getStatusCode(),
-        callH2Console(H2_USER).getStatusLine().getStatusCode());
-  }
-
-  @Test
-  public void testH2ConsoleAdmin() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.OK.getStatusCode(),
-        callH2Console(ROOT).getStatusLine().getStatusCode());
-  }
-
-  @Test
-  public void testH2ConsoleUnauthorized() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.UNAUTHORIZED.getStatusCode(),
-        callH2Console(UNPRIVILEGED).getStatusLine().getStatusCode());
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
index 3b6b539..6b18296 100644
--- a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
@@ -14,6 +14,7 @@
 package org.apache.aurora.scheduler.offers;
 
 import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -27,7 +28,6 @@ import org.apache.aurora.common.util.testing.FakeTicker;
 import org.apache.aurora.gen.HostAttributes;
 import org.apache.aurora.gen.MaintenanceMode;
 import org.apache.aurora.scheduler.HostOffer;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverDisconnected;
@@ -538,8 +538,8 @@ public class OfferManagerImplTest extends EasyMockTest {
         RETURN_DELAY,
         Long.MAX_VALUE,
         FAKE_TICKER);
-    DelayExecutor executorMock = createMock(DelayExecutor.class);
-    FakeScheduledExecutor clock = FakeScheduledExecutor.fromDelayExecutor(executorMock);
+    ScheduledExecutorService executorMock = createMock(ScheduledExecutorService.class);
+    FakeScheduledExecutor clock = FakeScheduledExecutor.fromScheduledExecutorService(executorMock);
     addTearDown(clock::assertEmpty);
     offerManager = new OfferManagerImpl(
         driver,

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
index 14e4040..5e5c518 100644
--- a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
@@ -13,6 +13,9 @@
  */
 package org.apache.aurora.scheduler.pruning;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -28,7 +31,6 @@ import org.apache.aurora.common.util.testing.FakeClock;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.base.Tasks;
@@ -53,6 +55,7 @@ import static org.apache.aurora.gen.ScheduleStatus.STARTING;
 import static org.apache.aurora.scheduler.pruning.TaskHistoryPruner.TASKS_PRUNED;
 import static org.apache.aurora.scheduler.testing.BatchWorkerUtil.expectBatchExecute;
 import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.junit.Assert.assertEquals;
 
@@ -64,7 +67,7 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
   private static final Amount<Long, Time> ONE_HOUR = Amount.of(1L, Time.HOURS);
   private static final int PER_JOB_HISTORY = 2;
 
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private FakeClock clock;
   private StateManager stateManager;
   private StorageTestUtil storageUtil;
@@ -75,7 +78,7 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
 
   @Before
   public void setUp() throws Exception {
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     clock = new FakeClock();
     stateManager = createMock(StateManager.class);
     storageUtil = new StorageTestUtil(this);
@@ -310,9 +313,11 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
 
   private Capture<Runnable> expectDelayedPrune(long timestampMillis) {
     Capture<Runnable> capture = createCapture();
-    executor.execute(
+    expect(executor.schedule(
         EasyMock.capture(capture),
-        eq(Amount.of(pruner.calculateTimeout(timestampMillis), Time.MILLISECONDS)));
+        eq(pruner.calculateTimeout(timestampMillis)),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return capture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java b/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
index 8fd501b..1bf3320 100644
--- a/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
@@ -15,6 +15,7 @@ package org.apache.aurora.scheduler.reconciliation;
 
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
 
 import javax.inject.Singleton;
 
@@ -34,7 +35,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.app.LifecycleModule;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.events.PubsubEventModule;
@@ -68,8 +68,8 @@ public class KillRetryTest extends EasyMockTest {
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
     backoffStrategy = createMock(BackoffStrategy.class);
-    final DelayExecutor executorMock = createMock(DelayExecutor.class);
-    clock = FakeScheduledExecutor.fromDelayExecutor(executorMock);
+    final ScheduledExecutorService executorMock = createMock(ScheduledExecutorService.class);
+    clock = FakeScheduledExecutor.fromScheduledExecutorService(executorMock);
     addTearDown(clock::assertEmpty);
     statsProvider = new FakeStatsProvider();
 
@@ -81,7 +81,8 @@ public class KillRetryTest extends EasyMockTest {
           protected void configure() {
             bind(Driver.class).toInstance(driver);
             bind(Storage.class).toInstance(storageUtil.storage);
-            bind(DelayExecutor.class).annotatedWith(AsyncExecutor.class).toInstance(executorMock);
+            bind(ScheduledExecutorService.class).annotatedWith(AsyncExecutor.class)
+                .toInstance(executorMock);
             PubsubEventModule.bindSubscriber(binder(), KillRetry.class);
             bind(KillRetry.class).in(Singleton.class);
             bind(BackoffStrategy.class).toInstance(backoffStrategy);

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
index 9da99c6..71125bc 100644
--- a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
@@ -13,6 +13,8 @@
  */
 package org.apache.aurora.scheduler.reconciliation;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import com.google.common.base.Optional;
@@ -28,7 +30,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
 import org.apache.aurora.gen.TaskEvent;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.state.StateChangeResult;
 import org.apache.aurora.scheduler.state.StateManager;
@@ -59,7 +60,7 @@ public class TaskTimeoutTest extends EasyMockTest {
   private static final Amount<Long, Time> TIMEOUT = Amount.of(1L, Time.MINUTES);
 
   private AtomicLong timedOutTaskCounter;
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private StorageTestUtil storageUtil;
   private StateManager stateManager;
   private FakeClock clock;
@@ -68,7 +69,7 @@ public class TaskTimeoutTest extends EasyMockTest {
 
   @Before
   public void setUp() {
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     storageUtil = new StorageTestUtil(this);
     stateManager = createMock(StateManager.class);
     clock = new FakeClock();
@@ -91,7 +92,11 @@ public class TaskTimeoutTest extends EasyMockTest {
 
   private Capture<Runnable> expectTaskWatch(Amount<Long, Time> expireIn) {
     Capture<Runnable> capture = createCapture();
-    executor.execute(EasyMock.capture(capture), eq(expireIn));
+    expect(executor.schedule(
+        EasyMock.capture(capture),
+        eq(expireIn.as(Time.MILLISECONDS).longValue()),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return capture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
index b88d5f1..fb85876 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
@@ -14,6 +14,7 @@
 package org.apache.aurora.scheduler.scheduling;
 
 import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.RateLimiter;
@@ -27,7 +28,6 @@ import org.apache.aurora.gen.JobKey;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
@@ -70,8 +70,8 @@ public class TaskGroupsTest extends EasyMockTest {
   public void setUp() throws Exception {
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
-    DelayExecutor executor = createMock(DelayExecutor.class);
-    clock = FakeScheduledExecutor.fromDelayExecutor(executor);
+    ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
+    clock = FakeScheduledExecutor.fromScheduledExecutorService(executor);
     backoffStrategy = createMock(BackoffStrategy.class);
     taskScheduler = createMock(TaskScheduler.class);
     rateLimiter = createMock(RateLimiter.class);

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
index 433f791..2501618 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
@@ -13,6 +13,9 @@
  */
 package org.apache.aurora.scheduler.scheduling;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 
@@ -25,7 +28,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskEvent;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.state.StateChangeResult;
@@ -49,7 +51,7 @@ public class TaskThrottlerTest extends EasyMockTest {
 
   private RescheduleCalculator rescheduleCalculator;
   private FakeClock clock;
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private StorageTestUtil storageUtil;
   private StateManager stateManager;
   private TaskThrottler throttler;
@@ -58,7 +60,7 @@ public class TaskThrottlerTest extends EasyMockTest {
   public void setUp() throws Exception {
     rescheduleCalculator = createMock(RescheduleCalculator.class);
     clock = new FakeClock();
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
     stateManager = createMock(StateManager.class);
@@ -119,9 +121,11 @@ public class TaskThrottlerTest extends EasyMockTest {
 
   private Capture<Runnable> expectThrottled(long penaltyMs) {
     Capture<Runnable> stateChangeCapture = createCapture();
-    executor.execute(
+    expect(executor.schedule(
         capture(stateChangeCapture),
-        eq(Amount.of(penaltyMs, Time.MILLISECONDS)));
+        eq(penaltyMs),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return stateChangeCapture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
index 0857974..bcc7438 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
@@ -117,7 +117,6 @@ public class RecoveryTest extends EasyMockTest {
     recovery.commit();
     transaction.getValue().apply(storeProvider);
 
-    snapshot.getValue().unsetDbScript();
     assertEquals(SNAPSHOT1, snapshot.getValue());
   }
 
@@ -147,7 +146,6 @@ public class RecoveryTest extends EasyMockTest {
     recovery.commit();
     transaction.getValue().apply(storeProvider);
 
-    snapshot.getValue().unsetDbScript();
     assertEquals(modified, snapshot.getValue());
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
deleted file mode 100644
index 46dc7f5..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractAttributeStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class AttributeStoreTest extends AbstractAttributeStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
deleted file mode 100644
index dd9da19..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.storage.AbstractCronJobStoreTest;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-
-public class CronJobStoreTest extends AbstractCronJobStoreTest {
-  @Override
-  protected Module getStorageModule() {
-    return Modules.combine(
-        DbModule.testModuleWithWorkQueue(),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        });
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
deleted file mode 100644
index 2229e4e..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.scheduler.async.GatedWorkQueue;
-import org.apache.aurora.scheduler.async.GatedWorkQueue.GatedOperation;
-import org.apache.aurora.scheduler.storage.AttributeStore;
-import org.apache.aurora.scheduler.storage.CronJobStore;
-import org.apache.aurora.scheduler.storage.JobUpdateStore;
-import org.apache.aurora.scheduler.storage.LockStore;
-import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.SchedulerStore;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
-import org.apache.aurora.scheduler.storage.Storage.StorageException;
-import org.apache.aurora.scheduler.storage.Storage.Work;
-import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.ibatis.exceptions.PersistenceException;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.easymock.EasyMock;
-import org.easymock.IExpectationSetters;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-
-public class DbStorageTest extends EasyMockTest {
-  private GatedWorkQueue gatedWorkQueue;
-  private Work.Quiet<String> readWork;
-
-  private DbStorage storage;
-
-  @Before
-  public void setUp() {
-    gatedWorkQueue = createMock(GatedWorkQueue.class);
-    readWork = createMock(new Clazz<Work.Quiet<String>>() { });
-    StatsProvider statsProvider = createMock(StatsProvider.class);
-
-    storage = new DbStorage(
-        createMock(SqlSessionFactory.class),
-        createMock(EnumBackfill.class),
-        gatedWorkQueue,
-        createMock(CronJobStore.Mutable.class),
-        createMock(TaskStore.Mutable.class),
-        createMock(SchedulerStore.Mutable.class),
-        createMock(AttributeStore.Mutable.class),
-        createMock(LockStore.Mutable.class),
-        createMock(QuotaStore.Mutable.class),
-        createMock(JobUpdateStore.Mutable.class),
-        statsProvider);
-  }
-
-  @Test(expected = StorageException.class)
-  public void testReadFails() {
-    expect(readWork.apply(EasyMock.anyObject()))
-        .andThrow(new PersistenceException());
-
-    control.replay();
-
-    storage.read(readWork);
-  }
-
-  @Test
-  public void testRead() {
-    expect(readWork.apply(EasyMock.anyObject())).andReturn("hi");
-
-    control.replay();
-
-    assertEquals("hi", storage.read(readWork));
-  }
-
-  private IExpectationSetters<?> expectGateClosed() throws Exception {
-    return expect(gatedWorkQueue.closeDuring(EasyMock.anyObject()))
-        .andAnswer(() -> {
-          GatedOperation<?, ?> op = (GatedOperation<?, ?>) EasyMock.getCurrentArguments()[0];
-          return op.doWithGateClosed();
-        });
-  }
-
-  @Test
-  public void testGateWithReentrantWrites() throws Exception {
-    expectGateClosed().times(2);
-
-    control.replay();
-
-    storage.write((NoResult.Quiet) storeProvider -> noopWrite());
-  }
-
-  private void noopWrite() {
-    storage.write((NoResult.Quiet) storeProvider -> {
-      // No-op.
-    });
-  }
-
-  @Test
-  public void testFlushWithSeqentialWrites() throws Exception {
-    expectGateClosed().times(2);
-
-    control.replay();
-
-    noopWrite();
-    noopWrite();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
deleted file mode 100644
index c7d437f..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.aurora.common.stats.SlidingStats;
-import org.apache.aurora.common.stats.Stats;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.common.util.Clock;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.plugin.Invocation;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import static junit.framework.TestCase.assertNotNull;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({MappedStatement.class, Method.class})
-public class InstrumentingInterceptorTest extends EasyMockTest {
-  private InstrumentingInterceptor interceptor;
-  private Invocation invocation;
-  private SlidingStats slidingStats;
-
-  private Clock mockClock;
-
-  @Before
-  public void setUp() throws Exception {
-    invocation = createMock(Invocation.class);
-    mockClock = createMock(Clock.class);
-    slidingStats = createMock(SlidingStats.class);
-    interceptor = new InstrumentingInterceptor(mockClock, name -> slidingStats);
-  }
-
-  private void expectGetArgs(Object[] args, int times) {
-    expect(invocation.getArgs()).andReturn(args).times(times);
-  }
-
-  @Test
-  public void testStatIsCreatedOnce() throws Throwable {
-    final AtomicLong factoryCallCount = new AtomicLong(0);
-    interceptor = new InstrumentingInterceptor(mockClock, name -> {
-      factoryCallCount.incrementAndGet();
-      return slidingStats;
-    });
-
-    String statName = "test";
-    MappedStatement fakeMappedStatement = createMock(MappedStatement.class);
-    Object[] args = new Object[] {fakeMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn(statName);
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn(statName);
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    control.replay();
-
-    // Perform the test
-    interceptor.intercept(invocation);
-
-    assertEquals(1L, factoryCallCount.get());
-    interceptor.intercept(invocation);
-    assertEquals(1L, factoryCallCount.get());
-  }
-
-  @Test
-  public void testInterceptMarksMetrics() throws Throwable {
-    MappedStatement fakeMappedStatement = createMock(MappedStatement.class);
-    Object[] args = new Object[] {fakeMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn("test");
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    control.replay();
-
-    // Perform the test
-    Object res = interceptor.intercept(invocation);
-    assertEquals("result", res);
-  }
-
-  @Test
-  public void testInterceptNotAMappedStatement() throws Throwable {
-    interceptor = new InstrumentingInterceptor(mockClock);
-    Method mockMethod = PowerMock.createMock(Method.class);
-
-    Object notAMappedStatement = new Object();
-    Object[] args = new Object[] {notAMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 2);
-
-    expect(invocation.getMethod()).andReturn(mockMethod);
-    expect(invocation.getTarget()).andReturn("test");
-    expect(invocation.proceed()).andReturn(null);
-
-    control.replay();
-
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total_per_sec"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_events"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_per_event"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_events_per_sec"));
-
-    interceptor.intercept(invocation);
-
-    // upon interception of invocation that does not have a valid MappedStatement use
-    // invalid_invocations as the name
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total_per_sec"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_events"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_per_event"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_events_per_sec"));
-
-    assertEquals(1000L, Stats.getVariable("mybatis.invalid_invocations_nanos_total").read());
-    assertEquals(1L, Stats.getVariable("mybatis.invalid_invocations_events").read());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
deleted file mode 100644
index f7e355b..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.inject.Injector;
-
-import org.apache.aurora.scheduler.storage.AbstractJobUpdateStoreTest;
-
-public class JobUpdateStoreTest extends AbstractJobUpdateStoreTest {
-  @Override
-  protected Injector createStorageInjector() {
-    return DbUtil.createStorageInjector(DbModule.testModuleWithWorkQueue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
deleted file mode 100644
index e2965b2..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractLockStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class LockStoreTest extends AbstractLockStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java b/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
deleted file mode 100644
index d594bce..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Optional;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.CharStreams;
-import com.google.inject.Injector;
-
-import org.apache.aurora.scheduler.storage.db.views.MigrationChangelogEntry;
-import org.apache.ibatis.migration.Change;
-import org.apache.ibatis.migration.JavaMigrationLoader;
-import org.apache.ibatis.migration.MigrationLoader;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.junit.Test;
-
-import static org.apache.aurora.scheduler.storage.db.DbModule.testModuleWithWorkQueue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class MigrationManagerImplIT {
-  private Injector createMigrationInjector(MigrationLoader migrationLoader) {
-    return DbUtil.createStorageInjector(
-        testModuleWithWorkQueue(),
-        new DbModule.MigrationManagerModule(migrationLoader));
-  }
-
-  /**
-   * Ensure all changes have been applied and their downgrade scripts stored appropriately.
-   *
-   * @param sqlSessionFactory The sql session factory.
-   * @param loader A migration loader.
-   * @throws Exception If the changes were not applied properly.
-   */
-  private void assertMigrationComplete(
-      SqlSessionFactory sqlSessionFactory,
-      MigrationLoader loader) throws Exception {
-
-    try (SqlSession session = sqlSessionFactory.openSession()) {
-      MigrationMapper mapper = session.getMapper(MigrationMapper.class);
-
-      List<MigrationChangelogEntry> appliedChanges = mapper.selectAll();
-
-      for (Change change : loader.getMigrations()) {
-        Optional<MigrationChangelogEntry> appliedChange = appliedChanges
-            .stream()
-            .filter(c -> c.getId().equals(change.getId()))
-            .findFirst();
-
-        assertTrue(appliedChange.isPresent());
-        assertEquals(
-            CharStreams.toString(loader.getScriptReader(change, true /* undo */)),
-            appliedChange.get().getDowngradeScript());
-      }
-
-      // As long as the tables exist, neither of these statements should fail.
-      try (Connection c = session.getConnection()) {
-        try (PreparedStatement select = c.prepareStatement("SELECT * FROM V001_test_table")) {
-          select.execute();
-        }
-        try (PreparedStatement select = c.prepareStatement("SELECT * FROM V002_test_table2")) {
-          select.execute();
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testMigrate() throws Exception {
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    injector.getInstance(MigrationManager.class).migrate();
-    assertMigrationComplete(injector.getInstance(SqlSessionFactory.class), loader);
-  }
-
-  @Test
-  public void testNoMigrationNecessary() throws Exception {
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    MigrationManager migrationManager = injector.getInstance(MigrationManager.class);
-
-    migrationManager.migrate();
-
-    SqlSessionFactory sqlSessionFactory = injector.getInstance(SqlSessionFactory.class);
-    assertMigrationComplete(sqlSessionFactory, loader);
-
-    // Run the migration a second time, no changes should be made.
-    migrationManager.migrate();
-    assertMigrationComplete(sqlSessionFactory, loader);
-  }
-
-  private void assertRollbackComplete(SqlSessionFactory sqlSessionFactory) throws Exception {
-    try (SqlSession session = sqlSessionFactory.openSession()) {
-      MigrationMapper mapper = session.getMapper(MigrationMapper.class);
-
-      assertTrue(mapper.selectAll().isEmpty());
-      try (Connection c = session.getConnection()) {
-        for (String table : ImmutableList.of("V001_test_table", "V002_test_table2")) {
-          try (PreparedStatement select = c.prepareStatement("SELECT * FROM " + table)) {
-            select.execute();
-            fail("Select from " + table + " should have failed, the table should have been "
-                + "dropped.");
-          } catch (SQLException e) {
-            // This exception is expected.
-            assertTrue(
-                e.getMessage().startsWith("Table \"" + table.toUpperCase() + "\" not found"));
-          }
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testRollback() throws Exception {
-    // Run a normal migration which will apply one the change found in the testmigration package.
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    MigrationManager migrationManager = injector.getInstance(MigrationManager.class);
-
-    migrationManager.migrate();
-
-    // Now we intentionally pass a reference to a non-existent package to ensure that no migrations
-    // are found. As such a rollback is expected to be detected and a downgrade be performed.
-    MigrationLoader rollbackLoader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.nomigrations");
-    Injector rollbackInjector = createMigrationInjector(rollbackLoader);
-    MigrationManager rollbackManager = rollbackInjector.getInstance(MigrationManager.class);
-
-    rollbackManager.migrate();
-
-    assertRollbackComplete(rollbackInjector.getInstance(SqlSessionFactory.class));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
deleted file mode 100644
index 1ed1a12..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-public class MyBatisCacheImplTest {
-  private MyBatisCacheImpl cache;
-
-  @Before
-  public void setUp() {
-    cache = new MyBatisCacheImpl("cache.id");
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testExceptionWithoutSize() {
-    cache.getSize();
-  }
-
-  @Test
-  public void testGetAndSet() {
-    String key = "key";
-    String value = "value";
-
-    cache.setSize(100);
-
-    assertNull(cache.getObject(key));
-
-    cache.putObject(key, value);
-
-    assertEquals(cache.getObject(key), value);
-
-    cache.clear();
-
-    assertNull(cache.getObject(key));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
deleted file mode 100644
index 048db06..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractQuotaStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class QuotaStoreTest extends AbstractQuotaStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
deleted file mode 100644
index 74c9d1d..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.scheduler.base.TaskTestUtil;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.aurora.gen.Resource.diskMb;
-import static org.apache.aurora.gen.Resource.numCpus;
-import static org.apache.aurora.gen.Resource.ramMb;
-import static org.junit.Assert.assertEquals;
-
-public class RowGarbageCollectorTest {
-
-  private static final IJobKey JOB_A = IJobKey.build(new JobKey("roleA", "envA", "jobA"));
-  private static final IJobKey JOB_B = IJobKey.build(new JobKey("roleB", "envB", "jobB"));
-  private static final IScheduledTask TASK_A2 = TaskTestUtil.makeTask("task_a2", JOB_A);
-  private static final ITaskConfig CONFIG_A =
-      ITaskConfig.build(TASK_A2.getAssignedTask().getTask().newBuilder()
-              .setResources(ImmutableSet.of(numCpus(1.0), ramMb(124246), diskMb(1024))));
-  private static final ITaskConfig CONFIG_B = TaskTestUtil.makeConfig(JOB_B);
-
-  private JobKeyMapper jobKeyMapper;
-  private TaskMapper taskMapper;
-  private TaskConfigMapper taskConfigMapper;
-  private RowGarbageCollector rowGc;
-
-  @Before
-  public void setUp() {
-    Injector injector = Guice.createInjector(
-        DbModule.testModuleWithWorkQueue(),
-        new DbModule.GarbageCollectorModule(new DbModule.Options()),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        }
-    );
-
-    rowGc = injector.getInstance(RowGarbageCollector.class);
-    injector.getInstance(Storage.class).prepare();
-    taskMapper = injector.getInstance(TaskMapper.class);
-    jobKeyMapper = injector.getInstance(JobKeyMapper.class);
-    taskConfigMapper = injector.getInstance(TaskConfigMapper.class);
-  }
-
-  @Test
-  public void testNoop() {
-    rowGc.runOneIteration();
-  }
-
-  @Test
-  public void testGarbageCollection() {
-    rowGc.runOneIteration();
-    assertEquals(ImmutableList.of(), jobKeyMapper.selectAll());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_A));
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-
-    jobKeyMapper.merge(JOB_A);
-    rowGc.runOneIteration();
-    assertEquals(ImmutableList.of(), jobKeyMapper.selectAll());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_A));
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-
-    jobKeyMapper.merge(JOB_A);
-    taskConfigMapper.insert(CONFIG_A, new InsertResult());
-    InsertResult a2Insert = new InsertResult();
-    taskConfigMapper.insert(TASK_A2.getAssignedTask().getTask(), a2Insert);
-    taskMapper.insertScheduledTask(TASK_A2, a2Insert.getId(), new InsertResult());
-    jobKeyMapper.merge(JOB_B);
-    taskConfigMapper.insert(CONFIG_B, new InsertResult());
-    rowGc.runOneIteration();
-    // Only job A and config A2 are still referenced, other rows are deleted.
-    assertEquals(ImmutableList.of(JOB_A.newBuilder()), jobKeyMapper.selectAll());
-    // Note: Using the ramMb as a sentinel value, since relations in the TaskConfig are not
-    // populated, therefore full object equivalence cannot easily be used.
-    assertEquals(
-        TASK_A2.getAssignedTask().getTask().getRamMb(),
-        Iterables.getOnlyElement(taskConfigMapper.selectConfigsByJob(JOB_A)).toImmutable()
-            .getRamMb());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
deleted file mode 100644
index 55c4576..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractSchedulerStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class SchedulerStoreTest extends AbstractSchedulerStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
deleted file mode 100644
index 45a2f11..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.storage.AbstractTaskStoreTest;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-
-public class TaskStoreTest extends AbstractTaskStoreTest {
-  @Override
-  protected Module getStorageModule() {
-    return Modules.combine(
-        DbModule.testModuleWithWorkQueue(),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        });
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java b/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
deleted file mode 100644
index 45a5b5e..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.testmigration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V001_TestMigration implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(1L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "A test migration";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE V001_test_table(id int);";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE V001_test_table;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java b/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
deleted file mode 100644
index 621ca4c..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.testmigration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V002_TestMigration2 implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(2L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "A second test migration";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE V002_test_table2(id int);";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE V002_test_table2;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
index 5a28f0b..2d161c8 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
@@ -13,15 +13,8 @@
  */
 package org.apache.aurora.scheduler.storage.log;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.util.Map;
 
-import javax.sql.DataSource;
-
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -64,9 +57,6 @@ import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.db.DbModule;
-import org.apache.aurora.scheduler.storage.db.DbStorage;
-import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
@@ -82,7 +72,6 @@ import org.junit.Test;
 
 import static org.apache.aurora.common.util.testing.FakeBuildInfo.generateBuildInfo;
 import static org.apache.aurora.scheduler.resources.ResourceManager.aggregateFromBag;
-import static org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import static org.apache.aurora.scheduler.storage.log.SnapshotStoreImpl.SNAPSHOT_RESTORE;
 import static org.apache.aurora.scheduler.storage.log.SnapshotStoreImpl.SNAPSHOT_SAVE;
 import static org.junit.Assert.assertEquals;
@@ -93,7 +82,6 @@ public class SnapshotStoreImplIT {
   private static final long NOW = 10335463456L;
   private static final IJobKey JOB_KEY = JobKeys.from("role", "env", "job");
 
-  private Storage storage;
   private SnapshotStoreImpl snapshotStore;
 
   private void setUpStore() {
@@ -105,82 +93,24 @@ public class SnapshotStoreImplIT {
             bind(StatsProvider.class).toInstance(new FakeStatsProvider());
           }
         });
-    storage = injector.getInstance(Storage.class);
 
     FakeClock clock = new FakeClock();
     clock.setNowMillis(NOW);
     snapshotStore = new SnapshotStoreImpl(
         generateBuildInfo(),
         clock,
-        storage,
+        injector.getInstance(Storage.class),
         TaskTestUtil.THRIFT_BACKFILL);
     Stats.flush();
   }
 
-  private static Snapshot makeComparable(Snapshot snapshot) {
-    Snapshot copy = snapshot.deepCopy();
-    // Ignore DB snapshot. It will be tested by asserting the DB data.
-    copy.unsetDbScript();
-    return copy;
-  }
-
-  @Test
-  public void testNoDBTaskStore() {
-    setUpStore();
-    populateStore(storage);
-
-    Snapshot snapshot1 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot1));
-    assertSnapshotSaveStats(1L);
-
-    snapshotStore.applySnapshot(snapshot1);
-    Snapshot snapshot2 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot2));
-    assertEquals(makeComparable(snapshot1), makeComparable(snapshot2));
-    assertSnapshotRestoreStats(1L);
-    assertSnapshotSaveStats(2L);
-  }
-
-  @Test
-  public void testMigrateFromDBStores() {
-    // Produce a snapshot from DbStorage, populating the dbScript field.
-    Injector injector = DbUtil.createStorageInjector(DbModule.testModuleWithWorkQueue());
-    DbStorage dbStorage = injector.getInstance(DbStorage.class);
-    populateStore(dbStorage);
-
-    Snapshot dbScriptSnapshot = new Snapshot();
-    try (Connection c = ((DataSource) dbStorage.getUnsafeStoreAccess()).getConnection()) {
-      try (PreparedStatement ps = c.prepareStatement("SCRIPT")) {
-        try (ResultSet rs = ps.executeQuery()) {
-          ImmutableList.Builder<String> builder = ImmutableList.builder();
-          while (rs.next()) {
-            String columnValue = rs.getString("SCRIPT");
-            builder.add(columnValue + "\n");
-          }
-          dbScriptSnapshot.setDbScript(builder.build());
-        }
-      }
-    } catch (SQLException e) {
-      throw new RuntimeException(e);
-    }
-
-    // Verify that the dbScript snapshot can be loaded into a storage, and the resulting snapshot
-    // fills thrift fields.
-    setUpStore();
-    snapshotStore.applySnapshot(dbScriptSnapshot);
-    Snapshot snapshot2 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot2));
-    assertSnapshotRestoreStats(2L);
-    assertSnapshotSaveStats(2L);
-  }
-
   @Test
   public void testBackfill() {
     setUpStore();
     snapshotStore.applySnapshot(makeNonBackfilled());
 
     Snapshot backfilled = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(backfilled));
+    assertEquals(expected(), backfilled);
     assertSnapshotRestoreStats(1L);
     assertSnapshotSaveStats(1L);
   }
@@ -260,25 +190,6 @@ public class SnapshotStoreImplIT {
     return expected();
   }
 
-  private void populateStore(Storage toPopulate) {
-    toPopulate.write((NoResult.Quiet) store -> {
-      store.getUnsafeTaskStore().saveTasks(ImmutableSet.of(TASK));
-      store.getCronJobStore().saveAcceptedJob(CRON_JOB);
-      store.getQuotaStore().saveQuota(ROLE, QUOTA);
-      store.getAttributeStore().saveHostAttributes(ATTRIBUTES);
-      store.getSchedulerStore().saveFrameworkId(FRAMEWORK_ID);
-      store.getLockStore().saveLock(LOCK);
-      store.getJobUpdateStore().saveJobUpdate(UPDATE.getUpdate(), Optional.of(LOCK.getToken()));
-      store.getJobUpdateStore().saveJobUpdateEvent(
-          UPDATE.getUpdate().getSummary().getKey(),
-          UPDATE.getUpdateEvents().get(0));
-      store.getJobUpdateStore().saveJobInstanceUpdateEvent(
-          UPDATE.getUpdate().getSummary().getKey(),
-          UPDATE.getInstanceEvents().get(0)
-      );
-    });
-  }
-
   private void assertSnapshotSaveStats(long count) {
     for (String stat : snapshotStore.snapshotFieldNames()) {
       assertEquals(count, Stats.getVariable(SNAPSHOT_SAVE + stat + "_events").read());

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
index 66b415c..15e0e30 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
@@ -17,16 +17,12 @@ import com.google.inject.AbstractModule;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
-import org.apache.aurora.common.stats.SlidingStats;
 import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.scheduler.storage.AbstractCronJobStoreTest;
-import org.apache.aurora.scheduler.storage.db.InstrumentingInterceptor;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.junit.Test;
 
 import static org.apache.aurora.scheduler.storage.mem.MemCronJobStore.CRON_JOBS_SIZE;
-import static org.easymock.EasyMock.createMock;
 import static org.junit.Assert.assertEquals;
 
 public class MemCronJobStoreTest extends AbstractCronJobStoreTest {
@@ -42,12 +38,6 @@ public class MemCronJobStoreTest extends AbstractCronJobStoreTest {
           @Override
           protected void configure() {
             bind(StatsProvider.class).toInstance(statsProvider);
-
-            // bindings for mybatis interceptor
-            SlidingStats slidingStats = createMock(SlidingStats.class);
-            bind(InstrumentingInterceptor.class).toInstance(new InstrumentingInterceptor(
-                Clock.SYSTEM_CLOCK, s -> slidingStats
-            ));
           }
         });
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
index 9e75c98..027f2f0 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
@@ -18,18 +18,14 @@ import com.google.inject.AbstractModule;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
-import org.apache.aurora.common.stats.SlidingStats;
 import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.storage.AbstractTaskStoreTest;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.db.InstrumentingInterceptor;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.createMock;
 import static org.junit.Assert.assertEquals;
 
 public class MemTaskStoreTest extends AbstractTaskStoreTest {
@@ -45,12 +41,6 @@ public class MemTaskStoreTest extends AbstractTaskStoreTest {
           @Override
           protected void configure() {
             bind(StatsProvider.class).toInstance(statsProvider);
-
-            // bindings for mybatis interceptor
-            SlidingStats slidingStats = createMock(SlidingStats.class);
-            bind(InstrumentingInterceptor.class).toInstance(new InstrumentingInterceptor(
-                Clock.SYSTEM_CLOCK, s -> slidingStats
-            ));
           }
         });
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
index ce6e5a4..0aea369 100644
--- a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
+++ b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
@@ -27,7 +27,6 @@ import org.apache.aurora.common.collections.Pair;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 
@@ -64,17 +63,21 @@ public final class FakeScheduledExecutor extends FakeClock {
       Object[] args = EasyMock.getCurrentArguments();
       Runnable work = (Runnable) args[0];
       @SuppressWarnings("unchecked")
-      Amount<Long, Time> delay = (Amount<Long, Time>) args[1];
-      addDelayedWork(executor, delay.as(Time.MILLISECONDS), work);
+      long value = (long) args[1];
+      @SuppressWarnings("unchecked")
+      TimeUnit unit = (TimeUnit) args[2];
+
+      addDelayedWork(executor, TimeUnit.MILLISECONDS.convert(value, unit), work);
       return null;
     };
   }
 
-  public static FakeScheduledExecutor fromDelayExecutor(DelayExecutor mock) {
+  public static FakeScheduledExecutor fromScheduledExecutorService(ScheduledExecutorService mock) {
     FakeScheduledExecutor executor = new FakeScheduledExecutor();
-    mock.execute(
+    mock.schedule(
         EasyMock.<Runnable>anyObject(),
-        EasyMock.<Amount<Long, Time>>anyObject());
+        EasyMock.anyLong(),
+        EasyMock.<TimeUnit>anyObject());
     expectLastCall().andAnswer(answerExecuteWithDelay(executor)).anyTimes();
 
     mock.execute(EasyMock.anyObject());


[5/5] aurora git commit: Remove the internal SQL database

Posted by wf...@apache.org.
Remove the internal SQL database

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


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

Branch: refs/heads/master
Commit: 94276046606da4e1491ee3d0e0c29cd3649a82e6
Parents: e0624b2
Author: Bill Farner <wf...@apache.org>
Authored: Mon Nov 13 13:19:28 2017 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Mon Nov 13 13:19:28 2017 -0800

----------------------------------------------------------------------
 RELEASE-NOTES.md                                |   5 +
 .../thrift/org/apache/aurora/gen/storage.thrift |   2 +-
 build.gradle                                    |   6 -
 .../aurora/benchmark/SchedulingBenchmarks.java  |  74 ++-
 .../aurora/benchmark/TaskStoreBenchmarks.java   |  26 -
 .../aurora/scheduler/async/AsyncModule.java     |  25 +-
 .../aurora/scheduler/async/DelayExecutor.java   |  33 -
 .../aurora/scheduler/async/GatedWorkQueue.java  |  41 --
 .../scheduler/async/GatingDelayExecutor.java    |  98 ---
 .../aurora/scheduler/http/H2ConsoleModule.java  |  63 --
 .../http/api/security/HttpSecurityModule.java   |  11 +-
 .../aurora/scheduler/offers/Deferment.java      |  10 +-
 .../scheduler/pruning/TaskHistoryPruner.java    |  12 +-
 .../scheduler/reconciliation/KillRetry.java     |  11 +-
 .../scheduler/reconciliation/TaskTimeout.java   |  14 +-
 .../aurora/scheduler/scheduling/TaskGroups.java |   9 +-
 .../scheduler/scheduling/TaskThrottler.java     |  15 +-
 .../scheduler/storage/db/AttributeMapper.java   |  83 ---
 .../scheduler/storage/db/CronJobMapper.java     |  40 --
 .../scheduler/storage/db/DbAttributeStore.java  |  95 ---
 .../scheduler/storage/db/DbCronJobStore.java    |  84 ---
 .../scheduler/storage/db/DbJobUpdateStore.java  | 268 ---------
 .../scheduler/storage/db/DbLockStore.java       |  81 ---
 .../aurora/scheduler/storage/db/DbModule.java   | 364 -----------
 .../scheduler/storage/db/DbQuotaStore.java      |  82 ---
 .../scheduler/storage/db/DbSchedulerStore.java  |  48 --
 .../aurora/scheduler/storage/db/DbStorage.java  | 242 --------
 .../scheduler/storage/db/DbTaskStore.java       | 207 -------
 .../aurora/scheduler/storage/db/DbUtil.java     |  76 ---
 .../scheduler/storage/db/EnumBackfill.java      |  75 ---
 .../scheduler/storage/db/EnumValueMapper.java   |  31 -
 .../scheduler/storage/db/FrameworkIdMapper.java |  26 -
 .../storage/db/GarbageCollectedTableMapper.java |  33 -
 .../scheduler/storage/db/InsertResult.java      |  36 --
 .../storage/db/InstrumentingInterceptor.java    | 139 -----
 .../db/JobInstanceUpdateEventMapper.java        |  34 --
 .../scheduler/storage/db/JobKeyMapper.java      |  36 --
 .../storage/db/JobUpdateDetailsMapper.java      | 210 -------
 .../storage/db/JobUpdateEventMapper.java        |  34 --
 .../scheduler/storage/db/LockKeyMapper.java     |  49 --
 .../aurora/scheduler/storage/db/LockMapper.java |  53 --
 .../scheduler/storage/db/MigrationManager.java  |  29 -
 .../storage/db/MigrationManagerImpl.java        | 134 -----
 .../scheduler/storage/db/MigrationMapper.java   |  51 --
 .../scheduler/storage/db/MyBatisCacheImpl.java  | 119 ----
 .../scheduler/storage/db/PruneVictim.java       |  40 --
 .../scheduler/storage/db/QuotaMapper.java       |  79 ---
 .../storage/db/RowGarbageCollector.java         |  99 ---
 .../scheduler/storage/db/TaskConfigManager.java | 161 -----
 .../scheduler/storage/db/TaskConfigMapper.java  | 210 -------
 .../aurora/scheduler/storage/db/TaskMapper.java |  99 ---
 .../migration/V001_CreateAppcImagesTable.java   |  46 --
 .../migration/V002_CreateDockerImagesTable.java |  46 --
 .../V003_CreateResourceTypesTable.java          |  56 --
 .../migration/V004_CreateTaskResourceTable.java |  74 ---
 .../V005_CreateQuotaResourceTable.java          |  68 ---
 .../db/migration/V006_PopulateTierField.java    |  51 --
 .../V007_CreateMesosFetcherURIsTable.java       |  46 --
 .../V008_CreateUpdateMetadataTable.java         |  45 --
 .../V009_CreateContainerVolumesTable.java       |  53 --
 .../migration/V010_RemoveUniqueConstraint.java  |  41 --
 .../typehandlers/AbstractTEnumTypeHandler.java  |  70 ---
 .../CronCollisionPolicyTypeHandler.java         |  26 -
 .../JobUpdateActionTypeHandler.java             |  26 -
 .../JobUpdateStatusTypeHandler.java             |  26 -
 .../MaintenanceModeTypeHandler.java             |  26 -
 .../db/typehandlers/ResourceTypeHandler.java    |  26 -
 .../typehandlers/ScheduleStatusTypeHandler.java |  26 -
 .../storage/db/typehandlers/TypeHandlers.java   |  41 --
 .../db/typehandlers/VolumeModeTypeHandler.java  |  23 -
 .../scheduler/storage/db/views/DBResource.java  |  32 -
 .../storage/db/views/DBResourceAggregate.java   |  56 --
 .../scheduler/storage/db/views/DBSaveQuota.java |  29 -
 .../storage/db/views/DbAssginedPort.java        |  30 -
 .../storage/db/views/DbAssignedTask.java        |  48 --
 .../storage/db/views/DbConstraint.java          |  30 -
 .../scheduler/storage/db/views/DbContainer.java |  38 --
 .../scheduler/storage/db/views/DbImage.java     |  38 --
 .../storage/db/views/DbInstanceTaskConfig.java  |  33 -
 .../storage/db/views/DbJobConfiguration.java    |  43 --
 .../scheduler/storage/db/views/DbJobUpdate.java |  36 --
 .../storage/db/views/DbJobUpdateDetails.java    |  33 -
 .../db/views/DbJobUpdateInstructions.java       |  45 --
 .../storage/db/views/DbScheduledTask.java       |  54 --
 .../db/views/DbStoredJobUpdateDetails.java      |  30 -
 .../storage/db/views/DbTaskConfig.java          | 101 ----
 .../storage/db/views/DbTaskConstraint.java      |  45 --
 .../scheduler/storage/db/views/LockRow.java     |  46 --
 .../db/views/MigrationChangelogEntry.java       |  48 --
 .../scheduler/storage/db/views/Pairs.java       |  38 --
 .../storage/log/SnapshotStoreImpl.java          |  86 ---
 .../scheduler/storage/db/AttributeMapper.xml    |  90 ---
 .../scheduler/storage/db/CronJobMapper.xml      | 109 ----
 .../scheduler/storage/db/EnumValueMapper.xml    |  15 -
 .../scheduler/storage/db/FrameworkIdMapper.xml  |  32 -
 .../storage/db/JobInstanceUpdateEventMapper.xml |  33 -
 .../scheduler/storage/db/JobKeyMapper.xml       |  47 --
 .../storage/db/JobUpdateDetailsMapper.xml       | 598 -------------------
 .../storage/db/JobUpdateEventMapper.xml         |  35 --
 .../aurora/scheduler/storage/db/LockMapper.xml  |  83 ---
 .../scheduler/storage/db/MigrationMapper.xml    |  55 --
 .../aurora/scheduler/storage/db/QuotaMapper.xml |  91 ---
 .../scheduler/storage/db/TaskConfigMapper.xml   | 460 --------------
 .../aurora/scheduler/storage/db/TaskMapper.xml  | 241 --------
 .../aurora/scheduler/storage/db/schema.sql      | 392 ------------
 .../aurora/scheduler/async/AsyncModuleTest.java |   3 +-
 .../async/GatingDelayExecutorTest.java          | 151 -----
 .../scheduler/http/H2ConsoleModuleIT.java       |  40 --
 .../http/api/security/HttpSecurityIT.java       |  48 --
 .../scheduler/offers/OfferManagerImplTest.java  |   6 +-
 .../pruning/TaskHistoryPrunerTest.java          |  15 +-
 .../scheduler/reconciliation/KillRetryTest.java |   9 +-
 .../reconciliation/TaskTimeoutTest.java         |  13 +-
 .../scheduler/scheduling/TaskGroupsTest.java    |   6 +-
 .../scheduler/scheduling/TaskThrottlerTest.java |  14 +-
 .../scheduler/storage/backup/RecoveryTest.java  |   2 -
 .../storage/db/AttributeStoreTest.java          |  24 -
 .../scheduler/storage/db/CronJobStoreTest.java  |  39 --
 .../scheduler/storage/db/DbStorageTest.java     | 117 ----
 .../db/InstrumentingInterceptorTest.java        | 162 -----
 .../storage/db/JobUpdateStoreTest.java          |  25 -
 .../scheduler/storage/db/LockStoreTest.java     |  24 -
 .../storage/db/MigrationManagerImplIT.java      | 157 -----
 .../storage/db/MyBatisCacheImplTest.java        |  52 --
 .../scheduler/storage/db/QuotaStoreTest.java    |  24 -
 .../storage/db/RowGarbageCollectorTest.java     | 113 ----
 .../storage/db/SchedulerStoreTest.java          |  24 -
 .../scheduler/storage/db/TaskStoreTest.java     |  39 --
 .../db/testmigration/V001_TestMigration.java    |  40 --
 .../db/testmigration/V002_TestMigration2.java   |  40 --
 .../storage/log/SnapshotStoreImplIT.java        |  93 +--
 .../storage/mem/MemCronJobStoreTest.java        |  10 -
 .../scheduler/storage/mem/MemTaskStoreTest.java |  10 -
 .../testing/FakeScheduledExecutor.java          |  15 +-
 134 files changed, 162 insertions(+), 9091 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/RELEASE-NOTES.md
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 92f9c98..d653b79 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -5,6 +5,11 @@
 
 - Updated to Mesos 1.4.0.
 
+### Deprecations and removals:
+
+- Removed the ability to recover from SQL-based backups and snapshots.  An 0.20.0 scheduler
+  will not be able to recover backups or replicated log data created prior to 0.19.0.
+
 0.19.0
 ======
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/api/src/main/thrift/org/apache/aurora/gen/storage.thrift
----------------------------------------------------------------------
diff --git a/api/src/main/thrift/org/apache/aurora/gen/storage.thrift b/api/src/main/thrift/org/apache/aurora/gen/storage.thrift
index ccb5825..74983ba 100644
--- a/api/src/main/thrift/org/apache/aurora/gen/storage.thrift
+++ b/api/src/main/thrift/org/apache/aurora/gen/storage.thrift
@@ -144,7 +144,7 @@ struct Snapshot {
   8: set<QuotaConfiguration> quotaConfigurations
   9: set<api.Lock> locks
   10: set<StoredJobUpdateDetails> jobUpdateDetails
-  11: list<string> dbScript
+  //11: removed
   //12: removed
 }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index aa416b7..af11991 100644
--- a/build.gradle
+++ b/build.gradle
@@ -87,7 +87,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
   ext.jerseyRev = '1.19'
   ext.junitRev = '4.12'
   ext.logbackRev = '1.2.3'
-  ext.mybatisRev = '3.4.1'
   ext.nettyRev = '4.0.52.Final'
   ext.protobufRev = '3.3.0'
   ext.servletRev = '3.1.0'
@@ -120,7 +119,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
         force "org.apache.zookeeper:zookeeper:${zookeeperRev}"
         force "org.hamcrest:hamcrest-core:1.3"
         force "org.slf4j:slf4j-api:${slf4jRev}"
-        force "org.mybatis:mybatis:${mybatisRev}"
       }
     }
   }
@@ -373,7 +371,6 @@ dependencies {
   compile "com.google.inject:guice:${guiceRev}"
   compile "com.google.inject.extensions:guice-assistedinject:${guiceRev}"
   compile "com.google.protobuf:protobuf-java:${protobufRev}"
-  compile 'com.h2database:h2:1.4.196'
   compile 'com.hubspot.jackson:jackson-datatype-protobuf:0.9.3'
   compile "com.fasterxml.jackson.core:jackson-core:${jacksonRev}"
   compile "com.sun.jersey:jersey-core:${jerseyRev}"
@@ -396,9 +393,6 @@ dependencies {
   compile "org.eclipse.jetty:jetty-server:${jettyDep}"
   compile "org.eclipse.jetty:jetty-servlet:${jettyDep}"
   compile "org.eclipse.jetty:jetty-servlets:${jettyDep}"
-  compile "org.mybatis:mybatis:${mybatisRev}"
-  compile 'org.mybatis:mybatis-guice:3.7'
-  compile 'org.mybatis:mybatis-migrations:3.2.0'
   compile 'org.quartz-scheduler:quartz:2.2.2'
 
   testCompile "com.sun.jersey:jersey-client:${jerseyRev}"

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
index 292bb29..1708a50 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
@@ -15,6 +15,10 @@ package org.apache.aurora.benchmark;
 
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.AbstractExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
 import javax.inject.Singleton;
@@ -46,7 +50,6 @@ import org.apache.aurora.scheduler.HostOffer;
 import org.apache.aurora.scheduler.TaskIdGenerator;
 import org.apache.aurora.scheduler.TierModule;
 import org.apache.aurora.scheduler.async.AsyncModule;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.config.CliOptions;
 import org.apache.aurora.scheduler.config.CommandLine;
@@ -138,20 +141,11 @@ public class SchedulingBenchmarks {
           new PrivateModule() {
             @Override
             protected void configure() {
+
               // We use a no-op executor for async work, as this benchmark is focused on the
               // synchronous scheduling operations.
-              bind(DelayExecutor.class).annotatedWith(AsyncModule.AsyncExecutor.class)
-                  .toInstance(new DelayExecutor() {
-                    @Override
-                    public void execute(Runnable work, Amount<Long, Time> minDelay) {
-                      // No-op.
-                    }
-
-                    @Override
-                    public void execute(Runnable command) {
-                      // No-op.
-                    }
-                  });
+              bind(ScheduledExecutorService.class).annotatedWith(AsyncModule.AsyncExecutor.class)
+                  .toInstance(new NoopExecutor());
               bind(Deferment.class).to(Deferment.Noop.class);
               bind(OfferManager.class).to(OfferManager.OfferManagerImpl.class);
               bind(OfferManager.OfferManagerImpl.class).in(Singleton.class);
@@ -400,4 +394,58 @@ public class SchedulingBenchmarks {
       return ImmutableSet.of("" + System.currentTimeMillis());
     }
   }
+
+  private static class NoopExecutor extends AbstractExecutorService
+      implements ScheduledExecutorService {
+
+    @Override
+    public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
+      return null;
+    }
+
+    @Override
+    public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+      return null;
+    }
+
+    @Override
+    public ScheduledFuture<?> scheduleAtFixedRate(
+        Runnable command, long initialDelay, long period, TimeUnit unit) {
+      return null;
+    }
+
+    @Override
+    public ScheduledFuture<?> scheduleWithFixedDelay(
+        Runnable command, long initialDelay, long delay, TimeUnit unit) {
+      return null;
+    }
+
+    @Override
+    public void shutdown() {
+    }
+
+    @Override
+    public List<Runnable> shutdownNow() {
+      return null;
+    }
+
+    @Override
+    public boolean isShutdown() {
+      return false;
+    }
+
+    @Override
+    public boolean isTerminated() {
+      return false;
+    }
+
+    @Override
+    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+      return false;
+    }
+
+    @Override
+    public void execute(Runnable command) {
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/jmh/java/org/apache/aurora/benchmark/TaskStoreBenchmarks.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/TaskStoreBenchmarks.java b/src/jmh/java/org/apache/aurora/benchmark/TaskStoreBenchmarks.java
index 6f2f9f4..9ec9865 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/TaskStoreBenchmarks.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/TaskStoreBenchmarks.java
@@ -27,7 +27,6 @@ import org.apache.aurora.common.util.testing.FakeClock;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.apache.aurora.scheduler.storage.mem.MemStorageModule;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
@@ -111,29 +110,4 @@ public class TaskStoreBenchmarks {
           storage.read(store -> store.getTaskStore().fetchTasks(Query.unscoped())));
     }
   }
-
-  public static class DBFetchTasksBenchmark extends AbstractFetchTasksBenchmark {
-    @Setup(Level.Trial)
-    @Override
-    public void setUp() {
-      storage = DbUtil.createStorage();
-    }
-
-    @Setup(Level.Iteration)
-    public void setUpIteration() {
-      createTasks(numTasks);
-    }
-
-    @TearDown(Level.Iteration)
-    public void tearDownIteration() {
-      deleteTasks();
-    }
-
-    @Benchmark
-    public int run() {
-      // Iterate through results in case the result is lazily computed.
-      return Iterables.size(
-          storage.read(store -> store.getTaskStore().fetchTasks(Query.unscoped())));
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/async/AsyncModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/async/AsyncModule.java b/src/main/java/org/apache/aurora/scheduler/async/AsyncModule.java
index 68f7ddb..0166d41 100644
--- a/src/main/java/org/apache/aurora/scheduler/async/AsyncModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/async/AsyncModule.java
@@ -81,20 +81,15 @@ public class AsyncModule extends AbstractModule {
       @Override
       protected void configure() {
         bind(ScheduledThreadPoolExecutor.class).toInstance(afterTransaction);
-        bind(ScheduledExecutorService.class).toInstance(afterTransaction);
-
-        bind(GatingDelayExecutor.class).in(Singleton.class);
-        expose(GatingDelayExecutor.class);
-
         bind(RegisterGauges.class).in(Singleton.class);
         expose(RegisterGauges.class);
       }
     });
     SchedulerServicesModule.addAppStartupServiceBinding(binder()).to(RegisterGauges.class);
 
-    bind(Executor.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
-    bind(DelayExecutor.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
-    bind(GatedWorkQueue.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
+    bind(Executor.class).annotatedWith(AsyncExecutor.class).toInstance(afterTransaction);
+    bind(ScheduledExecutorService.class).annotatedWith(AsyncExecutor.class)
+        .toInstance(afterTransaction);
   }
 
   static class RegisterGauges extends AbstractIdleService {
@@ -104,31 +99,19 @@ public class AsyncModule extends AbstractModule {
     @VisibleForTesting
     static final String ASYNC_TASKS_GAUGE = "async_tasks_completed";
 
-    @VisibleForTesting
-    static final String DELAY_QUEUE_GAUGE = "delay_executor_queue_size";
-
     private final StatsProvider statsProvider;
     private final ScheduledThreadPoolExecutor executor;
-    private final GatingDelayExecutor delayExecutor;
 
     @Inject
-    RegisterGauges(
-        StatsProvider statsProvider,
-        ScheduledThreadPoolExecutor executor,
-        GatingDelayExecutor delayExecutor) {
-
+    RegisterGauges(StatsProvider statsProvider, ScheduledThreadPoolExecutor executor) {
       this.statsProvider = requireNonNull(statsProvider);
       this.executor = requireNonNull(executor);
-      this.delayExecutor = requireNonNull(delayExecutor);
     }
 
     @Override
     protected void startUp() {
       statsProvider.makeGauge(TIMEOUT_QUEUE_GAUGE, () -> executor.getQueue().size());
       statsProvider.makeGauge(ASYNC_TASKS_GAUGE, executor::getCompletedTaskCount);
-      // Using a lambda rather than method ref to sidestep a bug in PMD that makes it think
-      // delayExecutor is unused.
-      statsProvider.makeGauge(DELAY_QUEUE_GAUGE, delayExecutor::getQueueSize);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/async/DelayExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/async/DelayExecutor.java b/src/main/java/org/apache/aurora/scheduler/async/DelayExecutor.java
deleted file mode 100644
index c851e5b..0000000
--- a/src/main/java/org/apache/aurora/scheduler/async/DelayExecutor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.async;
-
-import java.util.concurrent.Executor;
-
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-
-/**
- * An executor that supports executing work after a minimum time delay.
- */
-public interface DelayExecutor extends Executor {
-
-  /**
-   * Executes {@code work} after no less than {@code minDelay}.
-   *
-   * @param work Work to execute.
-   * @param minDelay Minimum amount of time to wait before executing the work.
-   */
-  void execute(Runnable work, Amount<Long, Time> minDelay);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/async/GatedWorkQueue.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/async/GatedWorkQueue.java b/src/main/java/org/apache/aurora/scheduler/async/GatedWorkQueue.java
deleted file mode 100644
index 7032271..0000000
--- a/src/main/java/org/apache/aurora/scheduler/async/GatedWorkQueue.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.async;
-
-/**
- * A work queue that only executes pending work when flushed.
- */
-public interface GatedWorkQueue {
-
-  /**
-   * Closes the gate on the work queue for the duration of an operation.
-   *
-   * @param operation Operation to execute while keeping the gate closed.
-   * @param <T> Operation return type.
-   * @param <E> Operation exception type.
-   * @return The value returned by the {@code operation}.
-   * @throws E Exception thrown by the {@code operation}.
-   */
-  <T, E extends Exception> T closeDuring(GatedOperation<T, E> operation) throws E;
-
-  /**
-   * Operation prevents new items from being executed on the work queue.
-   *
-   * @param <T> Operation return type.
-   * @param <E> Operation exception type.
-   */
-  interface GatedOperation<T, E extends Exception> {
-    T doWithGateClosed() throws E;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/async/GatingDelayExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/async/GatingDelayExecutor.java b/src/main/java/org/apache/aurora/scheduler/async/GatingDelayExecutor.java
deleted file mode 100644
index a7240ae..0000000
--- a/src/main/java/org/apache/aurora/scheduler/async/GatingDelayExecutor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.async;
-
-import java.util.Queue;
-import java.util.concurrent.ScheduledExecutorService;
-
-import javax.inject.Inject;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * An executor that may be temporarily gated with {@link #closeDuring(GatedOperation)}.  When the
- * executor is gated, newly-submitted work will be enqueued and executed once the gate is opened as
- * a result of {@link #closeDuring(GatedOperation)} returning.
- */
-class GatingDelayExecutor implements DelayExecutor, GatedWorkQueue {
-
-  private final ScheduledExecutorService gated;
-  private final Queue<Runnable> queue = Lists.newLinkedList();
-
-  /**
-   * Creates a gating delay executor that will gate work from the provided executor.
-   *
-   * @param gated Delegate to execute work with when ungated.
-   */
-  @Inject
-  GatingDelayExecutor(ScheduledExecutorService gated) {
-    this.gated = requireNonNull(gated);
-  }
-
-  private final ThreadLocal<Boolean> isOpen = new ThreadLocal<Boolean>() {
-    @Override
-    protected Boolean initialValue() {
-      return true;
-    }
-  };
-
-  @Override
-  public <T, E extends Exception> T closeDuring(GatedOperation<T, E> operation) throws E {
-    boolean startedOpen = isOpen.get();
-    isOpen.set(false);
-
-    try {
-      return operation.doWithGateClosed();
-    } finally {
-      if (startedOpen) {
-        isOpen.set(true);
-        flush();
-      }
-    }
-  }
-
-  synchronized int getQueueSize() {
-    return queue.size();
-  }
-
-  private synchronized void enqueue(Runnable work) {
-    if (isOpen.get()) {
-      work.run();
-    } else {
-      queue.add(work);
-    }
-  }
-
-  private synchronized void flush() {
-    for (Runnable work : Iterables.consumingIterable(queue)) {
-      work.run();
-    }
-  }
-
-  @Override
-  public synchronized void execute(Runnable command) {
-    enqueue(() -> gated.execute(command));
-  }
-
-  @Override
-  public synchronized void execute(Runnable work, Amount<Long, Time> minDelay) {
-    enqueue(() -> gated.schedule(work, minDelay.getValue(), minDelay.getUnit().getTimeUnit()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/http/H2ConsoleModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/H2ConsoleModule.java b/src/main/java/org/apache/aurora/scheduler/http/H2ConsoleModule.java
deleted file mode 100644
index ee10f47..0000000
--- a/src/main/java/org/apache/aurora/scheduler/http/H2ConsoleModule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.http;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.servlet.ServletModule;
-
-import org.h2.server.web.WebServlet;
-
-/**
- * Binding module for the H2 management console.
- * <p>
- * See: http://www.h2database.com/html/tutorial.html#tutorial_starting_h2_console
- */
-public class H2ConsoleModule extends ServletModule {
-  public static final String H2_PATH = "/h2console";
-  public static final String H2_PERM = "h2_management_console";
-
-  @Parameters(separators = "=")
-  public static class Options {
-    @Parameter(
-        names = "-enable_h2_console",
-        description = "Enable H2 DB management console.",
-        arity = 1)
-    public boolean enableH2Console = false;
-  }
-
-  private final boolean enabled;
-
-  public H2ConsoleModule(Options options) {
-    this(options.enableH2Console);
-  }
-
-  @VisibleForTesting
-  public H2ConsoleModule(boolean enabled) {
-    this.enabled = enabled;
-  }
-
-  @Override
-  protected void configureServlets() {
-    if (enabled) {
-      filter(H2_PATH, H2_PATH + "/*").through(LeaderRedirectFilter.class);
-      serve(H2_PATH, H2_PATH + "/*").with(new WebServlet(), ImmutableMap.of(
-          "webAllowOthers", "true",
-          "ifExists", "true"
-      ));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityModule.java b/src/main/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityModule.java
index 5229450..d81671c 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityModule.java
@@ -54,8 +54,6 @@ import org.apache.shiro.subject.Subject;
 
 import static java.util.Objects.requireNonNull;
 
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PATH;
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PERM;
 import static org.apache.aurora.scheduler.http.api.ApiModule.API_PATH;
 import static org.apache.aurora.scheduler.spi.Permissions.Domain.THRIFT_AURORA_ADMIN;
 import static org.apache.shiro.guice.web.ShiroWebModule.guiceFilterModule;
@@ -68,12 +66,9 @@ import static org.apache.shiro.web.filter.authc.AuthenticatingFilter.PERMISSIVE;
  * included with this package.
  */
 public class HttpSecurityModule extends ServletModule {
-  public static final String HTTP_REALM_NAME = "Apache Aurora Scheduler";
+  private static final String HTTP_REALM_NAME = "Apache Aurora Scheduler";
 
-  private static final String H2_PATTERN = H2_PATH + "/**";
   private static final String ALL_PATTERN = "/**";
-  private static final Key<? extends Filter> K_STRICT =
-      Key.get(ShiroKerberosAuthenticationFilter.class);
   private static final Key<? extends Filter> K_PERMISSIVE =
       Key.get(ShiroKerberosPermissiveAuthenticationFilter.class);
 
@@ -176,8 +171,6 @@ public class HttpSecurityModule extends ServletModule {
       }
     });
     install(guiceFilterModule(API_PATH));
-    install(guiceFilterModule(H2_PATH));
-    install(guiceFilterModule(H2_PATH + "/*"));
     install(new ShiroWebModule(getServletContext()) {
 
       // Replace the ServletContainerSessionManager which causes subject.runAs(...) in a
@@ -200,12 +193,10 @@ public class HttpSecurityModule extends ServletModule {
         // more specific pattern first.
         switch (mechanism) {
           case BASIC:
-            addFilterChain(H2_PATTERN, NO_SESSION_CREATION, AUTHC_BASIC, config(PERMS, H2_PERM));
             addFilterChainWithAfterAuthFilter(config(AUTHC_BASIC, PERMISSIVE));
             break;
 
           case NEGOTIATE:
-            addFilterChain(H2_PATTERN, NO_SESSION_CREATION, K_STRICT, config(PERMS, H2_PERM));
             addFilterChainWithAfterAuthFilter(K_PERMISSIVE);
             break;
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/offers/Deferment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/offers/Deferment.java b/src/main/java/org/apache/aurora/scheduler/offers/Deferment.java
index f3ec886..90a4428 100644
--- a/src/main/java/org/apache/aurora/scheduler/offers/Deferment.java
+++ b/src/main/java/org/apache/aurora/scheduler/offers/Deferment.java
@@ -13,6 +13,8 @@
  */
 package org.apache.aurora.scheduler.offers;
 
+import java.util.concurrent.ScheduledExecutorService;
+
 import javax.inject.Inject;
 
 import com.google.common.base.Supplier;
@@ -20,7 +22,6 @@ import com.google.common.base.Supplier;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 
 import static java.util.Objects.requireNonNull;
 
@@ -51,12 +52,12 @@ public interface Deferment {
    */
   class DelayedDeferment implements Deferment {
     private final Supplier<Amount<Long, Time>> delay;
-    private final DelayExecutor executor;
+    private final ScheduledExecutorService executor;
 
     @Inject
     public DelayedDeferment(
         Supplier<Amount<Long, Time>> delay,
-        @AsyncExecutor DelayExecutor executor) {
+        @AsyncExecutor ScheduledExecutorService executor) {
 
       this.delay = requireNonNull(delay);
       this.executor = requireNonNull(executor);
@@ -64,7 +65,8 @@ public interface Deferment {
 
     @Override
     public void defer(Runnable action) {
-      executor.execute(action, delay.get());
+      Amount<Long, Time> actionDelay = delay.get();
+      executor.schedule(action, actionDelay.getValue(), actionDelay.getUnit().getTimeUnit());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java b/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java
index f778494..3cafbc2 100644
--- a/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java
+++ b/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java
@@ -14,6 +14,8 @@
 package org.apache.aurora.scheduler.pruning;
 
 import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.inject.Inject;
@@ -34,7 +36,6 @@ import org.apache.aurora.gen.apiConstants;
 import org.apache.aurora.scheduler.BatchWorker;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.state.StateManager;
@@ -61,7 +62,7 @@ public class TaskHistoryPruner implements EventSubscriber {
   @VisibleForTesting
   static final String TASKS_PRUNED = "tasks_pruned";
 
-  private final DelayExecutor executor;
+  private final ScheduledExecutorService executor;
   private final StateManager stateManager;
   private final Clock clock;
   private final HistoryPrunnerSettings settings;
@@ -96,7 +97,7 @@ public class TaskHistoryPruner implements EventSubscriber {
 
   @Inject
   TaskHistoryPruner(
-      @AsyncExecutor DelayExecutor executor,
+      @AsyncExecutor ScheduledExecutorService executor,
       StateManager stateManager,
       Clock clock,
       HistoryPrunnerSettings settings,
@@ -161,7 +162,7 @@ public class TaskHistoryPruner implements EventSubscriber {
 
     LOG.debug("Prune task {} in {} ms.", taskId, timeRemaining);
 
-    executor.execute(
+    executor.schedule(
         shutdownOnError(
             lifecycle,
             LOG,
@@ -170,7 +171,8 @@ public class TaskHistoryPruner implements EventSubscriber {
               LOG.info("Pruning expired inactive task " + taskId);
               deleteTasks(ImmutableSet.of(taskId));
             }),
-        Amount.of(timeRemaining, Time.MILLISECONDS));
+        timeRemaining,
+        TimeUnit.MILLISECONDS);
 
     executor.execute(
         shutdownOnError(

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/reconciliation/KillRetry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/reconciliation/KillRetry.java b/src/main/java/org/apache/aurora/scheduler/reconciliation/KillRetry.java
index 31afa7f..53a3a53 100644
--- a/src/main/java/org/apache/aurora/scheduler/reconciliation/KillRetry.java
+++ b/src/main/java/org/apache/aurora/scheduler/reconciliation/KillRetry.java
@@ -13,6 +13,8 @@
  */
 package org.apache.aurora.scheduler.reconciliation;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.inject.Inject;
@@ -21,13 +23,10 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Iterables;
 import com.google.common.eventbus.Subscribe;
 
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.common.util.BackoffStrategy;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.events.PubsubEvent.EventSubscriber;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
@@ -50,7 +49,7 @@ public class KillRetry implements EventSubscriber {
 
   private final Driver driver;
   private final Storage storage;
-  private final DelayExecutor executor;
+  private final ScheduledExecutorService executor;
   private final BackoffStrategy backoffStrategy;
   private final AtomicLong killRetries;
 
@@ -58,7 +57,7 @@ public class KillRetry implements EventSubscriber {
   KillRetry(
       Driver driver,
       Storage storage,
-      @AsyncExecutor DelayExecutor executor,
+      @AsyncExecutor ScheduledExecutorService executor,
       BackoffStrategy backoffStrategy,
       StatsProvider statsProvider) {
 
@@ -86,7 +85,7 @@ public class KillRetry implements EventSubscriber {
 
     void tryLater() {
       retryInMs.set(backoffStrategy.calculateBackoffMs(retryInMs.get()));
-      executor.execute(this, Amount.of(retryInMs.get(), Time.MILLISECONDS));
+      executor.schedule(this, retryInMs.get(), TimeUnit.MILLISECONDS);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/reconciliation/TaskTimeout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/reconciliation/TaskTimeout.java b/src/main/java/org/apache/aurora/scheduler/reconciliation/TaskTimeout.java
index 8e9a0d3..9910e77 100644
--- a/src/main/java/org/apache/aurora/scheduler/reconciliation/TaskTimeout.java
+++ b/src/main/java/org/apache/aurora/scheduler/reconciliation/TaskTimeout.java
@@ -15,6 +15,8 @@ package org.apache.aurora.scheduler.reconciliation;
 
 import java.util.EnumSet;
 import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.inject.Inject;
@@ -29,7 +31,6 @@ import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.events.PubsubEvent.EventSubscriber;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.state.StateChangeResult;
@@ -65,7 +66,7 @@ class TaskTimeout extends AbstractIdleService implements EventSubscriber {
       ScheduleStatus.KILLING,
       ScheduleStatus.DRAINING);
 
-  private final DelayExecutor executor;
+  private final ScheduledExecutorService executor;
   private final Storage storage;
   private final StateManager stateManager;
   private final Amount<Long, Time> timeout;
@@ -73,7 +74,7 @@ class TaskTimeout extends AbstractIdleService implements EventSubscriber {
 
   @Inject
   TaskTimeout(
-      @AsyncExecutor DelayExecutor executor,
+      @AsyncExecutor ScheduledExecutorService executor,
       Storage storage,
       StateManager stateManager,
       Amount<Long, Time> timeout,
@@ -140,7 +141,7 @@ class TaskTimeout extends AbstractIdleService implements EventSubscriber {
         LOG.debug("Retrying timeout of task {} in {}", taskId, NOT_STARTED_RETRY);
         // TODO(wfarner): This execution should not wait for a transaction, but a second executor
         // would be weird.
-        executor.execute(this, NOT_STARTED_RETRY);
+        executor.schedule(this, NOT_STARTED_RETRY.as(Time.MILLISECONDS), TimeUnit.MILLISECONDS);
       }
     }
   }
@@ -148,9 +149,10 @@ class TaskTimeout extends AbstractIdleService implements EventSubscriber {
   @Subscribe
   public void recordStateChange(TaskStateChange change) {
     if (isTransient(change.getNewState())) {
-      executor.execute(
+      executor.schedule(
           new TimedOutTaskHandler(change.getTaskId(), change.getNewState()),
-          timeout);
+          timeout.as(Time.MILLISECONDS),
+          TimeUnit.MILLISECONDS);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/scheduling/TaskGroups.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskGroups.java b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskGroups.java
index 2d3492d..b9987e4 100644
--- a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskGroups.java
+++ b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskGroups.java
@@ -19,6 +19,8 @@ import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.inject.Inject;
@@ -39,7 +41,6 @@ import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.common.util.BackoffStrategy;
 import org.apache.aurora.scheduler.BatchWorker;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.EventSubscriber;
@@ -73,7 +74,7 @@ public class TaskGroups implements EventSubscriber {
   static final String SCHEDULE_ATTEMPTS_BLOCKS = "schedule_attempts_blocks";
 
   private final ConcurrentMap<TaskGroupKey, TaskGroup> groups = Maps.newConcurrentMap();
-  private final DelayExecutor executor;
+  private final ScheduledExecutorService executor;
   private final TaskGroupsSettings settings;
   private final TaskScheduler taskScheduler;
   private final RescheduleCalculator rescheduleCalculator;
@@ -134,7 +135,7 @@ public class TaskGroups implements EventSubscriber {
   @VisibleForTesting
   @Inject
   public TaskGroups(
-      @AsyncExecutor DelayExecutor executor,
+      @AsyncExecutor ScheduledExecutorService executor,
       TaskGroupsSettings settings,
       TaskScheduler taskScheduler,
       RescheduleCalculator rescheduleCalculator,
@@ -153,7 +154,7 @@ public class TaskGroups implements EventSubscriber {
     // Avoid check-then-act by holding the intrinsic lock.  If not done atomically, we could
     // remove a group while a task is being added to it.
     if (group.hasMore()) {
-      executor.execute(evaluate, Amount.of(group.getPenaltyMs(), Time.MILLISECONDS));
+      executor.schedule(evaluate, group.getPenaltyMs(), TimeUnit.MILLISECONDS);
     } else {
       groups.remove(group.getKey());
     }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/scheduling/TaskThrottler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskThrottler.java b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskThrottler.java
index 867c9bd..24692b0 100644
--- a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskThrottler.java
+++ b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskThrottler.java
@@ -13,19 +13,19 @@
  */
 package org.apache.aurora.scheduler.scheduling;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import javax.inject.Inject;
 
 import com.google.common.base.Optional;
 import com.google.common.eventbus.Subscribe;
 
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.stats.SlidingStats;
 import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.scheduler.BatchWorker;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.EventSubscriber;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
@@ -46,7 +46,7 @@ class TaskThrottler implements EventSubscriber {
 
   private final RescheduleCalculator rescheduleCalculator;
   private final Clock clock;
-  private final DelayExecutor executor;
+  private final ScheduledExecutorService executor;
   private final StateManager stateManager;
   private final TaskEventBatchWorker batchWorker;
 
@@ -56,7 +56,7 @@ class TaskThrottler implements EventSubscriber {
   TaskThrottler(
       RescheduleCalculator rescheduleCalculator,
       Clock clock,
-      @AsyncExecutor DelayExecutor executor,
+      @AsyncExecutor ScheduledExecutorService executor,
       StateManager stateManager,
       TaskEventBatchWorker batchWorker) {
 
@@ -74,7 +74,7 @@ class TaskThrottler implements EventSubscriber {
           + rescheduleCalculator.getFlappingPenaltyMs(stateChange.getTask());
       long delayMs = Math.max(0, readyAtMs - clock.nowMillis());
       throttleStats.accumulate(delayMs);
-      executor.execute(() ->
+      executor.schedule((Runnable) () ->
               batchWorker.execute(storeProvider -> {
                 stateManager.changeState(
                     storeProvider,
@@ -84,7 +84,8 @@ class TaskThrottler implements EventSubscriber {
                     Optional.absent());
                 return BatchWorker.NO_RESULT;
               }),
-          Amount.of(delayMs, Time.MILLISECONDS));
+          delayMs,
+          TimeUnit.MILLISECONDS);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/AttributeMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/AttributeMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/AttributeMapper.java
deleted file mode 100644
index a454887..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/AttributeMapper.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.gen.HostAttributes;
-import org.apache.aurora.gen.MaintenanceMode;
-import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper interface for Attribute.xml.
- */
-interface AttributeMapper {
-  /**
-   * Saves attributes for a host, based on {@link IHostAttributes#getHost()}.
-   *
-   * @param attributes Host attributes to save.
-   */
-  void insert(IHostAttributes attributes);
-
-  /**
-   * Deletes all attributes and attribute values associated with a slave.
-   *
-   * @param host Host to delete associated values from.
-   */
-  void deleteAttributeValues(@Param("host") String host);
-
-  /**
-   * Updates the mode and slave ID associated with a host.
-   *
-   * @param host Host to update.
-   * @param mode New host maintenance mode.
-   * @param slaveId New host slave ID.
-   */
-  void updateHostModeAndSlaveId(
-      @Param("host") String host,
-      @Param("mode") MaintenanceMode mode,
-      @Param("slaveId") String slaveId);
-
-  /**
-   * Inserts values in {@link IHostAttributes#getAttributes()}, associating them with
-   * {@link IHostAttributes#getSlaveId()}.
-   *
-   * @param attributes Attributes containing values to insert.
-   */
-  void insertAttributeValues(IHostAttributes attributes);
-
-  /**
-   * Retrieves the host attributes associated with a host.
-   *
-   * @param host Host to fetch attributes for.
-   * @return Attributes associated with {@code host}, or {@code null} if no association exists.
-   */
-  @Nullable
-  HostAttributes select(@Param("host") String host);
-
-  /**
-   * Retrieves all stored host attributes.
-   *
-   * @return All host attributes.
-   */
-  List<HostAttributes> selectAll();
-
-  /**
-   * Deletes all stored attributes and values.
-   */
-  void truncate();
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/CronJobMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/CronJobMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/CronJobMapper.java
deleted file mode 100644
index b07928d..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/CronJobMapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.scheduler.storage.db.views.DbJobConfiguration;
-import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper for cron jobs.
- */
-interface CronJobMapper {
-
-  void merge(@Param("job") IJobConfiguration job, @Param("task_config_id") long taskConfigId);
-
-  void delete(@Param("job") IJobKey job);
-
-  void truncate();
-
-  List<DbJobConfiguration> selectAll();
-
-  @Nullable
-  DbJobConfiguration select(@Param("job") IJobKey job);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
deleted file mode 100644
index fee465b..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Objects;
-import java.util.Set;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-
-import org.apache.aurora.scheduler.storage.AttributeStore;
-import org.apache.aurora.scheduler.storage.entities.IAttribute;
-import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import static org.apache.aurora.common.base.MorePreconditions.checkNotBlank;
-import static org.apache.aurora.common.inject.TimedInterceptor.Timed;
-
-/**
- * Attribute store backed by a relational database.
- */
-class DbAttributeStore implements AttributeStore.Mutable {
-
-  private final AttributeMapper mapper;
-
-  @Inject
-  DbAttributeStore(AttributeMapper mapper) {
-    this.mapper = Objects.requireNonNull(mapper);
-  }
-
-  @Override
-  public void deleteHostAttributes() {
-    mapper.truncate();
-  }
-
-  @Timed("attribute_store_save")
-  @Override
-  public boolean saveHostAttributes(IHostAttributes hostAttributes) {
-    checkNotBlank(hostAttributes.getHost());
-    checkArgument(hostAttributes.isSetMode());
-
-    if (Iterables.any(hostAttributes.getAttributes(), EMPTY_VALUES)) {
-      throw new IllegalArgumentException(
-          "Host attributes contains empty values: " + hostAttributes);
-    }
-
-    Optional<IHostAttributes> existing = getHostAttributes(hostAttributes.getHost());
-    if (existing.equals(Optional.of(hostAttributes))) {
-      return false;
-    } else if (existing.isPresent()) {
-      mapper.updateHostModeAndSlaveId(
-          hostAttributes.getHost(),
-          hostAttributes.getMode(),
-          hostAttributes.getSlaveId());
-    } else {
-      mapper.insert(hostAttributes);
-    }
-
-    mapper.deleteAttributeValues(hostAttributes.getHost());
-    if (!hostAttributes.getAttributes().isEmpty()) {
-      mapper.insertAttributeValues(hostAttributes);
-    }
-
-    return true;
-  }
-
-  private static final Predicate<IAttribute> EMPTY_VALUES =
-      attribute -> attribute.getValues().isEmpty();
-
-  @Timed("attribute_store_fetch_one")
-  @Override
-  public Optional<IHostAttributes> getHostAttributes(String host) {
-    return Optional.fromNullable(mapper.select(host)).transform(IHostAttributes::build);
-  }
-
-  @Timed("attribute_store_fetch_all")
-  @Override
-  public Set<IHostAttributes> getHostAttributes() {
-    return IHostAttributes.setFromBuilders(mapper.selectAll());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbCronJobStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbCronJobStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbCronJobStore.java
deleted file mode 100644
index e48a982..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbCronJobStore.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import javax.inject.Inject;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.FluentIterable;
-
-import org.apache.aurora.common.inject.TimedInterceptor.Timed;
-import org.apache.aurora.scheduler.storage.CronJobStore;
-import org.apache.aurora.scheduler.storage.db.views.DbJobConfiguration;
-import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Cron job store backed by a relational database.
- */
-class DbCronJobStore implements CronJobStore.Mutable {
-  private final CronJobMapper cronJobMapper;
-  private final JobKeyMapper jobKeyMapper;
-  private final TaskConfigManager taskConfigManager;
-
-  @Inject
-  DbCronJobStore(
-      CronJobMapper cronJobMapper,
-      JobKeyMapper jobKeyMapper,
-      TaskConfigManager taskConfigManager) {
-
-    this.cronJobMapper = requireNonNull(cronJobMapper);
-    this.jobKeyMapper = requireNonNull(jobKeyMapper);
-    this.taskConfigManager = requireNonNull(taskConfigManager);
-  }
-
-  @Timed("db_storage_cron_save_accepted_job")
-  @Override
-  public void saveAcceptedJob(IJobConfiguration jobConfig) {
-    requireNonNull(jobConfig);
-    jobKeyMapper.merge(jobConfig.getKey());
-    cronJobMapper.merge(jobConfig, taskConfigManager.insert(jobConfig.getTaskConfig()));
-  }
-
-  @Timed("db_storage_cron_remove_job")
-  @Override
-  public void removeJob(IJobKey jobKey) {
-    requireNonNull(jobKey);
-    cronJobMapper.delete(jobKey);
-  }
-
-  @Timed("db_storage_cron_delete_jobs")
-  @Override
-  public void deleteJobs() {
-    cronJobMapper.truncate();
-  }
-
-  @Timed("db_storage_cron_fetch_jobs")
-  @Override
-  public Iterable<IJobConfiguration> fetchJobs() {
-    return FluentIterable.from(cronJobMapper.selectAll())
-        .transform(DbJobConfiguration::toImmutable)
-        .toList();
-  }
-
-  @Timed("db_storage_cron_fetch_job")
-  @Override
-  public Optional<IJobConfiguration> fetchJob(IJobKey jobKey) {
-    requireNonNull(jobKey);
-    return Optional.fromNullable(cronJobMapper.select(jobKey))
-        .transform(DbJobConfiguration::toImmutable);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/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
deleted file mode 100644
index af854da..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStore.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.inject.Inject;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-
-import org.apache.aurora.common.base.MorePreconditions;
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.gen.JobUpdateAction;
-import org.apache.aurora.gen.JobUpdateStatus;
-import org.apache.aurora.gen.storage.StoredJobUpdateDetails;
-import org.apache.aurora.scheduler.storage.JobUpdateStore;
-import org.apache.aurora.scheduler.storage.Util;
-import org.apache.aurora.scheduler.storage.db.views.DbJobUpdate;
-import org.apache.aurora.scheduler.storage.db.views.DbJobUpdateInstructions;
-import org.apache.aurora.scheduler.storage.db.views.DbStoredJobUpdateDetails;
-import org.apache.aurora.scheduler.storage.entities.IInstanceTaskConfig;
-import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateDetails;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateEvent;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateInstructions;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateQuery;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateSummary;
-import org.apache.aurora.scheduler.storage.entities.IMetadata;
-import org.apache.aurora.scheduler.storage.entities.IRange;
-
-import static java.util.Objects.requireNonNull;
-
-import static org.apache.aurora.common.inject.TimedInterceptor.Timed;
-
-/**
- * A relational database-backed job update store.
- */
-public class DbJobUpdateStore implements JobUpdateStore.Mutable {
-
-  private final JobKeyMapper jobKeyMapper;
-  private final JobUpdateDetailsMapper detailsMapper;
-  private final JobUpdateEventMapper jobEventMapper;
-  private final JobInstanceUpdateEventMapper instanceEventMapper;
-  private final TaskConfigManager taskConfigManager;
-  private final LoadingCache<JobUpdateStatus, AtomicLong> jobUpdateEventStats;
-  private final LoadingCache<JobUpdateAction, AtomicLong> jobUpdateActionStats;
-
-  @Inject
-  DbJobUpdateStore(
-      JobKeyMapper jobKeyMapper,
-      JobUpdateDetailsMapper detailsMapper,
-      JobUpdateEventMapper jobEventMapper,
-      JobInstanceUpdateEventMapper instanceEventMapper,
-      TaskConfigManager taskConfigManager,
-      StatsProvider statsProvider) {
-
-    this.jobKeyMapper = requireNonNull(jobKeyMapper);
-    this.detailsMapper = requireNonNull(detailsMapper);
-    this.jobEventMapper = requireNonNull(jobEventMapper);
-    this.instanceEventMapper = requireNonNull(instanceEventMapper);
-    this.taskConfigManager = requireNonNull(taskConfigManager);
-    this.jobUpdateEventStats = CacheBuilder.newBuilder()
-        .build(new CacheLoader<JobUpdateStatus, AtomicLong>() {
-          @Override
-          public AtomicLong load(JobUpdateStatus status) {
-            return statsProvider.makeCounter(Util.jobUpdateStatusStatName(status));
-          }
-        });
-    for (JobUpdateStatus status : JobUpdateStatus.values()) {
-      jobUpdateEventStats.getUnchecked(status).get();
-    }
-    this.jobUpdateActionStats = CacheBuilder.newBuilder()
-        .build(new CacheLoader<JobUpdateAction, AtomicLong>() {
-          @Override
-          public AtomicLong load(JobUpdateAction action) {
-            return statsProvider.makeCounter(Util.jobUpdateActionStatName(action));
-          }
-        });
-    for (JobUpdateAction action : JobUpdateAction.values()) {
-      jobUpdateActionStats.getUnchecked(action).get();
-    }
-  }
-
-  @Timed("job_update_store_save_update")
-  @Override
-  public void saveJobUpdate(IJobUpdate update, Optional<String> lockToken) {
-    requireNonNull(update);
-    if (!update.getInstructions().isSetDesiredState()
-        && update.getInstructions().getInitialState().isEmpty()) {
-      throw new IllegalArgumentException(
-          "Missing both initial and desired states. At least one is required.");
-    }
-
-    IJobUpdateKey key = update.getSummary().getKey();
-    jobKeyMapper.merge(key.getJob());
-    detailsMapper.insert(update.newBuilder());
-
-    if (lockToken.isPresent()) {
-      detailsMapper.insertLockToken(key, lockToken.get());
-    }
-
-    if (!update.getSummary().getMetadata().isEmpty()) {
-      detailsMapper.insertJobUpdateMetadata(
-          key,
-          IMetadata.toBuildersSet(update.getSummary().getMetadata()));
-    }
-
-    // Insert optional instance update overrides.
-    Set<IRange> instanceOverrides =
-        update.getInstructions().getSettings().getUpdateOnlyTheseInstances();
-
-    if (!instanceOverrides.isEmpty()) {
-      detailsMapper.insertInstanceOverrides(key, IRange.toBuildersSet(instanceOverrides));
-    }
-
-    // Insert desired state task config and instance mappings.
-    if (update.getInstructions().isSetDesiredState()) {
-      IInstanceTaskConfig desired = update.getInstructions().getDesiredState();
-      detailsMapper.insertTaskConfig(
-          key,
-          taskConfigManager.insert(desired.getTask()),
-          true,
-          new InsertResult());
-
-      detailsMapper.insertDesiredInstances(
-          key,
-          IRange.toBuildersSet(MorePreconditions.checkNotBlank(desired.getInstances())));
-    }
-
-    // Insert initial state task configs and instance mappings.
-    if (!update.getInstructions().getInitialState().isEmpty()) {
-      for (IInstanceTaskConfig config : update.getInstructions().getInitialState()) {
-        InsertResult result = new InsertResult();
-        detailsMapper.insertTaskConfig(
-            key,
-            taskConfigManager.insert(config.getTask()),
-            false,
-            result);
-
-        detailsMapper.insertTaskConfigInstances(
-            result.getId(),
-            IRange.toBuildersSet(MorePreconditions.checkNotBlank(config.getInstances())));
-      }
-    }
-  }
-
-  @Timed("job_update_store_save_event")
-  @Override
-  public void saveJobUpdateEvent(IJobUpdateKey key, IJobUpdateEvent event) {
-    jobEventMapper.insert(key, event.newBuilder());
-    jobUpdateEventStats.getUnchecked(event.getStatus()).incrementAndGet();
-  }
-
-  @Timed("job_update_store_save_instance_event")
-  @Override
-  public void saveJobInstanceUpdateEvent(IJobUpdateKey key, IJobInstanceUpdateEvent event) {
-    instanceEventMapper.insert(key, event.newBuilder());
-    jobUpdateActionStats.getUnchecked(event.getAction()).incrementAndGet();
-  }
-
-  @Timed("job_update_store_delete_all")
-  @Override
-  public void deleteAllUpdatesAndEvents() {
-    detailsMapper.truncate();
-  }
-
-  private static final Function<PruneVictim, IJobUpdateKey> GET_UPDATE_KEY =
-      victim -> IJobUpdateKey.build(victim.getUpdate());
-
-  @Timed("job_update_store_prune_history")
-  @Override
-  public Set<IJobUpdateKey> pruneHistory(int perJobRetainCount, long historyPruneThresholdMs) {
-    ImmutableSet.Builder<IJobUpdateKey> pruned = ImmutableSet.builder();
-
-    Set<Long> jobKeyIdsToPrune = detailsMapper.selectJobKeysForPruning(
-        perJobRetainCount,
-        historyPruneThresholdMs);
-
-    for (long jobKeyId : jobKeyIdsToPrune) {
-      Set<PruneVictim> pruneVictims = detailsMapper.selectPruneVictims(
-          jobKeyId,
-          perJobRetainCount,
-          historyPruneThresholdMs);
-
-      detailsMapper.deleteCompletedUpdates(
-          FluentIterable.from(pruneVictims).transform(PruneVictim::getRowId).toSet());
-      pruned.addAll(FluentIterable.from(pruneVictims).transform(GET_UPDATE_KEY));
-    }
-
-    return pruned.build();
-  }
-
-  @Timed("job_update_store_fetch_summaries")
-  @Override
-  public List<IJobUpdateSummary> fetchJobUpdateSummaries(IJobUpdateQuery query) {
-    return IJobUpdateSummary.listFromBuilders(detailsMapper.selectSummaries(query.newBuilder()));
-  }
-
-  @Timed("job_update_store_fetch_details_list")
-  @Override
-  public List<IJobUpdateDetails> fetchJobUpdateDetails(IJobUpdateQuery query) {
-    return FluentIterable
-        .from(detailsMapper.selectDetailsList(query.newBuilder()))
-        .transform(DbStoredJobUpdateDetails::toThrift)
-        .transform(StoredJobUpdateDetails::getDetails)
-        .transform(IJobUpdateDetails::build)
-        .toList();
-  }
-
-  @Timed("job_update_store_fetch_details")
-  @Override
-  public Optional<IJobUpdateDetails> fetchJobUpdateDetails(final IJobUpdateKey key) {
-    return Optional.fromNullable(detailsMapper.selectDetails(key))
-        .transform(DbStoredJobUpdateDetails::toThrift)
-        .transform(StoredJobUpdateDetails::getDetails)
-        .transform(IJobUpdateDetails::build);
-  }
-
-  @Timed("job_update_store_fetch_update")
-  @Override
-  public Optional<IJobUpdate> fetchJobUpdate(IJobUpdateKey key) {
-    return Optional.fromNullable(detailsMapper.selectUpdate(key))
-        .transform(DbJobUpdate::toImmutable);
-  }
-
-  @Timed("job_update_store_fetch_instructions")
-  @Override
-  public Optional<IJobUpdateInstructions> fetchJobUpdateInstructions(IJobUpdateKey key) {
-    return Optional.fromNullable(detailsMapper.selectInstructions(key))
-        .transform(DbJobUpdateInstructions::toImmutable);
-  }
-
-  @Timed("job_update_store_fetch_all_details")
-  @Override
-  public Set<StoredJobUpdateDetails> fetchAllJobUpdateDetails() {
-    return FluentIterable.from(detailsMapper.selectAllDetails())
-        .transform(DbStoredJobUpdateDetails::toThrift)
-        .toSet();
-  }
-
-  @Timed("job_update_store_fetch_instance_events")
-  @Override
-  public List<IJobInstanceUpdateEvent> fetchInstanceEvents(IJobUpdateKey key, int instanceId) {
-    return IJobInstanceUpdateEvent.listFromBuilders(
-        detailsMapper.selectInstanceUpdateEvents(key, instanceId));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbLockStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbLockStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbLockStore.java
deleted file mode 100644
index 9e28550..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbLockStore.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-
-import com.google.inject.Inject;
-
-import org.apache.aurora.GuavaUtils;
-import org.apache.aurora.scheduler.storage.LockStore;
-import org.apache.aurora.scheduler.storage.db.views.LockRow;
-import org.apache.aurora.scheduler.storage.entities.ILock;
-import org.apache.aurora.scheduler.storage.entities.ILockKey;
-
-import static java.util.Objects.requireNonNull;
-
-import static org.apache.aurora.common.inject.TimedInterceptor.Timed;
-
-/**
- * A relational database-backed lock store.
- */
-class DbLockStore implements LockStore.Mutable {
-
-  private final LockMapper mapper;
-  private final LockKeyMapper lockKeyMapper;
-
-  @Inject
-  DbLockStore(LockMapper mapper, LockKeyMapper lockKeyMapper) {
-    this.mapper = requireNonNull(mapper);
-    this.lockKeyMapper = requireNonNull(lockKeyMapper);
-  }
-
-  @Timed("lock_store_save_lock")
-  @Override
-  public void saveLock(ILock lock) {
-    lockKeyMapper.insert(lock.getKey());
-    mapper.insert(lock.newBuilder());
-  }
-
-  @Timed("lock_store_remove_lock")
-  @Override
-  public void removeLock(ILockKey lockKey) {
-    mapper.delete(lockKey.newBuilder());
-  }
-
-  @Timed("lock_store_delete_locks")
-  @Override
-  public void deleteLocks() {
-    mapper.truncate();
-  }
-
-  @Timed("lock_store_fetch_locks")
-  @Override
-  public Set<ILock> fetchLocks() {
-    return mapper.selectAll().stream().map(TO_ROW).collect(GuavaUtils.toImmutableSet());
-  }
-
-  @Timed("lock_store_fetch_lock")
-  @Override
-  public Optional<ILock> fetchLock(ILockKey lockKey) {
-    return Optional.ofNullable(mapper.select(lockKey.newBuilder())).map(TO_ROW);
-  }
-
-  /**
-   * LockRow converter to satisfy the ILock interface.
-   */
-  private static final Function<LockRow, ILock> TO_ROW = input -> ILock.build(input.getLock());
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
deleted file mode 100644
index 7bd37f7..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.inject.Singleton;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Parameters;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.AbstractScheduledService;
-import com.google.inject.AbstractModule;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.PrivateModule;
-import com.google.inject.TypeLiteral;
-import com.google.inject.util.Modules;
-
-import org.apache.aurora.common.inject.Bindings.KeyFactory;
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.scheduler.SchedulerServicesModule;
-import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.GatedWorkQueue;
-import org.apache.aurora.scheduler.config.types.TimeAmount;
-import org.apache.aurora.scheduler.storage.AttributeStore;
-import org.apache.aurora.scheduler.storage.CronJobStore;
-import org.apache.aurora.scheduler.storage.JobUpdateStore;
-import org.apache.aurora.scheduler.storage.LockStore;
-import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.SchedulerStore;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.db.typehandlers.TypeHandlers;
-import org.apache.ibatis.migration.JavaMigrationLoader;
-import org.apache.ibatis.migration.MigrationLoader;
-import org.apache.ibatis.session.AutoMappingBehavior;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
-import org.mybatis.guice.MyBatisModule;
-import org.mybatis.guice.datasource.builtin.PooledDataSourceProvider;
-import org.mybatis.guice.datasource.helper.JdbcHelper;
-
-import static java.util.Objects.requireNonNull;
-
-import static com.google.inject.name.Names.bindProperties;
-
-/**
- * Binding module for a relational database storage system.
- */
-public final class DbModule extends PrivateModule {
-
-  @Parameters(separators = "=")
-  public static class Options {
-    @Parameter(names = "-enable_db_metrics",
-        description =
-            "Whether to use MyBatis interceptor to measure the timing of intercepted Statements.",
-        arity = 1)
-    public boolean enableDbMetrics = true;
-
-    @Parameter(names = "-slow_query_log_threshold",
-        description = "Log all queries that take at least this long to execute.")
-    public TimeAmount slowQueryLogThreshold = new TimeAmount(25, Time.MILLISECONDS);
-
-    @Parameter(names = "-db_row_gc_interval",
-        description = "Interval on which to scan the database for unused row references.")
-    public TimeAmount dbRowGcInterval = new TimeAmount(2, Time.HOURS);
-
-    // http://h2database.com/html/grammar.html#set_lock_timeout
-    @Parameter(names = "-db_lock_timeout", description = "H2 table lock timeout")
-    public TimeAmount h2LockTimeout = new TimeAmount(1, Time.MINUTES);
-
-    @Parameter(names = "-db_max_active_connection_count",
-        description = "Max number of connections to use with database via MyBatis")
-    public int mybatisMaxActiveConnectionCount = -1;
-
-    @Parameter(names = "-db_max_idle_connection_count",
-        description = "Max number of idle connections to the database via MyBatis")
-    public int mybatisMaxIdleConnectionCount = -1;
-  }
-
-  private static final Set<Class<?>> MAPPER_CLASSES = ImmutableSet.<Class<?>>builder()
-      .add(AttributeMapper.class)
-      .add(CronJobMapper.class)
-      .add(EnumValueMapper.class)
-      .add(FrameworkIdMapper.class)
-      .add(JobInstanceUpdateEventMapper.class)
-      .add(JobKeyMapper.class)
-      .add(JobUpdateEventMapper.class)
-      .add(JobUpdateDetailsMapper.class)
-      .add(LockMapper.class)
-      .add(MigrationMapper.class)
-      .add(QuotaMapper.class)
-      .add(TaskConfigMapper.class)
-      .add(TaskMapper.class)
-      .build();
-
-  private final Options options;
-  private final KeyFactory keyFactory;
-  private final String jdbcSchema;
-
-  private DbModule(
-      Options options,
-      KeyFactory keyFactory,
-      String dbName,
-      Map<String, String> jdbcUriArgs) {
-
-    this.options = requireNonNull(options);
-    this.keyFactory = requireNonNull(keyFactory);
-
-    Map<String, String> args = ImmutableMap.<String, String>builder()
-        .putAll(jdbcUriArgs)
-        // READ COMMITTED transaction isolation.  More details here
-        // http://www.h2database.com/html/advanced.html?#transaction_isolation
-        .put("LOCK_MODE", "3")
-        // Send log messages from H2 to SLF4j
-        // See http://www.h2database.com/html/features.html#other_logging
-        .put("TRACE_LEVEL_FILE", "4")
-        // Enable Query Statistics
-        .put("QUERY_STATISTICS", "TRUE")
-        // Configure the lock timeout
-        .put("LOCK_TIMEOUT", options.h2LockTimeout.as(Time.MILLISECONDS).toString())
-        .build();
-    this.jdbcSchema = dbName + ";" + Joiner.on(";").withKeyValueSeparator("=").join(args);
-  }
-
-  /**
-   * Creates a module that will prepare a volatile storage system suitable for use in a production
-   * environment.
-   *
-   * @param keyFactory Binding scope for the storage system.
-   * @return A new database module for production.
-   */
-  public static Module productionModule(KeyFactory keyFactory, DbModule.Options options) {
-    return new DbModule(
-        options,
-        keyFactory,
-        "aurora",
-        ImmutableMap.of("DB_CLOSE_DELAY", "-1"));
-  }
-
-  @VisibleForTesting
-  public static Module testModule(KeyFactory keyFactory) {
-    DbModule.Options options = new DbModule.Options();
-    return new DbModule(
-        options,
-        keyFactory,
-        "testdb-" + UUID.randomUUID().toString(),
-        // A non-zero close delay is used here to avoid eager database cleanup in tests that
-        // make use of multiple threads.  Since all test databases are separately scoped by the
-        // included UUID, multiple DB instances will overlap in time but they should be distinct
-        // in content.
-        ImmutableMap.of("DB_CLOSE_DELAY", "5"));
-  }
-
-  /**
-   * Same as {@link #testModuleWithWorkQueue(KeyFactory)} but with default task store and
-   * key factory.
-   *
-   * @return A new database module for testing.
-   */
-  @VisibleForTesting
-  public static Module testModule() {
-    return testModule(KeyFactory.PLAIN);
-  }
-
-  /**
-   * Creates a module that will prepare a private in-memory database, using a specific task store
-   * implementation bound within the key factory and provided module.
-   *
-   * @param keyFactory Key factory to use.
-   * @return A new database module for testing.
-   */
-  @VisibleForTesting
-  public static Module testModuleWithWorkQueue(KeyFactory keyFactory) {
-    return Modules.combine(
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(GatedWorkQueue.class).annotatedWith(AsyncExecutor.class).toInstance(
-                new GatedWorkQueue() {
-                  @Override
-                  public <T, E extends Exception> T closeDuring(
-                      GatedOperation<T, E> operation) throws E {
-
-                    return operation.doWithGateClosed();
-                  }
-                });
-          }
-        },
-        testModule(keyFactory)
-    );
-  }
-
-  /**
-   * Same as {@link #testModuleWithWorkQueue(KeyFactory)} but with default key factory.
-   *
-   * @return A new database module for testing.
-   */
-  @VisibleForTesting
-  public static Module testModuleWithWorkQueue() {
-    return testModuleWithWorkQueue(KeyFactory.PLAIN);
-  }
-
-  private <T> void bindStore(Class<T> binding, Class<? extends T> impl) {
-    bind(binding).to(impl);
-    bind(impl).in(Singleton.class);
-    Key<T> key = keyFactory.create(binding);
-    bind(key).to(impl);
-    expose(key);
-  }
-
-  @Override
-  protected void configure() {
-    install(new MyBatisModule() {
-      @Override
-      protected void initialize() {
-        if (options.enableDbMetrics) {
-          addInterceptorClass(InstrumentingInterceptor.class);
-        }
-
-        bindProperties(binder(), ImmutableMap.of("JDBC.schema", jdbcSchema));
-        install(JdbcHelper.H2_IN_MEMORY_NAMED);
-
-        // We have no plans to take advantage of multiple DB environments. This is a
-        // required property though, so we use an unnamed environment.
-        environmentId("");
-
-        bindTransactionFactoryType(JdbcTransactionFactory.class);
-        bindDataSourceProviderType(PooledDataSourceProvider.class);
-        addMapperClasses(MAPPER_CLASSES);
-
-        // Full auto-mapping enables population of nested objects with minimal mapper configuration.
-        // Docs on settings can be found here:
-        // http://mybatis.github.io/mybatis-3/configuration.html#settings
-        autoMappingBehavior(AutoMappingBehavior.FULL);
-
-        addTypeHandlersClasses(TypeHandlers.getAll());
-
-        bind(new TypeLiteral<Amount<Long, Time>>() { })
-            .toInstance(options.slowQueryLogThreshold);
-
-        // Enable a ping query which will prevent the use of invalid connections in the
-        // connection pool.
-        bindProperties(binder(), ImmutableMap.of("mybatis.pooled.pingEnabled", "true"));
-        bindProperties(binder(), ImmutableMap.of("mybatis.pooled.pingQuery", "SELECT 1;"));
-
-        if (options.mybatisMaxActiveConnectionCount > 0) {
-          String val = String.valueOf(options.mybatisMaxActiveConnectionCount);
-          bindProperties(binder(), ImmutableMap.of("mybatis.pooled.maximumActiveConnections", val));
-        }
-
-        if (options.mybatisMaxIdleConnectionCount > 0) {
-          String val = String.valueOf(options.mybatisMaxIdleConnectionCount);
-          bindProperties(binder(), ImmutableMap.of("mybatis.pooled.maximumIdleConnections", val));
-        }
-
-        // Exposed for unit tests.
-        bind(TaskConfigManager.class);
-        expose(TaskConfigManager.class);
-
-        // TODO(wfarner): Don't expose these bindings once the task store is directly bound here.
-        expose(TaskMapper.class);
-        expose(TaskConfigManager.class);
-        expose(JobKeyMapper.class);
-      }
-    });
-    expose(keyFactory.create(CronJobStore.Mutable.class));
-    expose(keyFactory.create(TaskStore.Mutable.class));
-
-    bindStore(AttributeStore.Mutable.class, DbAttributeStore.class);
-    bindStore(LockStore.Mutable.class, DbLockStore.class);
-    bindStore(QuotaStore.Mutable.class, DbQuotaStore.class);
-    bindStore(SchedulerStore.Mutable.class, DbSchedulerStore.class);
-    bindStore(JobUpdateStore.Mutable.class, DbJobUpdateStore.class);
-    bindStore(TaskStore.Mutable.class, DbTaskStore.class);
-    bindStore(CronJobStore.Mutable.class, DbCronJobStore.class);
-
-    Key<Storage> storageKey = keyFactory.create(Storage.class);
-    bind(storageKey).to(DbStorage.class);
-    bind(DbStorage.class).in(Singleton.class);
-    expose(storageKey);
-
-    bind(EnumBackfill.class).to(EnumBackfill.EnumBackfillImpl.class);
-    bind(EnumBackfill.EnumBackfillImpl.class).in(Singleton.class);
-    expose(EnumBackfill.class);
-
-    expose(DbStorage.class);
-    expose(SqlSessionFactory.class);
-    expose(TaskMapper.class);
-    expose(TaskConfigMapper.class);
-    expose(JobKeyMapper.class);
-  }
-
-  /**
-   * Module that sets up a periodic database garbage-collection routine.
-   */
-  public static class GarbageCollectorModule extends AbstractModule {
-
-    private final Options options;
-
-    public GarbageCollectorModule(Options options) {
-      this.options = options;
-    }
-
-    @Override
-    protected void configure() {
-      install(new PrivateModule() {
-        @Override
-        protected void configure() {
-          bind(RowGarbageCollector.class).in(Singleton.class);
-          bind(AbstractScheduledService.Scheduler.class).toInstance(
-              AbstractScheduledService.Scheduler.newFixedRateSchedule(
-                  0L,
-                  options.dbRowGcInterval.getValue(),
-                  options.dbRowGcInterval.getUnit().getTimeUnit()));
-          expose(RowGarbageCollector.class);
-        }
-      });
-      SchedulerServicesModule.addSchedulerActiveServiceBinding(binder())
-          .to(RowGarbageCollector.class);
-    }
-  }
-
-  public static class MigrationManagerModule extends PrivateModule {
-    private static final String MIGRATION_PACKAGE =
-        "org.apache.aurora.scheduler.storage.db.migration";
-
-    private final MigrationLoader migrationLoader;
-
-    public MigrationManagerModule() {
-      this.migrationLoader = new JavaMigrationLoader(MIGRATION_PACKAGE);
-    }
-
-    public MigrationManagerModule(MigrationLoader migrationLoader) {
-      this.migrationLoader = requireNonNull(migrationLoader);
-    }
-
-    @Override
-    protected void configure() {
-      bind(MigrationLoader.class).toInstance(migrationLoader);
-
-      bind(MigrationManager.class).to(MigrationManagerImpl.class);
-      expose(MigrationManager.class);
-    }
-  }
-}


[3/5] aurora git commit: Remove the internal SQL database

Posted by wf...@apache.org.
http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java
deleted file mode 100644
index cda55c5..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.aurora.common.collections.Pair;
-import org.apache.aurora.scheduler.storage.db.views.DbTaskConfig;
-import org.apache.aurora.scheduler.storage.entities.IConstraint;
-import org.apache.aurora.scheduler.storage.entities.IDockerContainer;
-import org.apache.aurora.scheduler.storage.entities.IDockerParameter;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.aurora.scheduler.storage.entities.ILimitConstraint;
-import org.apache.aurora.scheduler.storage.entities.IMesosFetcherURI;
-import org.apache.aurora.scheduler.storage.entities.IMetadata;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-import org.apache.aurora.scheduler.storage.entities.IValueConstraint;
-import org.apache.aurora.scheduler.storage.entities.IVolume;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper for task config objects.
- */
-interface TaskConfigMapper extends GarbageCollectedTableMapper {
-
-  /**
-   * Inserts fields from a task config into the {@code task_configs} table.
-   *
-   * @param config Configuration to insert.
-   * @param result Container for auto-generated ID of the inserted row.
-   */
-  void insert(
-      @Param("config") ITaskConfig config,
-      @Param("result") InsertResult result);
-
-  /**
-   * Gets all task config rows referenced by a job.
-   *
-   * @param job Job to look up.
-   * @return Task config row container.
-   */
-  List<DbTaskConfig> selectConfigsByJob(IJobKey job);
-
-  /**
-   * Inserts the constraint association within an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param constraint Constraint to insert.
-   * @param result Container for auto-generated ID of the inserted row.
-   */
-  void insertConstraint(
-      @Param("configId") long configId,
-      @Param("constraint") IConstraint constraint,
-      @Param("result") InsertResult result);
-
-  /**
-   * Inserts the limit constraint association within an {@link IConstraint}.
-   *
-   * @param constraintId Constraint ID.
-   * @param constraint Constraint to insert.
-   */
-  void insertLimitConstraint(
-      @Param("constraintId") long constraintId,
-      @Param("constraint") ILimitConstraint constraint);
-
-  /**
-   * Inserts the value constraint association within an {@link IConstraint}.
-   *
-   * @param constraintId Constraint ID.
-   * @param constraint Constraint to insert.
-   * @param result Container for auto-generated ID of the inserted row.
-   */
-  void insertValueConstraint(
-      @Param("constraintId") long constraintId,
-      @Param("constraint") IValueConstraint constraint,
-      @Param("result") InsertResult result);
-
-  /**
-   * Inserts the values association within an {@link IValueConstraint}.
-   *
-   * @param valueConstraintId Value constraint ID.
-   * @param values Values to insert.
-   */
-  void insertValueConstraintValues(
-      @Param("valueConstraintId") long valueConstraintId,
-      @Param("values") Set<String> values);
-
-  /**
-   * Inserts the requested ports association within an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param ports Port names to insert.
-   */
-  void insertRequestedPorts(
-      @Param("configId") long configId,
-      @Param("ports") Set<String> ports);
-
-  /**
-   * Inserts the task links association within an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param links Task links to insert.
-   */
-  void insertTaskLinks(@Param("configId") long configId, @Param("links") Map<String, String> links);
-
-  /**
-   * Inserts the container association within an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param container Container to insert.
-   */
-  void insertContainer(
-      @Param("configId") long configId,
-      @Param("container") IDockerContainer container,
-      @Param("result") InsertResult result);
-
-  /**
-   * Inserts docker parameters in association with an {@link IDockerContainer}.
-   *
-   * @param containerId Docker container row ID.
-   * @param parameters Parameters to insert.
-   */
-  void insertDockerParameters(
-      @Param("containerId") long containerId,
-      @Param("parameters") List<IDockerParameter> parameters);
-
-  /**
-   * Inserts the metadata association within an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param metadata Metadata associated with the task config.
-   */
-  void insertMetadata(
-      @Param("configId") long configId,
-      @Param("metadata") Set<IMetadata> metadata);
-
-  /**
-   * Inserts the Mesos Fetcher URIs in association with an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param uris Resources Mesos Fetcher should place in sandbox.
-   */
-  void insertMesosFetcherUris(
-      @Param("configId") long configId,
-      @Param("uris") Set<IMesosFetcherURI> uris);
-
-  /**
-   * Deletes task configs.
-   *
-   * @param configIds Configs to delete.
-   */
-  void delete(@Param("configIds") Set<Long> configIds);
-
-  /**
-   * Inserts an AppC image association with an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param name The name of the image.
-   * @param imageId The image's identifier.
-   */
-  void insertAppcImage(
-      @Param("configId") long configId,
-      @Param("name") String name,
-      @Param("imageId") String imageId);
-
-  /**
-   * Inserts a Docker image association with an {@link ITaskConfig}.
-   *
-   * @param configId Task config ID.
-   * @param name The name of the image.
-   * @param tag The image's tag.
-   */
-  void insertDockerImage(
-      @Param("configId") long configId,
-      @Param("name") String name,
-      @Param("tag") String tag);
-
-  /**
-   * Inserts task resources.
-   *
-   * @param configId Task config ID.
-   * @param values Resources to insert.
-   */
-  void insertResources(
-      @Param("configId") long configId,
-      @Param("values") List<Pair<Integer, String>> values);
-
-  /**
-   * Inserts a task's volume mounts.
-   *
-   * @param configId Task config ID.
-   * @param volumes Volumes to insert.
-   */
-  void insertVolumes(
-      @Param("configId") long configId,
-      @Param("volumes") List<IVolume> volumes);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java
deleted file mode 100644
index cbcef84..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.scheduler.storage.db.views.DbScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.ITaskEvent;
-import org.apache.aurora.scheduler.storage.entities.ITaskQuery;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper for scheduled tasks.
- */
-interface TaskMapper {
-
-  /**
-   * Inserts a scheduled task.
-   *
-   * @param task Task to insert.
-   */
-  void insertScheduledTask(
-      @Param("task") IScheduledTask task,
-      @Param("configId") long configId,
-      @Param("result") InsertResult result);
-
-  /**
-   * Gets tasks based on a query.
-   *
-   * @param query Query to use as a filter for tasks.
-   * @return Tasks matching the query.
-   */
-  List<DbScheduledTask> select(ITaskQuery query);
-
-  /**
-   * Gets a task by ID.
-   *
-   * @param taskId ID of the task to fetch.
-   * @return Task with the specified ID.
-   */
-  @Nullable
-  DbScheduledTask selectById(@Param("taskId") String taskId);
-
-  /**
-   * Gets job keys of all stored tasks.
-   *
-   * @return Job keys.
-   */
-  Set<JobKey> selectJobKeys();
-
-  /**
-   * Inserts the task events association within an
-   * {@link org.apache.aurora.scheduler.storage.entities.IScheduledTask}.
-   *
-   * @param taskRowId Task row ID.
-   * @param events Events to insert.
-   */
-  void insertTaskEvents(
-      @Param("taskRowId") long taskRowId,
-      @Param("events") List<ITaskEvent> events);
-
-  /**
-   * Inserts the assigned ports association within an
-   * {@link org.apache.aurora.scheduler.storage.entities.IScheduledTask}.
-   *
-   * @param taskRowId Task row ID.
-   * @param ports Assigned ports to insert.
-   */
-  void insertPorts(@Param("taskRowId") long taskRowId, @Param("ports") Map<String, Integer> ports);
-
-  /**
-   * Deletes all task rows.
-   */
-  void truncate();
-
-  /**
-   * Deletes task rows by ID.
-   *
-   * @param taskIds IDs of tasks to delete.
-   */
-  void deleteTasks(@Param("taskIds") Set<String> taskIds);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java
deleted file mode 100644
index 0735772..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V001_CreateAppcImagesTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(1L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the task_config_appc_images table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS task_config_appc_images("
-        + "id IDENTITY,"
-        + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,"
-        + "name VARCHAR NOT NULL,"
-        + "image_id VARCHAR NOT NULL,"
-        + "UNIQUE(task_config_id)"
-        + ");";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS task_config_appc_images;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java
deleted file mode 100644
index 9a1ef28..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V002_CreateDockerImagesTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(2L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the task_config_docker_images table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS task_config_docker_images("
-        + "id IDENTITY,"
-        + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,"
-        + "name VARCHAR NOT NULL,"
-        + "tag VARCHAR NOT NULL,"
-        + "UNIQUE(task_config_id)"
-        + ");";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS task_config_docker_images;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java
deleted file mode 100644
index 76c6916..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-import org.apache.aurora.scheduler.resources.ResourceType;
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V003_CreateResourceTypesTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(3L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the resource_types table.";
-  }
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS resource_types("
-        + "id INT PRIMARY KEY,"
-        + "name VARCHAR NOT NULL,"
-        + "UNIQUE(name)"
-        + ");\n"
-        + populateScript();
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS resource_types;";
-  }
-
-  private static String populateScript() {
-    return Arrays.stream(ResourceType.values())
-        .map(e -> String.format(
-            "MERGE INTO resource_types(id, name) KEY(name) VALUES (%d, '%s');",
-            e.getValue(),
-            e.name()))
-        .collect(Collectors.joining("\n"));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java
deleted file mode 100644
index af106a8..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.aurora.scheduler.resources.ResourceType;
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V004_CreateTaskResourceTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(4L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the task_resource table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS task_resource("
-        + "id IDENTITY,"
-        + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,"
-        + "type_id INT NOT NULL REFERENCES resource_types(id),"
-        + "value VARCHAR NOT NULL,"
-        + "UNIQUE(task_config_id, type_id, value)"
-        + ");\n"
-        + migrateScript();
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS task_resource;";
-  }
-
-  private static String migrateScript() {
-    return "MERGE INTO task_resource(task_config_id, type_id, value) "
-        + "KEY(task_config_id, type_id, value) "
-        + "SELECT t.id, rt.id, t.num_cpus FROM task_configs t "
-        + "JOIN resource_types rt ON rt.name = "
-        + String.format("'%s';%n", ResourceType.CPUS.name())
-
-        + "MERGE INTO task_resource(task_config_id, type_id, value) "
-        + "KEY(task_config_id, type_id, value) "
-        + "SELECT t.id, rt.id, t.ram_mb FROM task_configs t "
-        + "JOIN resource_types rt ON rt.NAME = "
-        + String.format("'%s';%n", ResourceType.RAM_MB.name())
-
-        + "MERGE INTO task_resource(task_config_id, type_id, value) "
-        + "KEY(task_config_id, type_id, value) "
-        + "SELECT t.id, rt.id, t.disk_mb FROM task_configs t "
-        + "JOIN resource_types rt ON rt.NAME = "
-        + String.format("'%s';%n", ResourceType.DISK_MB.name())
-
-        + "MERGE INTO task_resource(task_config_id, type_id, value) "
-        + "KEY(task_config_id, type_id, value) "
-        + "SELECT tcrp.task_config_id, rt.id, tcrp.port_name FROM task_config_requested_ports tcrp "
-        + "JOIN resource_types rt ON rt.NAME = "
-        + String.format("'%s';%n", ResourceType.PORTS.name());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java
deleted file mode 100644
index cd06346..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.aurora.scheduler.resources.ResourceType;
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V005_CreateQuotaResourceTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(5L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the quota_resource table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS quota_resource("
-        + "id IDENTITY,"
-        + "quota_id BIGINT NOT NULL REFERENCES quotas(id) ON DELETE CASCADE,"
-        + "type_id INT NOT NULL REFERENCES resource_types(id),"
-        + "value VARCHAR NOT NULL,"
-        + "UNIQUE(quota_id, type_id)"
-        + ");\n"
-        + migrateScript();
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS quota_resource;";
-  }
-
-  private static String migrateScript() {
-    return "MERGE INTO quota_resource(quota_id, type_id, value) "
-        + "KEY(quota_id, type_id, value) "
-        + "SELECT q.id, rt.id, q.num_cpus FROM quotas q "
-        + "JOIN resource_types rt ON rt.name = "
-        + String.format("'%s';%n", ResourceType.CPUS.name())
-
-        + "MERGE INTO quota_resource(quota_id, type_id, value) "
-        + "KEY(quota_id, type_id, value) "
-        + "SELECT q.id, rt.id, q.ram_mb FROM quotas q "
-        + "JOIN resource_types rt ON rt.name = "
-        + String.format("'%s';%n", ResourceType.RAM_MB.name())
-
-        + "MERGE INTO quota_resource(quota_id, type_id, value) "
-        + "KEY(quota_id, type_id, value) "
-        + "SELECT q.id, rt.id, q.disk_mb FROM quotas q "
-        + "JOIN resource_types rt ON rt.name = "
-        + String.format("'%s';%n", ResourceType.DISK_MB.name());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java
deleted file mode 100644
index ac85b54..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V006_PopulateTierField implements MigrationScript {
-
-  private static final String PREFERRED_TIER_NAME = "preferred";
-  private static final String PREEMPTIBLE_TIER_NAME = "preemptible";
-
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(6L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Populate task_configs.tier field.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "UPDATE task_configs "
-        + String.format(
-            "SET tier = CASEWHEN(production = 1, '%s', '%s') ",
-            PREFERRED_TIER_NAME,
-            PREEMPTIBLE_TIER_NAME)
-        + "WHERE tier IS NULL;";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "UPDATE task_configs "
-        + "SET production = 1 "
-        + String.format("WHERE tier = '%s';", PREFERRED_TIER_NAME);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java
deleted file mode 100644
index d474e17..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V007_CreateMesosFetcherURIsTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(7L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the task_config_mesos_fetcher_uris table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS task_config_mesos_fetcher_uris("
-        + "id IDENTITY,"
-        + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,"
-        + "value VARCHAR NOT NULL,"
-        + "extract BOOLEAN NOT NULL,"
-        + "cache BOOLEAN NOT NULL"
-        + ");";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS task_config_mesos_fetcher_uris;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java
deleted file mode 100644
index bc86271..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V008_CreateUpdateMetadataTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(8L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the job_update_metadata table.";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS job_update_metadata("
-        + "id IDENTITY,"
-        + "update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,"
-        + "key VARCHAR NOT NULL,"
-        + "value VARCHAR NOT NULL"
-        + ");";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS job_update_metadata;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java
deleted file mode 100644
index f6cd06a..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V009_CreateContainerVolumesTable implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(9L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Create the task_config_volumes and volume_modes tables";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE IF NOT EXISTS volume_modes("
-        + "id INT PRIMARY KEY,"
-        + "name VARCHAR NOT NULL,"
-        + "UNIQUE(name)"
-        + ");"
-        + "CREATE TABLE IF NOT EXISTS task_config_volumes("
-        + "id IDENTITY,"
-        + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,"
-        + "host_path VARCHAR NOT NULL,"
-        + "container_path VARCHAR NOT NULL,"
-        + "mode INT NOT NULL REFERENCES volume_modes(id),"
-        + "UNIQUE(task_config_id)"
-        + ");";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE IF EXISTS volume_modes;"
-        + "DROP TABLE IF EXISTS task_config_volumes;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java
deleted file mode 100644
index 08c38f3..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.migration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V010_RemoveUniqueConstraint implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(10L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "Remove unique constraint in task_config_volumes";
-  }
-
-  @Override
-  public String getUpScript() {
-    // The constraint name is taken from the schema so it is always constant.
-    return "ALTER TABLE IF EXISTS task_config_volumes DROP CONSTRAINT IF EXISTS CONSTRAINT_654B;";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "ALTER TABLE IF EXISTS task_config_volumes ADD UNIQUE(task_config_id);";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java
deleted file mode 100644
index 69f125b..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.ibatis.type.JdbcType;
-import org.apache.ibatis.type.TypeHandler;
-import org.apache.thrift.TEnum;
-
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * Type handler for fields of type {@link TEnum}.  Implementers need only override
- * {@link #fromValue(int)}.
- *
- * @param <T> Enum type.
- */
-abstract class AbstractTEnumTypeHandler<T extends TEnum> implements TypeHandler<T> {
-
-  /**
-   * Finds the enum value associated with the provided integer identity.
-   *
-   * @param value Value to find in the enum values.
-   * @return Enum value associated with {@code value}.
-   */
-  protected abstract T fromValue(int value);
-
-  @Override
-  public final void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType)
-      throws SQLException {
-
-    ps.setInt(i, parameter.getValue());
-  }
-
-  @Override
-  public final T getResult(ResultSet rs, String columnName) throws SQLException {
-    int i = rs.getInt(columnName);
-    checkState(!rs.wasNull());
-    return fromValue(i);
-  }
-
-  @Override
-  public final T getResult(ResultSet rs, int columnIndex) throws SQLException {
-    int i = rs.getInt(columnIndex);
-    checkState(!rs.wasNull());
-    return fromValue(i);
-  }
-
-  @Override
-  public final T getResult(CallableStatement cs, int columnIndex) throws SQLException {
-    int i = cs.getInt(columnIndex);
-    checkState(!cs.wasNull());
-    return fromValue(i);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java
deleted file mode 100644
index b87a29f..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.CronCollisionPolicy;
-
-/**
- * Type handler for {@link CronCollisionPolicy}.
- */
-public class CronCollisionPolicyTypeHandler extends AbstractTEnumTypeHandler<CronCollisionPolicy> {
-  @Override
-  protected CronCollisionPolicy fromValue(int value) {
-    return CronCollisionPolicy.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java
deleted file mode 100644
index 85ead70..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.JobUpdateAction;
-
-/**
- * Type handler for {@link JobUpdateAction}.
- */
-public class JobUpdateActionTypeHandler extends AbstractTEnumTypeHandler<JobUpdateAction> {
-  @Override
-  protected JobUpdateAction fromValue(int value) {
-    return JobUpdateAction.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java
deleted file mode 100644
index 2848bf8..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.JobUpdateStatus;
-
-/**
- * Type handler for {@link JobUpdateStatus}.
- */
-public class JobUpdateStatusTypeHandler extends AbstractTEnumTypeHandler<JobUpdateStatus> {
-  @Override
-  protected JobUpdateStatus fromValue(int value) {
-    return JobUpdateStatus.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java
deleted file mode 100644
index 8373ec7..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.MaintenanceMode;
-
-/**
- * Type handler for {@link MaintenanceMode}.
- */
-public class MaintenanceModeTypeHandler extends AbstractTEnumTypeHandler<MaintenanceMode> {
-  @Override
-  protected MaintenanceMode fromValue(int value) {
-    return MaintenanceMode.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java
deleted file mode 100644
index e1bb7fd..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.scheduler.resources.ResourceType;
-
-/**
- * Type handler for {@link ResourceType} enum.
- */
-public class ResourceTypeHandler extends AbstractTEnumTypeHandler<ResourceType> {
-  @Override
-  protected ResourceType fromValue(int value) {
-    return ResourceType.fromIdValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java
deleted file mode 100644
index b6b4f25..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.ScheduleStatus;
-
-/**
- * Type handler for {@link ScheduleStatus}.
- */
-public class ScheduleStatusTypeHandler extends AbstractTEnumTypeHandler<ScheduleStatus> {
-  @Override
-  protected ScheduleStatus fromValue(int value) {
-    return ScheduleStatus.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java
deleted file mode 100644
index 07e8c0b..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import java.util.List;
-
-import com.google.common.collect.ImmutableList;
-
-import org.apache.ibatis.type.TypeHandler;
-
-/**
- * Utility class to access the available type handler classes.
- */
-public final class TypeHandlers {
-  private TypeHandlers() {
-    // Utility class.
-  }
-
-  public static List<Class<? extends TypeHandler<?>>> getAll() {
-    return ImmutableList.<Class<? extends TypeHandler<?>>>builder()
-        .add(CronCollisionPolicyTypeHandler.class)
-        .add(JobUpdateActionTypeHandler.class)
-        .add(JobUpdateStatusTypeHandler.class)
-        .add(MaintenanceModeTypeHandler.class)
-        .add(ScheduleStatusTypeHandler.class)
-        .add(ResourceTypeHandler.class)
-        .add(VolumeModeTypeHandler.class)
-        .build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java
deleted file mode 100644
index 97f65e4..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.typehandlers;
-
-import org.apache.aurora.gen.Mode;
-
-public class VolumeModeTypeHandler extends AbstractTEnumTypeHandler<Mode> {
-  @Override
-  protected Mode fromValue(int value) {
-    return Mode.findByValue(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java
deleted file mode 100644
index 95a6de3..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.Resource;
-import org.apache.aurora.scheduler.resources.ResourceType;
-import org.apache.aurora.scheduler.storage.entities.IResource;
-
-public final class DBResource {
-  private ResourceType type;
-  private String value;
-
-  private DBResource() {
-  }
-
-  Resource toThrift() {
-    return IResource.newBuilder(
-        type.getValue(),
-        type.getAuroraResourceConverter().parseFrom(value));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java
deleted file mode 100644
index 461d5c2..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.aurora.GuavaUtils;
-import org.apache.aurora.common.collections.Pair;
-import org.apache.aurora.gen.ResourceAggregate;
-import org.apache.aurora.scheduler.resources.ResourceType;
-import org.apache.aurora.scheduler.storage.entities.IResource;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
-
-import static org.apache.aurora.GuavaUtils.toImmutableSet;
-
-public final class DBResourceAggregate {
-  private double numCpus;
-  private long ramMb;
-  private long diskMb;
-  private List<DBResource> resources;
-
-  private DBResourceAggregate() {
-  }
-
-  public ResourceAggregate toThrift() {
-    return new ResourceAggregate()
-        .setNumCpus(numCpus)
-        .setRamMb(ramMb)
-        .setDiskMb(diskMb)
-        .setResources(resources.stream().map(DBResource::toThrift).collect(toImmutableSet()));
-  }
-
-  public static List<Pair<Integer, String>> pairsFromResources(Set<IResource> resources) {
-    return resources.stream()
-        .map(e -> Pair.of(
-            ResourceType.fromResource(e).getValue(),
-            ResourceType.fromResource(e).getAuroraResourceConverter().stringify(e.getRawValue())))
-        .collect(GuavaUtils.toImmutableList());
-  }
-
-  public IResourceAggregate toImmutable() {
-    return IResourceAggregate.build(toThrift());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java
deleted file mode 100644
index 3d48592..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.common.collections.Pair;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
-
-public final class DBSaveQuota {
-  private String role;
-  private DBResourceAggregate quota;
-
-  private DBSaveQuota() {
-  }
-
-  public Pair<String, IResourceAggregate> toImmutable() {
-    return Pair.of(role, quota.toImmutable());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java
deleted file mode 100644
index fdfff77..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-public final class DbAssginedPort {
-  private String name;
-  private Integer port;
-
-  private DbAssginedPort() {
-  }
-
-  public Integer getPort() {
-    return port;
-  }
-
-  public String getName() {
-    return name;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java
deleted file mode 100644
index cbc6a0c..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.List;
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-
-import org.apache.aurora.gen.AssignedTask;
-
-public final class DbAssignedTask {
-  private String taskId;
-  private String slaveId;
-  private String slaveHost;
-  private DbTaskConfig task;
-  private List<DbAssginedPort> assignedPorts;
-  private int instanceId;
-
-  private DbAssignedTask() {
-  }
-
-  AssignedTask toThrift() {
-    Map<String, Integer> ports = Maps.newHashMap();
-    for (DbAssginedPort port: assignedPorts) {
-      ports.put(port.getName(), port.getPort());
-    }
-
-    return new AssignedTask()
-        .setTaskId(taskId)
-        .setSlaveId(slaveId)
-        .setSlaveHost(slaveHost)
-        .setTask(task.toThrift())
-        .setAssignedPorts(ports)
-        .setInstanceId(instanceId);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java
deleted file mode 100644
index 9366757..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.Constraint;
-
-public final class DbConstraint {
-  private String name;
-  private DbTaskConstraint constraint;
-
-  private DbConstraint() {
-  }
-
-  Constraint toThrift() {
-    return new Constraint()
-        .setName(name)
-        .setConstraint(constraint.toThrift());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java
deleted file mode 100644
index 8d4d7ec..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.Container;
-import org.apache.aurora.gen.DockerContainer;
-import org.apache.aurora.gen.MesosContainer;
-
-public final class DbContainer {
-  private DockerContainer docker;
-  private DbImage image;
-
-  private DbContainer() {
-  }
-
-  Container toThrift() {
-    if (docker != null) {
-      return Container.docker(docker);
-    }
-
-    if (image != null) {
-      return Container.mesos(new MesosContainer().setImage(image.toThrift()));
-    }
-
-    return Container.mesos(new MesosContainer());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java
deleted file mode 100644
index 5964a2a..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.AppcImage;
-import org.apache.aurora.gen.DockerImage;
-import org.apache.aurora.gen.Image;
-
-public final class DbImage {
-  private AppcImage appc;
-  private DockerImage docker;
-
-  private DbImage() {
-  }
-
-  Image toThrift() {
-    if (appc != null) {
-      return Image.appc(appc);
-    }
-
-    if (docker != null) {
-      return Image.docker(docker);
-    }
-
-    throw new IllegalStateException("Unknown image type.");
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java
deleted file mode 100644
index f3fd7a9..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.Set;
-
-import org.apache.aurora.gen.InstanceTaskConfig;
-import org.apache.aurora.gen.Range;
-
-public final class DbInstanceTaskConfig {
-  private DbTaskConfig task;
-  private Set<Range> instances;
-
-  private DbInstanceTaskConfig() {
-  }
-
-  InstanceTaskConfig toThrift() {
-    return new InstanceTaskConfig()
-        .setTask(task.toThrift())
-        .setInstances(instances);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java
deleted file mode 100644
index 40a5013..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.CronCollisionPolicy;
-import org.apache.aurora.gen.Identity;
-import org.apache.aurora.gen.JobConfiguration;
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
-
-public final class DbJobConfiguration {
-  private JobKey key;
-  private Identity owner;
-  private String cronSchedule;
-  private CronCollisionPolicy cronCollisionPolicy;
-  private DbTaskConfig taskConfig;
-  private int instanceCount;
-
-  private DbJobConfiguration() {
-  }
-
-  public IJobConfiguration toImmutable() {
-    return IJobConfiguration.build(
-        new JobConfiguration()
-        .setKey(key)
-        .setOwner(owner)
-        .setCronSchedule(cronSchedule)
-        .setCronCollisionPolicy(cronCollisionPolicy)
-        .setTaskConfig(taskConfig.toThrift())
-        .setInstanceCount(instanceCount));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java
deleted file mode 100644
index 78703e9..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.JobUpdate;
-import org.apache.aurora.gen.JobUpdateSummary;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
-
-public final class DbJobUpdate {
-  private JobUpdateSummary summary;
-  private DbJobUpdateInstructions instructions;
-
-  private DbJobUpdate() {
-  }
-
-  JobUpdate toThrift() {
-    return new JobUpdate()
-        .setSummary(summary)
-        .setInstructions(instructions.toThrift());
-  }
-
-  public IJobUpdate toImmutable() {
-    return IJobUpdate.build(toThrift());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java
deleted file mode 100644
index 3a52724..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.List;
-
-import org.apache.aurora.gen.JobInstanceUpdateEvent;
-import org.apache.aurora.gen.JobUpdateDetails;
-import org.apache.aurora.gen.JobUpdateEvent;
-
-public final class DbJobUpdateDetails {
-  private DbJobUpdate update;
-  private List<JobUpdateEvent> updateEvents;
-  private List<JobInstanceUpdateEvent> instanceEvents;
-
-  public JobUpdateDetails toThrift() {
-    return new JobUpdateDetails()
-        .setUpdate(update.toThrift())
-        .setUpdateEvents(updateEvents)
-        .setInstanceEvents(instanceEvents);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java
deleted file mode 100644
index d19aa85..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.Set;
-
-import com.google.common.collect.FluentIterable;
-
-import org.apache.aurora.gen.JobUpdateInstructions;
-import org.apache.aurora.gen.JobUpdateSettings;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateInstructions;
-
-public final class DbJobUpdateInstructions {
-  private Set<DbInstanceTaskConfig> initialState;
-  private DbInstanceTaskConfig desiredState;
-  private JobUpdateSettings settings;
-
-  private DbJobUpdateInstructions() {
-  }
-
-  JobUpdateInstructions toThrift() {
-    return new JobUpdateInstructions()
-        .setInitialState(
-            FluentIterable.from(initialState)
-                .transform(DbInstanceTaskConfig::toThrift)
-                .toSet())
-        .setDesiredState(desiredState == null ? null : desiredState.toThrift())
-        .setSettings(settings);
-  }
-
-  public IJobUpdateInstructions toImmutable() {
-    return IJobUpdateInstructions.build(toThrift());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java
deleted file mode 100644
index 6260923..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.List;
-
-import com.google.common.collect.Ordering;
-import com.google.common.primitives.Longs;
-
-import org.apache.aurora.gen.ScheduleStatus;
-import org.apache.aurora.gen.ScheduledTask;
-import org.apache.aurora.gen.TaskEvent;
-import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
-
-public final class DbScheduledTask {
-  private DbAssignedTask assignedTask;
-  private ScheduleStatus status;
-  private int failureCount;
-  private List<TaskEvent> taskEvents;
-  private String ancestorId;
-
-  private DbScheduledTask() {
-  }
-
-  public IScheduledTask toImmutable() {
-    return IScheduledTask.build(
-        new ScheduledTask()
-            .setAssignedTask(assignedTask.toThrift())
-            .setStatus(status)
-            .setFailureCount(failureCount)
-            // Must be sorting a copy because taskEvents is populated by MyBatis and it might
-            // reuse the same instance.
-            .setTaskEvents(BY_TIMESTAMP.immutableSortedCopy(taskEvents))
-            .setAncestorId(ancestorId));
-  }
-
-  private static final Ordering<TaskEvent> BY_TIMESTAMP = new Ordering<TaskEvent>() {
-    @Override
-    public int compare(TaskEvent left, TaskEvent right) {
-      return Longs.compare(left.getTimestamp(), right.getTimestamp());
-    }
-  };
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java
deleted file mode 100644
index 8ec6d47..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.storage.StoredJobUpdateDetails;
-
-public final class DbStoredJobUpdateDetails {
-  private DbJobUpdateDetails details;
-  private String lockToken;
-
-  private DbStoredJobUpdateDetails() {
-  }
-
-  public StoredJobUpdateDetails toThrift() {
-    return new StoredJobUpdateDetails()
-        .setDetails(details.toThrift())
-        .setLockToken(lockToken);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java
deleted file mode 100644
index 138cd53..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.List;
-
-import com.google.common.collect.ImmutableSet;
-
-import org.apache.aurora.common.collections.Pair;
-import org.apache.aurora.gen.Container;
-import org.apache.aurora.gen.ExecutorConfig;
-import org.apache.aurora.gen.Identity;
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.gen.MesosContainer;
-import org.apache.aurora.gen.MesosFetcherURI;
-import org.apache.aurora.gen.Metadata;
-import org.apache.aurora.gen.TaskConfig;
-import org.apache.aurora.gen.Volume;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-
-import static org.apache.aurora.GuavaUtils.toImmutableSet;
-
-public final class DbTaskConfig {
-  private long rowId;
-  private JobKey job;
-  private Identity owner;
-  private boolean isService;
-  private double numCpus;
-  private long ramMb;
-  private long diskMb;
-  private int priority;
-  private int maxTaskFailures;
-  private boolean production;
-  private List<DbConstraint> constraints;
-  private List<String> requestedPorts;
-  private List<Pair<String, String>> taskLinks;
-  private String contactEmail;
-  private ExecutorConfig executorConfig;
-  private List<Metadata> metadata;
-  private List<MesosFetcherURI> mesosFetcherUris;
-  private DbContainer container;
-  private List<Volume> volumes;
-  private String tier;
-  private List<DBResource> resources;
-
-  private DbTaskConfig() {
-  }
-
-  public long getRowId() {
-    return rowId;
-  }
-
-  TaskConfig toThrift() {
-    TaskConfig builder = new TaskConfig()
-        .setJob(job)
-        .setOwner(owner)
-        .setIsService(isService)
-        .setNumCpus(numCpus)
-        .setRamMb(ramMb)
-        .setDiskMb(diskMb)
-        .setPriority(priority)
-        .setMaxTaskFailures(maxTaskFailures)
-        .setProduction(production)
-        .setTier(tier)
-        .setConstraints(constraints.stream()
-            .map(DbConstraint::toThrift)
-            .collect(toImmutableSet()))
-        .setRequestedPorts(ImmutableSet.copyOf(requestedPorts))
-        .setTaskLinks(Pairs.toMap(taskLinks))
-        .setContactEmail(contactEmail)
-        .setExecutorConfig(executorConfig)
-        .setMetadata(ImmutableSet.copyOf(metadata))
-        .setMesosFetcherUris(ImmutableSet.copyOf(mesosFetcherUris))
-        .setContainer(
-            container == null ? Container.mesos(new MesosContainer()) : container.toThrift())
-        .setResources(resources.stream().map(DBResource::toThrift).collect(toImmutableSet()));
-
-    // In the DB Layer volumes are associated with a task config, since containers are not
-    // modelled as tables.
-    if (builder.getContainer().isSetMesos()) {
-      builder.getContainer().getMesos().setVolumes(volumes);
-    }
-
-    return builder;
-  }
-
-  public ITaskConfig toImmutable() {
-    return ITaskConfig.build(toThrift());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java
deleted file mode 100644
index e3e1b7a..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.gen.LimitConstraint;
-import org.apache.aurora.gen.TaskConstraint;
-import org.apache.aurora.gen.ValueConstraint;
-
-public final class DbTaskConstraint {
-  private ValueConstraint value;
-  private LimitConstraint limit;
-
-  private DbTaskConstraint() {
-  }
-
-  private static boolean isSet(Object o) {
-    return o != null;
-  }
-
-  @Nullable
-  TaskConstraint toThrift() {
-    // Using the isSet shim to work around a well-intentioned PMD rule that prefers positive
-    // branching (would trip if we did value != null directly here.
-    if (isSet(value)) {
-      return TaskConstraint.value(value);
-    } else if (isSet(limit)) {
-      return TaskConstraint.limit(limit);
-    } else {
-      return null;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java
deleted file mode 100644
index aaa0a68..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.gen.Lock;
-import org.apache.aurora.gen.LockKey;
-
-/**
- * The union of {@link Lock} and {@link JobKey}. This class is required because the generated
- * thrift code for {@code union} fields is incompatible with the mapping behaviour of MyBatis.
- * This class works around this incompatibility by explicitly initialising an empty lock with
- * the union field set to an empty {@link JobKey} instance and exposing a getter method for MyBatis.
- * Note that this only works because the {@link LockKey} is a union of exactly one type. If LockKey
- * is modified to support more types, we will need to rework this design.
- *
- * TODO(davmclau):
- * These intermediate classes for resolving relationships on Thrift union types should be
- * auto-generated, as the logic will be identical in each one. The generated code needs to allow
- * for exactly one field in the union to be set, returning null when the getter for the field
- * is called the first time.
- */
-public class LockRow {
-  private final Lock lock = new Lock();
-
-  public LockRow() {
-    LockKey lockKey = new LockKey();
-    lock.setKey(lockKey);
-    lockKey.setJob(new JobKey());
-  }
-
-  public Lock getLock() {
-    return lock;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java
deleted file mode 100644
index 6159af6..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.Arrays;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Objects;
-
-import org.apache.ibatis.migration.Change;
-
-public class MigrationChangelogEntry extends Change {
-  private byte[] downgradeScript;
-
-  public String getDowngradeScript() {
-    return new String(downgradeScript, Charsets.UTF_8);
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (!(o instanceof MigrationChangelogEntry)) {
-      return false;
-    }
-
-    if (!super.equals(o)) {
-      return false;
-    }
-
-    MigrationChangelogEntry other = (MigrationChangelogEntry) o;
-    return Arrays.equals(downgradeScript, other.downgradeScript);
-  }
-
-  @Override
-  public int hashCode() {
-    return Objects.hashCode(super.hashCode(), downgradeScript);
-  }
-}


[4/5] aurora git commit: Remove the internal SQL database

Posted by wf...@apache.org.
http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbQuotaStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbQuotaStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbQuotaStore.java
deleted file mode 100644
index 0ea21b5..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbQuotaStore.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-
-import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.db.views.DBResourceAggregate;
-import org.apache.aurora.scheduler.storage.db.views.DBSaveQuota;
-import org.apache.aurora.scheduler.storage.db.views.Pairs;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
-
-import static java.util.Objects.requireNonNull;
-
-import static org.apache.aurora.common.inject.TimedInterceptor.Timed;
-
-/**
- * Quota store backed by a relational database.
- */
-class DbQuotaStore implements QuotaStore.Mutable {
-
-  private final QuotaMapper mapper;
-
-  @Inject
-  DbQuotaStore(QuotaMapper mapper) {
-    this.mapper = requireNonNull(mapper);
-  }
-
-  @Timed("quota_store_fetch_quota")
-  @Override
-  public Optional<IResourceAggregate> fetchQuota(String role) {
-    return Optional.fromNullable(mapper.select(role))
-        .transform(DBResourceAggregate::toImmutable);
-  }
-
-  @Timed("quota_store_fetch_quotas")
-  @Override
-  public Map<String, IResourceAggregate> fetchQuotas() {
-    return Pairs.toMap(mapper.selectAll().stream()
-        .map(DBSaveQuota::toImmutable)
-        .collect(Collectors.toList()));
-  }
-
-  @Timed("quota_store_delete_quotas")
-  @Override
-  public void deleteQuotas() {
-    mapper.truncate();
-  }
-
-  @Timed("quota_store_remove_quota")
-  @Override
-  public void removeQuota(String role) {
-    mapper.delete(role);
-  }
-
-  @Timed("quota_store_save_quota")
-  @Override
-  public void saveQuota(String role, IResourceAggregate quota) {
-    mapper.delete(role);
-    InsertResult quotaInsert = new InsertResult();
-    mapper.insert(role, quota.newBuilder(), quotaInsert);
-    mapper.insertResources(
-        quotaInsert.getId(),
-        Pairs.toMap(DBResourceAggregate.pairsFromResources(quota.getResources())));
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStore.java
deleted file mode 100644
index 026dfc9..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStore.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Objects;
-
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
-
-import org.apache.aurora.scheduler.storage.SchedulerStore;
-
-import static org.apache.aurora.common.inject.TimedInterceptor.Timed;
-
-/**
- * A relational database-backed scheduler store.
- */
-class DbSchedulerStore implements SchedulerStore.Mutable {
-
-  private final FrameworkIdMapper mapper;
-
-  @Inject
-  DbSchedulerStore(FrameworkIdMapper mapper) {
-    this.mapper = Objects.requireNonNull(mapper);
-  }
-
-  @Timed("scheduler_store_save_framework_id")
-  @Override
-  public void saveFrameworkId(String frameworkId) {
-    mapper.insert(Objects.requireNonNull(frameworkId));
-  }
-
-  @Timed("scheduler_store_fetch_framework_id")
-  @Override
-  public Optional<String> fetchFrameworkId() {
-    return Optional.fromNullable(mapper.select());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbStorage.java
deleted file mode 100644
index aa7c03b..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbStorage.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-
-import javax.sql.DataSource;
-
-import com.google.common.base.Supplier;
-import com.google.common.io.CharStreams;
-import com.google.common.util.concurrent.AbstractIdleService;
-import com.google.inject.Inject;
-
-import org.apache.aurora.common.inject.TimedInterceptor.Timed;
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.GatedWorkQueue;
-import org.apache.aurora.scheduler.async.GatedWorkQueue.GatedOperation;
-import org.apache.aurora.scheduler.storage.AttributeStore;
-import org.apache.aurora.scheduler.storage.CronJobStore;
-import org.apache.aurora.scheduler.storage.JobUpdateStore;
-import org.apache.aurora.scheduler.storage.LockStore;
-import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.SchedulerStore;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.ibatis.builder.StaticSqlSource;
-import org.apache.ibatis.datasource.pooled.PoolState;
-import org.apache.ibatis.datasource.pooled.PooledDataSource;
-import org.apache.ibatis.exceptions.PersistenceException;
-import org.apache.ibatis.mapping.MappedStatement.Builder;
-import org.apache.ibatis.session.Configuration;
-import org.apache.ibatis.session.ExecutorType;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.mybatis.guice.transactional.Transactional;
-
-import static java.util.Objects.requireNonNull;
-
-import static org.apache.ibatis.mapping.SqlCommandType.UPDATE;
-
-/**
- * A storage implementation backed by a relational database.
- * <p>
- * Delegates read and write concurrency semantics to the underlying database.
- */
-public class DbStorage extends AbstractIdleService implements Storage {
-
-  private final SqlSessionFactory sessionFactory;
-  private final EnumBackfill enumBackfill;
-  private final MutableStoreProvider storeProvider;
-  private final GatedWorkQueue gatedWorkQueue;
-  private final StatsProvider statsProvider;
-
-  @Inject
-  DbStorage(
-      SqlSessionFactory sessionFactory,
-      EnumBackfill enumBackfill,
-      @AsyncExecutor GatedWorkQueue gatedWorkQueue,
-      final CronJobStore.Mutable cronJobStore,
-      final TaskStore.Mutable taskStore,
-      final SchedulerStore.Mutable schedulerStore,
-      final AttributeStore.Mutable attributeStore,
-      final LockStore.Mutable lockStore,
-      final QuotaStore.Mutable quotaStore,
-      final JobUpdateStore.Mutable jobUpdateStore,
-      StatsProvider statsProvider) {
-
-    this.sessionFactory = requireNonNull(sessionFactory);
-    this.enumBackfill = requireNonNull(enumBackfill);
-    this.gatedWorkQueue = requireNonNull(gatedWorkQueue);
-    requireNonNull(cronJobStore);
-    requireNonNull(taskStore);
-    requireNonNull(schedulerStore);
-    requireNonNull(attributeStore);
-    requireNonNull(lockStore);
-    requireNonNull(quotaStore);
-    requireNonNull(jobUpdateStore);
-    storeProvider = new MutableStoreProvider() {
-      @Override
-      public SchedulerStore.Mutable getSchedulerStore() {
-        return schedulerStore;
-      }
-
-      @Override
-      public CronJobStore.Mutable getCronJobStore() {
-        return cronJobStore;
-      }
-
-      @Override
-      public TaskStore getTaskStore() {
-        return taskStore;
-      }
-
-      @Override
-      public TaskStore.Mutable getUnsafeTaskStore() {
-        return taskStore;
-      }
-
-      @Override
-      public LockStore.Mutable getLockStore() {
-        return lockStore;
-      }
-
-      @Override
-      public QuotaStore.Mutable getQuotaStore() {
-        return quotaStore;
-      }
-
-      @Override
-      public AttributeStore.Mutable getAttributeStore() {
-        return attributeStore;
-      }
-
-      @Override
-      public JobUpdateStore.Mutable getJobUpdateStore() {
-        return jobUpdateStore;
-      }
-    };
-    this.statsProvider = requireNonNull(statsProvider);
-  }
-
-  @SuppressWarnings("unchecked")
-  public <T> T getUnsafeStoreAccess() {
-    return (T) sessionFactory.getConfiguration().getEnvironment().getDataSource();
-  }
-
-  @Timed("db_storage_read_operation")
-  @Override
-  @Transactional
-  public <T, E extends Exception> T read(Work<T, E> work) throws StorageException, E {
-    try {
-      return work.apply(storeProvider);
-    } catch (PersistenceException e) {
-      throw new StorageException(e.getMessage(), e);
-    }
-  }
-
-  @Transactional
-  <T, E extends Exception> T transactionedWrite(MutateWork<T, E> work) throws E {
-    return work.apply(storeProvider);
-  }
-
-  @Timed("db_storage_write_operation")
-  @Override
-  public <T, E extends Exception> T write(MutateWork<T, E> work) throws StorageException, E {
-    // NOTE: Async work is intentionally executed regardless of whether the transaction succeeded.
-    // Doing otherwise runs the risk of cross-talk between transactions and losing async tasks
-    // due to failure of an unrelated transaction.  This matches behavior prior to the
-    // introduction of DbStorage, but should be revisited.
-    // TODO(wfarner): Consider revisiting to execute async work only when the transaction is
-    // successful.
-    return gatedWorkQueue.closeDuring((GatedOperation<T, E>) () -> {
-      try {
-        return transactionedWrite(work);
-      } catch (PersistenceException e) {
-        throw new StorageException(e.getMessage(), e);
-      }
-    });
-  }
-
-  @Override
-  public void prepare() {
-    startAsync().awaitRunning();
-  }
-
-  private static void addMappedStatement(Configuration configuration, String name, String sql) {
-    configuration.addMappedStatement(
-        new Builder(configuration, name, new StaticSqlSource(configuration, sql), UPDATE).build());
-  }
-
-  /**
-   * Creates the SQL schema during service start-up.
-   * Note: This design assumes a volatile database engine.
-   */
-  @Override
-  @Transactional
-  protected void startUp() throws IOException {
-    Configuration configuration = sessionFactory.getConfiguration();
-    String createStatementName = "create_tables";
-    configuration.setMapUnderscoreToCamelCase(true);
-
-    // The ReuseExecutor will cache jdbc Statements with equivalent SQL, improving performance
-    // slightly when redundant queries are made.
-    configuration.setDefaultExecutorType(ExecutorType.REUSE);
-
-    addMappedStatement(
-        configuration,
-        createStatementName,
-        CharStreams.toString(new InputStreamReader(
-            DbStorage.class.getResourceAsStream("schema.sql"),
-            StandardCharsets.UTF_8)));
-
-    try (SqlSession session = sessionFactory.openSession()) {
-      session.update(createStatementName);
-    }
-
-    enumBackfill.backfill();
-
-    createPoolMetrics();
-  }
-
-  @Override
-  protected void shutDown() {
-    // noop
-  }
-
-  private void createPoolMetrics() {
-    DataSource dataSource = sessionFactory.getConfiguration().getEnvironment().getDataSource();
-    // Should not fail because we specify a PoolDataSource in DbModule
-    PoolState poolState = ((PooledDataSource) dataSource).getPoolState();
-
-    createPoolGauge("requests", poolState::getRequestCount);
-    createPoolGauge("average_request_time_ms", poolState::getAverageRequestTime);
-    createPoolGauge("average_wait_time_ms", poolState::getAverageWaitTime);
-    createPoolGauge("connections_had_to_wait", poolState::getHadToWaitCount);
-    createPoolGauge("bad_connections", poolState::getBadConnectionCount);
-    createPoolGauge("claimed_overdue_connections", poolState::getClaimedOverdueConnectionCount);
-    createPoolGauge("average_overdue_checkout_time_ms", poolState::getAverageOverdueCheckoutTime);
-    createPoolGauge("average_checkout_time_ms", poolState::getAverageCheckoutTime);
-    createPoolGauge("idle_connections", poolState::getIdleConnectionCount);
-    createPoolGauge("active_connections", poolState::getActiveConnectionCount);
-  }
-
-  private void createPoolGauge(String name, Supplier<? extends Number> gauge) {
-    String prefix = "db_storage_mybatis_connection_pool_";
-    statsProvider.makeGauge(prefix + name, gauge);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
deleted file mode 100644
index 573d76d..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Set;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-
-import org.apache.aurora.common.inject.TimedInterceptor.Timed;
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.scheduler.base.Query;
-import org.apache.aurora.scheduler.base.Query.Builder;
-import org.apache.aurora.scheduler.base.Tasks;
-import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.db.views.DbScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * A task store implementation based on a relational database.
- * <p>
- * TODO(wfarner): Consider modifying code generator to support directly producing ITaskConfig, etc
- * from myBatis (it will set private final fields just fine).  This would reduce memory and time
- * spent translating and copying objects.
- */
-class DbTaskStore implements TaskStore.Mutable {
-
-  private static final Logger LOG = LoggerFactory.getLogger(DbTaskStore.class);
-
-  private final TaskMapper taskMapper;
-  private final TaskConfigManager configManager;
-  private final Clock clock;
-  private final long slowQueryThresholdNanos;
-
-  @Inject
-  DbTaskStore(
-      TaskMapper taskMapper,
-      TaskConfigManager configManager,
-      Clock clock,
-      Amount<Long, Time> slowQueryThreshold) {
-
-    LOG.warn("DbTaskStore is experimental, and should not be used in production clusters!");
-    this.taskMapper = requireNonNull(taskMapper);
-    this.configManager = requireNonNull(configManager);
-    this.clock = requireNonNull(clock);
-    this.slowQueryThresholdNanos =  slowQueryThreshold.as(Time.NANOSECONDS);
-  }
-
-  @Timed("db_storage_fetch_task")
-  @Override
-  public Optional<IScheduledTask> fetchTask(String taskId) {
-    requireNonNull(taskId);
-    return Optional.fromNullable(taskMapper.selectById(taskId))
-        .transform(DbScheduledTask::toImmutable);
-  }
-
-  @Timed("db_storage_fetch_tasks")
-  @Override
-  public Iterable<IScheduledTask> fetchTasks(Builder query) {
-    requireNonNull(query);
-
-    // TODO(wfarner): Consider making slow query logging more reusable, or pushing it down into the
-    //                database.
-    long start = clock.nowNanos();
-    Iterable<IScheduledTask> result = matches(query);
-    long durationNanos = clock.nowNanos() - start;
-    boolean infoLevel = durationNanos >= slowQueryThresholdNanos;
-    long time = Amount.of(durationNanos, Time.NANOSECONDS).as(Time.MILLISECONDS);
-    String message = "Query took {} ms: {}";
-    if (infoLevel) {
-      LOG.info(message, time, query.get());
-    } else if (LOG.isDebugEnabled()) {
-      LOG.debug(message, time, query.get());
-    }
-
-    return result;
-  }
-
-  @Timed("db_storage_get_job_keys")
-  @Override
-  public ImmutableSet<IJobKey> getJobKeys() {
-    return IJobKey.setFromBuilders(taskMapper.selectJobKeys());
-  }
-
-  @Timed("db_storage_save_tasks")
-  @Override
-  public void saveTasks(Set<IScheduledTask> tasks) {
-    if (tasks.isEmpty()) {
-      return;
-    }
-
-    // TODO(wfarner): Restrict the TaskStore.Mutable methods to more specific mutations.  It would
-    //                simplify this code if we did not have to handle full object tree mutations.
-
-    deleteTasks(Tasks.ids(tasks));
-
-    // Maintain a cache of all task configs that exist for a job key so that identical entities
-    LoadingCache<ITaskConfig, Long> configCache = CacheBuilder.newBuilder()
-        .build(new CacheLoader<ITaskConfig, Long>() {
-          @Override
-          public Long load(ITaskConfig config) {
-            return configManager.insert(config);
-          }
-        });
-
-    for (IScheduledTask task : tasks) {
-      InsertResult result = new InsertResult();
-      taskMapper.insertScheduledTask(
-          task,
-          configCache.getUnchecked(task.getAssignedTask().getTask()),
-          result);
-
-      if (!task.getTaskEvents().isEmpty()) {
-        taskMapper.insertTaskEvents(result.getId(), task.getTaskEvents());
-      }
-      if (!task.getAssignedTask().getAssignedPorts().isEmpty()) {
-        taskMapper.insertPorts(result.getId(), task.getAssignedTask().getAssignedPorts());
-      }
-    }
-  }
-
-  @Timed("db_storage_delete_all_tasks")
-  @Override
-  public void deleteAllTasks() {
-    taskMapper.truncate();
-  }
-
-  @Timed("db_storage_delete_tasks")
-  @Override
-  public void deleteTasks(Set<String> taskIds) {
-    if (!taskIds.isEmpty()) {
-      taskMapper.deleteTasks(taskIds);
-    }
-  }
-
-  @Timed("db_storage_mutate_task")
-  @Override
-  public Optional<IScheduledTask> mutateTask(
-      String taskId,
-      Function<IScheduledTask, IScheduledTask> mutator) {
-
-    requireNonNull(taskId);
-    requireNonNull(mutator);
-
-    return fetchTask(taskId).transform(original -> {
-      IScheduledTask maybeMutated = mutator.apply(original);
-      requireNonNull(maybeMutated);
-      if (!original.equals(maybeMutated)) {
-        Preconditions.checkState(
-            Tasks.id(original).equals(Tasks.id(maybeMutated)),
-            "A task's ID may not be mutated.");
-        saveTasks(ImmutableSet.of(maybeMutated));
-      }
-      return maybeMutated;
-    });
-  }
-
-  private FluentIterable<IScheduledTask> matches(Query.Builder query) {
-    Iterable<DbScheduledTask> results;
-    Predicate<IScheduledTask> filter;
-    if (query.get().getTaskIds().size() == 1) {
-      // Optimize queries that are scoped to a single task, as the dynamic SQL used for arbitrary
-      // queries comes with a performance penalty.
-      results = Optional.fromNullable(
-          taskMapper.selectById(Iterables.getOnlyElement(query.get().getTaskIds())))
-          .asSet();
-      filter = Util.queryFilter(query);
-    } else {
-      results = taskMapper.select(query.get());
-      // Additional filtering is not necessary in this case, since the query does it for us.
-      filter = Predicates.alwaysTrue();
-    }
-
-    return FluentIterable.from(results)
-        .transform(DbScheduledTask::toImmutable)
-        .filter(filter);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/DbUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbUtil.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbUtil.java
deleted file mode 100644
index 443b473..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbUtil.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-
-import static org.apache.aurora.scheduler.storage.db.DbModule.testModuleWithWorkQueue;
-
-/**
- * Utility class for creating ad-hoc storage instances.
- */
-public final class DbUtil {
-
-  private DbUtil() {
-    // Utility class.
-  }
-
-  /**
-   * Creates a new, empty storage system with bindings for the new storage.
-   *
-   * @param dbModule {@link DbModule} to install.
-   * @return An injector with bindings necessary for a storage system.
-   */
-  public static Injector createStorageInjector(Module dbModule) {
-    return createStorageInjector(dbModule, new DbModule.MigrationManagerModule());
-  }
-
-  public static Injector createStorageInjector(Module dbModule, Module migrationModule) {
-    Injector injector = Guice.createInjector(
-        migrationModule,
-        dbModule,
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            FakeStatsProvider stats = new FakeStatsProvider();
-            bind(StatsProvider.class).toInstance(stats);
-            bind(FakeStatsProvider.class).toInstance(stats);
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        });
-    Storage storage = injector.getInstance(Storage.class);
-    storage.prepare();
-    return injector;
-  }
-
-  /**
-   * Creates a new, empty test storage system.
-   * <p>
-   * TODO(wfarner): Rename this to createTestStorage() to avoid misuse.
-   *
-   * @return A new storage instance.
-   */
-  public static Storage createStorage() {
-    return createStorageInjector(testModuleWithWorkQueue()).getInstance(Storage.class);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/EnumBackfill.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/EnumBackfill.java b/src/main/java/org/apache/aurora/scheduler/storage/db/EnumBackfill.java
deleted file mode 100644
index b4731c9..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/EnumBackfill.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import javax.inject.Inject;
-
-import org.apache.aurora.gen.CronCollisionPolicy;
-import org.apache.aurora.gen.JobUpdateAction;
-import org.apache.aurora.gen.JobUpdateStatus;
-import org.apache.aurora.gen.MaintenanceMode;
-import org.apache.aurora.gen.Mode;
-import org.apache.aurora.gen.ScheduleStatus;
-
-import org.apache.aurora.scheduler.resources.ResourceType;
-
-import static java.util.Objects.requireNonNull;
-
-public interface EnumBackfill {
-  /**
-   * Hydrates all of the enum tables in the database.
-   */
-  void backfill();
-
-  class EnumBackfillImpl implements EnumBackfill {
-
-    private final EnumValueMapper enumValueMapper;
-
-    @Inject
-    public EnumBackfillImpl(EnumValueMapper mapper) {
-      this.enumValueMapper = requireNonNull(mapper);
-    }
-
-    @Override
-    public void backfill() {
-      for (CronCollisionPolicy policy : CronCollisionPolicy.values()) {
-        enumValueMapper.addEnumValue("cron_policies", policy.getValue(), policy.name());
-      }
-
-      for (MaintenanceMode mode : MaintenanceMode.values()) {
-        enumValueMapper.addEnumValue("maintenance_modes", mode.getValue(), mode.name());
-      }
-
-      for (JobUpdateStatus status : JobUpdateStatus.values()) {
-        enumValueMapper.addEnumValue("job_update_statuses", status.getValue(), status.name());
-      }
-
-      for (JobUpdateAction jua : JobUpdateAction.values()) {
-        enumValueMapper.addEnumValue("job_instance_update_actions", jua.getValue(), jua.name());
-      }
-
-      for (ScheduleStatus status : ScheduleStatus.values()) {
-        enumValueMapper.addEnumValue("task_states", status.getValue(), status.name());
-      }
-
-      for (ResourceType type : ResourceType.values()) {
-        enumValueMapper.addEnumValue("resource_types", type.getValue(), type.name());
-      }
-
-      for (Mode mode : Mode.values()) {
-        enumValueMapper.addEnumValue("volume_modes", mode.getValue(), mode.name());
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/EnumValueMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/EnumValueMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/EnumValueMapper.java
deleted file mode 100644
index 33948a7..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/EnumValueMapper.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.ibatis.annotations.Param;
-
-/**
- * Mapper used to populate static enum value tables.
- */
-interface EnumValueMapper {
-
-  /**
-   * Inserts an enum value.
-   *
-   * @param table Name of the enum value table.
-   * @param id Unique enum ID.
-   * @param name Human-readable enum name.
-   */
-  void addEnumValue(@Param("table") String table, @Param("id") int id, @Param("name") String name);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.java
deleted file mode 100644
index 240767c..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import javax.annotation.Nullable;
-
-/**
- * MyBatis mapper class for FrameworkIdMapper.xml.
- */
-interface FrameworkIdMapper {
-  @Nullable
-  String select();
-
-  void insert(String id);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/GarbageCollectedTableMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/GarbageCollectedTableMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/GarbageCollectedTableMapper.java
deleted file mode 100644
index 83e42a9..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/GarbageCollectedTableMapper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-/**
- * Base interface for a table mapper whose rows should be garbage-collected when unreferenced.
- */
-interface GarbageCollectedTableMapper {
-  /**
-   * Selects the IDs of all rows in the table.
-   */
-  List<Long> selectAllRowIds();
-
-  /**
-   * Attempts to delete a row from the table.
-   */
-  void deleteRow(@Param("rowId") long rowId);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/InsertResult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/InsertResult.java b/src/main/java/org/apache/aurora/scheduler/storage/db/InsertResult.java
deleted file mode 100644
index 8a81579..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/InsertResult.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-/**
- * MyBatis returns auto-generated IDs through mutable fields in parameters.
- * This class can be used as an additional {@link org.apache.ibatis.annotations.Param Param} to
- * retrieve the ID when the inserted object is not self-identifying.
- */
-public class InsertResult {
-  private long id = Long.MIN_VALUE;
-  private boolean isSet;
-
-  public long getId() {
-    if (!isSet) {
-      throw new IllegalStateException("Missing ID value.");
-    }
-    return id;
-  }
-
-  void setId(long value) {
-    id = value;
-    isSet = true;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptor.java b/src/main/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptor.java
deleted file mode 100644
index caf1d64..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptor.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Properties;
-import java.util.function.Function;
-import javax.annotation.Nonnull;
-import javax.inject.Inject;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-
-import org.apache.aurora.common.stats.SlidingStats;
-import org.apache.aurora.common.util.Clock;
-import org.apache.ibatis.cache.CacheKey;
-import org.apache.ibatis.executor.Executor;
-import org.apache.ibatis.mapping.BoundSql;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.plugin.Interceptor;
-import org.apache.ibatis.plugin.Intercepts;
-import org.apache.ibatis.plugin.Invocation;
-import org.apache.ibatis.plugin.Plugin;
-import org.apache.ibatis.plugin.Signature;
-import org.apache.ibatis.session.ResultHandler;
-import org.apache.ibatis.session.RowBounds;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * A Mybatis Executor invocation interceptor that exports timing information for update and query
- * mapped statements.
- *
- * Currently intercepting the following invocations:
- * 1. update(MappedStatement ms, Object parameter)
- * 2. query(MappedStatement ms, Object parameter, RowBounds rowBounds,
- *      ResultHandler resultHandler, CacheKey cacheKey, BoundSql boundSql)
- * 3. query(MappedStatement ms, Object parameter, RowBounds rowBounds,
- *      ResultHandler resultHandler)
- * 4. queryCursor(MappedStatement ms, Object parameter, RowBounds rowBounds)
- *
- * more signatures can be added from: org.apache.ibatis.executors
- */
-@Intercepts({
-    @Signature(
-        type = Executor.class,
-        method = "update",
-        args = {MappedStatement.class, Object.class}),
-    @Signature(type = Executor.class,
-        method = "query",
-        args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class,
-            CacheKey.class, BoundSql.class}),
-    @Signature(type = Executor.class,
-        method = "query",
-        args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
-    @Signature(type = Executor.class,
-        method = "queryCursor",
-        args = {MappedStatement.class, Object.class, RowBounds.class})
-    })
-public class InstrumentingInterceptor implements Interceptor {
-  private static final String INVALID_INVOCATION_METRIC_NAME = "invalid_invocations";
-  private static final String STATS_NAME_PREFIX = "mybatis.";
-  private static final Logger LOG = LoggerFactory.getLogger(InstrumentingInterceptor.class);
-  private final Clock clock;
-  private final LoadingCache<String, SlidingStats> stats;
-
-  @Inject
-  public InstrumentingInterceptor(Clock clock) {
-    this(clock, (String name) -> new SlidingStats(name, "nanos"));
-  }
-
-  @VisibleForTesting
-  public InstrumentingInterceptor(Clock clock, Function<String, SlidingStats> statsFactory) {
-    this.clock = requireNonNull(clock);
-
-    this.stats = CacheBuilder.newBuilder().build(new CacheLoader<String, SlidingStats>() {
-      @Override public SlidingStats load(String statsName) {
-        return statsFactory.apply(STATS_NAME_PREFIX + statsName);
-      }
-    });
-  }
-
-  private String generateStatsName(Invocation invocation) {
-    if (firstArgumentIsMappedStatement(invocation)) {
-      MappedStatement statement = (MappedStatement) invocation.getArgs()[0];
-      return statement.getId();
-    }
-
-    LOG.warn("Received invocation for unknown or invalid target. Invocation target: {}. "
-            + "Invocation method: {}. Using metric name '{}' instead.",
-        invocation.getTarget(),
-        invocation.getMethod(),
-        INVALID_INVOCATION_METRIC_NAME);
-    return INVALID_INVOCATION_METRIC_NAME;
-  }
-
-  private boolean firstArgumentIsMappedStatement(Invocation invocation) {
-    return invocation != null
-        && invocation.getArgs() != null
-        && invocation.getArgs()[0] instanceof MappedStatement;
-  }
-
-  @Override
-  public Object intercept(@Nonnull Invocation invocation) throws Throwable {
-    long start = clock.nowNanos();
-    try {
-      return invocation.proceed();
-    } finally {
-      String statsName = generateStatsName(invocation);
-      SlidingStats stat = stats.get(statsName);
-      stat.accumulate(clock.nowNanos() - start);
-    }
-  }
-
-  @Override
-  public Object plugin(Object target) {
-    return Plugin.wrap(target, this);
-  }
-
-  @Override
-  public void setProperties(Properties properties) {
-    // intentionally left empty as instructed in http://www.mybatis.org/mybatis-3/configuration.html
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.java
deleted file mode 100644
index 591b781..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.gen.JobInstanceUpdateEvent;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper class for JobInstanceUpdateEventMapper.xml
- *
- * See http://mybatis.github.io/mybatis-3/sqlmap-xml.html for more details.
- */
-interface JobInstanceUpdateEventMapper {
-
-  /**
-   * Inserts a new job instance update event into the database.
-   *
-   * @param key Update key of the event.
-   * @param event Event to insert.
-   */
-  void insert(@Param("key") IJobUpdateKey key, @Param("event") JobInstanceUpdateEvent event);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/JobKeyMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/JobKeyMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/JobKeyMapper.java
deleted file mode 100644
index ac0a998..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/JobKeyMapper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-
-/**
- * MyBatis mapper class for JobKeyMapper.xml
- *
- * See http://mybatis.github.io/mybatis-3/sqlmap-xml.html for more details.
- */
-interface JobKeyMapper extends GarbageCollectedTableMapper {
-  /**
-   * Saves the job key, updating the existing value if it exists.
-   */
-  void merge(IJobKey key);
-
-  /**
-   * Selects all job keys from the database.
-   */
-  List<JobKey> selectAll();
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.java
deleted file mode 100644
index 91053ef..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.gen.JobInstanceUpdateEvent;
-import org.apache.aurora.gen.JobUpdate;
-import org.apache.aurora.gen.JobUpdateQuery;
-import org.apache.aurora.gen.JobUpdateSummary;
-import org.apache.aurora.gen.Metadata;
-import org.apache.aurora.gen.Range;
-import org.apache.aurora.scheduler.storage.db.views.DbJobUpdate;
-import org.apache.aurora.scheduler.storage.db.views.DbJobUpdateInstructions;
-import org.apache.aurora.scheduler.storage.db.views.DbStoredJobUpdateDetails;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper class for JobUpdateDetailsMapper.xml
- *
- * See http://mybatis.github.io/mybatis-3/sqlmap-xml.html for more details.
- */
-interface JobUpdateDetailsMapper {
-
-  /**
-   * Inserts new job update.
-   *
-   * @param jobUpdate Job update to insert.
-   */
-  void insert(JobUpdate jobUpdate);
-
-  /**
-   * Inserts an association between an update and a lock.
-   *
-   * @param key Unique update identifier.
-   * @param lockToken Unique lock identifier, resulting from
-   *        {@link org.apache.aurora.scheduler.storage.entities.ILock#getToken()}.
-   */
-  void insertLockToken(@Param("key") IJobUpdateKey key, @Param("lockToken") String lockToken);
-
-  /**
-   * Inserts a task configuration entry for an update.
-   *
-   * @param key Update to insert task configs for.
-   * @param taskConfigRow task configuration row.
-   * @param isNew Flag to identify if the task config is existing {@code false} or
-   *              desired {@code true}.
-   * @param result Container for auto-generated ID of the inserted job update row.
-   */
-  void insertTaskConfig(
-      @Param("key") IJobUpdateKey key,
-      @Param("taskConfigRow") long taskConfigRow,
-      @Param("isNew") boolean isNew,
-      @Param("result") InsertResult result);
-
-  /**
-   * Inserts the job update metadata entries for an update.
-   *
-   * @param key Update to insert task configs for.
-   * @param metadata Set of metadata (key, value) pairs.
-   */
-  void insertJobUpdateMetadata(
-      @Param("key") IJobUpdateKey key,
-      @Param("metadata") Set<Metadata> metadata);
-
-  /**
-   * Maps inserted task config with a set of associated instance ranges.
-   *
-   * @param configId ID of the task config stored.
-   * @param ranges Set of instance ID ranges.
-   */
-  void insertTaskConfigInstances(
-      @Param("configId") long configId,
-      @Param("ranges") Set<Range> ranges);
-
-  /**
-   * Maps update with an optional set of
-   * {@link org.apache.aurora.gen.JobUpdateSettings#updateOnlyTheseInstances}.
-   *
-   * @param key Update to store overrides for.
-   * @param ranges Instance ID ranges to associate with an update.
-   */
-  void insertInstanceOverrides(@Param("key") IJobUpdateKey key, @Param("ranges") Set<Range> ranges);
-
-  /**
-   * Maps update with a set of instance IDs in
-   * {@link org.apache.aurora.gen.JobUpdateInstructions#desiredState}.
-   *
-   * @param key Update to store desired instances for.
-   * @param ranges Desired instance ID ranges to associate with an update.
-   */
-  void insertDesiredInstances(@Param("key") IJobUpdateKey key, @Param("ranges") Set<Range> ranges);
-
-  /**
-   * Deletes all updates and events from the database.
-   */
-  void truncate();
-
-  /**
-   * Deletes all updates and events with update ID in {@code updates}.
-   *
-   * @param rowIds Row IDs of updates to delete.
-   */
-  void deleteCompletedUpdates(@Param("rowIds") Set<Long> rowIds);
-
-  /**
-   * Selects all distinct job key IDs associated with at least {@code perJobRetainCount} completed
-   * updates or updates completed before {@code historyPruneThresholdMs}.
-   *
-   * @param perJobRetainCount Number of updates to keep per job.
-   * @param historyPruneThresholdMs History pruning timestamp threshold.
-   * @return Job key database row IDs.
-   */
-  Set<Long> selectJobKeysForPruning(
-      @Param("retainCount") int perJobRetainCount,
-      @Param("pruneThresholdMs") long historyPruneThresholdMs);
-
-  /**
-   * Groups all updates without a job lock in reverse chronological order of their created times
-   * and deletes anything in excess of {@code perJobRetainCount} or older than
-   * {@code historyPruneThresholdMs}.
-   *
-   * @param jobKeyId Job key ID to select pruning victims for.
-   * @param perJobRetainCount Number of updates to keep per job.
-   * @param historyPruneThresholdMs History pruning timestamp threshold.
-   * @return Victims to prune.
-   */
-  Set<PruneVictim> selectPruneVictims(
-      @Param("keyId") long jobKeyId,
-      @Param("retainCount") int perJobRetainCount,
-      @Param("pruneThresholdMs") long historyPruneThresholdMs);
-
-  /**
-   * Gets all job update summaries matching the provided {@code query}.
-   * All {@code query} fields are ANDed together.
-   *
-   * @param query Query to filter results by.
-   * @return Job update summaries matching the query.
-   */
-  List<JobUpdateSummary> selectSummaries(JobUpdateQuery query);
-
-  /**
-   * Gets details for the provided {@code key}.
-   *
-   * @param key Update to get.
-   * @return Job update details for the provided update ID, if it exists.
-   */
-  @Nullable
-  DbStoredJobUpdateDetails selectDetails(@Param("key") IJobUpdateKey key);
-
-  /**
-   * Gets all job update details matching the provided {@code query}.
-   * All {@code query} fields are ANDed together.
-   *
-   * @param query Query to filter results by.
-   * @return Job update details matching the query.
-   */
-  List<DbStoredJobUpdateDetails> selectDetailsList(JobUpdateQuery query);
-
-  /**
-   * Gets job update for the provided {@code update}.
-   *
-   * @param key Update to select by.
-   * @return Job update for the provided update ID, if it exists.
-   */
-  @Nullable
-  DbJobUpdate selectUpdate(@Param("key") IJobUpdateKey key);
-
-  /**
-   * Gets job update instructions for the provided {@code update}.
-   *
-   * @param key Update to select by.
-   * @return Job update instructions for the provided update ID, if it exists.
-   */
-  @Nullable
-  DbJobUpdateInstructions selectInstructions(@Param("key") IJobUpdateKey key);
-
-  /**
-   * Gets all stored job update details.
-   *
-   * @return All stored job update details.
-   */
-  Set<DbStoredJobUpdateDetails> selectAllDetails();
-
-  /**
-   * Gets job instance update events for a specific instance within an update.
-   *
-   * @param key Update identifier.
-   * @param instanceId Instance to fetch events for.
-   * @return Instance events affecting {@code instanceId} within {@code key}.
-   */
-  List<JobInstanceUpdateEvent> selectInstanceUpdateEvents(
-      @Param("key") IJobUpdateKey key,
-      @Param("instanceId") int instanceId);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.java
deleted file mode 100644
index d1a3c3f..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.gen.JobUpdateEvent;
-import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper class for JobUpdateEventMapper.xml
- *
- * See http://mybatis.github.io/mybatis-3/sqlmap-xml.html for more details.
- */
-interface JobUpdateEventMapper {
-
-  /**
-   * Inserts a new job update event into the database.
-   *
-   * @param key ID of the update associated with the event.
-   * @param event Event to insert.
-   */
-  void insert(@Param("key") IJobUpdateKey key, @Param("event") JobUpdateEvent event);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/LockKeyMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/LockKeyMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/LockKeyMapper.java
deleted file mode 100644
index 9760674..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/LockKeyMapper.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import com.google.inject.Inject;
-
-import org.apache.aurora.scheduler.storage.entities.ILockKey;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Mapper for LockKeys. Not a MyBatis mapper, this just encapsulates the logic for writing
- * union types so it does not leak into the related object's implementation.
- *
- * TODO(davmclau):
- * Consider creating these classes with code generation since something like this will be needed
- * for all union field relationships. Might not be possible unless the code generator also defines
- * a mapper interface for every field in the union as well as the associated XML mapper config
- * with the SQL to satisfy the interface.
- *
- */
-class LockKeyMapper {
-
-  private final JobKeyMapper jobKeyMapper;
-
-  @Inject
-  LockKeyMapper(JobKeyMapper jobKeyMapper) {
-    this.jobKeyMapper = requireNonNull(jobKeyMapper);
-  }
-
-  public void insert(ILockKey key) {
-    if (key.isSetJob()) {
-      jobKeyMapper.merge(requireNonNull(key.getJob()));
-    } else {
-      throw new IllegalArgumentException("Unsupported lock type on LockKey.");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/LockMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/LockMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/LockMapper.java
deleted file mode 100644
index b9f338c..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/LockMapper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-
-import org.apache.aurora.gen.Lock;
-import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.scheduler.storage.db.views.LockRow;
-
-/**
- * MyBatis mapper class for LockMapper.xml
- *
- * See http://mybatis.github.io/mybatis-3/sqlmap-xml.html for more details.
- */
-interface LockMapper {
-
-  /**
-   * Inserts a lock into the database.
-   */
-  void insert(Lock lock);
-
-  /**
-   * Deletes all locks from the database with the given lockKey.
-   */
-  void delete(LockKey lockKey);
-
-  /**
-   * Deletes all locks from the database.
-   */
-  void truncate();
-
-  /**
-   * Selects all locks from the database as {@link LockRow} instances.
-   */
-  List<LockRow> selectAll();
-
-  /**
-   * Fetches the lock with the given lock key.
-   */
-  LockRow select(LockKey lockKey);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManager.java b/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManager.java
deleted file mode 100644
index fa986da..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.sql.SQLException;
-
-/**
- * Manage schema migrations.
- */
-public interface MigrationManager {
-  /**
-   * Perform a migration, upgrading the schema if there are unapplied changes or downgrading it if
-   * there are applies changes which do not exist in the current version.
-   *
-   * @throws SQLException In the event of a problem performing the migration.
-   */
-  void migrate() throws SQLException;
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImpl.java b/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImpl.java
deleted file mode 100644
index f9b8c42..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImpl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.List;
-import javax.inject.Inject;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.CharStreams;
-
-import org.apache.aurora.scheduler.storage.db.views.MigrationChangelogEntry;
-import org.apache.ibatis.migration.Change;
-import org.apache.ibatis.migration.DataSourceConnectionProvider;
-import org.apache.ibatis.migration.MigrationLoader;
-import org.apache.ibatis.migration.operations.UpOperation;
-import org.apache.ibatis.migration.options.DatabaseOperationOption;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Objects.requireNonNull;
-
-public class MigrationManagerImpl implements MigrationManager {
-  private static final Logger LOG = LoggerFactory.getLogger(MigrationManagerImpl.class);
-
-  private final SqlSessionFactory sqlSessionFactory;
-  private final MigrationLoader migrationLoader;
-
-  @Inject
-  MigrationManagerImpl(SqlSessionFactory sqlSessionFactory, MigrationLoader migrationLoader) {
-    this.sqlSessionFactory = requireNonNull(sqlSessionFactory);
-    this.migrationLoader = requireNonNull(migrationLoader);
-  }
-
-  @Override
-  public void migrate() throws SQLException {
-    LOG.info("Running db migrations.");
-
-    try (SqlSession sqlSession = sqlSessionFactory.openSession(true /* auto commit */)) {
-      MigrationMapper mapper = sqlSession.getMapper(MigrationMapper.class);
-
-      LOG.info("Bootstrapping changelog table (if necessary).");
-      mapper.bootstrapChangelog();
-
-      if (!checkRollback(mapper, migrationLoader.getMigrations())) {
-        DatabaseOperationOption options = new DatabaseOperationOption();
-        options.setAutoCommit(true);
-
-        new UpOperation().operate(
-            new DataSourceConnectionProvider(
-                sqlSessionFactory.getConfiguration().getEnvironment().getDataSource()),
-            migrationLoader,
-            options,
-            null);
-
-        saveDowngradeScript(mapper);
-      }
-    }
-  }
-
-  /**
-   * Iterates applied changes to ensure they all exist on the classpath. For any changes that do not
-   * exist on the classpath, their downgrade script is run.
-   *
-   * @param mapper A {@link MigrationMapper} instance used to modify the changelog.
-   * @param changes The list of {@link Change}s found on the classpath.
-   * @return true if a rollback was detected, false otherwise.
-   * @throws SQLException in the event a SQL failure.
-   */
-  private boolean checkRollback(MigrationMapper mapper, List<Change> changes) throws SQLException {
-    boolean rollback = false;
-
-    List<MigrationChangelogEntry> appliedChanges = mapper.selectAll();
-
-    for (MigrationChangelogEntry change : appliedChanges) {
-      // We cannot directly call changes.contains(...) since contains relies on Change#equals
-      // which includes class in its equality check rather than checking instanceof. Instead we just
-      // find the first element in changes whose id matches our applied change. If it does not exist
-      // then this must be a rollback.
-      if (changes.stream().anyMatch(c -> c.getId().equals(change.getId()))) {
-        LOG.info("Change " + change.getId() + " has been applied, no other downgrades are "
-            + "necessary");
-        break;
-      }
-
-      LOG.info("No migration corresponding to change id " + change.getId() + " found. Assuming "
-          + "this is a rollback.");
-      LOG.info("Downgrade SQL for " + change.getId() + " is: " + change.getDowngradeScript());
-
-      try (SqlSession session = sqlSessionFactory.openSession(true)) {
-        try (Connection c = session.getConnection()) {
-          try (PreparedStatement downgrade = c.prepareStatement(change.getDowngradeScript())) {
-            downgrade.execute();
-            rollback = true;
-          }
-        }
-      }
-
-      LOG.info("Deleting applied change: " + change.getId());
-      mapper.delete(change.getId());
-    }
-
-    return rollback;
-  }
-
-  private void saveDowngradeScript(MigrationMapper mapper) {
-    for (Change c : migrationLoader.getMigrations()) {
-      try {
-        String downgradeScript = CharStreams.toString(migrationLoader.getScriptReader(c, true));
-        LOG.info("Saving downgrade script for change id " + c.getId() + ": " + downgradeScript);
-
-        mapper.saveDowngradeScript(c.getId(), downgradeScript.getBytes(Charsets.UTF_8));
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationMapper.java
deleted file mode 100644
index 0c17aa7..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/MigrationMapper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import org.apache.aurora.scheduler.storage.db.views.MigrationChangelogEntry;
-import org.apache.ibatis.annotations.Param;
-
-interface MigrationMapper {
-  /**
-   * Creates the changelog table if it does not already exist.
-   */
-  void bootstrapChangelog();
-
-  /**
-   * Saves the downgrade script for the supplied change id into the changelog.
-   *
-   * @param changeId The id of the change.
-   * @param downgradeScript The script to be run when a change is rolled back.
-   */
-  void saveDowngradeScript(
-      @Param("changeId") BigDecimal changeId,
-      @Param("downgradeScript") byte[] downgradeScript);
-
-  /**
-   * Select all applied changes from the changelog.
-   *
-   * @return A list of changelog entries mapping only their ids and downgrade scripts.
-   */
-  List<MigrationChangelogEntry> selectAll();
-
-  /**
-   * Deletes the specified change from the changelog.
-   *
-   * @param changeId The id of the change to delete.
-   */
-  void delete(@Param("changeId") BigDecimal changeId);
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImpl.java b/src/main/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImpl.java
deleted file mode 100644
index d9d406f..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReadWriteLock;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.primitives.Ints;
-
-import org.apache.aurora.common.stats.StatImpl;
-import org.apache.aurora.common.stats.Stats;
-import org.apache.ibatis.cache.Cache;
-
-import static java.util.Objects.requireNonNull;
-
-public class MyBatisCacheImpl implements Cache {
-  private com.google.common.cache.Cache<Object, Object> delegate;
-  private final String id;
-  private Integer size;
-  private final AtomicInteger clearCount = new AtomicInteger(0);
-
-  public MyBatisCacheImpl(String id) {
-    this.id = requireNonNull(id);
-  }
-
-  public void setSize(Integer size) {
-    this.size = requireNonNull(size);
-    initCache();
-  }
-
-  private void initCache() {
-    Preconditions.checkState(delegate == null);
-    requireNonNull(size);
-
-    delegate = CacheBuilder.newBuilder()
-        .maximumSize(size)
-        .recordStats()
-        .softValues()
-        .build();
-    initStats();
-  }
-
-  private void initStats() {
-    makeStat("request_count", () -> delegate.stats().requestCount());
-    makeStat("hit_count", () ->  delegate.stats().hitCount());
-    makeStat("hit_rate",  () -> delegate.stats().hitRate());
-    makeStat("miss_count", () -> delegate.stats().missCount());
-    makeStat("miss_rate", () -> delegate.stats().missRate());
-    makeStat("eviction_count", () -> delegate.stats().evictionCount());
-    makeStat("size", () -> delegate.size());
-    makeStat("clear_count", clearCount::get);
-  }
-
-  private <T extends Number> void makeStat(String name, Supplier<T> supplier) {
-    String prefix = "db_storage_mybatis_cache_" + id + "_";
-    Stats.export(new StatImpl<Number>(prefix + name) {
-      @Override
-      public Number read() {
-        return supplier.get();
-      }
-    });
-  }
-
-  @Override
-  public String getId() {
-    return id;
-  }
-
-  @Override
-  public void putObject(Object key, Object value) {
-    if (key == null || value == null) {
-      return;
-    }
-    delegate.put(key, value);
-  }
-
-  @Override
-  public Object getObject(Object key) {
-    return delegate.getIfPresent(key);
-  }
-
-  @Override
-  public Object removeObject(Object key) {
-    delegate.invalidate(key);
-    // MyBatis says the return value is not used.
-    return null;
-  }
-
-  @Override
-  public void clear() {
-    delegate.invalidateAll();
-    clearCount.incrementAndGet();
-  }
-
-  @Override
-  public int getSize() {
-    return Ints.saturatedCast(delegate.size());
-  }
-
-  @Override
-  public ReadWriteLock getReadWriteLock() {
-    // MyBatis says this value is no longer used.
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/PruneVictim.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/PruneVictim.java b/src/main/java/org/apache/aurora/scheduler/storage/db/PruneVictim.java
deleted file mode 100644
index 144f5a3..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/PruneVictim.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import org.apache.aurora.gen.JobUpdateKey;
-
-/**
- * A job update that should be pruned.
- */
-public class PruneVictim {
-  private long rowId;
-  private JobUpdateKey update;
-
-  public long getRowId() {
-    return rowId;
-  }
-
-  public JobUpdateKey getUpdate() {
-    return update;
-  }
-
-  public void setRowId(long rowId) {
-    this.rowId = rowId;
-  }
-
-  public void setUpdate(JobUpdateKey update) {
-    this.update = update;
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/QuotaMapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/QuotaMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/QuotaMapper.java
deleted file mode 100644
index 7ebbb43..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/QuotaMapper.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-import org.apache.aurora.gen.ResourceAggregate;
-import org.apache.aurora.scheduler.storage.db.views.DBResourceAggregate;
-import org.apache.aurora.scheduler.storage.db.views.DBSaveQuota;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * MyBatis mapper class for QuotaMapper.xml.
- */
-interface QuotaMapper {
-  /**
-   * Inserts the quota for the given {@code role}.
-   *
-   * @param role Role to insert quota for.
-   * @param quota Quota value to store.
-   * @param result Container for auto-generated ID of the inserted row.
-   */
-  void insert(
-      @Param("role") String role,
-      @Param("quota") ResourceAggregate quota,
-      @Param("result") InsertResult result);
-
-  /**
-   * Insert quota resources.
-   *
-   * @param quotaId Quota ID to merge resources for.
-   * @param values Resources to merge.
-   */
-  void insertResources(
-      @Param("quotaId") long quotaId,
-      @Param("values") Map<Integer, String> values);
-
-  /**
-   * Gets the quota assigned to a role.
-   *
-   * @param role Role to select quota for.
-   * @return The previously-saved quota for the role, if it exists.
-   */
-  @Nullable
-  DBResourceAggregate select(String role);
-
-  /**
-   * Gets all saved quotas.
-   *
-   * @return All quotas stored in the database.
-   */
-  List<DBSaveQuota> selectAll();
-
-  /**
-   * Removes the quota stored for a role.
-   *
-   * @param role Role to delete the quota entry for, if one exists.
-   */
-  void delete(String role);
-
-  /**
-   * Removes all stored quota records.
-   */
-  void truncate();
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java b/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
deleted file mode 100644
index d29bcf3..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.inject.Inject;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.AbstractScheduledService;
-
-import org.apache.aurora.common.inject.TimedInterceptor.Timed;
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
-import org.apache.ibatis.exceptions.PersistenceException;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * A periodic cleanup routine for unreferenced database relations.
- */
-class RowGarbageCollector extends AbstractScheduledService {
-
-  private static final Logger LOG = LoggerFactory.getLogger(RowGarbageCollector.class);
-
-  // Note: these are deliberately ordered to remove 'parent' references first, but since
-  // this is an iterative process, it is not strictly necessary.
-  private static final List<Class<? extends GarbageCollectedTableMapper>> TABLES =
-      ImmutableList.of(TaskConfigMapper.class, JobKeyMapper.class);
-
-  private final AtomicLong deletedCount;
-  private final Scheduler iterationScheduler;
-  private final SqlSessionFactory sessionFactory;
-
-  // Note: Storage is only used to acquire the same application-level lock used by other storage
-  // mutations.  This sidesteps the issue of DB deadlocks (e.g. AURORA-1401).
-  private final Storage storage;
-
-  @Inject
-  RowGarbageCollector(
-      Scheduler iterationScheduler,
-      SqlSessionFactory sessionFactory,
-      Storage storage,
-      StatsProvider statsProvider) {
-
-    this.iterationScheduler = requireNonNull(iterationScheduler);
-    this.sessionFactory = requireNonNull(sessionFactory);
-    this.storage = requireNonNull(storage);
-    this.deletedCount = statsProvider.makeCounter("row_garbage_collector_deleted");
-  }
-
-  @Override
-  protected Scheduler scheduler() {
-    return iterationScheduler;
-  }
-
-  @Timed("row_garbage_collector_run")
-  @VisibleForTesting
-  @Override
-  public void runOneIteration() {
-    LOG.info("Scanning database tables for unreferenced rows.");
-
-    long startCount = deletedCount.get();
-    for (Class<? extends GarbageCollectedTableMapper> tableClass : TABLES) {
-      storage.write((NoResult.Quiet) storeProvider -> {
-        try (SqlSession session = sessionFactory.openSession(true)) {
-          GarbageCollectedTableMapper table = session.getMapper(tableClass);
-          for (long rowId : table.selectAllRowIds()) {
-            try {
-              table.deleteRow(rowId);
-              deletedCount.incrementAndGet();
-            } catch (PersistenceException e) {
-              // Expected for rows that are still referenced.
-            }
-          }
-        }
-      });
-    }
-    LOG.info("Deleted {} unreferenced rows.", Long.valueOf(deletedCount.get() - startCount));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigManager.java b/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigManager.java
deleted file mode 100644
index d2eb6aa..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigManager.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db;
-
-import java.util.Map;
-import java.util.Optional;
-
-import javax.inject.Inject;
-
-import com.google.common.collect.Maps;
-
-import org.apache.aurora.scheduler.storage.db.views.DBResourceAggregate;
-import org.apache.aurora.scheduler.storage.db.views.DbTaskConfig;
-import org.apache.aurora.scheduler.storage.entities.IAppcImage;
-import org.apache.aurora.scheduler.storage.entities.IConstraint;
-import org.apache.aurora.scheduler.storage.entities.IDockerContainer;
-import org.apache.aurora.scheduler.storage.entities.IDockerImage;
-import org.apache.aurora.scheduler.storage.entities.IImage;
-import org.apache.aurora.scheduler.storage.entities.IMesosContainer;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-import org.apache.aurora.scheduler.storage.entities.IValueConstraint;
-
-import static java.util.Objects.requireNonNull;
-
-class TaskConfigManager {
-  private final TaskConfigMapper configMapper;
-  private final JobKeyMapper jobKeyMapper;
-
-  @Inject
-  TaskConfigManager(TaskConfigMapper configMapper, JobKeyMapper jobKeyMapper) {
-    this.configMapper = requireNonNull(configMapper);
-    this.jobKeyMapper = requireNonNull(jobKeyMapper);
-  }
-
-  private Optional<Long> getConfigRow(ITaskConfig config) {
-    // NOTE: The 'config' object passed in MUST have all version-relevant fields populated in order
-    // to correctly compare with objects loaded from DB. This may not hold true if a 'config' is
-    // passed from storage recovery routine during version downgrade and fields are not properly
-    // backfilled. See AURORA-1603 for more details.
-
-    // We could optimize this slightly by first comparing the un-hydrated row and breaking early.
-    Map<ITaskConfig, DbTaskConfig> rowsByConfig =
-        Maps.uniqueIndex(
-            configMapper.selectConfigsByJob(config.getJob()),
-            DbTaskConfig::toImmutable);
-
-    return Optional.ofNullable(rowsByConfig.get(config)).map(DbTaskConfig::getRowId);
-  }
-
-  long insert(ITaskConfig config) {
-    InsertResult configInsert = new InsertResult();
-
-    // Determine whether this config is already stored.
-    Optional<Long> existingRow = getConfigRow(config);
-    if (existingRow.isPresent()) {
-      return existingRow.get();
-    }
-
-    jobKeyMapper.merge(config.getJob());
-    configMapper.insert(config, configInsert);
-    for (IConstraint constraint : config.getConstraints()) {
-      InsertResult constraintResult = new InsertResult();
-      configMapper.insertConstraint(configInsert.getId(), constraint, constraintResult);
-      switch (constraint.getConstraint().getSetField()) {
-        case VALUE:
-          IValueConstraint valueConstraint = constraint.getConstraint().getValue();
-          InsertResult valueResult = new InsertResult();
-          configMapper.insertValueConstraint(
-              constraintResult.getId(),
-              valueConstraint,
-              valueResult);
-          configMapper.insertValueConstraintValues(
-              valueResult.getId(),
-              valueConstraint.getValues());
-          break;
-
-        case LIMIT:
-          configMapper.insertLimitConstraint(
-              constraintResult.getId(),
-              constraint.getConstraint().getLimit());
-          break;
-
-        default:
-          throw new IllegalStateException(
-              "Unhandled constraint type " + constraint.getConstraint().getSetField());
-      }
-    }
-
-    if (!config.getResources().isEmpty()) {
-      configMapper.insertResources(
-          configInsert.getId(),
-          DBResourceAggregate.pairsFromResources(config.getResources()));
-    }
-
-    if (!config.getRequestedPorts().isEmpty()) {
-      configMapper.insertRequestedPorts(configInsert.getId(), config.getRequestedPorts());
-    }
-
-    if (!config.getTaskLinks().isEmpty()) {
-      configMapper.insertTaskLinks(configInsert.getId(), config.getTaskLinks());
-    }
-
-    if (!config.getMetadata().isEmpty()) {
-      configMapper.insertMetadata(configInsert.getId(), config.getMetadata());
-    }
-
-    if (!config.getMesosFetcherUris().isEmpty()) {
-      configMapper.insertMesosFetcherUris(configInsert.getId(), config.getMesosFetcherUris());
-    }
-
-    if (config.getContainer().isSetDocker()) {
-      IDockerContainer container = config.getContainer().getDocker();
-      InsertResult containerInsert = new InsertResult();
-      configMapper.insertContainer(configInsert.getId(), container, containerInsert);
-      if (!container.getParameters().isEmpty()) {
-        configMapper.insertDockerParameters(containerInsert.getId(), container.getParameters());
-      }
-    } else if (config.getContainer().isSetMesos()
-        && config.getContainer().getMesos().isSetImage()) {
-
-      IMesosContainer container = config.getContainer().getMesos();
-      IImage image = container.getImage();
-
-      switch (image.getSetField()) {
-        case DOCKER:
-          IDockerImage dockerImage = image.getDocker();
-          configMapper.insertDockerImage(
-              configInsert.getId(),
-              dockerImage.getName(),
-              dockerImage.getTag());
-          break;
-        case APPC:
-          IAppcImage appcImage = image.getAppc();
-          configMapper.insertAppcImage(
-              configInsert.getId(),
-              appcImage.getName(),
-              appcImage.getImageId());
-          break;
-        default:
-          throw new IllegalStateException("Unexpected image type: " + image.getSetField());
-      }
-
-      if (!container.getVolumes().isEmpty()) {
-        configMapper.insertVolumes(configInsert.getId(), container.getVolumes());
-      }
-    }
-
-    return configInsert.getId();
-  }
-}


[2/5] aurora git commit: Remove the internal SQL database

Posted by wf...@apache.org.
http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/Pairs.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/Pairs.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/Pairs.java
deleted file mode 100644
index 106b7af..0000000
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/Pairs.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.storage.db.views;
-
-import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
-
-import org.apache.aurora.common.collections.Pair;
-
-/**
- * Utility class for translating collections of {@link Pair} to and from maps.
- */
-public final class Pairs {
-
-  private Pairs() {
-    // Utility class.
-  }
-
-  public static <K, V> Map<K, V> toMap(Iterable<Pair<K, V>> pairs) {
-    ImmutableMap.Builder<K, V> map = ImmutableMap.builder();
-    for (Pair<K, V> pair : pairs) {
-      map.put(pair.getFirst(), pair.getSecond());
-    }
-    return map.build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/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 3258879..6462b80 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
@@ -13,27 +13,19 @@
  */
 package org.apache.aurora.scheduler.storage.log;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
 import java.util.Arrays;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.inject.Inject;
-import javax.sql.DataSource;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.inject.Injector;
 
 import org.apache.aurora.common.inject.TimedInterceptor.Timed;
 import org.apache.aurora.common.stats.SlidingStats;
@@ -57,11 +49,6 @@ import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.Storage.Volatile;
-import org.apache.aurora.scheduler.storage.db.DbModule;
-import org.apache.aurora.scheduler.storage.db.DbStorage;
-import org.apache.aurora.scheduler.storage.db.DbUtil;
-import org.apache.aurora.scheduler.storage.db.EnumBackfill;
-import org.apache.aurora.scheduler.storage.db.MigrationManager;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent;
@@ -88,12 +75,6 @@ public class SnapshotStoreImpl implements SnapshotStore<Snapshot> {
 
   private static final Logger LOG = LoggerFactory.getLogger(SnapshotStoreImpl.class);
 
-  /**
-   * Number of rows to run in a single batch during dbsnapshot restore.
-   */
-  private static final int DB_BATCH_SIZE = 20;
-
-  private static final String DB_SCRIPT_FIELD = "dbscript";
   private static final String LOCK_FIELD = "locks";
   private static final String HOST_ATTRIBUTES_FIELD = "hosts";
   private static final String QUOTA_FIELD = "quota";
@@ -110,73 +91,6 @@ public class SnapshotStoreImpl implements SnapshotStore<Snapshot> {
   }
 
   private final Iterable<SnapshotField> snapshotFields = Arrays.asList(
-      // Order is critical here. The DB snapshot should always be tried first to ensure
-      // graceful migration to DBTaskStore. Otherwise, there is a direct risk of losing the cluster.
-      // The following scenario illustrates how that can happen:
-      // - Dbsnapshot:ON, DBTaskStore:OFF
-      // - Scheduler is updated with DBTaskStore:ON, restarts and populates all tasks from snapshot
-      // - Should the dbsnapshot get applied last, all tables would be dropped and recreated BUT
-      //   since there was no task data stored in dbsnapshot (DBTaskStore was OFF last time
-      //   snapshot was cut), all tasks would be erased
-      // - If the above is not detected before a new snapshot is cut all tasks will be dropped the
-      //   moment a new snapshot is created
-      new SnapshotField() {
-        @Override
-        public String getName() {
-          return DB_SCRIPT_FIELD;
-        }
-
-        @Override
-        public void saveToSnapshot(MutableStoreProvider store, Snapshot snapshot) {
-          // No-op.
-        }
-
-        @Override
-        public void restoreFromSnapshot(MutableStoreProvider store, Snapshot snapshot) {
-          if (snapshot.isSetDbScript()) {
-            LOG.info("Loading contents from legacy dbScript field");
-
-            Injector injector = DbUtil.createStorageInjector(DbModule.testModuleWithWorkQueue());
-
-            DbStorage tempStorage = injector.getInstance(DbStorage.class);
-            MigrationManager migrationManager = injector.getInstance(MigrationManager.class);
-            EnumBackfill enumBackfill = injector.getInstance(EnumBackfill.class);
-
-            try (Connection c = ((DataSource) tempStorage.getUnsafeStoreAccess()).getConnection()) {
-              LOG.info("Dropping all tables");
-              try (PreparedStatement drop = c.prepareStatement("DROP ALL OBJECTS")) {
-                drop.executeUpdate();
-              }
-
-              LOG.info("Restoring dbsnapshot. Row count: " + snapshot.getDbScript().size());
-              // Partition the restore script into manageable size batches to avoid possible OOM
-              // due to large size DML statement.
-              List<List<String>> batches = Lists.partition(snapshot.getDbScript(), DB_BATCH_SIZE);
-              for (List<String> batch : batches) {
-                try (PreparedStatement restore = c.prepareStatement(Joiner.on("").join(batch))) {
-                  restore.executeUpdate();
-                }
-              }
-            } catch (SQLException e) {
-              throw new RuntimeException(e);
-            }
-
-            try {
-              migrationManager.migrate();
-            } catch (SQLException e) {
-              throw new RuntimeException(e);
-            }
-
-            // This ensures any subsequently added enum values since the last snapshot exist in
-            // the db.
-            enumBackfill.backfill();
-
-            // Load the contents of the DB into the main storage.
-            Snapshot dbSnapshot = createSnapshot(tempStorage);
-            applySnapshot(dbSnapshot);
-          }
-        }
-      },
       new SnapshotField() {
         @Override
         public String getName() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
deleted file mode 100644
index d49c90b..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.AttributeMapper">
-  <cache type="org.apache.aurora.scheduler.storage.db.MyBatisCacheImpl">
-    <property name="size" value="50000"/>
-  </cache>
-  <insert id="insert">
-    INSERT INTO host_attributes (
-      host,
-      mode,
-      slave_id
-    ) VALUES (
-      #{host},
-      #{mode, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.MaintenanceModeTypeHandler},
-      #{slaveId}
-    )
-  </insert>
-
-  <insert id="insertAttributeValues">
-    INSERT INTO host_attribute_values (
-      host_attribute_id,
-      name,
-      value
-    ) VALUES
-    <foreach item="attribute" collection="attributes" separator=",">
-      <foreach item="value" collection="attribute.values" open="(" separator="),(" close=")">
-        (SELECT id FROM host_attributes WHERE slave_id = #{slaveId}),
-        #{attribute.name},
-        #{value}
-      </foreach>
-    </foreach>
-  </insert>
-
-  <delete id="deleteAttributeValues">
-    <!-- This assumes the schema enables cascading deletes in the values table. -->
-    DELETE FROM host_attribute_values
-    WHERE host_attribute_id IN (SELECT id FROM host_attributes WHERE host = #{host})
-  </delete>
-
-  <update id="updateHostModeAndSlaveId">
-    UPDATE host_attributes SET
-      mode = #{mode, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.MaintenanceModeTypeHandler},
-      slave_id = #{slaveId}
-    WHERE host = #{host}
-  </update>
-
-  <resultMap id="hostAttributeResultMap" type="org.apache.aurora.gen.HostAttributes">
-    <id column="a_id" />
-    <result property="mode"
-            column="a_mode"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.MaintenanceModeTypeHandler" />
-    <result property="host" column="a_host" />
-    <result property="slaveId" column="a_slave_id" />
-    <collection property="attributes" ofType="org.apache.aurora.gen.Attribute" columnPrefix="v_">
-      <id column="name" property="name" />
-      <collection property="values" ofType="String">
-        <result column="value" />
-      </collection>
-    </collection>
-  </resultMap>
-
-  <sql id="unscoped_select">
-    SELECT
-      a.id AS a_id,
-      a.host AS a_host,
-      a.mode AS a_mode,
-      a.slave_id AS a_slave_id,
-      v.id AS v_id,
-      v.name AS v_name,
-      v.value AS v_value
-    FROM host_attributes as a
-    // Left outer join since a host attribute may have an empty set of values (no matching rows).
-    LEFT OUTER JOIN host_attribute_values AS v ON v.host_attribute_id = a.id
-  </sql>
-
-  <select id="select" resultMap="hostAttributeResultMap">
-    <include refid="unscoped_select"/>
-    WHERE host = #{host}
-  </select>
-
-  <select id="selectAll" resultMap="hostAttributeResultMap">
-    <include refid="unscoped_select"/>
-  </select>
-
-  <delete id="truncate">
-    DELETE FROM host_attributes
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/CronJobMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/CronJobMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/CronJobMapper.xml
deleted file mode 100644
index 1434f45..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/CronJobMapper.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.CronJobMapper">
-
-  <insert id="merge">
-    MERGE INTO cron_jobs(
-      job_key_id,
-      creator_user,
-      cron_schedule,
-      <if test="job.cronCollisionPolicy != null">
-        cron_collision_policy,
-      </if>
-      task_config_row_id,
-      instance_count
-    ) KEY(job_key_id) VALUES (
-      (
-        SELECT ID
-        FROM job_keys
-        WHERE role = #{job.key.role}
-          AND environment = #{job.key.environment}
-          AND name = #{job.key.name}
-      ),
-      #{job.owner.user},
-      #{job.cronSchedule},
-      <if test="job.cronCollisionPolicy != null">
-      #{job.cronCollisionPolicy, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.CronCollisionPolicyTypeHandler},
-      </if>
-      #{task_config_id},
-      #{job.instanceCount}
-    )
-  </insert>
-
-  <delete id="delete">
-    DELETE FROM cron_jobs
-    WHERE job_key_id
-    IN (SELECT id
-        FROM job_keys
-        WHERE role = #{job.role}
-          AND environment = #{job.environment}
-          AND name = #{job.name})
-  </delete>
-
-  <delete id="truncate">
-    DELETE FROM cron_jobs
-  </delete>
-
-  <resultMap
-      id="cronJobWrapperResultMap"
-      type="org.apache.aurora.scheduler.storage.db.views.DbJobConfiguration">
-
-    <id column="c_id" />
-    <result property="owner.user" column="creator_user"/>
-    <result
-        property="cronCollisionPolicy"
-        column="cron_collision_policy"
-        typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.CronCollisionPolicyTypeHandler"/>
-    <association
-        property="key"
-        resultMap="org.apache.aurora.scheduler.storage.db.JobKeyMapper.jobKeyMap"
-        columnPrefix="j_"/>
-    <association
-        property="taskConfig"
-        select="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.selectConfig"
-        column="task_config_row_id"
-        foreignColumn="id"/>
-  </resultMap>
-
-  <sql id="unscopedSelect">
-    SELECT
-      c.id AS c_id,
-      c.creator_user AS creator_user,
-      c.cron_schedule AS cron_schedule,
-      c.cron_collision_policy AS cron_collision_policy,
-      c.task_config_row_id AS task_config_row_id,
-      c.instance_count AS instance_count,
-      j.role AS j_role,
-      j.environment AS j_environment,
-      j.name AS j_name
-    FROM cron_jobs AS c
-    INNER JOIN job_keys AS j ON j.id = c.job_key_id
-  </sql>
-
-  <select id="selectAll" resultMap="cronJobWrapperResultMap">
-    <include refid="unscopedSelect"/>
-  </select>
-
-  <select id="select" resultMap="cronJobWrapperResultMap">
-    <include refid="unscopedSelect"/>
-    WHERE j.role = #{job.role}
-      AND environment = #{job.environment}
-      AND name = #{job.name}
-  </select>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/EnumValueMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/EnumValueMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/EnumValueMapper.xml
deleted file mode 100644
index b1f9672..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/EnumValueMapper.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.EnumValueMapper">
-  <insert id="addEnumValue">
-    MERGE INTO ${table} (
-      id,
-      name
-    ) VALUES (
-      #{id},
-      #{name}
-    )
-  </insert>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.xml
deleted file mode 100644
index 74568ab..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/FrameworkIdMapper.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.FrameworkIdMapper">
-  <insert id="insert">
-    MERGE INTO framework_id (
-      id,
-      framework_id
-    ) KEY(id) VALUES (
-      1,
-      #{id}
-    )
-  </insert>
-
-  <select id="select" resultType="String">
-    SELECT framework_id FROM framework_id
-  </select>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.xml
deleted file mode 100644
index 1b58406..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobInstanceUpdateEventMapper.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.JobInstanceUpdateEventMapper">
-  <insert id="insert">
-    INSERT INTO job_instance_update_events (
-      update_row_id,
-      action,
-      instance_id,
-      timestamp_ms
-    ) VALUES (
-      <include refid="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper.select_update_row_id"/>,
-      #{event.action, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateActionTypeHandler},
-      #{event.instanceId},
-      #{event.timestampMs}
-    )
-  </insert>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/JobKeyMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobKeyMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobKeyMapper.xml
deleted file mode 100644
index 3b5a7c9..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobKeyMapper.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.JobKeyMapper">
-  <insert id="merge">
-    MERGE INTO job_keys (
-      role,
-      environment,
-      name
-    ) KEY(role, environment, name) VALUES (
-      #{role},
-      #{environment},
-      #{name}
-    )
-  </insert>
-
-  <select id="selectAll" resultType="org.apache.aurora.gen.JobKey">
-    SELECT * FROM job_keys
-  </select>
-
-  <select id="selectAllRowIds" resultType="long">
-    SELECT id FROM job_keys
-  </select>
-
-  <delete id="deleteRow">
-    DELETE FROM job_keys WHERE id = #{rowId}
-  </delete>
-
-  <resultMap id="jobKeyMap" type="org.apache.aurora.gen.JobKey">
-    <id column="id" />
-  </resultMap>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
deleted file mode 100644
index aded483..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
+++ /dev/null
@@ -1,598 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper">
-  <sql id="job_key_inner_join">
-    INNER JOIN job_keys AS j ON j.id = u.job_key_id
-  </sql>
-
-  <sql id="filter_by_update_key">
-    u.update_id = #{key.id}
-    AND j.role = #{key.job.role}
-    AND j.environment = #{key.job.environment}
-    AND j.name = #{key.job.name}
-  </sql>
-
-  <sql id="select_update_row_id">
-      (
-        SELECT u.id
-        FROM job_updates AS u
-        <!-- Full qualification is needed since this fragment is accessed from outside of this
-             mapper.  Without full qualification, mybatis looks for job_key_inner_join in the
-             caller's namespace.  It's unclear if this is a feature or bug in mybatis.
-         -->
-        <include refid="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper.job_key_inner_join"/>
-        WHERE <include refid="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper.filter_by_update_key"/>
-      )
-  </sql>
-
-  <insert id="insert">
-    INSERT INTO job_updates (
-      job_key_id,
-      update_id,
-      user,
-      update_group_size,
-      max_per_instance_failures,
-      max_failed_instances,
-      min_wait_in_instance_running_ms,
-      rollback_on_failure,
-      wait_for_batch_completion,
-      block_if_no_pulses_after_ms
-    ) VALUES (
-      (
-        SELECT ID
-        FROM job_keys
-        WHERE role = #{summary.key.job.role}
-          AND environment = #{summary.key.job.environment}
-          AND name = #{summary.key.job.name}
-      ),
-      #{summary.key.id},
-      #{summary.user},
-      #{instructions.settings.updateGroupSize},
-      #{instructions.settings.maxPerInstanceFailures},
-      #{instructions.settings.maxFailedInstances},
-      #{instructions.settings.minWaitInInstanceRunningMs},
-      #{instructions.settings.rollbackOnFailure},
-      #{instructions.settings.waitForBatchCompletion},
-      #{instructions.settings.blockIfNoPulsesAfterMs},
-    )
-  </insert>
-
-  <insert id="insertLockToken">
-    INSERT INTO job_update_locks (
-      update_row_id,
-      lock_token
-    ) VALUES (
-      <include refid="select_update_row_id"/>,
-      #{lockToken}
-    )
-  </insert>
-
-  <insert id="insertTaskConfig" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO job_update_configs (
-      update_row_id,
-      task_config_row_id,
-      is_new
-    ) VALUES (
-      <include refid="select_update_row_id"/>,
-      #{taskConfigRow},
-      #{isNew}
-    )
-  </insert>
-
-  <insert id="insertJobUpdateMetadata">
-    INSERT INTO job_update_metadata (
-      update_row_id,
-      key,
-      value
-    ) VALUES
-    <foreach item="element" collection="metadata" open="(" separator="),(" close=")">
-      <include refid="select_update_row_id"/>,
-      #{element.key},
-      #{element.value}
-    </foreach>
-  </insert>
-
-  <sql id="insert_instance_ranges">
-    <foreach item="element" collection="ranges" open="(" separator="),(" close=")">
-      <include refid="select_update_row_id"/>,
-      #{element.first},
-      #{element.last}
-    </foreach>
-  </sql>
-
-  <insert id="insertTaskConfigInstances">
-    INSERT INTO job_update_configs_to_instances (
-      config_id,
-      first,
-      last
-    ) VALUES
-    <foreach item="element" collection="ranges" open="(" separator="),(" close=")">
-      #{configId},
-      #{element.first},
-      #{element.last}
-    </foreach>
-  </insert>
-
-  <insert id="insertInstanceOverrides">
-    INSERT INTO job_updates_to_instance_overrides (
-      update_row_id,
-      first,
-      last
-    ) VALUES
-  <include refid="insert_instance_ranges" />
-  </insert>
-
-  <insert id="insertDesiredInstances">
-    INSERT INTO job_updates_to_desired_instances (
-      update_row_id,
-      first,
-      last
-    ) VALUES
-    <include refid="insert_instance_ranges" />
-  </insert>
-
-  <resultMap id="jobUpdateStateMap" type="org.apache.aurora.gen.JobUpdateState">
-    <id column="update_id" />
-    <result property="status"
-            column="status"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateStatusTypeHandler" />
-  </resultMap>
-
-  <resultMap id="jobUpdateSummaryMap" type="org.apache.aurora.gen.JobUpdateSummary">
-    <id column="update_id" property="key.id" javaType="String" />
-    <association property="key.job"
-                 resultMap="org.apache.aurora.scheduler.storage.db.JobKeyMapper.jobKeyMap"
-                 columnPrefix="jk_"/>
-    <association property="state"
-                 resultMap="jobUpdateStateMap"
-                 columnPrefix="just_" />
-    <collection property="metadata"
-                select="selectJobUpdateMetadata"
-                column="id"
-                foreignColumn="update_row_id">
-    </collection>
-  </resultMap>
-
-  <resultMap id="rangeMap" type="org.apache.aurora.gen.Range">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap
-      id="instanceConfigMap"
-      type="org.apache.aurora.scheduler.storage.db.views.DbInstanceTaskConfig">
-    <id column="id" />
-    <association
-        property="task"
-        select="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.selectConfig"
-        column="task_config_row_id"
-        foreignColumn="row_id"/>
-    <collection property="instances" resultMap="rangeMap" columnPrefix="r_" notNullColumn="id" />
-  </resultMap>
-
-  <resultMap id="jobUpdateSettingsMap" type="org.apache.aurora.gen.JobUpdateSettings">
-    <id column="id" />
-    <collection property="updateOnlyTheseInstances"
-                select="selectInstanceOverrides"
-                column="id"
-                foreignColumn="update_row_id" />
-  </resultMap>
-
-  <resultMap
-      id="jobUpdateInstructionMap"
-      type="org.apache.aurora.scheduler.storage.db.views.DbJobUpdateInstructions">
-    <id column="id" />
-    <association property="desiredState" resultMap="instanceConfigMap" columnPrefix="ditc_" />
-    <association property="settings" resultMap="jobUpdateSettingsMap" columnPrefix="juse_"/>
-    <collection property="initialState"
-                select="selectInstanceConfigs"
-                column="id"
-                foreignColumn="update_row_id" />
-  </resultMap>
-
-  <resultMap id="jobUpdateMap" type="org.apache.aurora.scheduler.storage.db.views.DbJobUpdate">
-    <id column="u_id" />
-    <association property="summary" resultMap="jobUpdateSummaryMap" columnPrefix="jusm_"/>
-    <association property="instructions" resultMap="jobUpdateInstructionMap" columnPrefix="jui_"/>
-  </resultMap>
-
-  <resultMap id="metadataMap" type="org.apache.aurora.gen.Metadata">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap id="jobInstanceUpdateMap" type="org.apache.aurora.gen.JobInstanceUpdateEvent">
-    <id column="id" />
-    <result property="action"
-            column="action"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateActionTypeHandler"/>
-  </resultMap>
-
-  <resultMap id="jobUpdateEventMap" type="org.apache.aurora.gen.JobUpdateEvent">
-    <id column="id" />
-    <result property="status"
-            column="status"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateStatusTypeHandler"/>
-  </resultMap>
-
-  <resultMap
-      id="jobUpdateDetailsMap"
-      type="org.apache.aurora.scheduler.storage.db.views.DbStoredJobUpdateDetails">
-    <id column="u_id" />
-    <association property="details.update" resultMap="jobUpdateMap" />
-    <collection property="details.updateEvents"
-                select="selectUpdateEvents"
-                column="u_id"
-                foreignColumn="update_row_id">
-    </collection>
-    <collection property="details.instanceEvents"
-                select="selectInstanceEvents"
-                column="u_id"
-                foreignColumn="update_row_id">
-    </collection>
-  </resultMap>
-
-  <sql id="status_inner_join">
-    INNER JOIN
-    (
-      SELECT
-        e_s.update_row_id,
-        e_s.status
-      FROM job_update_events AS e_s
-      INNER JOIN
-      (
-        SELECT
-          update_row_id,
-          MAX(timestamp_ms) AS timestamp_ms
-        FROM job_update_events
-        GROUP BY update_row_id
-      ) AS e_t ON e_t.update_row_id = e_s.update_row_id AND e_t.timestamp_ms = e_s.timestamp_ms
-    ) AS max_status ON max_status.update_row_id = u.id
-  </sql>
-
-  <sql id="created_timestamp_inner_join">
-    INNER JOIN
-    (
-      SELECT
-        update_row_id,
-        MIN(timestamp_ms) AS timestamp_ms
-      FROM job_update_events
-      GROUP BY update_row_id
-    ) AS min_ts ON min_ts.update_row_id = u.id
-  </sql>
-
-  <sql id="last_updated_timestamp_inner_join">
-    INNER JOIN
-    (
-      SELECT
-        update_row_id,
-        MAX(timestamp_ms) AS timestamp_ms
-      FROM
-      (
-        SELECT
-          update_row_id,
-          timestamp_ms
-        FROM job_update_events
-        UNION ALL
-        SELECT
-          update_row_id,
-          timestamp_ms
-        FROM job_instance_update_events
-      )
-      GROUP BY update_row_id
-    ) AS max_ts ON max_ts.update_row_id = u.id
-  </sql>
-
-  <sql id="timestamps_inner_joins">
-    <include refid="status_inner_join" />
-    <include refid="created_timestamp_inner_join" />
-    <include refid="last_updated_timestamp_inner_join" />
-  </sql>
-
-  <sql id="query_filter">
-    <if test="key != null || role != null || user != null || jobKey != null || updateStatuses != null || limit != 0 || offset != 0">
-      WHERE TRUE
-      <if test="key != null">
-        AND <include refid="filter_by_update_key"/>
-      </if>
-      <if test="user != null">AND u.user = #{user}</if>
-      <if test="role != null">AND j.role = #{role}</if>
-      <if test="jobKey != null">
-        AND j.role = #{jobKey.role}
-        AND j.name = #{jobKey.name}
-        AND j.environment = #{jobKey.environment}
-      </if>
-      <if test="updateStatuses != null and !updateStatuses.isEmpty()">
-        AND (max_status.status IN
-        <foreach item="element" collection="updateStatuses" open="(" separator="," close="))">
-          #{element, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateStatusTypeHandler}
-        </foreach>
-      </if>
-    </if>
-    ORDER BY max_ts.timestamp_ms DESC
-    <if test="limit != 0">LIMIT #{limit}</if>
-    <if test="offset != 0">OFFSET #{offset}</if>
-  </sql>
-
-  <select id="selectSummaries" resultMap="jobUpdateSummaryMap">
-    SELECT
-      u.id AS id,
-      u.update_id AS update_id,
-      u.user AS user,
-      max_status.status AS just_status,
-      min_ts.timestamp_ms AS just_created_timestamp_ms,
-      max_ts.timestamp_ms AS just_last_modified_timestamp_ms,
-      j.id AS jk_id,
-      j.role AS jk_role,
-      j.environment AS jk_environment,
-      j.name AS jk_name
-    FROM job_updates AS u
-    <include refid="job_key_inner_join" />
-    <include refid="timestamps_inner_joins" />
-    <include refid="query_filter" />
-  </select>
-
-  <!--Column naming convention below follows the thrift object hierarchy and columnPrefix
-    attributes used in associations.
-    For example: jusm_just_status maps to JobUpdateSummary/JobUpdateState/status field.-->
-  <sql id="job_update_columns">
-      u.id AS u_id,
-      u.id AS jusm_id,
-      u.update_id AS jusm_update_id,
-      u.user AS jusm_user,
-      max_status.status AS jusm_just_status,
-      min_ts.timestamp_ms AS jusm_just_created_timestamp_ms,
-      max_ts.timestamp_ms AS jusm_just_last_modified_timestamp_ms,
-      j.id AS jusm_jk_id,
-      j.role AS jusm_jk_role,
-      j.environment AS jusm_jk_environment,
-      j.name AS jusm_jk_name,
-      u.id AS jui_juse_id,
-      u.update_group_size AS jui_juse_update_group_size,
-      u.max_per_instance_failures AS jui_juse_max_per_instance_failures,
-      u.max_failed_instances AS jui_juse_max_failed_instances,
-      u.min_wait_in_instance_running_ms AS jui_juse_min_wait_in_instance_running_ms,
-      u.rollback_on_failure AS jui_juse_rollback_on_failure,
-      u.wait_for_batch_completion AS jui_juse_wait_for_batch_completion,
-      u.block_if_no_pulses_after_ms AS jui_juse_block_if_no_pulses_after_ms,
-      u.id AS jui_id,
-      cn.id AS jui_ditc_id,
-      cn.task_config_row_id AS jui_ditc_task_config_row_id,
-      di.id AS jui_ditc_r_id,
-      di.first AS jui_ditc_r_first,
-      di.last AS jui_ditc_r_last
-  </sql>
-
-  <sql id="job_update_outer_joins">
-    LEFT OUTER JOIN job_update_configs AS cn ON cn.update_row_id = u.id AND cn.is_new = TRUE
-    LEFT OUTER JOIN job_updates_to_desired_instances AS di ON di.update_row_id = u.id
-  </sql>
-
-  <sql id="lock_outer_join">
-    LEFT OUTER JOIN job_update_locks AS l on l.update_row_id = u.id
-  </sql>
-
-  <sql id="unscoped_details_select">
-    SELECT
-      <include refid="job_update_columns" />,
-      l.lock_token AS lock_token
-    FROM job_updates AS u
-    <include refid="job_key_inner_join" />
-    <include refid="timestamps_inner_joins" />
-    <include refid="job_update_outer_joins" />
-    <include refid="lock_outer_join" />
-  </sql>
-
-  <!--Ideally, update instruction columns could be derived from job_update_columns above but that
-      hits against the limits of mybatis code reuse as specifying a common "jui_" column prefix
-      in case of a standalone (no parent association) select appears to be impossible.-->
-  <select id="selectInstructions" resultMap="jobUpdateInstructionMap">
-    SELECT
-      u.id AS juse_id,
-      u.update_group_size AS juse_update_group_size,
-      u.max_per_instance_failures AS juse_max_per_instance_failures,
-      u.max_failed_instances AS juse_max_failed_instances,
-      u.min_wait_in_instance_running_ms AS juse_min_wait_in_instance_running_ms,
-      u.rollback_on_failure AS juse_rollback_on_failure,
-      u.wait_for_batch_completion AS juse_wait_for_batch_completion,
-      u.block_if_no_pulses_after_ms AS juse_block_if_no_pulses_after_ms,
-      u.id AS id,
-      cn.id AS ditc_id,
-      cn.task_config_row_id AS ditc_task_config_row_id,
-      di.id AS ditc_r_id,
-      di.first AS ditc_r_first,
-      di.last AS ditc_r_last
-    FROM job_updates AS u
-    <include refid="job_key_inner_join" />
-    <include refid="job_update_outer_joins" />
-    WHERE <include refid="filter_by_update_key"/>
-  </select>
-
-  <select id="selectUpdate" resultMap="jobUpdateMap">
-    SELECT
-      <include refid="job_update_columns" />
-    FROM job_updates AS u
-    <include refid="job_key_inner_join" />
-    <include refid="timestamps_inner_joins" />
-    <include refid="job_update_outer_joins" />
-    WHERE <include refid="filter_by_update_key"/>
-  </select>
-
-  <select id="selectDetails" resultMap="jobUpdateDetailsMap">
-    <include refid="unscoped_details_select"/>
-    WHERE <include refid="filter_by_update_key"/>
-  </select>
-
-  <select id="selectDetailsList" resultMap="jobUpdateDetailsMap">
-    <include refid="unscoped_details_select"/>
-    <include refid="query_filter"/>
-  </select>
-
-  <select id="selectAllDetails" resultMap="jobUpdateDetailsMap">
-    <include refid="unscoped_details_select"/>
-  </select>
-
-  <select id="selectInstanceConfigs" resultMap="instanceConfigMap">
-    SELECT
-      co.id,
-      co.task_config_row_id AS task_config_row_id,
-      ci.id AS r_id,
-      ci.first AS r_first,
-      ci.last AS r_last
-    FROM job_update_configs as co
-    INNER JOIN job_update_configs_to_instances AS ci ON ci.config_id = co.id
-    WHERE co.update_row_id = #{id}
-      AND co.is_new = FALSE
-  </select>
-
-  <select id="selectInstanceOverrides" resultMap="rangeMap">
-    SELECT
-      o.id,
-      o.first,
-      o.last
-    FROM job_updates_to_instance_overrides as o
-    WHERE update_row_id = #{id}
-  </select>
-
-  <select id="selectInstanceUpdateEvents" resultMap="jobInstanceUpdateMap">
-    SELECT
-      e.id,
-      instance_id,
-      timestamp_ms,
-      action
-    FROM job_instance_update_events as e
-    INNER JOIN job_updates as u ON u.id = e.update_row_id
-    <include refid="job_key_inner_join" />
-    WHERE <include refid="filter_by_update_key"/>
-      AND e.instance_id = #{instanceId}
-    ORDER BY e.timestamp_ms
-  </select>
-
-  <select id="selectUpdateEvents" resultMap="jobUpdateEventMap">
-    SELECT
-      e.id,
-      status,
-      timestamp_ms,
-      e.user,
-      message
-    FROM job_update_events as e
-    WHERE update_row_id = #{id}
-    ORDER BY e.id
-  </select>
-
-  <select id="selectInstanceEvents" resultMap="jobInstanceUpdateMap">
-    SELECT
-      e.id,
-      instance_id,
-      timestamp_ms,
-      action
-    FROM job_instance_update_events as e
-    WHERE update_row_id = #{id}
-    ORDER BY e.id
-  </select>
-
-  <select id="selectJobUpdateMetadata" resultMap="metadataMap">
-    SELECT
-      m.id,
-      m.key,
-      m.value
-    FROM job_update_metadata as m
-    WHERE update_row_id = #{id}
-  </select>
-
-  <delete id="truncate">
-    DELETE FROM job_updates;
-  </delete>
-
-  <select id="selectJobKeysForPruning" resultType="long">
-    SELECT DISTINCT
-      u.job_key_id
-    FROM job_updates as u
-    <include refid="created_timestamp_inner_join" />
-    <include refid="lock_outer_join" />
-    WHERE l.id IS NULL
-    GROUP BY u.job_key_id
-    HAVING COUNT(u.job_key_id) > #{retainCount}
-    UNION
-    SELECT DISTINCT
-      u.job_key_id
-    FROM job_updates as u
-    <include refid="created_timestamp_inner_join" />
-    <include refid="lock_outer_join" />
-    WHERE min_ts.timestamp_ms &lt; #{pruneThresholdMs} AND l.id IS NULL
-  </select>
-
-  <resultMap id="jobUpdateKeyMap" type="org.apache.aurora.gen.JobUpdateKey">
-    <association property="job"
-                 resultMap="org.apache.aurora.scheduler.storage.db.JobKeyMapper.jobKeyMap"
-                 columnPrefix="jk_"/>
-  </resultMap>
-
-  <resultMap id="pruneVictimMap" type="org.apache.aurora.scheduler.storage.db.PruneVictim">
-    <id column="row_id" property="rowId"/>
-    <association property="update" resultMap="jobUpdateKeyMap" columnPrefix="u_" />
-  </resultMap>
-
-  <select id="selectPruneVictims" resultMap="pruneVictimMap">
-    SELECT
-      row_id,
-      u_id,
-      u_jk_role,
-      u_jk_environment,
-      u_jk_name
-    FROM
-    (
-      SELECT
-        u.id as row_id,
-        u.update_id AS u_id,
-        j.role AS u_jk_role,
-        j.environment AS u_jk_environment,
-        j.name AS u_jk_name
-      FROM job_updates as u
-      <include refid="job_key_inner_join" />
-      <include refid="created_timestamp_inner_join" />
-      <include refid="lock_outer_join" />
-      WHERE u.job_key_id = #{keyId}
-        AND l.id IS NULL
-      ORDER BY min_ts.timestamp_ms DESC
-      LIMIT NULL
-      OFFSET #{retainCount}
-    )
-    UNION
-    SELECT
-      u.id,
-      u.update_id AS u_id,
-      j.role AS u_jk_role,
-      j.environment AS u_jk_environment,
-      j.name AS u_jk_name
-    FROM job_updates as u
-    <include refid="job_key_inner_join" />
-    <include refid="created_timestamp_inner_join" />
-    <include refid="lock_outer_join" />
-    WHERE u.job_key_id = #{keyId}
-      AND min_ts.timestamp_ms &lt;= #{pruneThresholdMs}
-      AND l.id IS NULL
-  </select>
-
-  <delete id="deleteCompletedUpdates">
-    DELETE FROM job_updates
-    WHERE id IN
-    <foreach item="element" collection="rowIds" open="(" separator="," close=")">
-      #{element}
-    </foreach>
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
deleted file mode 100644
index 910d830..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.JobUpdateEventMapper">
-  <insert id="insert">
-    INSERT INTO job_update_events (
-      update_row_id,
-      status,
-      user,
-      timestamp_ms,
-      message
-    ) VALUES (
-      <include refid="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper.select_update_row_id"/>,
-      #{event.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateStatusTypeHandler},
-      #{event.user},
-      #{event.timestampMs},
-      #{event.message}
-    )
-  </insert>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/LockMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/LockMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/LockMapper.xml
deleted file mode 100644
index ce8ed3a..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/LockMapper.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.LockMapper">
-  <insert id="insert">
-    INSERT INTO locks (
-      job_key_id,
-      token,
-      user,
-      timestampMs,
-      message
-    ) VALUES (
-      (
-        SELECT ID
-        FROM job_keys
-        WHERE role = #{key.job.role}
-          AND environment = #{key.job.environment}
-          AND name = #{key.job.name}
-      ),
-      #{token},
-      #{user},
-      #{timestampMs},
-      #{message}
-    )
-  </insert>
-
-  <resultMap id="lockResultMap" type="org.apache.aurora.scheduler.storage.db.views.LockRow">
-    <!--
-      Normally you can have MyBatis auto-map these columns and/or use assocations, but
-      in this case we need to work-around thrift union type issues and prevent MyBatis
-      from trying to create new objects like it does with associations.
-      Explicitly mapping each column to a single base property (lock, here) does just that.
-    -->
-    <result column="token" property="lock.token"/>
-    <result column="user" property="lock.user"/>
-    <result column="timestampMs" property="lock.timestampMs"/>
-    <result column="message" property="lock.message"/>
-    <result column="role" property="lock.key.job.role"/>
-    <result column="environment" property="lock.key.job.environment"/>
-    <result column="name" property="lock.key.job.name"/>
-  </resultMap>
-
-  <select id="selectAll" resultMap="lockResultMap">
-    SELECT * FROM locks AS lock
-    JOIN job_keys AS key ON job_key_id = key.id
-  </select>
-  <sql id="jobKeyScope">
-    JOIN job_keys AS key ON key.role = #{job.role}
-    AND key.environment = #{job.environment}
-    AND key.name = #{job.name}
-    AND key.id = job_key_id
-  </sql>
-  <select id="select" resultMap="lockResultMap">
-    SELECT * FROM locks <include refid="jobKeyScope" />
-  </select>
-  <delete id="delete">
-    DELETE FROM locks
-    WHERE job_key_id
-      IN (SELECT id
-          FROM job_keys
-          WHERE role = #{job.role}
-            AND environment = #{job.environment}
-            AND name = #{job.name})
-  </delete>
-  <delete id="truncate">
-    DELETE FROM locks
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/MigrationMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/MigrationMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/MigrationMapper.xml
deleted file mode 100644
index f6881ac..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/MigrationMapper.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.MigrationMapper">
-  <update id="bootstrapChangelog">
-    CREATE TABLE IF NOT EXISTS changelog (
-      id BIGINT NOT NULL PRIMARY KEY,
-      applied_at VARCHAR(25) NOT NULL,
-      description VARCHAR(255) NOT NULL,
-      downgrade_script BLOB NULL,
-
-      UNIQUE(id)
-    );
-  </update>
-
-  <update id="saveDowngradeScript">
-    UPDATE changelog
-    SET downgrade_script = #{downgradeScript}
-    WHERE id = #{changeId}
-  </update>
-
-  <resultMap
-      id="changelogResultMap"
-      type="org.apache.aurora.scheduler.storage.db.views.MigrationChangelogEntry">
-
-  </resultMap>
-
-  <select id="selectAll" resultMap="changelogResultMap">
-    SELECT
-      id,
-      downgrade_script
-    FROM changelog
-    ORDER BY id DESC
-  </select>
-
-  <delete id="delete">
-    DELETE FROM changelog
-    WHERE id = #{changeId}
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/QuotaMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/QuotaMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/QuotaMapper.xml
deleted file mode 100644
index 0f46968..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/QuotaMapper.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.QuotaMapper">
-  <insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO quotas (
-      role,
-      num_cpus,
-      ram_mb,
-      disk_mb
-    ) VALUES (
-      #{role},
-      #{quota.numCpus},
-      #{quota.ramMb},
-      #{quota.diskMb}
-    )
-  </insert>
-
-  <insert id="insertResources">
-    INSERT INTO quota_resource (
-      quota_id,
-      type_id,
-      value
-    ) VALUES (
-    <foreach index="type" item="value" collection="values" separator="),(">
-      #{quotaId},
-      #{type},
-      #{value}
-    </foreach>
-    )
-  </insert>
-
-  <resultMap id="quotaMap" type="org.apache.aurora.scheduler.storage.db.views.DBResourceAggregate">
-    <id column="id" />
-    <collection
-        property="resources"
-        columnPrefix="qr_"
-        resultMap="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.resourceMap"/>
-  </resultMap>
-
-  <resultMap id="quotaResultMap" type="org.apache.aurora.scheduler.storage.db.views.DBSaveQuota">
-    <id column="id" />
-    <association property="quota" resultMap="quotaMap" />
-  </resultMap>
-
-  <sql id="unscopedSelect">
-    SELECT
-      q.id,
-      q.role,
-      q.num_cpus,
-      q.ram_mb,
-      q.disk_mb,
-      qr.id as qr_id,
-      qr.type_id as qr_type_id,
-      qr.value as qr_value
-    FROM quotas AS q
-    INNER JOIN quota_resource AS qr ON qr.quota_id = q.id
-  </sql>
-
-  <select id="select" resultMap="quotaMap">
-    <include refid="unscopedSelect"/>
-    WHERE role = #{id}
-  </select>
-
-  <select id="selectAll" resultMap="quotaResultMap">
-    <include refid="unscopedSelect"/>
-  </select>
-
-  <delete id="delete">
-    DELETE FROM quotas
-    WHERE role = #{id}
-  </delete>
-
-  <delete id="truncate">
-    DELETE FROM quotas
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.xml
deleted file mode 100644
index 5422183..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.xml
+++ /dev/null
@@ -1,460 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.TaskConfigMapper">
-  <cache type="org.apache.aurora.scheduler.storage.db.MyBatisCacheImpl">
-    <property name="size" value="1000"/>
-  </cache>
-  <insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO task_configs (
-      job_key_id,
-      creator_user,
-      service,
-      num_cpus,
-      ram_mb,
-      disk_mb,
-      priority,
-      max_task_failures,
-      production,
-      contact_email,
-      executor_name,
-      executor_data,
-      tier
-    ) VALUES (
-      (
-        SELECT ID
-        FROM job_keys
-        WHERE role = #{config.job.role}
-          AND environment = #{config.job.environment}
-          AND name = #{config.job.name}
-      ),
-      #{config.owner.user},
-      #{config.isService},
-      #{config.numCpus},
-      #{config.ramMb},
-      #{config.diskMb},
-      #{config.priority},
-      #{config.maxTaskFailures},
-      #{config.production},
-      #{config.contactEmail},
-      #{config.executorConfig.name},
-      #{config.executorConfig.data},
-      #{config.tier}
-    )
-  </insert>
-
-  <resultMap id="limitConstraintMap" type="org.apache.aurora.gen.LimitConstraint">
-    <id column="id"/>
-  </resultMap>
-
-  <resultMap id="valueConstraintMap" type="org.apache.aurora.gen.ValueConstraint">
-    <id column="id"/>
-
-    <collection property="values" ofType="String" columnPrefix="v_">
-      <result column="value" />
-    </collection>
-  </resultMap>
-
-  <resultMap id="taskConstraintMap" type="org.apache.aurora.scheduler.storage.db.views.DbTaskConstraint">
-    <id column="id"/>
-    <association property="value" resultMap="valueConstraintMap" columnPrefix="v_"/>
-    <association property="limit" resultMap="limitConstraintMap" columnPrefix="l_"/>
-  </resultMap>
-
-  <resultMap id="constraintMap" type="org.apache.aurora.scheduler.storage.db.views.DbConstraint">
-    <id column="id"/>
-    <association property="constraint" resultMap="taskConstraintMap"/>
-  </resultMap>
-
-  <resultMap id="dockerParameterMap" type="org.apache.aurora.gen.DockerParameter">
-    <id column="id"/>
-  </resultMap>
-
-  <select id="selectDockerParameters" resultMap="dockerParameterMap">
-    SELECT
-      id,
-      name,
-      value
-    FROM task_config_docker_container_parameters
-    WHERE container_id = #{id}
-  </select>
-
-  <resultMap id="dockerContainerMap" type="org.apache.aurora.gen.DockerContainer">
-    <id column="id"/>
-    <result column="docker_image" property="image"/>
-    <collection
-        property="parameters"
-        select="selectDockerParameters"
-        column="id"
-        foreignColumn="container_id"/>
-  </resultMap>
-
-  <resultMap id="dockerImageMap" type="org.apache.aurora.gen.DockerImage">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap id="appcImageMap" type="org.apache.aurora.gen.AppcImage">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap id="imageMap" type="org.apache.aurora.scheduler.storage.db.views.DbImage">
-    <association property="appc" columnPrefix="appc_" resultMap="appcImageMap" />
-    <association property="docker" columnPrefix="docker_" resultMap="dockerImageMap" />
-  </resultMap>
-
-  <resultMap id="containerMap" type="org.apache.aurora.scheduler.storage.db.views.DbContainer">
-    <!--NOTE: Do not put any collections under here. ContainerMap doesn't correspond to a table, it's a syntheic map
-    for assocations. Since it doesn't have a table, there is no unique id. Since there is no unique id, MyBatis nested
-    result map collections fail.
-    -->
-    <association property="docker" resultMap="dockerContainerMap" />
-    <association property="image" columnPrefix="image_" resultMap="imageMap" />
-  </resultMap>
-
-  <resultMap id="metadataMap" type="org.apache.aurora.gen.Metadata">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap id="mesosFetcherUrisMap" type="org.apache.aurora.gen.MesosFetcherURI">
-    <id column="id" />
-  </resultMap>
-
-  <resultMap id="volumeMap" type="org.apache.aurora.gen.Volume">
-    <id column="id" />
-    <result property="mode" column="mode" typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.VolumeModeTypeHandler" />
-  </resultMap>
-
-  <resultMap id="resourceMap" type="org.apache.aurora.scheduler.storage.db.views.DBResource">
-    <id column="id" />
-    <result property="type"
-            column="type_id"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ResourceTypeHandler" />
-  </resultMap>
-
-  <resultMap id="taskConfigMap" type="org.apache.aurora.scheduler.storage.db.views.DbTaskConfig">
-    <id column="id" property="rowId" />
-    <result column="creator_user" property="owner.user"/>
-    <result column="executor_name" property="executorConfig.name"/>
-    <result column="executor_data" property="executorConfig.data"/>
-    <association
-        property="job"
-        resultMap="org.apache.aurora.scheduler.storage.db.JobKeyMapper.jobKeyMap"
-        columnPrefix="j_"/>
-    <association property="container" resultMap="containerMap" columnPrefix="c_"/>
-    <collection property="volumes" columnPrefix="volume_" resultMap="volumeMap" notNullColumn="id" />
-    <collection
-        property="constraints"
-        columnPrefix="constraint_"
-        resultMap="constraintMap"/>
-    <collection property="requestedPorts" ofType="String" columnPrefix="p_">
-      <result column="port_name" />
-    </collection>
-    <collection property="metadata" resultMap="metadataMap" columnPrefix="m_"/>
-    <collection property="mesosFetcherUris" resultMap="mesosFetcherUrisMap" columnPrefix="u_"/>
-    <collection
-        property="taskLinks"
-        select="selectTaskLinks"
-        column="id"
-        foreignColumn="task_config_id"/>
-    <!-- TODO(maxim): move resources to a main join when task level fields are removed. -->
-    <collection
-        property="resources"
-        select="selectResources"
-        column="id"
-        foreignColumn="task_config_id" />
-  </resultMap>
-
-  <sql id="unscopedConfigSelect">
-    SELECT
-      c.id AS id,
-      c.creator_user AS creator_user,
-      c.service AS is_service,
-      c.num_cpus AS num_cpus,
-      c.ram_mb AS ram_mb,
-      c.disk_mb AS disk_mb,
-      c.priority AS priority,
-      c.max_task_failures AS max_task_failures,
-      c.production AS production,
-      c.contact_email AS contact_email,
-      c.executor_name AS executor_name,
-      c.executor_data AS executor_data,
-      c.tier AS tier,
-      j.role AS j_role,
-      j.environment AS j_environment,
-      j.name AS j_name,
-      p.port_name AS p_port_name,
-      d.id AS c_id,
-      d.image AS c_docker_image,
-      m.id AS m_id,
-      m.key AS m_key,
-      m.value AS m_value,
-      u.id AS u_id,
-      u.value AS u_value,
-      u.extract AS u_extract,
-      u.cache AS u_cache,
-      di.name as c_image_docker_name,
-      di.tag as c_image_docker_tag,
-      ai.name as c_image_appc_name,
-      ai.image_id as c_image_appc_image_id,
-      v.id as volume_id,
-      v.host_path as volume_host_path,
-      v.container_path as volume_container_path,
-      v.mode as volume_mode,
-      tc.id AS constraint_id,
-      tc.name AS constraint_name,
-      tlc.id AS constraint_l_id,
-      tlc.value AS constraint_l_limit,
-      tvc.id AS constraint_v_id,
-      tvc.negated AS constraint_v_negated,
-      tvcv.value as constraint_v_v_value
-    FROM task_configs AS c
-    INNER JOIN job_keys AS j ON j.id = c.job_key_id
-    LEFT OUTER JOIN task_config_requested_ports AS p ON p.task_config_id = c.id
-    LEFT OUTER JOIN task_config_docker_containers AS d ON d.task_config_id = c.id
-    LEFT OUTER JOIN task_config_metadata AS m ON m.task_config_id = c.id
-    LEFT OUTER JOIN task_config_mesos_fetcher_uris AS u ON u.task_config_id = c.id
-    LEFT OUTER JOIN task_config_docker_images AS di ON di.task_config_id = c.id
-    LEFT OUTER JOIN task_config_appc_images AS ai ON ai.task_config_id = c.id
-    LEFT OUTER JOIN task_config_volumes AS v ON v.task_config_id = c.id
-    LEFT OUTER JOIN task_constraints AS tc ON tc.task_config_id = c.id
-    LEFT OUTER JOIN limit_constraints as tlc ON tlc.constraint_id = tc.id
-    LEFT OUTER JOIN value_constraints as tvc ON tvc.constraint_id = tc.id
-    LEFT OUTER JOIN value_constraint_values AS tvcv ON tvcv.value_constraint_id = tvc.id
-  </sql>
-
-  <select id="selectConfig" resultMap="taskConfigMap">
-    <include refid="unscopedConfigSelect"/>
-    WHERE c.id = #{id}
-  </select>
-
-  <select id="selectConfigsByJob" resultMap="taskConfigMap">
-    <include refid="unscopedConfigSelect"/>
-    WHERE j.role = #{role}
-      AND j.environment = #{environment}
-      AND j.name = #{name}
-  </select>
-
-  <insert id="insertConstraint" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO task_constraints (
-      task_config_id,
-      name
-    ) VALUES (
-      #{configId},
-      #{constraint.name}
-    )
-  </insert>
-
-  <insert id="insertLimitConstraint">
-    INSERT INTO limit_constraints (
-      constraint_id,
-      value
-    ) VALUES (
-      #{constraintId},
-      #{constraint.limit}
-    )
-  </insert>
-
-  <insert id="insertValueConstraint" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO value_constraints (
-      constraint_id,
-      negated
-    ) VALUES (
-      #{constraintId},
-      #{constraint.negated}
-    )
-  </insert>
-
-  <insert id="insertValueConstraintValues">
-    INSERT INTO value_constraint_values (
-      value_constraint_id,
-      value
-    ) VALUES (
-      <foreach item="value" collection="values" separator="),(">
-        #{valueConstraintId},
-        #{value}
-      </foreach>
-    )
-  </insert>
-
-  <insert id="insertRequestedPorts">
-    INSERT INTO task_config_requested_ports (
-      task_config_id,
-      port_name
-    ) VALUES (
-      <foreach item="port" collection="ports" separator="),(">
-        #{configId},
-        #{port}
-      </foreach>
-    )
-  </insert>
-
-  <insert id="insertResources">
-    INSERT INTO task_resource (
-      task_config_id,
-      type_id,
-      value
-    ) VALUES (
-      <foreach item="value" collection="values" separator="),(">
-        #{configId},
-        #{value.first},
-        #{value.second}
-      </foreach>
-    )
-  </insert>
-
-  <insert id="insertTaskLinks" >
-    INSERT INTO task_config_task_links (
-      task_config_id,
-      label,
-      url
-    ) VALUES (
-      <foreach index="label" item="url" collection="links" separator="),(">
-        #{configId},
-        #{label},
-        #{url}
-      </foreach>
-    )
-  </insert>
-
-  <resultMap id="taskLinkMap" type="org.apache.aurora.common.collections.Pair">
-    <constructor>
-      <arg column="label"/>
-      <arg column="url"/>
-    </constructor>
-  </resultMap>
-
-  <select id="selectTaskLinks" resultMap="taskLinkMap">
-    SELECT
-      id,
-      label,
-      url
-    FROM task_config_task_links
-    WHERE task_config_id = #{id}
-  </select>
-
-  <select id="selectResources" resultMap="resourceMap">
-    SELECT
-      id,
-      type_id,
-      value
-    FROM task_resource
-    WHERE task_config_id = #{id}
-  </select>
-
-  <insert id="insertContainer" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO task_config_docker_containers (
-      task_config_id,
-      image
-    ) VALUES (
-      #{configId},
-      #{container.image}
-    )
-  </insert>
-
-  <insert id="insertDockerParameters">
-    INSERT INTO task_config_docker_container_parameters (
-      container_id,
-      name,
-      value
-    ) VALUES (
-    <foreach item="parameter" collection="parameters" separator="),(">
-      #{containerId},
-      #{parameter.name},
-      #{parameter.value}
-    </foreach>
-    )
-  </insert>
-
-  <insert id="insertDockerImage">
-    INSERT INTO task_config_docker_images (
-      task_config_id,
-      name,
-      tag
-    ) VALUES (
-      #{configId},
-      #{name},
-      #{tag}
-    )
-  </insert>
-
-  <insert id="insertAppcImage">
-    INSERT INTO task_config_appc_images (
-      task_config_id,
-      name,
-      image_id
-    ) VALUES (
-      #{configId},
-      #{name},
-      #{imageId}
-    )
-  </insert>
-
-  <insert id="insertMetadata">
-    INSERT INTO task_config_metadata (
-      task_config_id,
-      key,
-      value
-    ) VALUES (
-    <foreach item="entry" collection="metadata" separator="),(">
-      #{configId},
-      #{entry.key},
-      #{entry.value}
-    </foreach>
-    )
-  </insert>
-
-  <insert id="insertMesosFetcherUris">
-    INSERT INTO task_config_mesos_fetcher_uris (
-      task_config_id,
-      value,
-      extract,
-      cache
-    ) VALUES (
-    <foreach item="entry" collection="uris" separator="),(">
-      #{configId},
-      #{entry.value},
-      #{entry.extract},
-      #{entry.cache}
-    </foreach>
-    )
-  </insert>
-
-  <insert id="insertVolumes">
-    INSERT INTO task_config_volumes (
-      task_config_id,
-      host_path,
-      container_path,
-      mode
-    ) VALUES (
-    <foreach item="volume" collection="volumes" separator="),(">
-      #{configId},
-      #{volume.hostPath},
-      #{volume.containerPath},
-      #{volume.mode, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.VolumeModeTypeHandler}
-    </foreach>
-    )
-  </insert>
-
-  <select id="selectAllRowIds" resultType="long">
-    SELECT id FROM task_configs
-  </select>
-
-  <delete id="deleteRow">
-    DELETE FROM task_configs WHERE id = #{rowId}
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
deleted file mode 100644
index 0ecffab..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
+++ /dev/null
@@ -1,241 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<!DOCTYPE mapper
-    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.aurora.scheduler.storage.db.TaskMapper">
-  <cache type="org.apache.aurora.scheduler.storage.db.MyBatisCacheImpl">
-    <property name="size" value="10000"/>
-  </cache>
-  <insert id="insertScheduledTask" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
-    INSERT INTO tasks (
-      task_id,
-      slave_row_id,
-      instance_id,
-      status,
-      failure_count,
-      ancestor_task_id,
-      task_config_row_id,
-    ) VALUES (
-      #{task.assignedTask.taskId},
-      (
-        SELECT ID
-        FROM host_attributes
-        WHERE slave_id = #{task.assignedTask.slaveId}
-          AND host = #{task.assignedTask.slaveHost}
-      ),
-      #{task.assignedTask.instanceId},
-      #{task.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler},
-      #{task.failureCount},
-      #{task.ancestorId},
-      #{configId}
-    )
-  </insert>
-
-  <resultMap id="taskEventMap" type="org.apache.aurora.gen.TaskEvent">
-    <id column="id"/>
-    <result property="status"
-            column="status"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
-    <result column="timestamp_ms" property="timestamp" />
-    <result column="message" property="message" />
-    <result column="scheduler_host" property="scheduler" />
-  </resultMap>
-
-  <resultMap id="scheduledTaskMap" type="org.apache.aurora.scheduler.storage.db.views.DbScheduledTask">
-    <id column="row_id"/>
-    <result property="status"
-            column="status"
-            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
-    <result column="task_id" property="assignedTask.taskId"/>
-    <result column="slave_id" property="assignedTask.slaveId"/>
-    <result column="slave_host" property="assignedTask.slaveHost"/>
-    <result column="instance_id" property="assignedTask.instanceId"/>
-    <association
-        property="assignedTask.task"
-        select="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.selectConfig"
-        column="task_config_row_id"
-        foreignColumn="row_id"/>
-    <collection
-        property="assignedTask.assignedPorts"
-        resultMap="portMap"
-        columnPrefix="tp_"/>
-    <collection
-        property="taskEvents"
-        resultMap="taskEventMap"
-        columnPrefix="te_"
-        notNullColumn="status"/>
-  </resultMap>
-
-  <sql id="unscopedSelect">
-    <!--
-    N.B. For any one-to-many relationship, results from the joined table *must* include the id
-    otherwise mybatis will not be able to disambiguate identical rows leading to an explosion
-    of related rows on each save.
-    -->
-    SELECT
-      t.id AS row_id,
-      t.task_config_row_id AS task_config_row_id,
-      t.task_id AS task_id,
-      t.instance_id AS instance_id,
-      t.status AS status,
-      t.failure_count AS failure_count,
-      t.ancestor_task_id AS ancestor_id,
-      j.role AS c_j_role,
-      j.environment AS c_j_environment,
-      j.name AS c_j_name,
-      h.slave_id AS slave_id,
-      h.host AS slave_host,
-      tp.id as tp_id,
-      tp.name as tp_name,
-      tp.port as tp_port,
-      te.id as te_id,
-      te.timestamp_ms as te_timestamp,
-      te.status as te_status,
-      te.message as te_message,
-      te.scheduler_host as te_scheduler
-    FROM tasks AS t
-    INNER JOIN task_configs as c ON c.id = t.task_config_row_id
-    INNER JOIN job_keys AS j ON j.id = c.job_key_id
-    LEFT OUTER JOIN task_ports as tp ON tp.task_row_id = t.id
-    LEFT OUTER JOIN task_events as te ON te.task_row_id = t.id
-    LEFT OUTER JOIN host_attributes AS h ON h.id = t.slave_row_id
-  </sql>
-
-  <select id="selectById" resultMap="scheduledTaskMap">
-    <include refid="unscopedSelect"/>
-    WHERE
-      t.task_id = #{taskId}
-  </select>
-
-  <select id="select" resultMap="scheduledTaskMap">
-    <include refid="unscopedSelect"/>
-    <where>
-      <if test="role != null">
-        j.role = #{role}
-      </if>
-      <if test="environment != null">
-        AND j.environment = #{environment}
-      </if>
-      <if test="jobName != null">
-        AND j.name = #{jobName}
-      </if>
-      <if test="!taskIds.isEmpty()">
-        AND t.task_id IN (
-        <foreach item="task_id" collection="taskIds" separator=",">
-          #{task_id}
-        </foreach>
-        )
-      </if>
-      <if test="!statuses.isEmpty()">
-        AND t.status IN (
-        <foreach item="element" collection="statuses" separator=",">
-          #{element, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler}
-        </foreach>
-        )
-      </if>
-      <if test="!instanceIds.isEmpty()">
-        AND t.instance_id IN (
-        <foreach item="instance_id" collection="instanceIds" separator=",">
-          #{instance_id}
-        </foreach>
-        )
-      </if>
-      <if test="!slaveHosts.isEmpty()">
-        AND h.host IN (
-        <foreach item="host" collection="slaveHosts" separator=",">
-          #{host}
-        </foreach>
-        )
-      </if>
-      <if test="!jobKeys.isEmpty()">
-        AND (
-        <foreach item="jobKey" collection="jobKeys" open="(" separator=") OR (" close=")">
-          j.role = #{jobKey.role}
-          AND j.name = #{jobKey.name}
-          AND j.environment = #{jobKey.environment}
-        </foreach>
-        )
-      </if>
-    </where>
-  </select>
-
-  <select id="selectJobKeys" resultMap="org.apache.aurora.scheduler.storage.db.JobKeyMapper.jobKeyMap">
-    SELECT DISTINCT
-      j.role AS role,
-      j.environment AS environment,
-      j.name AS name
-    FROM tasks AS t
-    INNER JOIN task_configs as c ON c.id = t.task_config_row_id
-    INNER JOIN job_keys AS j ON j.id = c.job_key_id
-  </select>
-
-  <insert id="insertTaskEvents">
-    INSERT INTO task_events(
-      task_row_id,
-      timestamp_ms,
-      status,
-      message,
-      scheduler_host
-    ) VALUES (
-    <foreach item="event" collection="events" separator="),(">
-      #{taskRowId},
-      #{event.timestamp},
-      #{event.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler},
-      #{event.message},
-      #{event.scheduler}
-    </foreach>
-    )
-  </insert>
-
-  <insert id="insertPorts">
-    INSERT INTO task_ports(
-      task_row_id,
-      name,
-      port
-    ) VALUES (
-    <foreach index="name" item="port" collection="ports" separator="),(">
-      #{taskRowId},
-      #{name},
-      #{port}
-    </foreach>
-    )
-  </insert>
-
-  <resultMap id="portMap" type="org.apache.aurora.scheduler.storage.db.views.DbAssginedPort">
-    <id column="id"/>
-    <result column="name" property="name" />
-    <result column="port" property="port" />
-  </resultMap>
-
-  <delete id="truncate">
-    <!--
-    This assumes cascading deletes will clean up all references.  Also, once the job store is
-    migrated, there will be a clash between deletes on the two that needs to be resolved.  At that
-    point it probably makes sense to remove all of the store-specific truncate verbs and use a
-    single control.
-     -->
-    DELETE FROM tasks
-  </delete>
-
-  <delete id="deleteTasks">
-    DELETE FROM tasks WHERE task_id IN (
-    <foreach item="task_id" collection="taskIds" separator=",">
-      #{task_id}
-    </foreach>
-    )
-  </delete>
-</mapper>

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql b/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
deleted file mode 100644
index 7a86f47..0000000
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
+++ /dev/null
@@ -1,392 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- schema for h2 engine.
-/* TODO(maxim): Consider using TIMESTAMP instead of BIGINT for all "timestamp" fields below. */
-
-CREATE TABLE framework_id(
-  id INT PRIMARY KEY,
-  framework_id VARCHAR NOT NULL,
-
-  UNIQUE(framework_id)
-);
-
-CREATE TABLE job_keys(
-  id IDENTITY,
-  role VARCHAR NOT NULL,
-  environment VARCHAR NOT NULL,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(role, environment, name)
-);
-
-CREATE TABLE locks(
-  id IDENTITY,
-  job_key_id BIGINT NOT NULL REFERENCES job_keys(id),
-  token VARCHAR NOT NULL,
-  user VARCHAR NOT NULL,
-  timestampMs BIGINT NOT NULL,
-  message VARCHAR,
-
-  UNIQUE(job_key_id),
-  UNIQUE(token)
-);
-
-CREATE TABLE maintenance_modes(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE host_attributes(
-  id IDENTITY,
-  host VARCHAR NOT NULL,
-  mode INT NOT NULL REFERENCES maintenance_modes(id),
-  slave_id VARCHAR NOT NULL,
-
-  UNIQUE(host),
-  UNIQUE(slave_id),
-);
-
-CREATE TABLE host_attribute_values(
-  id IDENTITY,
-  host_attribute_id BIGINT NOT NULL REFERENCES host_attributes(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-  value VARCHAR NOT NULL,
-
-  UNIQUE(host_attribute_id, name, value)
-);
-
-/**
- * NOTE: This table is truncated by TaskMapper, which will cause a conflict when the table is shared
- * with the forthcoming jobs table.  See note in TaskMapper about this before migrating MemJobStore.
- */
-CREATE TABLE task_configs(
-  id IDENTITY,
-  job_key_id BIGINT NOT NULL REFERENCES job_keys(id),
-  creator_user VARCHAR NOT NULL,
-  service BOOLEAN NOT NULL,
-  num_cpus DOUBLE NOT NULL,
-  ram_mb BIGINT NOT NULL,
-  disk_mb BIGINT NOT NULL,
-  priority INTEGER NOT NULL,
-  max_task_failures INTEGER NOT NULL,
-  production BOOLEAN NOT NULL,
-  contact_email VARCHAR,
-  executor_name VARCHAR,
-  executor_data VARCHAR,
-  tier VARCHAR
-);
-
-CREATE TABLE resource_types(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE task_resource(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  type_id INT NOT NULL REFERENCES resource_types(id),
-  value VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id, type_id, value)
-);
-
-CREATE TABLE quotas(
-  id IDENTITY,
-  role VARCHAR NOT NULL,
-  num_cpus DOUBLE NOT NULL,
-  ram_mb BIGINT NOT NULL,
-  disk_mb BIGINT NOT NULL,
-
-  UNIQUE(role)
-);
-
-CREATE TABLE quota_resource(
-  id IDENTITY,
-  quota_id BIGINT NOT NULL REFERENCES quotas(id) ON DELETE CASCADE,
-  type_id INT NOT NULL REFERENCES resource_types(id),
-  value VARCHAR NOT NULL,
-
-  UNIQUE(quota_id, type_id)
-);
-
-CREATE TABLE task_constraints(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id, name)
-);
-
-CREATE TABLE value_constraints(
-  id IDENTITY,
-  constraint_id BIGINT NOT NULL REFERENCES task_constraints(id) ON DELETE CASCADE,
-  negated BOOLEAN NOT NULL,
-
-  UNIQUE(constraint_id)
-);
-
-CREATE TABLE value_constraint_values(
-  id IDENTITY,
-  value_constraint_id BIGINT NOT NULL REFERENCES value_constraints(id) ON DELETE CASCADE,
-  value VARCHAR NOT NULL,
-
-  UNIQUE(value_constraint_id, value)
-);
-
-CREATE TABLE limit_constraints(
-  id IDENTITY,
-  constraint_id BIGINT NOT NULL REFERENCES task_constraints(id) ON DELETE CASCADE,
-  value INTEGER NOT NULL,
-
-  UNIQUE(constraint_id)
-);
-
-CREATE TABLE task_config_requested_ports(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  port_name VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id, port_name)
-);
-
-CREATE TABLE task_config_task_links(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  label VARCHAR NOT NULL,
-  url VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id, label)
-);
-
-CREATE TABLE task_config_metadata(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  key VARCHAR NOT NULL,
-  value VARCHAR NOT NULL
-);
-
-CREATE TABLE task_config_mesos_fetcher_uris(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  value VARCHAR NOT NULL,
-  extract BOOLEAN NOT NULL,
-  cache BOOLEAN NOT NULL
-);
-
-CREATE TABLE task_config_docker_containers(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  image VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id)
-);
-
-CREATE TABLE task_config_docker_container_parameters(
-  id IDENTITY,
-  container_id BIGINT NOT NULL REFERENCES task_config_docker_containers(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-  value VARCHAR NOT NULL
-);
-
-CREATE TABLE task_config_docker_images(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-  tag VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id)
-);
-
-CREATE TABLE task_config_appc_images(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-  image_id VARCHAR NOT NULL,
-
-  UNIQUE(task_config_id)
-);
-
-CREATE TABLE volume_modes(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE task_config_volumes(
-  id IDENTITY,
-  task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE,
-  host_path VARCHAR NOT NULL,
-  container_path VARCHAR NOT NULL,
-  mode INT NOT NULL REFERENCES volume_modes(id),
-);
-
-CREATE TABLE task_states(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE tasks(
-  id IDENTITY,
-  task_id VARCHAR NOT NULL,
-  slave_row_id BIGINT REFERENCES host_attributes(id),
-  instance_id INTEGER NOT NULL,
-  status INT NOT NULL REFERENCES task_states(id),
-  failure_count INTEGER NOT NULL,
-  ancestor_task_id VARCHAR NULL,
-  task_config_row_id BIGINT NOT NULL REFERENCES task_configs(id),
-
-  UNIQUE(task_id)
-);
-
-CREATE TABLE task_events(
-  id IDENTITY,
-  task_row_id BIGINT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
-  timestamp_ms BIGINT NOT NULL,
-  status INT NOT NULL REFERENCES task_states(id),
-  message VARCHAR NULL,
-  scheduler_host VARCHAR NULL,
-);
-
-CREATE TABLE task_ports(
-  id IDENTITY,
-  task_row_id BIGINT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
-  name VARCHAR NOT NULL,
-  port INT NOT NULL,
-
-  UNIQUE(task_row_id, name)
-);
-
-CREATE TABLE cron_policies(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE cron_jobs(
-  id IDENTITY,
-  job_key_id BIGINT NOT NULL REFERENCES job_keys(id),
-  creator_user VARCHAR NOT NULL,
-  cron_schedule VARCHAR NOT NULL,
-  cron_collision_policy INT NOT NULL REFERENCES cron_policies(id),
-  task_config_row_id BIGINT NOT NULL REFERENCES task_configs(id),
-  instance_count INT NOT NULL,
-
-  UNIQUE(job_key_id)
-);
-
-CREATE TABLE job_instance_update_actions(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE job_update_statuses(
-  id INT PRIMARY KEY,
-  name VARCHAR NOT NULL,
-
-  UNIQUE(name)
-);
-
-CREATE TABLE job_updates(
-  id IDENTITY,
-  job_key_id BIGINT NOT NULL REFERENCES job_keys(id),
-  update_id VARCHAR NOT NULL,
-  user VARCHAR NOT NULL,
-  update_group_size INT NOT NULL,
-  max_per_instance_failures INT NOT NULL,
-  max_failed_instances INT NOT NULL,
-  min_wait_in_instance_running_ms INT NOT NULL,
-  rollback_on_failure BOOLEAN NOT NULL,
-  wait_for_batch_completion BOOLEAN NOT NULL,
-  block_if_no_pulses_after_ms INT NULL,
-
-  UNIQUE(update_id, job_key_id)
-);
-
-CREATE TABLE job_update_metadata(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  key VARCHAR NOT NULL,
-  value VARCHAR NOT NULL
-);
-
-CREATE TABLE job_update_locks(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  lock_token VARCHAR NOT NULL REFERENCES locks(token) ON DELETE CASCADE,
-
-  UNIQUE(update_row_id),
-  UNIQUE(lock_token)
-);
-
-CREATE TABLE job_update_configs(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  task_config_row_id BIGINT NOT NULL REFERENCES task_configs(id),
-  is_new BOOLEAN NOT NULL
-);
-
-CREATE TABLE job_updates_to_instance_overrides(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  first INT NOT NULL,
-  last INT NOT NULL,
-
-  UNIQUE(update_row_id, first, last)
-);
-
-CREATE TABLE job_updates_to_desired_instances(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  first INT NOT NULL,
-  last INT NOT NULL,
-
-  UNIQUE(update_row_id, first, last)
-);
-
-CREATE TABLE job_update_configs_to_instances(
-  id IDENTITY,
-  config_id BIGINT NOT NULL REFERENCES job_update_configs(id) ON DELETE CASCADE,
-  first INT NOT NULL,
-  last INT NOT NULL,
-
-  UNIQUE(config_id, first, last)
-);
-
-CREATE TABLE job_update_events(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  status INT NOT NULL REFERENCES job_update_statuses(id),
-  timestamp_ms BIGINT NOT NULL,
-  user VARCHAR,
-  message VARCHAR
-);
-
-CREATE TABLE job_instance_update_events(
-  id IDENTITY,
-  update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
-  action INT NOT NULL REFERENCES job_instance_update_actions(id),
-  instance_id INT NOT NULL,
-  timestamp_ms BIGINT NOT NULL
-);

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/async/AsyncModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/AsyncModuleTest.java b/src/test/java/org/apache/aurora/scheduler/async/AsyncModuleTest.java
index 74956cd..729fbf1 100644
--- a/src/test/java/org/apache/aurora/scheduler/async/AsyncModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/async/AsyncModuleTest.java
@@ -87,8 +87,7 @@ public class AsyncModuleTest extends EasyMockTest {
     assertEquals(
         ImmutableMap.of(
             RegisterGauges.TIMEOUT_QUEUE_GAUGE, 0,
-            RegisterGauges.ASYNC_TASKS_GAUGE, 0L,
-            RegisterGauges.DELAY_QUEUE_GAUGE, 0),
+            RegisterGauges.ASYNC_TASKS_GAUGE, 0L),
         statsProvider.getAllValues()
     );
   }