Added app::paths which handles Appc related path manipulation.

- Akin to slave::paths.

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


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

Branch: refs/heads/master
Commit: a070de312ee0e6902c34407e306ccdc8eaa3d8e9
Parents: 28d3041
Author: Jiang Yan Xu <[email protected]>
Authored: Mon Aug 10 11:12:31 2015 -0700
Committer: Jiang Yan Xu <[email protected]>
Committed: Thu Aug 13 15:15:20 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 |  2 +
 .../containerizer/provisioners/appc/paths.cpp   | 80 +++++++++++++++++++
 .../containerizer/provisioners/appc/paths.hpp   | 81 ++++++++++++++++++++
 3 files changed, 163 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a070de31/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 111aed9..f8e54d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -457,6 +457,7 @@ libmesos_no_3rdparty_la_SOURCES =                           
        \
        slave/containerizer/mesos/containerizer.cpp                     \
        slave/containerizer/mesos/launch.cpp                            \
        slave/containerizer/provisioner.cpp                             \
+       slave/containerizer/provisioners/appc/paths.cpp                 \
        slave/resource_estimators/noop.cpp                              \
        usage/usage.cpp                                                 \
        v1/attributes.cpp                                               \
@@ -711,6 +712,7 @@ libmesos_no_3rdparty_la_SOURCES +=                          
        \
        slave/containerizer/launcher.hpp                                \
        slave/containerizer/linux_launcher.hpp                          \
        slave/containerizer/provisioner.hpp                             \
+       slave/containerizer/provisioners/appc/paths.hpp                 \
        slave/containerizer/isolators/posix.hpp                         \
        slave/containerizer/isolators/posix/disk.hpp                    \
        slave/containerizer/isolators/cgroups/constants.hpp             \

http://git-wip-us.apache.org/repos/asf/mesos/blob/a070de31/src/slave/containerizer/provisioners/appc/paths.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/provisioners/appc/paths.cpp 
b/src/slave/containerizer/provisioners/appc/paths.cpp
new file mode 100644
index 0000000..a244d9a
--- /dev/null
+++ b/src/slave/containerizer/provisioners/appc/paths.cpp
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#include <stout/path.hpp>
+
+#include "slave/containerizer/provisioners/appc/paths.hpp"
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+namespace appc {
+namespace paths {
+
+string getStagingDir(const string& storeDir)
+{
+  return path::join(storeDir, "staging");
+}
+
+
+string getImagesDir(const string& storeDir)
+{
+  return path::join(storeDir, "images");
+}
+
+
+string getImagePath(const string& storeDir, const string& imageId)
+{
+  return path::join(getImagesDir(storeDir), imageId);
+}
+
+
+string getImageRootfsPath(
+    const string& storeDir,
+    const string& imageId)
+{
+  return path::join(getImagePath(storeDir, imageId), "rootfs");
+}
+
+
+string getImageRootfsPath(const std::string& imagePath)
+{
+  return path::join(imagePath, "rootfs");
+}
+
+
+string getImageManifestPath(
+    const string& storeDir,
+    const string& imageId)
+{
+  return path::join(getImagePath(storeDir, imageId), "manifest");
+}
+
+
+string getImageManifestPath(const std::string& imagePath)
+{
+  return path::join(imagePath, "manifest");
+}
+
+} // namespace paths {
+} // namespace appc {
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/a070de31/src/slave/containerizer/provisioners/appc/paths.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/provisioners/appc/paths.hpp 
b/src/slave/containerizer/provisioners/appc/paths.hpp
new file mode 100644
index 0000000..e358051
--- /dev/null
+++ b/src/slave/containerizer/provisioners/appc/paths.hpp
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef __MESOS_APPC_PATHS__
+#define __MESOS_APPC_PATHS__
+
+#include <list>
+#include <string>
+
+#include <mesos/mesos.hpp>
+
+namespace mesos {
+namespace internal {
+namespace slave {
+namespace appc {
+namespace paths {
+
+// The appc store file system layout is as follows:
+//
+// <root> ('--appc_store_dir' flag)
+// |--staging (contains temp directories for staging downloads)
+// |
+// |--images (stores validated images)
+//    |--<image_id> (in the form of "sha512-<128_character_hash_sum>")
+//       |--manifest
+//       |--rootfs
+//          |--... (according to the ACI spec)
+//
+// TODO(xujyan): The staging directory is unused for now (it's
+// externally managed) but implemented to illustrate the need for a
+// separate 'images' directory. Complete the layout diagram when the
+// staging directory is utilized by the provisioner.
+
+std::string getStagingDir(const std::string& storeDir);
+
+
+std::string getImagesDir(const std::string& storeDir);
+
+
+std::string getImagePath(
+    const std::string& storeDir,
+    const std::string& imageId);
+
+
+std::string getImageRootfsPath(
+    const std::string& storeDir,
+    const std::string& imageId);
+
+
+std::string getImageRootfsPath(const std::string& imagePath);
+
+
+std::string getImageManifestPath(
+    const std::string& storeDir,
+    const std::string& imageId);
+
+
+std::string getImageManifestPath(const std::string& imagePath);
+
+} // namespace paths {
+} // namespace appc {
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __MESOS_APPC_PATHS__

Reply via email to