aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Adding REVOCABLE_RESOURCES FrameworkInfo capability.
Date Sat, 22 Aug 2015 17:57:26 GMT
Repository: aurora
Updated Branches:
  refs/heads/master f4446a612 -> d8e948bed


Adding REVOCABLE_RESOURCES FrameworkInfo capability.

Bugs closed: AURORA-1419

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


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

Branch: refs/heads/master
Commit: d8e948bed6526a7e1ae83ada59e590ed8f09ab51
Parents: f4446a6
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Sat Aug 22 10:54:31 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Sat Aug 22 10:54:31 2015 -0700

----------------------------------------------------------------------
 .../mesos/CommandLineDriverSettingsModule.java  | 41 +++++++++++++++-----
 .../CommandLineDriverSettingsModuleTest.java    | 23 +++++++++++
 2 files changed, 55 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/d8e948be/src/main/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModule.java
b/src/main/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModule.java
index 54608c8..5c150b6 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModule.java
@@ -36,6 +36,8 @@ import com.twitter.common.quantity.Time;
 import org.apache.mesos.Protos;
 
 import static org.apache.mesos.Protos.FrameworkInfo;
+import static org.apache.mesos.Protos.FrameworkInfo.Capability;
+import static org.apache.mesos.Protos.FrameworkInfo.Capability.Type.REVOCABLE_RESOURCES;
 
 /**
  * Creates and binds {@link DriverSettings} based on values found on the command line.
@@ -75,20 +77,22 @@ public class CommandLineDriverSettingsModule extends AbstractModule {
           + "to exist on the mesos slaves.")
   private static final Arg<String> EXECUTOR_USER = Arg.create("root");
 
+  @CmdLine(name = "receive_revocable_resources",
+      help = "Allows receiving revocable resource offers from Mesos.")
+  private static final Arg<Boolean> RECEIVE_REVOCABLE_RESOURCES = Arg.create(false);
+
   // TODO(wfarner): Figure out a way to change this without risk of fallout (MESOS-703).
   private static final String TWITTER_FRAMEWORK_NAME = "TwitterScheduler";
 
   @Override
   protected void configure() {
-    FrameworkInfo frameworkInfo = FrameworkInfo.newBuilder()
-        .setUser(EXECUTOR_USER.get())
-        .setName(TWITTER_FRAMEWORK_NAME)
-        // Require slave checkpointing.  Assumes slaves have '--checkpoint=true' arg set.
-        .setCheckpoint(true)
-        .setFailoverTimeout(FRAMEWORK_FAILOVER_TIMEOUT.get().as(Time.SECONDS))
-        .build();
-    DriverSettings settings =
-        new DriverSettings(MESOS_MASTER_ADDRESS.get(), getCredentials(), frameworkInfo);
+    DriverSettings settings = new DriverSettings(
+        MESOS_MASTER_ADDRESS.get(),
+        getCredentials(),
+        buildFrameworkInfo(
+            EXECUTOR_USER.get(),
+            FRAMEWORK_FAILOVER_TIMEOUT.get(),
+            RECEIVE_REVOCABLE_RESOURCES.get()));
     bind(DriverSettings.class).toInstance(settings);
   }
 
@@ -115,6 +119,25 @@ public class CommandLineDriverSettingsModule extends AbstractModule {
   }
 
   @VisibleForTesting
+  static FrameworkInfo buildFrameworkInfo(
+      String executorUser,
+      Amount<Long, Time> failoverTimeout,
+      boolean revocable) {
+
+    FrameworkInfo.Builder infoBuilder = FrameworkInfo.newBuilder()
+        .setUser(executorUser)
+        .setName(TWITTER_FRAMEWORK_NAME)
+            // Require slave checkpointing.  Assumes slaves have '--checkpoint=true' arg
set.
+        .setCheckpoint(true)
+        .setFailoverTimeout(failoverTimeout.as(Time.SECONDS));
+
+    if (revocable) {
+      infoBuilder.addCapabilities(Capability.newBuilder().setType(REVOCABLE_RESOURCES));
+    }
+    return infoBuilder.build();
+  }
+
+  @VisibleForTesting
   static Properties parseCredentials(InputStream credentialsStream) {
     Properties properties = new Properties();
     try {

http://git-wip-us.apache.org/repos/asf/aurora/blob/d8e948be/src/test/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModuleTest.java
b/src/test/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModuleTest.java
index 9e17688..737378f 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/CommandLineDriverSettingsModuleTest.java
@@ -19,9 +19,13 @@ import java.io.IOException;
 import java.util.Properties;
 
 import com.google.common.base.Throwables;
+import com.twitter.common.quantity.Amount;
+import com.twitter.common.quantity.Time;
 
+import org.apache.mesos.Protos;
 import org.junit.Test;
 
+import static org.apache.mesos.Protos.FrameworkInfo.Capability.Type.REVOCABLE_RESOURCES;
 import static org.junit.Assert.assertEquals;
 
 public class CommandLineDriverSettingsModuleTest {
@@ -60,4 +64,23 @@ public class CommandLineDriverSettingsModuleTest {
         CommandLineDriverSettingsModule.parseCredentials(
             new ByteArrayInputStream(propertiesStream.toByteArray())));
   }
+
+  @Test
+  public void testFrameworkInfoNoRevocable() {
+    Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
+        "user",
+        Amount.of(1L, Time.MINUTES),
+        false);
+    assertEquals(0, info.getCapabilitiesCount());
+  }
+
+  @Test
+  public void testFrameworkInfoRevocable() {
+    Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
+        "user",
+        Amount.of(1L, Time.MINUTES),
+        true);
+    assertEquals(1, info.getCapabilitiesCount());
+    assertEquals(REVOCABLE_RESOURCES, info.getCapabilities(0).getType());
+  }
 }


Mime
View raw message