You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/07/14 22:47:53 UTC
mesos git commit: Added a method in the agent exposing a framework's
allocated resources.
Repository: mesos
Updated Branches:
refs/heads/master 51f2627bc -> a857696eb
Added a method in the agent exposing a framework's allocated resources.
This allows us to call a method to get the framework's allocated
resources, instead of call-sites having to each iterate over the
framework's executors and the framework's pending tasks. It turns
out that most call-sites forgot to account for the pending tasks,
and accounting for the pending tasks is non-trivial!
Review: https://reviews.apache.org/r/60636/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a857696e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a857696e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a857696e
Branch: refs/heads/master
Commit: a857696eb7f635556d680436f9298a10b18442c3
Parents: 51f2627
Author: Andrei Budnik <ab...@mesosphere.com>
Authored: Fri Jul 14 15:36:42 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Jul 14 15:47:39 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 32 ++++++++++++++++++++++++++++++++
src/slave/slave.hpp | 2 ++
2 files changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a857696e/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 64d2411..adbe65f 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -7479,6 +7479,38 @@ bool Framework::removePendingTask(
}
+Resources Framework::allocatedResources() const
+{
+ Resources allocated;
+
+ foreachvalue (const Executor* executor, executors) {
+ // TODO(abudnik): Currently `Executor::resources` does not include
+ // the executor's queued tasks!
+ allocated += executor->resources;
+ }
+
+ hashset<ExecutorID> pendingExecutors;
+
+ typedef hashmap<TaskID, TaskInfo> TaskMap;
+ foreachvalue (const TaskMap& pendingTasks, pending) {
+ foreachvalue (const TaskInfo& task, pendingTasks) {
+ allocated += task.resources();
+
+ ExecutorInfo executorInfo = slave->getExecutorInfo(info, task);
+ const ExecutorID& executorId = executorInfo.executor_id();
+
+ if (!executors.contains(executorId) &&
+ !pendingExecutors.contains(executorId)) {
+ allocated += executorInfo.resources();
+ pendingExecutors.insert(executorId);
+ }
+ }
+ }
+
+ return allocated;
+}
+
+
Executor::Executor(
Slave* _slave,
const FrameworkID& _frameworkId,
http://git-wip-us.apache.org/repos/asf/mesos/blob/a857696e/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 5ede32d..8bb03ec 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -872,6 +872,8 @@ public:
const TaskInfo& task,
const ExecutorInfo& executorInfo);
+ Resources allocatedResources() const;
+
enum State
{
RUNNING, // First state of a newly created framework.