Repository: aurora
Updated Branches:
  refs/heads/master 4aa639f31 -> c0fdcdcc6


Accept a command line argument for an executor configuration via json

Patch to allow Aurora to accept an executor config via commandline which 
overrides the default thermos one.

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


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

Branch: refs/heads/master
Commit: c0fdcdcc61fa31d57f9bc1e1c823b4b5cdda33cd
Parents: 4aa639f
Author: Renan DelValle <rdelv...@binghamton.edu>
Authored: Thu Dec 17 15:48:53 2015 -0600
Committer: Joshua Cohen <jco...@apache.org>
Committed: Thu Dec 17 15:48:53 2015 -0600

----------------------------------------------------------------------
 NEWS                                            |  3 ++
 .../configuration/executor/ExecutorModule.java  | 41 ++++++++++++++++++--
 2 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/c0fdcdcc/NEWS
----------------------------------------------------------------------
diff --git a/NEWS b/NEWS
index 24890b5..8b5a1a1 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@
   varied health checkers. The following fields from `HealthCheckConfig` are 
now deprecated:
   `endpoint`, `expected_response`, `expected_response_code` in favor of 
setting them as part of an
   `HttpHealthChecker.`
+ - Added support for taking in an executor configuration in JSON via a command 
line argument
+   `--custom_executor_config` which will override all other the command line 
arguments and default
+   values pertaining to the executor.
 
 0.10.0
 ------

http://git-wip-us.apache.org/repos/asf/aurora/blob/c0fdcdcc/src/main/java/org/apache/aurora/scheduler/configuration/executor/ExecutorModule.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/aurora/scheduler/configuration/executor/ExecutorModule.java
 
b/src/main/java/org/apache/aurora/scheduler/configuration/executor/ExecutorModule.java
index d047634..949c299 100644
--- 
a/src/main/java/org/apache/aurora/scheduler/configuration/executor/ExecutorModule.java
+++ 
b/src/main/java/org/apache/aurora/scheduler/configuration/executor/ExecutorModule.java
@@ -13,6 +13,10 @@
  */
 package org.apache.aurora.scheduler.configuration.executor;
 
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Stream;
@@ -24,6 +28,8 @@ import com.google.inject.AbstractModule;
 import org.apache.aurora.GuavaUtils;
 import org.apache.aurora.common.args.Arg;
 import org.apache.aurora.common.args.CmdLine;
+import org.apache.aurora.common.args.constraints.CanRead;
+import org.apache.aurora.common.args.constraints.Exists;
 import org.apache.aurora.common.base.MorePreconditions;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Data;
@@ -44,6 +50,14 @@ import static 
org.apache.aurora.scheduler.ResourceType.RAM_MB;
  * Binding module for {@link ExecutorSettings}.
  */
 public class ExecutorModule extends AbstractModule {
+
+  @CmdLine(
+      name = "custom_executor_config",
+      help = "Path to custom executor settings configuration file.")
+  @Exists
+  @CanRead
+  private static final Arg<File> CUSTOM_EXECUTOR_CONFIG = Arg.create(null);
+
   @CmdLine(name = "thermos_executor_path", help = "Path to the thermos 
executor entry point.")
   private static final Arg<String> THERMOS_EXECUTOR_PATH = Arg.create();
 
@@ -98,8 +112,7 @@ public class ExecutorModule extends AbstractModule {
         .build();
   }
 
-  @Override
-  protected void configure() {
+  private static ExecutorSettings makeThermosExecutorSettings()  {
     List<Protos.Volume> volumeMounts =
         ImmutableList.<Protos.Volume>builder()
             .add(Protos.Volume.newBuilder()
@@ -116,7 +129,7 @@ public class ExecutorModule extends AbstractModule {
                     .build()))
             .build();
 
-    bind(ExecutorSettings.class).toInstance(new ExecutorSettings(
+    return new ExecutorSettings(
         new ExecutorConfig(
             ExecutorInfo.newBuilder()
                 .setName("aurora.task")
@@ -126,7 +139,27 @@ public class ExecutorModule extends AbstractModule {
                 .addResources(makeResource(CPUS, EXECUTOR_OVERHEAD_CPUS.get()))
                 .addResources(makeResource(RAM_MB, 
EXECUTOR_OVERHEAD_RAM.get().as(Data.MB)))
                 .build(),
-            volumeMounts)));
+            volumeMounts));
+  }
+
+  private static ExecutorSettings makeCustomExecutorSettings() {
+    try {
+      return
+          new ExecutorSettings(
+              ExecutorSettingsLoader.read(
+                  Files.newBufferedReader(
+                      CUSTOM_EXECUTOR_CONFIG.get().toPath(),
+                      StandardCharsets.UTF_8)));
+    } catch (ExecutorSettingsLoader.ExecutorConfigException | IOException e) {
+      throw new IllegalArgumentException("Failed to read executor settings: " 
+ e, e);
+    }
+  }
+
+  @Override
+  protected void configure() {
+    
bind(ExecutorSettings.class).toInstance(CUSTOM_EXECUTOR_CONFIG.hasAppliedValue()
+        ? makeCustomExecutorSettings()
+        : makeThermosExecutorSettings());
   }
 
   private static Resource makeResource(ResourceType type, double value) {

Reply via email to