aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [1/2] aurora git commit: Shim interfaces to preface args system overhaul.
Date Tue, 19 Jan 2016 22:05:52 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 317aa4d7c -> fe13e4ed5


http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorageModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorageModule.java b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorageModule.java
index ed63a74..07ec54c 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorageModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorageModule.java
@@ -62,13 +62,42 @@ public class LogStorageModule extends PrivateModule {
   public static final Arg<Amount<Integer, Data>> MAX_LOG_ENTRY_SIZE =
       Arg.create(Amount.of(512, Data.KB));
 
+  interface Params {
+    Amount<Long, Time> dlogShutdownGracePeriod();
+
+    Amount<Long, Time> dlogSnapshotInterval();
+
+    Amount<Integer, Data> dlogMaxEntrySize();
+  }
+
+  private final Params params;
+
+  public LogStorageModule() {
+    this.params = new Params() {
+      @Override
+      public Amount<Long, Time> dlogShutdownGracePeriod() {
+        return SHUTDOWN_GRACE_PERIOD.get();
+      }
+
+      @Override
+      public Amount<Long, Time> dlogSnapshotInterval() {
+        return SNAPSHOT_INTERVAL.get();
+      }
+
+      @Override
+      public Amount<Integer, Data> dlogMaxEntrySize() {
+        return MAX_LOG_ENTRY_SIZE.get();
+      }
+    };
+  }
+
   @Override
   protected void configure() {
     bind(Settings.class)
-        .toInstance(new Settings(SHUTDOWN_GRACE_PERIOD.get(), SNAPSHOT_INTERVAL.get()));
+        .toInstance(new Settings(params.dlogShutdownGracePeriod(), params.dlogSnapshotInterval()));
 
     bind(new TypeLiteral<Amount<Integer, Data>>() { }).annotatedWith(MaxEntrySize.class)
-        .toInstance(MAX_LOG_ENTRY_SIZE.get());
+        .toInstance(params.dlogMaxEntrySize());
     bind(LogManager.class).in(Singleton.class);
     bind(LogStorage.class).in(Singleton.class);
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/main/java/org/apache/aurora/scheduler/storage/mem/InMemStoresModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/InMemStoresModule.java
b/src/main/java/org/apache/aurora/scheduler/storage/mem/InMemStoresModule.java
index 1b491f9..8909833 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/InMemStoresModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/InMemStoresModule.java
@@ -41,9 +41,20 @@ public final class InMemStoresModule extends PrivateModule {
   private static final Arg<Amount<Long, Time>> SLOW_QUERY_LOG_THRESHOLD =
       Arg.create(Amount.of(25L, Time.MILLISECONDS));
 
+  interface Params {
+    Amount<Long, Time> slowQueryLogThreshold();
+  }
+
+  private final Params params;
   private final KeyFactory keyFactory;
 
   public InMemStoresModule(KeyFactory keyFactory) {
+    this.params = new Params() {
+      @Override
+      public Amount<Long, Time> slowQueryLogThreshold() {
+        return SLOW_QUERY_LOG_THRESHOLD.get();
+      }
+    };
     this.keyFactory = requireNonNull(keyFactory);
   }
 
@@ -58,7 +69,7 @@ public final class InMemStoresModule extends PrivateModule {
   @Override
   protected void configure() {
     bind(new TypeLiteral<Amount<Long, Time>>() { }).annotatedWith(SlowQueryThreshold.class)
-        .toInstance(SLOW_QUERY_LOG_THRESHOLD.get());
+        .toInstance(params.slowQueryLogThreshold());
     bindStore(TaskStore.Mutable.class, MemTaskStore.class);
     expose(TaskStore.Mutable.class);
     bindStore(CronJobStore.Mutable.class, MemCronJobStore.class);

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/main/java/org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig.java
b/src/main/java/org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig.java
index 5b59d55..4838293 100644
--- a/src/main/java/org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig.java
+++ b/src/main/java/org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig.java
@@ -52,7 +52,19 @@ public final class FlaggedClientConfig {
 
   @CmdLine(name = "zk_digest_credentials",
            help = "user:password to use when authenticating with ZooKeeper.")
-  private static final Arg<String> DIGEST_CREDENTIALS = Arg.create();
+  private static final Arg<String> DIGEST_CREDENTIALS = Arg.create(null);
+
+  interface Params {
+    boolean zkInProc();
+
+    List<InetSocketAddress> zkEndpoints();
+
+    Optional<String> zkChrootPath();
+
+    Amount<Integer, Time> zkSessionTimeout();
+
+    Optional<String> zkDigestCredentials();
+  }
 
   private FlaggedClientConfig() {
     // Utility class.
@@ -64,15 +76,41 @@ public final class FlaggedClientConfig {
    * @return Configuration instance.
    */
   public static ClientConfig create() {
+    Params params = new Params() {
+      @Override
+      public boolean zkInProc() {
+        return IN_PROCESS.get();
+      }
+
+      @Override
+      public List<InetSocketAddress> zkEndpoints() {
+        return ZK_ENDPOINTS.get();
+      }
+
+      @Override
+      public Optional<String> zkChrootPath() {
+        return Optional.fromNullable(CHROOT_PATH.get());
+      }
+
+      @Override
+      public Amount<Integer, Time> zkSessionTimeout() {
+        return SESSION_TIMEOUT.get();
+      }
+
+      @Override
+      public Optional<String> zkDigestCredentials() {
+        return Optional.fromNullable(DIGEST_CREDENTIALS.get());
+      }
+    };
+
     return new ClientConfig(
-        ZK_ENDPOINTS.get(),
-        Optional.fromNullable(CHROOT_PATH.get()),
-        IN_PROCESS.get(),
-        SESSION_TIMEOUT.get(),
-        DIGEST_CREDENTIALS.hasAppliedValue()
-            ? getCredentials(DIGEST_CREDENTIALS.get())
-            : Credentials.NONE
-    );
+        params.zkEndpoints(),
+        params.zkChrootPath(),
+        params.zkInProc(),
+        params.zkSessionTimeout(),
+        params.zkDigestCredentials()
+            .transform(FlaggedClientConfig::getCredentials)
+            .or(Credentials.NONE));
   }
 
   private static Credentials getCredentials(String userAndPass) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
index 9fb8aad..35292a2 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
@@ -163,9 +163,8 @@ public class SchedulerIT extends BaseZooKeeperTest {
     log = control.createMock(Log.class);
     logStream = control.createMock(Stream.class);
     streamMatcher = LogOpMatcher.matcherFor(logStream);
-    entrySerializer = new EntrySerializer.EntrySerializerImpl(
-        LogStorageModule.MAX_LOG_ENTRY_SIZE.get(),
-        Hashing.md5());
+    entrySerializer =
+        new EntrySerializer.EntrySerializerImpl(Amount.of(512, Data.KB), Hashing.md5());
 
     zkClient = createZkClient();
   }
@@ -186,7 +185,14 @@ public class SchedulerIT extends BaseZooKeeperTest {
             0);
         bind(ExecutorSettings.class)
             .toInstance(TestExecutorSettings.thermosOnlyWithOverhead(executorOverhead));
-        install(new BackupModule(backupDir, SnapshotStoreImpl.class));
+        install(new BackupModule(
+            new BackupModule.Params() {
+              @Override
+              public File backupDir() {
+                return backupDir;
+              }
+            },
+            SnapshotStoreImpl.class));
 
         bind(IServerInfo.class).toInstance(
             IServerInfo.build(

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/test/java/org/apache/aurora/scheduler/app/local/LocalSchedulerMain.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/local/LocalSchedulerMain.java b/src/test/java/org/apache/aurora/scheduler/app/local/LocalSchedulerMain.java
index 4716b66..650cde6 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/local/LocalSchedulerMain.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/local/LocalSchedulerMain.java
@@ -83,6 +83,18 @@ public final class LocalSchedulerMain {
       }
     };
 
+    SchedulerMain.Params testParams = new SchedulerMain.Params() {
+      @Override
+      public String clusterName() {
+        return "local";
+      }
+
+      @Override
+      public String serversetPath() {
+        return "/aurora/local/scheduler";
+      }
+    };
+
     Module fakeMesos = new AbstractModule() {
       @Override
       protected void configure() {
@@ -94,6 +106,6 @@ public final class LocalSchedulerMain {
       }
     };
 
-    SchedulerMain.flagConfiguredMain(Modules.combine(fakeMesos, persistentStorage));
+    SchedulerMain.main(testParams, Modules.combine(fakeMesos, persistentStorage));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/test/java/org/apache/aurora/scheduler/http/AbstractJettyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/AbstractJettyTest.java b/src/test/java/org/apache/aurora/scheduler/http/AbstractJettyTest.java
index 19c8a1f..9c40aaf 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/AbstractJettyTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/AbstractJettyTest.java
@@ -135,7 +135,7 @@ public abstract class AbstractJettyTest extends EasyMockTest {
             });
           }
         },
-        new JettyServerModule(false));
+        new JettyServerModule(new JettyServerModule.Params() { }, false));
     schedulerWatcher = createCapture();
     expect(schedulers.watch(capture(schedulerWatcher))).andReturn(createMock(Command.class));
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/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 3e811a4..0c9d4f6 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
@@ -14,7 +14,9 @@
 package org.apache.aurora.scheduler.http.api.security;
 
 import java.io.IOException;
+import java.util.Optional;
 import java.util.Set;
+
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
@@ -157,7 +159,7 @@ public class HttpSecurityIT extends AbstractJettyTest {
         new H2ConsoleModule(true),
         new HttpSecurityModule(
             new IniShiroRealmModule(ini),
-            Key.get(Filter.class, SHIRO_AFTER_AUTH_FILTER_ANNOTATION)),
+            Optional.of(Key.get(Filter.class, SHIRO_AFTER_AUTH_FILTER_ANNOTATION))),
         new AbstractModule() {
           @Override
           protected void configure() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptorModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptorModuleTest.java
b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptorModuleTest.java
index 2c3e5f3..0bbb687 100644
--- a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptorModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptorModuleTest.java
@@ -67,9 +67,27 @@ public class PreemptorModuleTest extends EasyMockTest {
   @Test
   public void testPreemptorDisabled() throws Exception {
     Injector injector = createInjector(new PreemptorModule(
-        false,
-        Amount.of(0L, Time.SECONDS),
-        Amount.of(0L, Time.SECONDS)));
+        new PreemptorModule.Params() {
+          @Override
+          public boolean enablePreemptor() {
+            return false;
+          }
+
+          @Override
+          public Amount<Long, Time> preemptionDelay() {
+            return Amount.of(0L, Time.SECONDS);
+          }
+
+          @Override
+          public Amount<Long, Time> preemptionSlotHoldTime() {
+            return Amount.of(0L, Time.SECONDS);
+          }
+
+          @Override
+          public Amount<Long, Time> preemptionSlotSearchInterval() {
+            return Amount.of(0L, Time.SECONDS);
+          }
+        }));
 
     control.replay();
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/fe13e4ed/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java b/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
index 341e346..fe8c282 100644
--- a/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
@@ -13,6 +13,7 @@
  */
 package org.apache.aurora.scheduler.sla;
 
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -34,6 +35,7 @@ import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.common.util.testing.FakeClock;
 import org.apache.aurora.scheduler.app.LifecycleModule;
 import org.apache.aurora.scheduler.base.Query;
+import org.apache.aurora.scheduler.sla.MetricCalculator.MetricCategory;
 import org.apache.aurora.scheduler.sla.SlaModule.SlaUpdater;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
@@ -63,9 +65,22 @@ public class SlaModuleTest extends EasyMockTest {
     clock = new FakeClock();
     statsProvider = createMock(StatsProvider.class);
     module = new SlaModule(
-        Amount.of(5L, Time.MILLISECONDS),
-        ImmutableSet.of(JOB_UPTIMES, MEDIANS, PLATFORM_UPTIME),
-        ImmutableSet.of(JOB_UPTIMES, MEDIANS, PLATFORM_UPTIME));
+        new SlaModule.Params() {
+          @Override
+          public Amount<Long, Time> slaStatRefreshInterval() {
+            return Amount.of(5L, Time.MILLISECONDS);
+          }
+
+          @Override
+          public Set<MetricCategory> slaProdMetrics() {
+            return ImmutableSet.of(JOB_UPTIMES, MEDIANS, PLATFORM_UPTIME);
+          }
+
+          @Override
+          public Set<MetricCategory> slaNonProdMetrics() {
+            return slaProdMetrics();
+          }
+        });
     injector = Guice.createInjector(
         ImmutableList.<Module>builder()
             .add(module)


Mime
View raw message