Repository: mesos Updated Branches: refs/heads/master cdbacc092 -> 5ad643fd7
Added a constant to store agent capabilities. Instead of hardcoding in code, agent capabilities are stored in a constant and could be used by both agent initialization and http response generation. Review: https://reviews.apache.org/r/56644/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/16c59fce Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/16c59fce Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/16c59fce Branch: refs/heads/master Commit: 16c59fcefd75f00a2873e04b4943e51fd54b5046 Parents: cdbacc0 Author: Jay Guo <[email protected]> Authored: Tue Feb 21 13:00:49 2017 -0800 Committer: Benjamin Mahler <[email protected]> Committed: Tue Feb 21 13:01:45 2017 -0800 ---------------------------------------------------------------------- src/slave/constants.hpp | 5 +++++ src/slave/slave.cpp | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/16c59fce/src/slave/constants.hpp ---------------------------------------------------------------------- diff --git a/src/slave/constants.hpp b/src/slave/constants.hpp index 725689a..753756d 100644 --- a/src/slave/constants.hpp +++ b/src/slave/constants.hpp @@ -19,6 +19,8 @@ #include <stdint.h> +#include <mesos/mesos.hpp> + #include <stout/bytes.hpp> #include <stout/duration.hpp> @@ -149,6 +151,9 @@ Duration DEFAULT_MASTER_PING_TIMEOUT(); // Name of the executable for default executor. constexpr char MESOS_DEFAULT_EXECUTOR[] = "mesos-default-executor"; +constexpr SlaveInfo::Capability::Type MESOS_AGENT_CAPABILITIES[] = + {SlaveInfo::Capability::MULTI_ROLE}; + } // namespace slave { } // namespace internal { } // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/16c59fce/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 7564e8d..4590529 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -1388,8 +1388,11 @@ void Slave::doReliableRegistration(Duration maxBackoff) // Registering for the first time. RegisterSlaveMessage message; message.set_version(MESOS_VERSION); - message.add_agent_capabilities()->set_type( - SlaveInfo::Capability::MULTI_ROLE); + + foreach (const SlaveInfo::Capability::Type& capability, + MESOS_AGENT_CAPABILITIES) { + message.add_agent_capabilities()->set_type(capability); + } message.mutable_slave()->CopyFrom(info); @@ -1401,8 +1404,11 @@ void Slave::doReliableRegistration(Duration maxBackoff) // Re-registering, so send tasks running. ReregisterSlaveMessage message; message.set_version(MESOS_VERSION); - message.add_agent_capabilities()->set_type( - SlaveInfo::Capability::MULTI_ROLE); + + foreach (const SlaveInfo::Capability::Type& capability, + MESOS_AGENT_CAPABILITIES) { + message.add_agent_capabilities()->set_type(capability); + } // Include checkpointed resources. message.mutable_checkpointed_resources()->CopyFrom(checkpointedResources);
