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/02/23 22:15:50 UTC
mesos git commit: Exposed agent capabilities via
SlaveInfo::Capability directly.
Repository: mesos
Updated Branches:
refs/heads/master 2ee98b040 -> fb99cd00b
Exposed agent capabilities via SlaveInfo::Capability directly.
Instead of storing a vector of `SlaveInfo::Capability::Type` and
converting to `SlaveInfo::Capability` in the code, we now store
a vector of `SlaveInfo::Capabilility` directly for easier use.
Review: https://reviews.apache.org/r/56967/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fb99cd00
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fb99cd00
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fb99cd00
Branch: refs/heads/master
Commit: fb99cd00bd4155fee74a38b36bd9fff8e5f33fba
Parents: 2ee98b0
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Feb 23 14:05:34 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Feb 23 14:07:11 2017 -0800
----------------------------------------------------------------------
src/slave/constants.cpp | 13 +++++++++++++
src/slave/constants.hpp | 4 ++--
src/slave/http.cpp | 6 +++---
src/slave/slave.cpp | 15 +++++----------
4 files changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fb99cd00/src/slave/constants.cpp
----------------------------------------------------------------------
diff --git a/src/slave/constants.cpp b/src/slave/constants.cpp
index dbd2ecb..0fbcab8 100644
--- a/src/slave/constants.cpp
+++ b/src/slave/constants.cpp
@@ -14,10 +14,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <vector>
+
#include "master/constants.hpp"
#include "slave/constants.hpp"
+using std::vector;
+
namespace mesos {
namespace internal {
namespace slave {
@@ -28,6 +32,15 @@ Duration DEFAULT_MASTER_PING_TIMEOUT()
master::DEFAULT_MAX_AGENT_PING_TIMEOUTS;
}
+
+vector<SlaveInfo::Capability> AGENT_CAPABILITIES()
+{
+ SlaveInfo::Capability multiRoleCapability;
+ multiRoleCapability.set_type(SlaveInfo::Capability::MULTI_ROLE);
+
+ return {multiRoleCapability};
+}
+
} // namespace slave {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/fb99cd00/src/slave/constants.hpp
----------------------------------------------------------------------
diff --git a/src/slave/constants.hpp b/src/slave/constants.hpp
index 753756d..1f3c543 100644
--- a/src/slave/constants.hpp
+++ b/src/slave/constants.hpp
@@ -18,6 +18,7 @@
#define __SLAVE_CONSTANTS_HPP__
#include <stdint.h>
+#include <vector>
#include <mesos/mesos.hpp>
@@ -151,8 +152,7 @@ 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};
+std::vector<SlaveInfo::Capability> AGENT_CAPABILITIES();
} // namespace slave {
} // namespace internal {
http://git-wip-us.apache.org/repos/asf/mesos/blob/fb99cd00/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 17b6398..94731ec 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -144,9 +144,9 @@ static void json(JSON::ObjectWriter* writer, const TaskInfo& task)
static void json(
JSON::StringWriter* writer,
- const SlaveInfo::Capability::Type& capability)
+ const SlaveInfo::Capability& capability)
{
- writer->append(SlaveInfo::Capability::Type_Name(capability));
+ writer->append(SlaveInfo::Capability::Type_Name(capability.type()));
}
namespace internal {
@@ -1242,7 +1242,7 @@ Future<Response> Slave::Http::state(
writer->field("id", slave->info.id().value());
writer->field("pid", string(slave->self()));
writer->field("hostname", slave->info.hostname());
- writer->field("capabilities", MESOS_AGENT_CAPABILITIES);
+ writer->field("capabilities", AGENT_CAPABILITIES());
const Resources& totalResources = slave->totalResources;
http://git-wip-us.apache.org/repos/asf/mesos/blob/fb99cd00/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 4590529..fc480ae 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -1388,13 +1388,10 @@ void Slave::doReliableRegistration(Duration maxBackoff)
// Registering for the first time.
RegisterSlaveMessage message;
message.set_version(MESOS_VERSION);
-
- foreach (const SlaveInfo::Capability::Type& capability,
- MESOS_AGENT_CAPABILITIES) {
- message.add_agent_capabilities()->set_type(capability);
- }
-
message.mutable_slave()->CopyFrom(info);
+ foreach (const SlaveInfo::Capability& capability, AGENT_CAPABILITIES()) {
+ message.add_agent_capabilities()->CopyFrom(capability);
+ }
// Include checkpointed resources.
message.mutable_checkpointed_resources()->CopyFrom(checkpointedResources);
@@ -1404,10 +1401,8 @@ void Slave::doReliableRegistration(Duration maxBackoff)
// Re-registering, so send tasks running.
ReregisterSlaveMessage message;
message.set_version(MESOS_VERSION);
-
- foreach (const SlaveInfo::Capability::Type& capability,
- MESOS_AGENT_CAPABILITIES) {
- message.add_agent_capabilities()->set_type(capability);
+ foreach (const SlaveInfo::Capability& capability, AGENT_CAPABILITIES()) {
+ message.add_agent_capabilities()->CopyFrom(capability);
}
// Include checkpointed resources.