Make common type_utils symmetrical to v1 mesos. This aids in verifying the files are kept in sync. diff src/common/type_utils.cpp src/v1/mesos.cpp should result in only include and namespace differences.
Moved some things out of type_utils.cpp that are not part of the public API. They were moved into messages.cpp. Review: https://reviews.apache.org/r/38733 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bd791cac Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bd791cac Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bd791cac Branch: refs/heads/master Commit: bd791cacf4efa8ced83ee4c3a7f627d376534937 Parents: b7d48db Author: Joris Van Remoortere <[email protected]> Authored: Thu Sep 24 14:16:32 2015 -0700 Committer: Joris Van Remoortere <[email protected]> Committed: Thu Sep 24 17:47:21 2015 -0700 ---------------------------------------------------------------------- include/mesos/type_utils.hpp | 5 +++ include/mesos/v1/mesos.hpp | 5 +++ src/Makefile.am | 1 + src/common/type_utils.cpp | 49 -------------------------- src/messages/messages.cpp | 73 +++++++++++++++++++++++++++++++++++++++ src/v1/mesos.cpp | 4 ++- 6 files changed, 87 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/include/mesos/type_utils.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp index 6cedf07..06bf55d 100644 --- a/include/mesos/type_utils.hpp +++ b/include/mesos/type_utils.hpp @@ -61,6 +61,11 @@ bool operator==( bool operator==(const SlaveInfo& left, const SlaveInfo& right); bool operator==(const Volume& left, const Volume& right); +bool operator==(const Label& left, const Label& right); +bool operator==(const Labels& left, const Labels& right); + +bool operator==(const DiscoveryInfo& left, const DiscoveryInfo& right); + bool operator==(const URL& left, const URL& right); bool operator==(const TaskStatus& left, const TaskStatus& right); http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/include/mesos/v1/mesos.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/v1/mesos.hpp b/include/mesos/v1/mesos.hpp index 260e112..e5a0e69 100644 --- a/include/mesos/v1/mesos.hpp +++ b/include/mesos/v1/mesos.hpp @@ -42,6 +42,11 @@ bool operator==( bool operator==(const AgentInfo& left, const AgentInfo& right); bool operator==(const Volume& left, const Volume& right); +bool operator==(const Label& left, const Label& right); +bool operator==(const Labels& left, const Labels& right); + +bool operator==(const DiscoveryInfo& left, const DiscoveryInfo& right); + bool operator==(const URL& left, const URL& right); bool operator==(const TaskStatus& left, const TaskStatus& right); http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index 776483b..f082484 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -480,6 +480,7 @@ libmesos_no_3rdparty_la_SOURCES = \ master/allocator/allocator.cpp \ master/allocator/sorter/drf/sorter.cpp \ messages/flags.proto \ + messages/messages.cpp \ messages/messages.proto \ module/manager.cpp \ sched/constants.cpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/src/common/type_utils.cpp ---------------------------------------------------------------------- diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp index 5f74dab..0e11468 100644 --- a/src/common/type_utils.cpp +++ b/src/common/type_utils.cpp @@ -361,53 +361,4 @@ bool operator!=(const TaskStatus& left, const TaskStatus& right) return !(left == right); } - -namespace internal { - -bool operator==(const Task& left, const Task& right) -{ - // Order of task statuses is important. - if (left.statuses().size() != right.statuses().size()) { - return false; - } - - for (int i = 0; i < left.statuses().size(); i++) { - if (left.statuses().Get(i) != right.statuses().Get(i)) { - return false; - } - } - - return left.name() == right.name() && - left.task_id() == right.task_id() && - left.framework_id() == right.framework_id() && - left.executor_id() == right.executor_id() && - left.slave_id() == right.slave_id() && - left.state() == right.state() && - Resources(left.resources()) == Resources(right.resources()) && - left.status_update_state() == right.status_update_state() && - left.status_update_uuid() == right.status_update_uuid() && - left.labels() == right.labels() && - left.discovery() == right.discovery(); -} - - -std::ostream& operator<<( - std::ostream& stream, - const StatusUpdate& update) -{ - stream << update.status().state() - << (update.has_uuid() - ? " (UUID: " + stringify(UUID::fromBytes(update.uuid())) - : "") - << ") for task " << update.status().task_id(); - - if (update.status().has_healthy()) { - stream << " in health state " - << (update.status().healthy() ? "healthy" : "unhealthy"); - } - - return stream << " of framework " << update.framework_id(); -} - -} // namespace internal { } // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/src/messages/messages.cpp ---------------------------------------------------------------------- diff --git a/src/messages/messages.cpp b/src/messages/messages.cpp new file mode 100644 index 0000000..abf3ea3 --- /dev/null +++ b/src/messages/messages.cpp @@ -0,0 +1,73 @@ +/** + * 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. + */ + +#include "messages/messages.hpp" + +#include <mesos/resources.hpp> +#include <mesos/type_utils.hpp> + +namespace mesos { +namespace internal { + +bool operator==(const Task& left, const Task& right) +{ + // Order of task statuses is important. + if (left.statuses().size() != right.statuses().size()) { + return false; + } + + for (int i = 0; i < left.statuses().size(); i++) { + if (left.statuses().Get(i) != right.statuses().Get(i)) { + return false; + } + } + + return left.name() == right.name() && + left.task_id() == right.task_id() && + left.framework_id() == right.framework_id() && + left.executor_id() == right.executor_id() && + left.slave_id() == right.slave_id() && + left.state() == right.state() && + Resources(left.resources()) == Resources(right.resources()) && + left.status_update_state() == right.status_update_state() && + left.status_update_uuid() == right.status_update_uuid() && + left.labels() == right.labels() && + left.discovery() == right.discovery(); +} + + +std::ostream& operator<<( + std::ostream& stream, + const StatusUpdate& update) +{ + stream << update.status().state() + << (update.has_uuid() + ? " (UUID: " + stringify(UUID::fromBytes(update.uuid())) + : "") + << ") for task " << update.status().task_id(); + + if (update.status().has_healthy()) { + stream << " in health state " + << (update.status().healthy() ? "healthy" : "unhealthy"); + } + + return stream << " of framework " << update.framework_id(); +} + +} // namespace internal { +} // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/bd791cac/src/v1/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/v1/mesos.cpp b/src/v1/mesos.cpp index 631d6e5..e1ebb45 100644 --- a/src/v1/mesos.cpp +++ b/src/v1/mesos.cpp @@ -318,7 +318,9 @@ bool operator==(const MasterInfo& left, const MasterInfo& right) } -bool operator==(const ResourceStatistics& left, const ResourceStatistics& right) +bool operator==( + const ResourceStatistics& left, + const ResourceStatistics& right) { return left.SerializeAsString() == right.SerializeAsString(); }
