You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2015/06/03 01:00:39 UTC

mesos git commit: Defined protobuf for usage returned by Resource Monitor.

Repository: mesos
Updated Branches:
  refs/heads/master 56eb38650 -> 2a8921f91


Defined protobuf for usage returned by Resource Monitor.

Changed ResourceMonitor to use ResourceUsage instead of
ResourceMonitor::Usage by reusing the existing ResoureUsage in message
mesos.proto.

NOTE: That is required for modules which need to fetch ResourceUsage e.g
ResourceEstimator and QoSController.

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


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

Branch: refs/heads/master
Commit: 2a8921f91044825ebfb64626a8e2afc0517722a1
Parents: 56eb386
Author: Bartek Plotka <bw...@gmail.com>
Authored: Tue Jun 2 15:22:15 2015 -0700
Committer: Niklas Q. Nielsen <ni...@qni.dk>
Committed: Tue Jun 2 15:22:16 2015 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto | 24 ++++--------------------
 src/slave/monitor.cpp     | 41 +++++++++++++++++++----------------------
 src/slave/monitor.hpp     | 22 +++++++---------------
 3 files changed, 30 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2a8921f9/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 5cf81e2..6186c92 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -580,29 +580,13 @@ message ResourceStatistics {
 
 /**
  * Describes a snapshot of the resource usage for an executor.
- *
- * TODO(bmahler): Note that we want to be sending this information
- * to the master, and subsequently to the relevant scheduler. So
- * this proto is designed to be easy for the scheduler to use, this
- * is why we provide the slave id, executor info / task info.
  */
 message ResourceUsage {
-  required SlaveID slave_id = 1;
-  required FrameworkID framework_id = 2;
-
-  // Resource usage is for an executor. For tasks launched with
-  // an explicit executor, the executor id is provided. For tasks
-  // launched without an executor, our internal executor will be
-  // used. In this case, we provide the task id here instead, in
-  // order to make this message easier for schedulers to work with.
-
-  optional ExecutorID executor_id = 3; // If present, this executor was
-  optional string executor_name = 4;   // explicitly specified.
-
-  optional TaskID task_id = 5; // If present, the task did not have an executor.
-
+  // Source of the collected statistics.
+  optional ExecutorInfo executor_info = 1;
+  // Current resource usage.
   // If missing, the isolation module cannot provide resource usage.
-  optional ResourceStatistics statistics = 6;
+  optional ResourceStatistics statistics = 2;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2a8921f9/src/slave/monitor.cpp
----------------------------------------------------------------------
diff --git a/src/slave/monitor.cpp b/src/slave/monitor.cpp
index a5a52b1..8f7ff63 100644
--- a/src/slave/monitor.cpp
+++ b/src/slave/monitor.cpp
@@ -80,9 +80,9 @@ Future<Nothing> ResourceMonitorProcess::stop(
 }
 
 
-Future<list<ResourceMonitor::Usage>> ResourceMonitorProcess::usages()
+Future<list<ResourceUsage>> ResourceMonitorProcess::usages()
 {
-  list<Future<ResourceMonitor::Usage>> futures;
+  list<Future<ResourceUsage>> futures;
 
   foreachkey (const ContainerID& containerId, monitored) {
     futures.push_back(usage(containerId));
@@ -93,11 +93,11 @@ Future<list<ResourceMonitor::Usage>> ResourceMonitorProcess::usages()
 }
 
 
-list<ResourceMonitor::Usage> ResourceMonitorProcess::_usages(
-    list<Future<ResourceMonitor::Usage>> futures)
+list<ResourceUsage> ResourceMonitorProcess::_usages(
+    list<Future<ResourceUsage>> futures)
 {
-  list<ResourceMonitor::Usage> result;
-  foreach(const Future<ResourceMonitor::Usage>& future, futures) {
+  list<ResourceUsage> result;
+  foreach(const Future<ResourceUsage>& future, futures) {
     if (future.isReady()) {
       result.push_back(future.get());
     }
@@ -107,7 +107,7 @@ list<ResourceMonitor::Usage> ResourceMonitorProcess::_usages(
 }
 
 
-Future<ResourceMonitor::Usage> ResourceMonitorProcess::usage(
+Future<ResourceUsage> ResourceMonitorProcess::usage(
     ContainerID containerId)
 {
   if (!monitored.contains(containerId)) {
@@ -120,7 +120,6 @@ Future<ResourceMonitor::Usage> ResourceMonitorProcess::usage(
     .then(defer(
         self(),
         &ResourceMonitorProcess::_usage,
-        containerId,
         executorInfo,
         lambda::_1))
     .onFailed([containerId, executorInfo](const string& failure) {
@@ -140,15 +139,13 @@ Future<ResourceMonitor::Usage> ResourceMonitorProcess::usage(
 }
 
 
-ResourceMonitor::Usage ResourceMonitorProcess::_usage(
-    const ContainerID& containerId,
+ResourceUsage ResourceMonitorProcess::_usage(
     const ExecutorInfo& executorInfo,
     const ResourceStatistics& statistics)
 {
-  ResourceMonitor::Usage usage;
-  usage.containerId = containerId;
-  usage.executorInfo = executorInfo;
-  usage.statistics = statistics;
+  ResourceUsage usage;
+  usage.mutable_executor_info()->CopyFrom(executorInfo);
+  usage.mutable_statistics()->CopyFrom(statistics);
 
   return usage;
 }
@@ -171,7 +168,7 @@ Future<http::Response> ResourceMonitorProcess::_statistics(
 
 
 Future<http::Response> ResourceMonitorProcess::__statistics(
-    const Future<list<ResourceMonitor::Usage>>& futures,
+    const Future<list<ResourceUsage>>& futures,
     const http::Request& request)
 {
   if (!futures.isReady()) {
@@ -181,13 +178,13 @@ Future<http::Response> ResourceMonitorProcess::__statistics(
 
   JSON::Array result;
 
-  foreach (const ResourceMonitor::Usage& usage, futures.get()) {
+  foreach (const ResourceUsage& usage, futures.get()) {
     JSON::Object entry;
-    entry.values["framework_id"] = usage.executorInfo.framework_id().value();
-    entry.values["executor_id"] = usage.executorInfo.executor_id().value();
-    entry.values["executor_name"] = usage.executorInfo.name();
-    entry.values["source"] = usage.executorInfo.source();
-    entry.values["statistics"] = JSON::Protobuf(usage.statistics);
+    entry.values["framework_id"] = usage.executor_info().framework_id().value();
+    entry.values["executor_id"] = usage.executor_info().executor_id().value();
+    entry.values["executor_name"] = usage.executor_info().name();
+    entry.values["source"] = usage.executor_info().source();
+    entry.values["statistics"] = JSON::Protobuf(usage.statistics());
 
     result.values.push_back(entry);
   }
@@ -266,7 +263,7 @@ Future<Nothing> ResourceMonitor::stop(
 }
 
 
-Future<list<ResourceMonitor::Usage>> ResourceMonitor::usages()
+Future<list<ResourceUsage>> ResourceMonitor::usages()
 {
   return dispatch(process, &ResourceMonitorProcess::usages);
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/2a8921f9/src/slave/monitor.hpp
----------------------------------------------------------------------
diff --git a/src/slave/monitor.hpp b/src/slave/monitor.hpp
index 48fe59f..bee91ba 100644
--- a/src/slave/monitor.hpp
+++ b/src/slave/monitor.hpp
@@ -58,13 +58,6 @@ const extern size_t MONITORING_TIME_SERIES_CAPACITY;
 class ResourceMonitor
 {
 public:
-  struct Usage
-  {
-    ContainerID containerId;
-    ExecutorInfo executorInfo;
-    ResourceStatistics statistics;
-  };
-
   explicit ResourceMonitor(Containerizer* containerizer);
   ~ResourceMonitor();
 
@@ -79,7 +72,7 @@ public:
   process::Future<Nothing> stop(
       const ContainerID& containerId);
 
-  process::Future<std::list<Usage>> usages();
+  process::Future<std::list<ResourceUsage>> usages();
 
 private:
   ResourceMonitorProcess* process;
@@ -103,7 +96,7 @@ public:
   process::Future<Nothing> stop(
       const ContainerID& containerId);
 
-  process::Future<std::list<ResourceMonitor::Usage>> usages();
+  process::Future<std::list<ResourceUsage>> usages();
 
 protected:
   virtual void initialize()
@@ -115,15 +108,14 @@ protected:
 
 private:
   // Helper for returning the usage for a particular executor.
-  process::Future<ResourceMonitor::Usage> usage(ContainerID containerId);
+  process::Future<ResourceUsage> usage(ContainerID containerId);
 
-  ResourceMonitor::Usage _usage(
-    const ContainerID& containerId,
+  ResourceUsage _usage(
     const ExecutorInfo& executorInfo,
     const ResourceStatistics& statistics);
 
-  std::list<ResourceMonitor::Usage> _usages(
-      std::list<process::Future<ResourceMonitor::Usage>> future);
+  std::list<ResourceUsage> _usages(
+      std::list<process::Future<ResourceUsage>> future);
 
   // HTTP Endpoints.
   // Returns the monitoring statistics. Requests have no parameters.
@@ -132,7 +124,7 @@ private:
   process::Future<process::http::Response> _statistics(
       const process::http::Request& request);
   process::Future<process::http::Response> __statistics(
-      const process::Future<std::list<ResourceMonitor::Usage>>& futures,
+      const process::Future<std::list<ResourceUsage>>& futures,
       const process::http::Request& request);
 
   static const std::string STATISTICS_HELP;