Moved ContainerInfo::Image definition to the top level.

Review: https://reviews.apache.org/r/37054


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

Branch: refs/heads/master
Commit: ddfab613acdb998ede64d80abeb49300a88959c4
Parents: f077ae6
Author: Jie Yu <[email protected]>
Authored: Mon Aug 3 13:04:44 2015 -0700
Committer: Jie Yu <[email protected]>
Committed: Fri Aug 7 16:50:50 2015 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto                       | 59 +++++++++++---------
 src/slave/containerizer/mesos/containerizer.cpp |  9 ++-
 src/slave/containerizer/mesos/containerizer.hpp |  8 +--
 src/slave/containerizer/provisioner.cpp         |  7 ++-
 src/slave/containerizer/provisioner.hpp         |  4 +-
 .../containerizer/mesos_containerizer_tests.cpp | 11 ++--
 6 files changed, 51 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index a6748d1..3e55089 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1191,6 +1191,39 @@ message RateLimits {
 
 
 /**
+ * Describe an image used by tasks or executors. Note that it's only
+ * for tasks or executors launched by MesosContainerizer currently.
+ */
+message Image {
+  enum Type {
+    APPC = 1;
+  }
+
+  // Protobuf for specifying an Appc container image. See:
+  // https://github.com/appc/spec/blob/master/spec/aci.md
+  message AppC {
+    // The name of the image.
+    required string name = 1;
+
+    // An image ID is a string of the format "hash-value", where
+    // "hash" is the hash algorithm used and "value" is the hex
+    // encoded string of the digest. Currently the only permitted
+    // hash algorithm is sha512.
+    required string id = 2;
+
+    // Optional labels. Suggested labels: "version", "os", and "arch".
+    optional Labels labels = 3;
+  }
+
+  required Type type = 1;
+
+  // Only one of the following image messages should be set to match
+  // the type.
+  optional AppC appc = 2;
+}
+
+
+/**
  * Describes a volume mapping either from host to container or vice
  * versa. Both paths can either refer to a directory or a file.
  */
@@ -1258,32 +1291,6 @@ message ContainerInfo {
     optional bool force_pull_image = 6;
   }
 
-  message Image {
-    enum Type {
-      APPC = 1;
-    }
-
-    // Protobuf for specifying an Appc container image. See:
-    // https://github.com/appc/spec/blob/master/spec/aci.md
-    message AppC {
-      // The name of the image.
-      required string name = 1;
-
-      // An image ID is a string of the format "hash-value", where "hash"
-      // is the hash algorithm used and "value" is the hex encoded string of
-      // the digest. Currently the only permitted hash algorithm is sha512.
-      required string id = 2;
-
-      // Optional labels. Suggested labels: "version", "os", and "arch".
-      optional Labels labels = 3;
-    }
-
-    required Type type = 1;
-    // Only one of the following image messages should be set to match
-    // the type.
-    optional AppC appc = 2;
-  }
-
   message MesosInfo {
     optional Image image = 1;
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp 
b/src/slave/containerizer/mesos/containerizer.cpp
index 6d07ff1..0222245 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -197,7 +197,7 @@ Try<MesosContainerizer*> MesosContainerizer::create(
     return Error("Failed to create launcher: " + launcher.error());
   }
 
-  Try<hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>> provisioners =
+  Try<hashmap<Image::Type, Owned<Provisioner>>> provisioners =
     Provisioner::create(flags, fetcher);
 
   if (provisioners.isError()) {
@@ -220,7 +220,7 @@ MesosContainerizer::MesosContainerizer(
     Fetcher* fetcher,
     const Owned<Launcher>& launcher,
     const vector<Owned<Isolator>>& isolators,
-    const hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>& 
provisioners)
+    const hashmap<Image::Type, Owned<Provisioner>>& provisioners)
   : process(new MesosContainerizerProcess(
       flags,
       local,
@@ -634,7 +634,7 @@ Future<Nothing> MesosContainerizerProcess::provision(
     return Nothing();
   }
 
-  ContainerInfo::Image image = executorInfo.container().mesos().image();
+  Image image = executorInfo.container().mesos().image();
 
   if (!provisioners.contains(image.type())) {
     return Failure("ExecutorInfo specifies container image type '" +
@@ -1281,8 +1281,7 @@ void MesosContainerizerProcess::____destroy(
     return;
   }
 
-  ContainerInfo::Image::Type type =
-    container->executorInfo.container().mesos().image().type();
+  Image::Type type = 
container->executorInfo.container().mesos().image().type();
 
   if (!provisioners.contains(type)) {
     // We should have a provisioner to handle cleaning up the rootfs

http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/src/slave/containerizer/mesos/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.hpp 
b/src/slave/containerizer/mesos/containerizer.hpp
index 8851d30..68e9139 100644
--- a/src/slave/containerizer/mesos/containerizer.hpp
+++ b/src/slave/containerizer/mesos/containerizer.hpp
@@ -58,8 +58,7 @@ public:
       Fetcher* fetcher,
       const process::Owned<Launcher>& launcher,
       const std::vector<process::Owned<mesos::slave::Isolator>>& isolators,
-      const hashmap<ContainerInfo::Image::Type,
-                    process::Owned<Provisioner>>& provisioners);
+      const hashmap<Image::Type, process::Owned<Provisioner>>& provisioners);
 
 
   // Used for testing.
@@ -118,8 +117,7 @@ public:
       Fetcher* _fetcher,
       const process::Owned<Launcher>& _launcher,
       const std::vector<process::Owned<mesos::slave::Isolator>>& _isolators,
-      const hashmap<ContainerInfo::Image::Type,
-                    process::Owned<Provisioner>>& _provisioners)
+      const hashmap<Image::Type, process::Owned<Provisioner>>& _provisioners)
     : flags(_flags),
       local(_local),
       fetcher(_fetcher),
@@ -278,7 +276,7 @@ private:
   Fetcher* fetcher;
   const process::Owned<Launcher> launcher;
   const std::vector<process::Owned<mesos::slave::Isolator>> isolators;
-  hashmap<ContainerInfo::Image::Type, process::Owned<Provisioner>> 
provisioners;
+  hashmap<Image::Type, process::Owned<Provisioner>> provisioners;
 
   enum State
   {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/src/slave/containerizer/provisioner.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/provisioner.cpp 
b/src/slave/containerizer/provisioner.cpp
index df52e36..efc7e69 100644
--- a/src/slave/containerizer/provisioner.cpp
+++ b/src/slave/containerizer/provisioner.cpp
@@ -24,11 +24,12 @@ namespace mesos {
 namespace internal {
 namespace slave {
 
-Try<hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>>
-  Provisioner::create(const Flags& flags, Fetcher* fetcher)
+Try<hashmap<Image::Type, Owned<Provisioner>>> Provisioner::create(
+    const Flags& flags,
+    Fetcher* fetcher)
 {
   // TODO(tnachen): Load provisioners when one of them is available.
-  return hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>();
+  return hashmap<Image::Type, Owned<Provisioner>>();
 }
 
 } // namespace slave {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/src/slave/containerizer/provisioner.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/provisioner.hpp 
b/src/slave/containerizer/provisioner.hpp
index cb4d511..3df6d59 100644
--- a/src/slave/containerizer/provisioner.hpp
+++ b/src/slave/containerizer/provisioner.hpp
@@ -45,7 +45,7 @@ class Provisioner
 public:
   virtual ~Provisioner() {}
 
-  static Try<hashmap<ContainerInfo::Image::Type, process::Owned<Provisioner>>>
+  static Try<hashmap<Image::Type, process::Owned<Provisioner>>>
     create(const Flags& flags, Fetcher* fetcher);
 
   // Recover root filesystems for containers from the run states and
@@ -61,7 +61,7 @@ public:
   // image and return the absolute path to the root filesystem.
   virtual process::Future<std::string> provision(
       const ContainerID& containerId,
-      const ContainerInfo::Image& image) = 0;
+      const Image& image) = 0;
 
   // Destroy a previously provisioned root filesystem. Assumes that
   // all references (e.g., mounts, open files) to the provisioned

http://git-wip-us.apache.org/repos/asf/mesos/blob/ddfab613/src/tests/containerizer/mesos_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mesos_containerizer_tests.cpp 
b/src/tests/containerizer/mesos_containerizer_tests.cpp
index 213fa4b..4afa986 100644
--- a/src/tests/containerizer/mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/mesos_containerizer_tests.cpp
@@ -117,7 +117,7 @@ public:
         fetcher,
         Owned<Launcher>(launcher.get()),
         isolators,
-        hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>());
+        hashmap<Image::Type, Owned<Provisioner>>());
   }
 
   Try<MesosContainerizer*> CreateContainerizer(
@@ -430,8 +430,7 @@ public:
       Fetcher* fetcher,
       const Owned<Launcher>& launcher,
       const vector<Owned<Isolator>>& isolators,
-      const hashmap<ContainerInfo::Image::Type,
-                    Owned<Provisioner>>& provisioners)
+      const hashmap<Image::Type, Owned<Provisioner>>& provisioners)
     : MesosContainerizerProcess(
           flags,
           local,
@@ -548,7 +547,7 @@ TEST_F(MesosContainerizerDestroyTest, DestroyWhileFetching)
       &fetcher,
       Owned<Launcher>(launcher.get()),
       vector<Owned<Isolator>>(),
-      hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>());
+      hashmap<Image::Type, Owned<Provisioner>>());
 
   Future<Nothing> exec;
   Promise<bool> promise;
@@ -615,7 +614,7 @@ TEST_F(MesosContainerizerDestroyTest, DestroyWhilePreparing)
       &fetcher,
       Owned<Launcher>(launcher.get()),
       {Owned<Isolator>(isolator)},
-      hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>());
+      hashmap<Image::Type, Owned<Provisioner>>());
 
   MesosContainerizer 
containerizer((Owned<MesosContainerizerProcess>(process)));
 
@@ -693,7 +692,7 @@ TEST_F(MesosContainerizerDestroyTest, 
LauncherDestroyFailure)
       &fetcher,
       Owned<Launcher>(launcher),
       vector<Owned<Isolator>>(),
-      hashmap<ContainerInfo::Image::Type, Owned<Provisioner>>());
+      hashmap<Image::Type, Owned<Provisioner>>());
 
   MesosContainerizer 
containerizer((Owned<MesosContainerizerProcess>(process)));
 

Reply via email to