You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/09/15 02:32:19 UTC

mesos git commit: Added MOUNT or PATH disk type info when logging resources.

Repository: mesos
Updated Branches:
  refs/heads/master 1eaabd00a -> 5e1c68149


Added MOUNT or PATH disk type info when logging resources.

i.e., Added DiskInfo::Source info when outputting Resource::DiskInfo.

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


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

Branch: refs/heads/master
Commit: 5e1c6814915756ae71f6ae612826de7e494fc481
Parents: 1eaabd0
Author: Anindya Sinha <an...@apple.com>
Authored: Wed Sep 14 17:34:49 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Wed Sep 14 19:31:53 2016 -0700

----------------------------------------------------------------------
 src/common/resources.cpp      | 20 ++++++++++++++++++++
 src/tests/resources_tests.cpp | 18 ++++++++++++++++++
 src/v1/resources.cpp          | 20 ++++++++++++++++++++
 3 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1c6814/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index f841e91..f2d6cfe 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1717,6 +1717,19 @@ Resources& Resources::operator-=(const Resources& that)
 }
 
 
+ostream& operator<<(ostream& stream, const Resource::DiskInfo::Source& source)
+{
+  switch (source.type()) {
+    case Resource::DiskInfo::Source::MOUNT:
+      return stream << "MOUNT:" + source.mount().root();
+    case Resource::DiskInfo::Source::PATH:
+      return stream << "PATH:" + source.path().root();
+  }
+
+  UNREACHABLE();
+}
+
+
 ostream& operator<<(ostream& stream, const Volume& volume)
 {
   string volumeConfig = volume.container_path();
@@ -1743,7 +1756,14 @@ ostream& operator<<(ostream& stream, const Volume& volume)
 
 ostream& operator<<(ostream& stream, const Resource::DiskInfo& disk)
 {
+  if (disk.has_source()) {
+    stream << disk.source();
+  }
+
   if (disk.has_persistence()) {
+    if (disk.has_source()) {
+      stream << ",";
+    }
     stream << disk.persistence().id();
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1c6814/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index 3ade1c0..157b9f6 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -833,6 +833,24 @@ TEST(ResourcesTest, PrintingExtendedAttributes)
   stream << disk;
   EXPECT_EQ("disk(alice)[hadoop:/hdfs:/data:rw]:1", stream.str());
 
+  // Disk resource with MOUNT type.
+  stream.str("");
+  disk.mutable_disk()->mutable_source()->set_type(
+      Resource::DiskInfo::Source::MOUNT);
+  disk.mutable_disk()->mutable_source()->mutable_mount()->set_root("/mnt1");
+  stream << disk;
+  EXPECT_EQ("disk(alice)[MOUNT:/mnt1,hadoop:/hdfs:/data:rw]:1", stream.str());
+  disk.mutable_disk()->clear_source();
+
+  // Disk resource with PATH type.
+  stream.str("");
+  disk.mutable_disk()->mutable_source()->set_type(
+      Resource::DiskInfo::Source::PATH);
+  disk.mutable_disk()->mutable_source()->mutable_path()->set_root("/mnt2");
+  stream << disk;
+  EXPECT_EQ("disk(alice)[PATH:/mnt2,hadoop:/hdfs:/data:rw]:1", stream.str());
+  disk.mutable_disk()->clear_source();
+
   // Disk resource with host path and dynamic reservation without labels.
   stream.str("");
   disk.mutable_reservation()->set_principal("hdfs-p");

http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1c6814/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 4410a8f..92efa31 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1720,6 +1720,19 @@ Resources& Resources::operator-=(const Resources& that)
 }
 
 
+ostream& operator<<(ostream& stream, const Resource::DiskInfo::Source& source)
+{
+  switch (source.type()) {
+    case Resource::DiskInfo::Source::MOUNT:
+      return stream << "MOUNT:" + source.mount().root();
+    case Resource::DiskInfo::Source::PATH:
+      return stream << "PATH:" + source.path().root();
+  }
+
+  UNREACHABLE();
+}
+
+
 ostream& operator<<(ostream& stream, const Volume& volume)
 {
   string volumeConfig = volume.container_path();
@@ -1746,7 +1759,14 @@ ostream& operator<<(ostream& stream, const Volume& volume)
 
 ostream& operator<<(ostream& stream, const Resource::DiskInfo& disk)
 {
+  if (disk.has_source()) {
+    stream << disk.source();
+  }
+
   if (disk.has_persistence()) {
+    if (disk.has_source()) {
+      stream << ",";
+    }
     stream << disk.persistence().id();
   }