You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/05/31 21:51:15 UTC
[01/16] mesos git commit: Combined an 'undef' workaround for Windows.
Repository: mesos
Updated Branches:
refs/heads/master d5c5561c0 -> 3e4a12cca
Combined an 'undef' workaround for Windows.
Review: https://reviews.apache.org/r/59673
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3e4a12cc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3e4a12cc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3e4a12cc
Branch: refs/heads/master
Commit: 3e4a12ccab9efff8a7ba7e95c35429fa5ff86402
Parents: b415c8c
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:49:12 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3e4a12cc/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 77aff1d..7ffaed1 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -88,6 +88,7 @@
// constant in the Windows SDK.
#ifdef __WINDOWS__
#undef REGISTERING
+#undef REGISTERED
#endif // __WINDOWS__
namespace mesos {
@@ -742,16 +743,6 @@ public:
// Returns the task group associated with the task.
Option<TaskGroupInfo> getQueuedTaskGroup(const TaskID& taskId);
-// Undefine NetBios preprocessor macros used by the `State` enum.
-#ifdef REGISTERING
-#undef REGISTERING
-#endif // REGISTERING
-
-#ifdef REGISTERED
-#undef REGISTERED
-#endif // REGISTERED
-
-
enum State
{
REGISTERING, // Executor is launched but not (re-)registered yet.
[08/16] mesos git commit: Changed `Executor` and `Framework` to class.
Posted by ji...@apache.org.
Changed `Executor` and `Framework` to class.
It's wierd that `Executor` and `Framework` are struct, but they have
`private` fields.
Review: https://reviews.apache.org/r/59662
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/96e08d8f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/96e08d8f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/96e08d8f
Branch: refs/heads/master
Commit: 96e08d8ff1ab2a2f3b6096a26e5c4cab7575b40d
Parents: 96ec255
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:38:09 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/96e08d8f/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 769bb7e..9f4fc2f 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -100,8 +100,9 @@ namespace slave {
// Some forward declarations.
class StatusUpdateManager;
-struct Executor;
-struct Framework;
+class Executor;
+class Framework;
+
struct HttpConnection;
@@ -469,12 +470,12 @@ public:
const ContainerID& containerId);
private:
- friend struct Executor;
- friend struct Framework;
- friend struct Metrics;
-
+ friend class Executor;
+ friend class Framework;
friend class Http;
+ friend struct Metrics;
+
void _authenticate();
void authenticationTimeout(process::Future<bool> future);
@@ -683,8 +684,9 @@ std::ostream& operator<<(std::ostream& stream, const Executor& executor);
// Information describing an executor.
-struct Executor
+class Executor
{
+public:
Executor(
Slave* slave,
const FrameworkID& frameworkId,
@@ -845,8 +847,9 @@ private:
// Information about a framework.
-struct Framework
+class Framework
{
+public:
Framework(
Slave* slave,
const Flags& slaveFlags,
[13/16] mesos git commit: Moved Framework::hasTask to the source file.
Posted by ji...@apache.org.
Moved Framework::hasTask to the source file.
Review: https://reviews.apache.org/r/59666
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fc00c5bb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fc00c5bb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fc00c5bb
Branch: refs/heads/master
Commit: fc00c5bb379079dc01f33fe8ed1f7800a9bc0811
Parents: 3f5008a
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:55:04 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 20 ++++++++++++++++++++
src/slave/slave.hpp | 20 +-------------------
2 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fc00c5bb/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 014044d..0c62622 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -7307,6 +7307,26 @@ void Framework::recoverExecutor(
}
+bool Framework::hasTask(const TaskID& taskId)
+{
+ foreachkey (const ExecutorID& executorId, pending) {
+ if (pending[executorId].contains(taskId)) {
+ return true;
+ }
+ }
+
+ foreachvalue (Executor* executor, executors) {
+ if (executor->queuedTasks.contains(taskId) ||
+ executor->launchedTasks.contains(taskId) ||
+ executor->terminatedTasks.contains(taskId)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
Executor::Executor(
Slave* _slave,
const FrameworkID& _frameworkId,
http://git-wip-us.apache.org/repos/asf/mesos/blob/fc00c5bb/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index da25c73..4054ab3 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -865,6 +865,7 @@ public:
const hashset<TaskID>& tasksToRecheckpoint);
void checkpointFramework() const;
+ bool hasTask(const TaskID& taskId);
bool removePendingTask(
const TaskInfo& task,
@@ -909,25 +910,6 @@ public:
boost::circular_buffer<process::Owned<Executor>> completedExecutors;
- bool hasTask(const TaskID& taskId)
- {
- foreachkey (const ExecutorID& executorId, pending) {
- if (pending[executorId].contains(taskId)) {
- return true;
- }
- }
-
- foreachvalue (Executor* executor, executors) {
- if (executor->queuedTasks.contains(taskId) ||
- executor->launchedTasks.contains(taskId) ||
- executor->terminatedTasks.contains(taskId)) {
- return true;
- }
- }
-
- return false;
- }
-
private:
Framework(const Framework&) = delete;
Framework& operator=(const Framework&) = delete;
[12/16] mesos git commit: Removed an unnecessary function declaration
from slave.hpp.
Posted by ji...@apache.org.
Removed an unnecessary function declaration from slave.hpp.
Review: https://reviews.apache.org/r/59668
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/10ab6c22
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/10ab6c22
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/10ab6c22
Branch: refs/heads/master
Commit: 10ab6c225cab7f6bbe8890e06fb8aafde662bc92
Parents: 6254e2d
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:02:14 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 10 +++++++++-
src/slave/slave.hpp | 6 ------
2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/10ab6c22/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 052a7f7..89078ad 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -161,6 +161,14 @@ namespace slave {
using namespace state;
+// Forward declarations.
+
+// Needed for logging task/task group.
+static string taskOrTaskGroup(
+ const Option<TaskInfo>& task,
+ const Option<TaskGroupInfo>& taskGroup);
+
+
Slave::Slave(const string& id,
const slave::Flags& _flags,
MasterDetector* _detector,
@@ -7861,7 +7869,7 @@ std::ostream& operator<<(std::ostream& stream, Slave::State state)
}
-string taskOrTaskGroup(
+static string taskOrTaskGroup(
const Option<TaskInfo>& task,
const Option<TaskGroupInfo>& taskGroup)
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/10ab6c22/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index afa3a12..09b7f0a 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -951,12 +951,6 @@ std::ostream& operator<<(std::ostream& stream, Executor::State state);
std::ostream& operator<<(std::ostream& stream, Framework::State state);
std::ostream& operator<<(std::ostream& stream, Slave::State state);
-
-// Needed for logging task/task group.
-std::string taskOrTaskGroup(
- const Option<TaskInfo>& task,
- const Option<TaskGroupInfo>& taskGroup);
-
} // namespace slave {
} // namespace internal {
} // namespace mesos {
[02/16] mesos git commit: Reordered `Slave` copy constructor and
assignment operator.
Posted by ji...@apache.org.
Reordered `Slave` copy constructor and assignment operator.
Review: https://reviews.apache.org/r/59671
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a1731d4f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a1731d4f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a1731d4f
Branch: refs/heads/master
Commit: a1731d4f0ee8ea8a5f882a37cd7874d8bdbd67f4
Parents: e6a865b
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:33:34 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1731d4f/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 24b9258..d049956 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -476,6 +476,9 @@ private:
friend struct Metrics;
+ Slave(const Slave&) = delete;
+ Slave& operator=(const Slave&) = delete;
+
void _authenticate();
void authenticationTimeout(process::Future<bool> future);
@@ -505,9 +508,6 @@ private:
const FrameworkID& frameworkId,
const ExecutorID& executorId);
- Slave(const Slave&) = delete;
- Slave& operator=(const Slave&) = delete;
-
// Gauge methods.
double _frameworks_active()
{
[09/16] mesos git commit: Removed unnecessary friend declaration for
an stream operator.
Posted by ji...@apache.org.
Removed unnecessary friend declaration for an stream operator.
Review: https://reviews.apache.org/r/59663
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fc1fd076
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fc1fd076
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fc1fd076
Branch: refs/heads/master
Commit: fc1fd076ef81767afda9c61a4c206fc688cbb938
Parents: 96e08d8
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:39:53 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fc1fd076/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 9f4fc2f..4d29bef 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -742,10 +742,6 @@ public:
// Returns the task group associated with the task.
Option<TaskGroupInfo> getQueuedTaskGroup(const TaskID& taskId);
- friend std::ostream& operator<<(
- std::ostream& stream,
- const Executor& executor);
-
// Undefine NetBios preprocessor macros used by the `State` enum.
#ifdef REGISTERING
#undef REGISTERING
[14/16] mesos git commit: Removed some unnecessary std:: prefix in
slave.cpp.
Posted by ji...@apache.org.
Removed some unnecessary std:: prefix in slave.cpp.
Review: https://reviews.apache.org/r/59669
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/97272c80
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/97272c80
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/97272c80
Branch: refs/heads/master
Commit: 97272c80c3586bea568974161223d1c4ec381e36
Parents: 10ab6c2
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:03:57 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/97272c80/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 89078ad..c3df7d9 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -128,8 +128,10 @@ using mesos::slave::ResourceEstimator;
using std::find;
using std::list;
using std::map;
+using std::ostream;
using std::ostringstream;
using std::set;
+using std::shared_ptr;
using std::string;
using std::vector;
@@ -1493,7 +1495,7 @@ void Slave::doReliableRegistration(Duration maxBackoff)
completedFramework_->add_tasks()->CopyFrom(*task);
}
- foreach (const std::shared_ptr<Task>& task, executor->completedTasks) {
+ foreach (const shared_ptr<Task>& task, executor->completedTasks) {
VLOG(2) << "Reregistering completed task " << task->task_id();
completedFramework_->add_tasks()->CopyFrom(*task);
}
@@ -2953,7 +2955,7 @@ void Slave::killTask(
// send a TASK_KILLED update for all tasks in the group.
Option<TaskGroupInfo> taskGroup = executor->getQueuedTaskGroup(taskId);
- std::list<StatusUpdate> updates;
+ list<StatusUpdate> updates;
if (taskGroup.isSome()) {
foreach (const TaskInfo& task, taskGroup->tasks()) {
updates.push_back(protobuf::createStatusUpdate(
@@ -3010,7 +3012,7 @@ void Slave::killTask(
// send a TASK_KILLED update for all the other tasks.
Option<TaskGroupInfo> taskGroup = executor->getQueuedTaskGroup(taskId);
- std::list<StatusUpdate> updates;
+ list<StatusUpdate> updates;
if (taskGroup.isSome()) {
foreach (const TaskInfo& task, taskGroup->tasks()) {
updates.push_back(protobuf::createStatusUpdate(
@@ -7417,7 +7419,7 @@ void Executor::completeTask(const TaskID& taskId)
<< "Failed to find terminated task " << taskId;
Task* task = terminatedTasks[taskId];
- completedTasks.push_back(std::shared_ptr<Task>(task));
+ completedTasks.push_back(shared_ptr<Task>(task));
terminatedTasks.erase(taskId);
}
@@ -7818,7 +7820,7 @@ CommandInfo defaultExecutorCommandInfo(
}
-std::ostream& operator<<(std::ostream& stream, const Executor& executor)
+ostream& operator<<(ostream& stream, const Executor& executor)
{
stream << "'" << executor.id << "' of framework " << executor.frameworkId;
@@ -7835,7 +7837,7 @@ std::ostream& operator<<(std::ostream& stream, const Executor& executor)
}
-std::ostream& operator<<(std::ostream& stream, Executor::State state)
+ostream& operator<<(ostream& stream, Executor::State state)
{
switch (state) {
case Executor::REGISTERING: return stream << "REGISTERING";
@@ -7847,7 +7849,7 @@ std::ostream& operator<<(std::ostream& stream, Executor::State state)
}
-std::ostream& operator<<(std::ostream& stream, Framework::State state)
+ostream& operator<<(ostream& stream, Framework::State state)
{
switch (state) {
case Framework::RUNNING: return stream << "RUNNING";
@@ -7857,7 +7859,7 @@ std::ostream& operator<<(std::ostream& stream, Framework::State state)
}
-std::ostream& operator<<(std::ostream& stream, Slave::State state)
+ostream& operator<<(ostream& stream, Slave::State state)
{
switch (state) {
case Slave::RECOVERING: return stream << "RECOVERING";
[04/16] mesos git commit: Used `delete` for `Slave` copy constructor
and assignment operator.
Posted by ji...@apache.org.
Used `delete` for `Slave` copy constructor and assignment operator.
Review: https://reviews.apache.org/r/59659
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b90ba2b7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b90ba2b7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b90ba2b7
Branch: refs/heads/master
Commit: b90ba2b7aeffeffef0d590c813a924b94762207d
Parents: c565152
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 14:26:07 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b90ba2b7/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 8e9e36c..2a62eff 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -504,8 +504,8 @@ private:
const FrameworkID& frameworkId,
const ExecutorID& executorId);
- Slave(const Slave&); // No copying.
- Slave& operator=(const Slave&); // No assigning.
+ Slave(const Slave&) = delete;
+ Slave& operator=(const Slave&) = delete;
// Gauge methods.
double _frameworks_active()
[15/16] mesos git commit: Reordered gauge methods in `Slave` class.
Posted by ji...@apache.org.
Reordered gauge methods in `Slave` class.
Review: https://reviews.apache.org/r/59672
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b415c8ce
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b415c8ce
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b415c8ce
Branch: refs/heads/master
Commit: b415c8cef1f39ae94b2b59c3c74495e7dd141eba
Parents: a1731d4
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:36:53 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 240 +++++++++++++++++++++++------------------------
src/slave/slave.hpp | 24 ++---
2 files changed, 132 insertions(+), 132 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b415c8ce/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 247c7eb..0c7e5f4 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -6585,126 +6585,6 @@ Future<ResourceUsage> Slave::usage()
}
-// TODO(dhamon): Move these to their own metrics.hpp|cpp.
-double Slave::_tasks_staging()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- typedef hashmap<TaskID, TaskInfo> TaskMap;
- foreachvalue (const TaskMap& tasks, framework->pending) {
- count += tasks.size();
- }
-
- foreachvalue (Executor* executor, framework->executors) {
- count += executor->queuedTasks.size();
-
- foreachvalue (Task* task, executor->launchedTasks) {
- if (task->state() == TASK_STAGING) {
- count++;
- }
- }
- }
- }
- return count;
-}
-
-
-double Slave::_tasks_starting()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- foreachvalue (Task* task, executor->launchedTasks) {
- if (task->state() == TASK_STARTING) {
- count++;
- }
- }
- }
- }
- return count;
-}
-
-
-double Slave::_tasks_running()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- foreachvalue (Task* task, executor->launchedTasks) {
- if (task->state() == TASK_RUNNING) {
- count++;
- }
- }
- }
- }
- return count;
-}
-
-
-double Slave::_tasks_killing()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- foreachvalue (Task* task, executor->launchedTasks) {
- if (task->state() == TASK_KILLING) {
- count++;
- }
- }
- }
- }
- return count;
-}
-
-
-double Slave::_executors_registering()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- if (executor->state == Executor::REGISTERING) {
- count++;
- }
- }
- }
- return count;
-}
-
-
-double Slave::_executors_running()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- if (executor->state == Executor::RUNNING) {
- count++;
- }
- }
- }
- return count;
-}
-
-
-double Slave::_executors_terminating()
-{
- double count = 0.0;
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- if (executor->state == Executor::TERMINATING) {
- count++;
- }
- }
- }
- return count;
-}
-
-
-double Slave::_executor_directory_max_allowed_age_secs()
-{
- return executorDirectoryMaxAllowedAge.secs();
-}
-
-
// As a principle, we do not need to re-authorize actions that have already
// been authorized by the master. However, we re-authorize the RUN_TASK action
// on the agent even though the master has already authorized it because:
@@ -6880,6 +6760,126 @@ void Slave::sendExecutorTerminatedStatusUpdate(
}
+// TODO(dhamon): Move these to their own metrics.hpp|cpp.
+double Slave::_tasks_staging()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ typedef hashmap<TaskID, TaskInfo> TaskMap;
+ foreachvalue (const TaskMap& tasks, framework->pending) {
+ count += tasks.size();
+ }
+
+ foreachvalue (Executor* executor, framework->executors) {
+ count += executor->queuedTasks.size();
+
+ foreachvalue (Task* task, executor->launchedTasks) {
+ if (task->state() == TASK_STAGING) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_tasks_starting()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ foreachvalue (Task* task, executor->launchedTasks) {
+ if (task->state() == TASK_STARTING) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_tasks_running()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ foreachvalue (Task* task, executor->launchedTasks) {
+ if (task->state() == TASK_RUNNING) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_tasks_killing()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ foreachvalue (Task* task, executor->launchedTasks) {
+ if (task->state() == TASK_KILLING) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_executors_registering()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ if (executor->state == Executor::REGISTERING) {
+ count++;
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_executors_running()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ if (executor->state == Executor::RUNNING) {
+ count++;
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_executors_terminating()
+{
+ double count = 0.0;
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ if (executor->state == Executor::TERMINATING) {
+ count++;
+ }
+ }
+ }
+ return count;
+}
+
+
+double Slave::_executor_directory_max_allowed_age_secs()
+{
+ return executorDirectoryMaxAllowedAge.secs();
+}
+
+
double Slave::_resources_total(const string& name)
{
double total = 0.0;
http://git-wip-us.apache.org/repos/asf/mesos/blob/b415c8ce/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index d049956..77aff1d 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -508,6 +508,18 @@ private:
const FrameworkID& frameworkId,
const ExecutorID& executorId);
+ void sendExecutorTerminatedStatusUpdate(
+ const TaskID& taskId,
+ const process::Future<Option<
+ mesos::slave::ContainerTermination>>& termination,
+ const FrameworkID& frameworkId,
+ const Executor* executor);
+
+ // Forwards the current total of oversubscribed resources.
+ void forwardOversubscribed();
+ void _forwardOversubscribed(
+ const process::Future<Resources>& oversubscribable);
+
// Gauge methods.
double _frameworks_active()
{
@@ -543,18 +555,6 @@ private:
double _resources_revocable_used(const std::string& name);
double _resources_revocable_percent(const std::string& name);
- void sendExecutorTerminatedStatusUpdate(
- const TaskID& taskId,
- const process::Future<Option<
- mesos::slave::ContainerTermination>>& termination,
- const FrameworkID& frameworkId,
- const Executor* executor);
-
- // Forwards the current total of oversubscribed resources.
- void forwardOversubscribed();
- void _forwardOversubscribed(
- const process::Future<Resources>& oversubscribable);
-
const Flags flags;
const Http http;
[07/16] mesos git commit: Fixed some style issues in slave.hpp.
Posted by ji...@apache.org.
Fixed some style issues in slave.hpp.
Review: https://reviews.apache.org/r/59661
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/96ec255e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/96ec255e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/96ec255e
Branch: refs/heads/master
Commit: 96ec255e1160b7abc7a4c0222d43af5d87007ae4
Parents: 7ba736a
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:36:54 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/96ec255e/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 4e7c6be..769bb7e 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -96,7 +96,6 @@ namespace mesos {
class Authorizer;
namespace internal {
-
namespace slave {
// Some forward declarations.
@@ -105,6 +104,7 @@ struct Executor;
struct Framework;
struct HttpConnection;
+
class Slave : public ProtobufProcess<Slave>
{
public:
@@ -195,10 +195,10 @@ public:
void checkpointResources(const std::vector<Resource>& checkpointedResources);
void subscribe(
- HttpConnection http,
- const executor::Call::Subscribe& subscribe,
- Framework* framework,
- Executor* executor);
+ HttpConnection http,
+ const executor::Call::Subscribe& subscribe,
+ Framework* framework,
+ Executor* executor);
void registerExecutor(
const process::UPID& from,
[05/16] mesos git commit: Reordered some method definitions in
`Slave` class.
Posted by ji...@apache.org.
Reordered some method definitions in `Slave` class.
Moved all the metrics related continuation methods close to each other
so it's more consistent.
Review: https://reviews.apache.org/r/59660
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7ba736ae
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7ba736ae
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7ba736ae
Branch: refs/heads/master
Commit: 7ba736ae7c08cfe293bcb2298645b3c1248f3cc2
Parents: b90ba2b
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 14:30:23 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7ba736ae/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 2a62eff..4e7c6be 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -534,6 +534,14 @@ private:
double _executor_directory_max_allowed_age_secs();
+ double _resources_total(const std::string& name);
+ double _resources_used(const std::string& name);
+ double _resources_percent(const std::string& name);
+
+ double _resources_revocable_total(const std::string& name);
+ double _resources_revocable_used(const std::string& name);
+ double _resources_revocable_percent(const std::string& name);
+
void sendExecutorTerminatedStatusUpdate(
const TaskID& taskId,
const process::Future<Option<
@@ -573,14 +581,6 @@ private:
Metrics metrics;
- double _resources_total(const std::string& name);
- double _resources_used(const std::string& name);
- double _resources_percent(const std::string& name);
-
- double _resources_revocable_total(const std::string& name);
- double _resources_revocable_used(const std::string& name);
- double _resources_revocable_percent(const std::string& name);
-
process::Time startTime;
GarbageCollector* gc;
[16/16] mesos git commit: Removed an unnecessary declaration in
slave.hpp.
Posted by ji...@apache.org.
Removed an unnecessary declaration in slave.hpp.
Review: https://reviews.apache.org/r/59670
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e6a865b5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e6a865b5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e6a865b5
Branch: refs/heads/master
Commit: e6a865b519601fd9fbd3b44f5bc3d3a97c6a5bb8
Parents: 97272c8
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 16:32:07 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 64 ++++++++++++++++++++++++++----------------------
src/slave/slave.hpp | 6 -----
2 files changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e6a865b5/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index c3df7d9..247c7eb 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -171,6 +171,12 @@ static string taskOrTaskGroup(
const Option<TaskGroupInfo>& taskGroup);
+// Returns the command info for default executor.
+static CommandInfo defaultExecutorCommandInfo(
+ const std::string& launcherDir,
+ const Option<std::string>& user);
+
+
Slave::Slave(const string& id,
const slave::Flags& _flags,
MasterDetector* _detector,
@@ -7791,35 +7797,6 @@ map<string, string> executorEnvironment(
}
-CommandInfo defaultExecutorCommandInfo(
- const string& launcherDir,
- const Option<string>& user)
-{
- Result<string> path = os::realpath(
- path::join(launcherDir, MESOS_DEFAULT_EXECUTOR));
-
- CommandInfo commandInfo;
- if (path.isSome()) {
- commandInfo.set_shell(false);
- commandInfo.set_value(path.get());
- commandInfo.add_arguments(MESOS_DEFAULT_EXECUTOR);
- commandInfo.add_arguments("--launcher_dir=" + launcherDir);
- } else {
- commandInfo.set_shell(true);
- commandInfo.set_value(
- "echo '" +
- (path.isError() ? path.error() : "No such file or directory") +
- "'; exit 1");
- }
-
- if (user.isSome()) {
- commandInfo.set_user(user.get());
- }
-
- return commandInfo;
-}
-
-
ostream& operator<<(ostream& stream, const Executor& executor)
{
stream << "'" << executor.id << "' of framework " << executor.frameworkId;
@@ -7891,6 +7868,35 @@ static string taskOrTaskGroup(
return out.str();
}
+
+static CommandInfo defaultExecutorCommandInfo(
+ const string& launcherDir,
+ const Option<string>& user)
+{
+ Result<string> path = os::realpath(
+ path::join(launcherDir, MESOS_DEFAULT_EXECUTOR));
+
+ CommandInfo commandInfo;
+ if (path.isSome()) {
+ commandInfo.set_shell(false);
+ commandInfo.set_value(path.get());
+ commandInfo.add_arguments(MESOS_DEFAULT_EXECUTOR);
+ commandInfo.add_arguments("--launcher_dir=" + launcherDir);
+ } else {
+ commandInfo.set_shell(true);
+ commandInfo.set_value(
+ "echo '" +
+ (path.isError() ? path.error() : "No such file or directory") +
+ "'; exit 1");
+ }
+
+ if (user.isSome()) {
+ commandInfo.set_user(user.get());
+ }
+
+ return commandInfo;
+}
+
} // namespace slave {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/e6a865b5/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 09b7f0a..24b9258 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -941,12 +941,6 @@ std::map<std::string, std::string> executorEnvironment(
bool checkpoint);
-// Returns the command info for default executor.
-CommandInfo defaultExecutorCommandInfo(
- const std::string& launcherDir,
- const Option<std::string>& user);
-
-
std::ostream& operator<<(std::ostream& stream, Executor::State state);
std::ostream& operator<<(std::ostream& stream, Framework::State state);
std::ostream& operator<<(std::ostream& stream, Slave::State state);
[10/16] mesos git commit: Used `delete` for deleting copy constructor
and assignment operator.
Posted by ji...@apache.org.
Used `delete` for deleting copy constructor and assignment operator.
This is for `Executor` and `Framework` class in slave.hpp.
Review: https://reviews.apache.org/r/59664
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ca52dec7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ca52dec7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ca52dec7
Branch: refs/heads/master
Commit: ca52dec7da0d6327661326e90004c6f2e991ed5c
Parents: fc1fd07
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:40:55 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.hpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ca52dec7/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 4d29bef..c223e6a 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -835,8 +835,8 @@ public:
Option<mesos::slave::ContainerTermination> pendingTermination;
private:
- Executor(const Executor&); // No copying.
- Executor& operator=(const Executor&); // No assigning.
+ Executor(const Executor&) = delete;
+ Executor& operator=(const Executor&) = delete;
bool commandExecutor;
};
@@ -929,8 +929,8 @@ public:
}
private:
- Framework(const Framework&); // No copying.
- Framework& operator=(const Framework&); // No assigning.
+ Framework(const Framework&) = delete;
+ Framework& operator=(const Framework&) = delete;
};
[11/16] mesos git commit: Reordered the streaming functions in
slave.hpp|cpp.
Posted by ji...@apache.org.
Reordered the streaming functions in slave.hpp|cpp.
Ensure that the streaming functions are sorted according to alphabet
order.
Review: https://reviews.apache.org/r/59665
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3f5008a4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3f5008a4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3f5008a4
Branch: refs/heads/master
Commit: 3f5008a4226a489660a1be9185299d16825b0250
Parents: ca52dec
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:42:30 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 24 ++++++++++++------------
src/slave/slave.hpp | 4 ++--
2 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3f5008a4/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 4ba0958..014044d 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -7807,14 +7807,14 @@ std::ostream& operator<<(std::ostream& stream, const Executor& executor)
}
-std::ostream& operator<<(std::ostream& stream, Slave::State state)
+std::ostream& operator<<(std::ostream& stream, Executor::State state)
{
switch (state) {
- case Slave::RECOVERING: return stream << "RECOVERING";
- case Slave::DISCONNECTED: return stream << "DISCONNECTED";
- case Slave::RUNNING: return stream << "RUNNING";
- case Slave::TERMINATING: return stream << "TERMINATING";
- default: return stream << "UNKNOWN";
+ case Executor::REGISTERING: return stream << "REGISTERING";
+ case Executor::RUNNING: return stream << "RUNNING";
+ case Executor::TERMINATING: return stream << "TERMINATING";
+ case Executor::TERMINATED: return stream << "TERMINATED";
+ default: return stream << "UNKNOWN";
}
}
@@ -7829,14 +7829,14 @@ std::ostream& operator<<(std::ostream& stream, Framework::State state)
}
-std::ostream& operator<<(std::ostream& stream, Executor::State state)
+std::ostream& operator<<(std::ostream& stream, Slave::State state)
{
switch (state) {
- case Executor::REGISTERING: return stream << "REGISTERING";
- case Executor::RUNNING: return stream << "RUNNING";
- case Executor::TERMINATING: return stream << "TERMINATING";
- case Executor::TERMINATED: return stream << "TERMINATED";
- default: return stream << "UNKNOWN";
+ case Slave::RECOVERING: return stream << "RECOVERING";
+ case Slave::DISCONNECTED: return stream << "DISCONNECTED";
+ case Slave::RUNNING: return stream << "RUNNING";
+ case Slave::TERMINATING: return stream << "TERMINATING";
+ default: return stream << "UNKNOWN";
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/3f5008a4/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index c223e6a..da25c73 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -963,9 +963,9 @@ CommandInfo defaultExecutorCommandInfo(
const Option<std::string>& user);
-std::ostream& operator<<(std::ostream& stream, Slave::State state);
-std::ostream& operator<<(std::ostream& stream, Framework::State state);
std::ostream& operator<<(std::ostream& stream, Executor::State state);
+std::ostream& operator<<(std::ostream& stream, Framework::State state);
+std::ostream& operator<<(std::ostream& stream, Slave::State state);
// Needed for logging task/task group.
[06/16] mesos git commit: Pulled http related declarations in the
agent to a separate class.
Posted by ji...@apache.org.
Pulled http related declarations in the agent to a separate class.
Currently, it's nested in `Slave` class. This hurts readability a bit
and is not consistent with other structs like `Framework` or
`Executor`. This patch pulls the declarations into a separate Http
class and places it in a separate header to reduce the size of `Slave`
class.
Review: https://reviews.apache.org/r/59651
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c5651523
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c5651523
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c5651523
Branch: refs/heads/master
Commit: c5651523f3b08e8b1c0736f76c0f5f3ef868d976
Parents: d5c5561
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 12:18:27 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/Makefile.am | 1 +
src/slave/http.cpp | 99 ++++++++---------
src/slave/http.hpp | 272 +++++++++++++++++++++++++++++++++++++++++++++++
src/slave/slave.hpp | 271 ++--------------------------------------------
4 files changed, 330 insertions(+), 313 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c5651523/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e4ce85..392f492 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1069,6 +1069,7 @@ libmesos_no_3rdparty_la_SOURCES += \
slave/constants.hpp \
slave/flags.hpp \
slave/gc.hpp \
+ slave/http.hpp \
slave/metrics.hpp \
slave/paths.hpp \
slave/posix_signalhandler.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/c5651523/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 3160407..78b3586 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -67,6 +67,7 @@
#include "mesos/mesos.hpp"
#include "mesos/resources.hpp"
+#include "slave/http.hpp"
#include "slave/slave.hpp"
#include "slave/validation.hpp"
@@ -326,7 +327,7 @@ struct FrameworkWriter
};
-string Slave::Http::API_HELP()
+string Http::API_HELP()
{
return HELP(
TLDR(
@@ -337,7 +338,7 @@ string Slave::Http::API_HELP()
}
-Future<Response> Slave::Http::api(
+Future<Response> Http::api(
const Request& request,
const Option<Principal>& principal) const
{
@@ -507,7 +508,7 @@ Future<Response> Slave::Http::api(
}
-Future<Response> Slave::Http::_api(
+Future<Response> Http::_api(
const mesos::agent::Call& call,
Option<Owned<Reader<mesos::agent::Call>>>&& reader,
const RequestMediaTypes& mediaTypes,
@@ -603,7 +604,7 @@ Future<Response> Slave::Http::_api(
}
-string Slave::Http::EXECUTOR_HELP() {
+string Http::EXECUTOR_HELP() {
return HELP(
TLDR(
"Endpoint for the Executor HTTP API."),
@@ -656,12 +657,12 @@ Option<Error> verifyExecutorClaims(
}
-Future<Response> Slave::Http::executor(
+Future<Response> Http::executor(
const Request& request,
const Option<Principal>& principal) const
{
if (!slave->recoveryInfo.reconnect) {
- CHECK(slave->state == RECOVERING);
+ CHECK_EQ(slave->state, Slave::RECOVERING);
return ServiceUnavailable("Agent has not finished recovery");
}
@@ -807,7 +808,7 @@ Future<Response> Slave::Http::executor(
}
-string Slave::Http::FLAGS_HELP()
+string Http::FLAGS_HELP()
{
return HELP(
TLDR("Exposes the agent's flag configuration."),
@@ -819,7 +820,7 @@ string Slave::Http::FLAGS_HELP()
}
-Future<Response> Slave::Http::flags(
+Future<Response> Http::flags(
const Request& request,
const Option<Principal>& principal) const
{
@@ -854,7 +855,7 @@ Future<Response> Slave::Http::flags(
}
-JSON::Object Slave::Http::_flags() const
+JSON::Object Http::_flags() const
{
JSON::Object object;
@@ -873,7 +874,7 @@ JSON::Object Slave::Http::_flags() const
}
-Future<Response> Slave::Http::getFlags(
+Future<Response> Http::getFlags(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -910,7 +911,7 @@ Future<Response> Slave::Http::getFlags(
}
-string Slave::Http::HEALTH_HELP()
+string Http::HEALTH_HELP()
{
return HELP(
TLDR(
@@ -922,13 +923,13 @@ string Slave::Http::HEALTH_HELP()
}
-Future<Response> Slave::Http::health(const Request& request) const
+Future<Response> Http::health(const Request& request) const
{
return OK();
}
-Future<Response> Slave::Http::getHealth(
+Future<Response> Http::getHealth(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -944,7 +945,7 @@ Future<Response> Slave::Http::getHealth(
}
-Future<Response> Slave::Http::getVersion(
+Future<Response> Http::getVersion(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -957,7 +958,7 @@ Future<Response> Slave::Http::getVersion(
}
-Future<Response> Slave::Http::getMetrics(
+Future<Response> Http::getMetrics(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -989,7 +990,7 @@ Future<Response> Slave::Http::getMetrics(
}
-Future<Response> Slave::Http::getLoggingLevel(
+Future<Response> Http::getLoggingLevel(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1005,7 +1006,7 @@ Future<Response> Slave::Http::getLoggingLevel(
}
-Future<Response> Slave::Http::setLoggingLevel(
+Future<Response> Http::setLoggingLevel(
const mesos::agent::Call& call,
ContentType /*contentType*/,
const Option<Principal>& principal) const
@@ -1048,7 +1049,7 @@ Future<Response> Slave::Http::setLoggingLevel(
}
-Future<Response> Slave::Http::listFiles(
+Future<Response> Http::listFiles(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1096,7 +1097,7 @@ Future<Response> Slave::Http::listFiles(
}
-string Slave::Http::STATE_HELP() {
+string Http::STATE_HELP() {
return HELP(
TLDR(
"Information about state of the Agent."),
@@ -1198,7 +1199,7 @@ string Slave::Http::STATE_HELP() {
}
-Future<Response> Slave::Http::state(
+Future<Response> Http::state(
const Request& request,
const Option<Principal>& principal) const
{
@@ -1390,7 +1391,7 @@ Future<Response> Slave::Http::state(
}
-Future<Response> Slave::Http::getFrameworks(
+Future<Response> Http::getFrameworks(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1424,7 +1425,7 @@ Future<Response> Slave::Http::getFrameworks(
}
-mesos::agent::Response::GetFrameworks Slave::Http::_getFrameworks(
+mesos::agent::Response::GetFrameworks Http::_getFrameworks(
const Owned<ObjectApprover>& frameworksApprover) const
{
mesos::agent::Response::GetFrameworks getFrameworks;
@@ -1452,7 +1453,7 @@ mesos::agent::Response::GetFrameworks Slave::Http::_getFrameworks(
}
-Future<Response> Slave::Http::getExecutors(
+Future<Response> Http::getExecutors(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1497,7 +1498,7 @@ Future<Response> Slave::Http::getExecutors(
}
-mesos::agent::Response::GetExecutors Slave::Http::_getExecutors(
+mesos::agent::Response::GetExecutors Http::_getExecutors(
const Owned<ObjectApprover>& frameworksApprover,
const Owned<ObjectApprover>& executorsApprover) const
{
@@ -1553,7 +1554,7 @@ mesos::agent::Response::GetExecutors Slave::Http::_getExecutors(
}
-Future<Response> Slave::Http::getTasks(
+Future<Response> Http::getTasks(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1607,7 +1608,7 @@ Future<Response> Slave::Http::getTasks(
}
-mesos::agent::Response::GetTasks Slave::Http::_getTasks(
+mesos::agent::Response::GetTasks Http::_getTasks(
const Owned<ObjectApprover>& frameworksApprover,
const Owned<ObjectApprover>& tasksApprover,
const Owned<ObjectApprover>& executorsApprover) const
@@ -1731,7 +1732,7 @@ mesos::agent::Response::GetTasks Slave::Http::_getTasks(
}
-Future<Response> Slave::Http::getAgent(
+Future<Response> Http::getAgent(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1748,7 +1749,7 @@ Future<Response> Slave::Http::getAgent(
}
-Future<Response> Slave::Http::getState(
+Future<Response> Http::getState(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -1801,7 +1802,7 @@ Future<Response> Slave::Http::getState(
}
-mesos::agent::Response::GetState Slave::Http::_getState(
+mesos::agent::Response::GetState Http::_getState(
const Owned<ObjectApprover>& frameworksApprover,
const Owned<ObjectApprover>& tasksApprover,
const Owned<ObjectApprover>& executorsApprover) const
@@ -1821,7 +1822,7 @@ mesos::agent::Response::GetState Slave::Http::_getState(
}
-string Slave::Http::STATISTICS_HELP()
+string Http::STATISTICS_HELP()
{
return HELP(
TLDR(
@@ -1862,7 +1863,7 @@ string Slave::Http::STATISTICS_HELP()
}
-Future<Response> Slave::Http::statistics(
+Future<Response> Http::statistics(
const Request& request,
const Option<Principal>& principal) const
{
@@ -1899,7 +1900,7 @@ Future<Response> Slave::Http::statistics(
}
-Response Slave::Http::_statistics(
+Response Http::_statistics(
const ResourceUsage& usage,
const Request& request) const
{
@@ -1924,7 +1925,7 @@ Response Slave::Http::_statistics(
}
-string Slave::Http::CONTAINERS_HELP()
+string Http::CONTAINERS_HELP()
{
return HELP(
TLDR(
@@ -1971,7 +1972,7 @@ string Slave::Http::CONTAINERS_HELP()
}
-Future<Response> Slave::Http::containers(
+Future<Response> Http::containers(
const Request& request,
const Option<Principal>& principal) const
{
@@ -2003,7 +2004,7 @@ Future<Response> Slave::Http::containers(
}
-Future<Response> Slave::Http::getContainers(
+Future<Response> Http::getContainers(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2045,7 +2046,7 @@ Future<Response> Slave::Http::getContainers(
}
-Future<Response> Slave::Http::_containers(
+Future<Response> Http::_containers(
const Request& request,
const Option<Principal>& principal) const
{
@@ -2082,7 +2083,7 @@ Future<Response> Slave::Http::_containers(
}
-Future<JSON::Array> Slave::Http::__containers(
+Future<JSON::Array> Http::__containers(
Option<Owned<ObjectApprover>> approver) const
{
Owned<list<JSON::Object>> metadata(new list<JSON::Object>());
@@ -2188,7 +2189,7 @@ Future<JSON::Array> Slave::Http::__containers(
}
-Try<string> Slave::Http::extractEndpoint(const process::http::URL& url) const
+Try<string> Http::extractEndpoint(const process::http::URL& url) const
{
// Paths are of the form "/slave(n)/endpoint". We're only interested
// in the part after "/slave(n)" and tokenize the path accordingly.
@@ -2206,7 +2207,7 @@ Try<string> Slave::Http::extractEndpoint(const process::http::URL& url) const
}
-Future<Response> Slave::Http::readFile(
+Future<Response> Http::readFile(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2256,7 +2257,7 @@ Future<Response> Slave::Http::readFile(
}
-Future<Response> Slave::Http::launchNestedContainer(
+Future<Response> Http::launchNestedContainer(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2290,7 +2291,7 @@ Future<Response> Slave::Http::launchNestedContainer(
}
-Future<Response> Slave::Http::_launchNestedContainer(
+Future<Response> Http::_launchNestedContainer(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
@@ -2375,7 +2376,7 @@ Future<Response> Slave::Http::_launchNestedContainer(
}
-Future<Response> Slave::Http::waitNestedContainer(
+Future<Response> Http::waitNestedContainer(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2450,7 +2451,7 @@ Future<Response> Slave::Http::waitNestedContainer(
}
-Future<Response> Slave::Http::killNestedContainer(
+Future<Response> Http::killNestedContainer(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2511,7 +2512,7 @@ Future<Response> Slave::Http::killNestedContainer(
}
-Future<Response> Slave::Http::removeNestedContainer(
+Future<Response> Http::removeNestedContainer(
const mesos::agent::Call& call,
ContentType acceptType,
const Option<Principal>& principal) const
@@ -2573,7 +2574,7 @@ Future<Response> Slave::Http::removeNestedContainer(
}
-Future<Response> Slave::Http::_attachContainerInput(
+Future<Response> Http::_attachContainerInput(
const mesos::agent::Call& call,
Owned<Reader<mesos::agent::Call>>&& decoder,
const RequestMediaTypes& mediaTypes) const
@@ -2642,7 +2643,7 @@ Future<Response> Slave::Http::_attachContainerInput(
}
-Future<Response> Slave::Http::attachContainerInput(
+Future<Response> Http::attachContainerInput(
const mesos::agent::Call& call,
Owned<Reader<mesos::agent::Call>>&& decoder,
const RequestMediaTypes& mediaTypes,
@@ -2731,7 +2732,7 @@ Future<Nothing> connect(Pipe::Reader reader, Pipe::Writer writer)
}
-Future<Response> Slave::Http::launchNestedContainerSession(
+Future<Response> Http::launchNestedContainerSession(
const mesos::agent::Call& call,
const RequestMediaTypes& mediaTypes,
const Option<Principal>& principal) const
@@ -2863,7 +2864,7 @@ Future<Response> Slave::Http::launchNestedContainerSession(
}
-Future<Response> Slave::Http::_attachContainerOutput(
+Future<Response> Http::_attachContainerOutput(
const mesos::agent::Call& call,
const RequestMediaTypes& mediaTypes) const
{
@@ -2966,7 +2967,7 @@ Future<Response> Slave::Http::_attachContainerOutput(
}
-Future<Response> Slave::Http::attachContainerOutput(
+Future<Response> Http::attachContainerOutput(
const mesos::agent::Call& call,
const RequestMediaTypes& mediaTypes,
const Option<Principal>& principal) const
http://git-wip-us.apache.org/repos/asf/mesos/blob/c5651523/src/slave/http.hpp
----------------------------------------------------------------------
diff --git a/src/slave/http.hpp b/src/slave/http.hpp
new file mode 100644
index 0000000..b03b728
--- /dev/null
+++ b/src/slave/http.hpp
@@ -0,0 +1,272 @@
+// 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 __SLAVE_HTTP_HPP__
+#define __SLAVE_HTTP_HPP__
+
+#include <process/authenticator.hpp>
+#include <process/http.hpp>
+#include <process/future.hpp>
+#include <process/owned.hpp>
+#include <process/limiter.hpp>
+
+#include <stout/json.hpp>
+#include <stout/option.hpp>
+
+#include <mesos/authorizer/authorizer.hpp>
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+// Forward declarations.
+class Slave;
+
+
+// HTTP route handlers.
+class Http
+{
+public:
+ explicit Http(Slave* _slave)
+ : slave(_slave),
+ statisticsLimiter(new process::RateLimiter(2, Seconds(1))) {}
+
+ // /api/v1
+ process::Future<process::http::Response> api(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // /api/v1/executor
+ process::Future<process::http::Response> executor(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // /slave/flags
+ process::Future<process::http::Response> flags(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // /slave/health
+ process::Future<process::http::Response> health(
+ const process::http::Request& request) const;
+
+ // /slave/state
+ process::Future<process::http::Response> state(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>&) const;
+
+ // /slave/monitor/statistics
+ // /slave/monitor/statistics.json
+ process::Future<process::http::Response> statistics(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // /slave/containers
+ process::Future<process::http::Response> containers(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ static std::string API_HELP();
+ static std::string EXECUTOR_HELP();
+ static std::string FLAGS_HELP();
+ static std::string HEALTH_HELP();
+ static std::string STATE_HELP();
+ static std::string STATISTICS_HELP();
+ static std::string CONTAINERS_HELP();
+
+private:
+ JSON::Object _flags() const;
+
+ // Continuation for `/api` endpoint that handles streaming and non-streaming
+ // requests. In case of a streaming request, `call` would be the first
+ // record and additional records can be read using the `reader`. For
+ // non-streaming requests, `reader` would be set to `None()`.
+ process::Future<process::http::Response> _api(
+ const agent::Call& call,
+ Option<process::Owned<recordio::Reader<agent::Call>>>&& reader,
+ const RequestMediaTypes& mediaTypes,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // Make continuation for `statistics` `static` as it might
+ // execute when the invoking `Http` is already destructed.
+ process::http::Response _statistics(
+ const ResourceUsage& usage,
+ const process::http::Request& request) const;
+
+ // Continuation for `/containers` endpoint
+ process::Future<process::http::Response> _containers(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ // Helper function to collect containers status and resource statistics.
+ process::Future<JSON::Array> __containers(
+ Option<process::Owned<ObjectApprover>> approver) const;
+
+ // Helper routines for endpoint authorization.
+ Try<std::string> extractEndpoint(const process::http::URL& url) const;
+
+ // Agent API handlers.
+ process::Future<process::http::Response> getFlags(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getHealth(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getVersion(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getMetrics(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getLoggingLevel(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> setLoggingLevel(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> listFiles(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getContainers(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> readFile(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getFrameworks(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ mesos::agent::Response::GetFrameworks _getFrameworks(
+ const process::Owned<ObjectApprover>& frameworksApprover) const;
+
+ process::Future<process::http::Response> getExecutors(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ mesos::agent::Response::GetExecutors _getExecutors(
+ const process::Owned<ObjectApprover>& frameworksApprover,
+ const process::Owned<ObjectApprover>& executorsApprover) const;
+
+ process::Future<process::http::Response> getTasks(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ mesos::agent::Response::GetTasks _getTasks(
+ const process::Owned<ObjectApprover>& frameworksApprover,
+ const process::Owned<ObjectApprover>& tasksApprover,
+ const process::Owned<ObjectApprover>& executorsApprover) const;
+
+ process::Future<process::http::Response> getAgent(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> getState(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ mesos::agent::Response::GetState _getState(
+ const process::Owned<ObjectApprover>& frameworksApprover,
+ const process::Owned<ObjectApprover>& taskApprover,
+ const process::Owned<ObjectApprover>& executorsApprover) const;
+
+ process::Future<process::http::Response> launchNestedContainer(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> _launchNestedContainer(
+ const ContainerID& containerId,
+ const CommandInfo& commandInfo,
+ const Option<ContainerInfo>& containerInfo,
+ const Option<mesos::slave::ContainerClass>& containerClass,
+ ContentType acceptType,
+ const process::Owned<ObjectApprover>& approver) const;
+
+ process::Future<process::http::Response> waitNestedContainer(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> killNestedContainer(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> removeNestedContainer(
+ const mesos::agent::Call& call,
+ ContentType acceptType,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> launchNestedContainerSession(
+ const mesos::agent::Call& call,
+ const RequestMediaTypes& mediaTypes,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> attachContainerInput(
+ const mesos::agent::Call& call,
+ process::Owned<recordio::Reader<agent::Call>>&& decoder,
+ const RequestMediaTypes& mediaTypes,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> _attachContainerInput(
+ const mesos::agent::Call& call,
+ process::Owned<recordio::Reader<agent::Call>>&& decoder,
+ const RequestMediaTypes& mediaTypes) const;
+
+ process::Future<process::http::Response> attachContainerOutput(
+ const mesos::agent::Call& call,
+ const RequestMediaTypes& mediaTypes,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> _attachContainerOutput(
+ const mesos::agent::Call& call,
+ const RequestMediaTypes& mediaTypes) const;
+
+ Slave* slave;
+
+ // Used to rate limit the statistics endpoint.
+ process::Shared<process::RateLimiter> statisticsLimiter;
+};
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __SLAVE_HTTP_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/c5651523/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 77fb93a..8e9e36c 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -79,6 +79,7 @@
#include "slave/containerizer/containerizer.hpp"
#include "slave/flags.hpp"
#include "slave/gc.hpp"
+#include "slave/http.hpp"
#include "slave/metrics.hpp"
#include "slave/paths.hpp"
#include "slave/state.hpp"
@@ -468,6 +469,12 @@ public:
const ContainerID& containerId);
private:
+ friend struct Executor;
+ friend struct Framework;
+ friend struct Metrics;
+
+ friend class Http;
+
void _authenticate();
void authenticationTimeout(process::Future<bool> future);
@@ -497,270 +504,6 @@ private:
const FrameworkID& frameworkId,
const ExecutorID& executorId);
- // Inner class used to namespace HTTP route handlers (see
- // slave/http.cpp for implementations).
- class Http
- {
- public:
- explicit Http(Slave* _slave)
- : slave(_slave),
- statisticsLimiter(new process::RateLimiter(2, Seconds(1))) {}
-
- // /api/v1
- process::Future<process::http::Response> api(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // /api/v1/executor
- process::Future<process::http::Response> executor(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // /slave/flags
- process::Future<process::http::Response> flags(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // /slave/health
- process::Future<process::http::Response> health(
- const process::http::Request& request) const;
-
- // /slave/state
- process::Future<process::http::Response> state(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&)
- const;
-
- // /slave/monitor/statistics
- // /slave/monitor/statistics.json
- process::Future<process::http::Response> statistics(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // /slave/containers
- process::Future<process::http::Response> containers(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- static std::string API_HELP();
- static std::string EXECUTOR_HELP();
- static std::string FLAGS_HELP();
- static std::string HEALTH_HELP();
- static std::string STATE_HELP();
- static std::string STATISTICS_HELP();
- static std::string CONTAINERS_HELP();
-
- private:
- JSON::Object _flags() const;
-
- // Continuation for `/api` endpoint that handles streaming and non-streaming
- // requests. In case of a streaming request, `call` would be the first
- // record and additional records can be read using the `reader`. For
- // non-streaming requests, `reader` would be set to `None()`.
- process::Future<process::http::Response> _api(
- const agent::Call& call,
- Option<process::Owned<recordio::Reader<agent::Call>>>&& reader,
- const RequestMediaTypes& mediaTypes,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // Make continuation for `statistics` `static` as it might
- // execute when the invoking `Http` is already destructed.
- process::http::Response _statistics(
- const ResourceUsage& usage,
- const process::http::Request& request) const;
-
- // Continuation for `/containers` endpoint
- process::Future<process::http::Response> _containers(
- const process::http::Request& request,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- // Helper function to collect containers status and resource statistics.
- process::Future<JSON::Array> __containers(
- Option<process::Owned<ObjectApprover>> approver) const;
-
- // Helper routines for endpoint authorization.
- Try<std::string> extractEndpoint(const process::http::URL& url) const;
-
- // Agent API handlers.
-
- process::Future<process::http::Response> getFlags(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getHealth(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getVersion(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getMetrics(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getLoggingLevel(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> setLoggingLevel(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> listFiles(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getContainers(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> readFile(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getFrameworks(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- mesos::agent::Response::GetFrameworks _getFrameworks(
- const process::Owned<ObjectApprover>& frameworksApprover) const;
-
- process::Future<process::http::Response> getExecutors(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- mesos::agent::Response::GetExecutors _getExecutors(
- const process::Owned<ObjectApprover>& frameworksApprover,
- const process::Owned<ObjectApprover>& executorsApprover) const;
-
- process::Future<process::http::Response> getTasks(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- mesos::agent::Response::GetTasks _getTasks(
- const process::Owned<ObjectApprover>& frameworksApprover,
- const process::Owned<ObjectApprover>& tasksApprover,
- const process::Owned<ObjectApprover>& executorsApprover) const;
-
- process::Future<process::http::Response> getAgent(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> getState(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- mesos::agent::Response::GetState _getState(
- const process::Owned<ObjectApprover>& frameworksApprover,
- const process::Owned<ObjectApprover>& taskApprover,
- const process::Owned<ObjectApprover>& executorsApprover) const;
-
- process::Future<process::http::Response> launchNestedContainer(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> _launchNestedContainer(
- const ContainerID& containerId,
- const CommandInfo& commandInfo,
- const Option<ContainerInfo>& containerInfo,
- const Option<mesos::slave::ContainerClass>& containerClass,
- ContentType acceptType,
- const process::Owned<ObjectApprover>& approver) const;
-
- process::Future<process::http::Response> waitNestedContainer(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> killNestedContainer(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> removeNestedContainer(
- const mesos::agent::Call& call,
- ContentType acceptType,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> launchNestedContainerSession(
- const mesos::agent::Call& call,
- const RequestMediaTypes& mediaTypes,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> attachContainerInput(
- const mesos::agent::Call& call,
- process::Owned<recordio::Reader<agent::Call>>&& decoder,
- const RequestMediaTypes& mediaTypes,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> _attachContainerInput(
- const mesos::agent::Call& call,
- process::Owned<recordio::Reader<agent::Call>>&& decoder,
- const RequestMediaTypes& mediaTypes) const;
-
- process::Future<process::http::Response> attachContainerOutput(
- const mesos::agent::Call& call,
- const RequestMediaTypes& mediaTypes,
- const Option<process::http::authentication::Principal>&
- principal) const;
-
- process::Future<process::http::Response> _attachContainerOutput(
- const mesos::agent::Call& call,
- const RequestMediaTypes& mediaTypes) const;
-
- Slave* slave;
-
- // Used to rate limit the statistics endpoint.
- process::Shared<process::RateLimiter> statisticsLimiter;
- };
-
- friend struct Framework;
- friend struct Executor;
- friend struct Metrics;
-
Slave(const Slave&); // No copying.
Slave& operator=(const Slave&); // No assigning.
[03/16] mesos git commit: Reordered some methods in the agent code
into logic units.
Posted by ji...@apache.org.
Reordered some methods in the agent code into logic units.
Also, make sure the order in the header is in sync with that in the
corresponding source file.
Review: https://reviews.apache.org/r/59667
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6254e2df
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6254e2df
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6254e2df
Branch: refs/heads/master
Commit: 6254e2df9a609139cc478b1eea4f7e4925db269d
Parents: fc00c5b
Author: Jie Yu <yu...@gmail.com>
Authored: Tue May 30 15:55:19 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 31 14:51:10 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 112 +++++++++++++++++++++++------------------------
src/slave/slave.hpp | 10 +++--
2 files changed, 62 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6254e2df/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 0c62622..052a7f7 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -4882,6 +4882,26 @@ Executor* Slave::getExecutor(
}
+Executor* Slave::getExecutor(const ContainerID& containerId) const
+{
+ const ContainerID rootContainerId = protobuf::getRootContainerId(containerId);
+
+ // Locate the executor (for now we just loop since we don't
+ // index based on container id and this likely won't have a
+ // significant performance impact due to the low number of
+ // executors per-agent).
+ foreachvalue (Framework* framework, frameworks) {
+ foreachvalue (Executor* executor, framework->executors) {
+ if (rootContainerId == executor->containerId) {
+ return executor;
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+
ExecutorInfo Slave::getExecutorInfo(
const FrameworkInfo& frameworkInfo,
const TaskInfo& task) const
@@ -6943,6 +6963,15 @@ Framework::Framework(
completedExecutors(slaveFlags.max_completed_executors_per_framework) {}
+Framework::~Framework()
+{
+ // We own the non-completed executor pointers, so they need to be deleted.
+ foreachvalue (Executor* executor, executors) {
+ delete executor;
+ }
+}
+
+
void Framework::checkpointFramework() const
{
// Checkpoint the framework info.
@@ -6968,15 +6997,6 @@ void Framework::checkpointFramework() const
}
-Framework::~Framework()
-{
- // We own the non-completed executor pointers, so they need to be deleted.
- foreachvalue (Executor* executor, executors) {
- delete executor;
- }
-}
-
-
Executor* Framework::addExecutor(const ExecutorInfo& executorInfo)
{
// Verify that Resource.AllocationInfo is set, if coming
@@ -7066,18 +7086,6 @@ Executor* Framework::addExecutor(const ExecutorInfo& executorInfo)
}
-void Framework::destroyExecutor(const ExecutorID& executorId)
-{
- if (executors.contains(executorId)) {
- Executor* executor = executors[executorId];
- executors.erase(executorId);
-
- // Pass ownership of the executor pointer.
- completedExecutors.push_back(Owned<Executor>(executor));
- }
-}
-
-
Executor* Framework::getExecutor(const ExecutorID& executorId) const
{
if (executors.contains(executorId)) {
@@ -7101,44 +7109,15 @@ Executor* Framework::getExecutor(const TaskID& taskId) const
}
-// Return `true` if `task` was a pending task of this framework
-// before the removal; `false` otherwise.
-bool Framework::removePendingTask(
- const TaskInfo& task,
- const ExecutorInfo& executorInfo)
-{
- const ExecutorID executorId = executorInfo.executor_id();
-
- if (pending.contains(executorId) &&
- pending.at(executorId).contains(task.task_id())) {
- pending.at(executorId).erase(task.task_id());
- if (pending.at(executorId).empty()) {
- pending.erase(executorId);
- }
- return true;
- }
-
- return false;
-}
-
-
-Executor* Slave::getExecutor(const ContainerID& containerId) const
+void Framework::destroyExecutor(const ExecutorID& executorId)
{
- const ContainerID rootContainerId = protobuf::getRootContainerId(containerId);
+ if (executors.contains(executorId)) {
+ Executor* executor = executors[executorId];
+ executors.erase(executorId);
- // Locate the executor (for now we just loop since we don't
- // index based on container id and this likely won't have a
- // significant performance impact due to the low number of
- // executors per-agent).
- foreachvalue (Framework* framework, frameworks) {
- foreachvalue (Executor* executor, framework->executors) {
- if (rootContainerId == executor->containerId) {
- return executor;
- }
- }
+ // Pass ownership of the executor pointer.
+ completedExecutors.push_back(Owned<Executor>(executor));
}
-
- return nullptr;
}
@@ -7327,6 +7306,27 @@ bool Framework::hasTask(const TaskID& taskId)
}
+// Return `true` if `task` was a pending task of this framework
+// before the removal; `false` otherwise.
+bool Framework::removePendingTask(
+ const TaskInfo& task,
+ const ExecutorInfo& executorInfo)
+{
+ const ExecutorID executorId = executorInfo.executor_id();
+
+ if (pending.contains(executorId) &&
+ pending.at(executorId).contains(task.task_id())) {
+ pending.at(executorId).erase(task.task_id());
+ if (pending.at(executorId).empty()) {
+ pending.erase(executorId);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+
Executor::Executor(
Slave* _slave,
const FrameworkID& _frameworkId,
http://git-wip-us.apache.org/repos/asf/mesos/blob/6254e2df/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 4054ab3..afa3a12 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -854,25 +854,27 @@ public:
~Framework();
+ void checkpointFramework() const;
+
+ const FrameworkID id() const { return info.id(); }
+
Executor* addExecutor(const ExecutorInfo& executorInfo);
- void destroyExecutor(const ExecutorID& executorId);
Executor* getExecutor(const ExecutorID& executorId) const;
Executor* getExecutor(const TaskID& taskId) const;
+ void destroyExecutor(const ExecutorID& executorId);
+
void recoverExecutor(
const state::ExecutorState& state,
bool recheckpointExecutor,
const hashset<TaskID>& tasksToRecheckpoint);
- void checkpointFramework() const;
bool hasTask(const TaskID& taskId);
bool removePendingTask(
const TaskInfo& task,
const ExecutorInfo& executorInfo);
- const FrameworkID id() const { return info.id(); }
-
enum State
{
RUNNING, // First state of a newly created framework.