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 2014/08/13 20:43:26 UTC
[1/2] git commit: Revert "Refactored the protobuf message comparison
logic." This reverts commit 2d4eb0ef3c162502595f135408b0fe42cf29ebfa.
Repository: mesos
Updated Branches:
refs/heads/master 849fc4d36 -> 30fdabe1a
Revert "Refactored the protobuf message comparison logic."
This reverts commit 2d4eb0ef3c162502595f135408b0fe42cf29ebfa.
The original equality check does not care about the order of repeated
fields (e.g., environments).
Review: https://reviews.apache.org/r/24657
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/31a744e6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/31a744e6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/31a744e6
Branch: refs/heads/master
Commit: 31a744e644b2871d3e1651936ef8a41a782edab6
Parents: 849fc4d
Author: Jie Yu <yu...@gmail.com>
Authored: Wed Aug 13 10:23:34 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Aug 13 10:47:45 2014 -0700
----------------------------------------------------------------------
src/common/type_utils.cpp | 88 ++++++++++++++++++++++++++++++------------
1 file changed, 63 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/31a744e6/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index af0e3a6..c8fc7b3 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -16,54 +16,79 @@
* limitations under the License.
*/
-#include <string>
-
#include <mesos/mesos.hpp>
#include <mesos/resources.hpp>
#include "common/attributes.hpp"
#include "common/type_utils.hpp"
-using std::string;
-
namespace mesos {
-static bool equals(
- const google::protobuf::Message& left,
- const google::protobuf::Message& right)
+bool operator == (const Environment& left, const Environment& right)
{
- string _left;
- string _right;
-
- // NOTE: If either of the two messages is not initialized, we will
- // treat them as not equal.
- if (!left.SerializeToString(&_left)) {
+ if (left.variables().size() != right.variables().size()) {
return false;
}
- if (!right.SerializeToString(&_right)) {
- return false;
+ for (int i = 0; i < left.variables().size(); i++) {
+ const std::string& name = left.variables().Get(i).name();
+ const std::string& value = left.variables().Get(i).value();
+ bool found = false;
+ for (int j = 0; j < right.variables().size(); j++) {
+ if (name == right.variables().Get(j).name() &&
+ value == right.variables().Get(j).value()) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
}
- return _left == _right;
+ return true;
}
-bool operator == (const Environment& left, const Environment& right)
+bool operator == (const CommandInfo& left, const CommandInfo& right)
{
- return equals(left, right);
-}
+ if (left.uris().size() != right.uris().size()) {
+ return false;
+ }
+ for (int i=0; i<left.uris().size(); i++) {
+ bool found = false;
+ for (int j=0; j<right.uris().size(); j++) {
+ if (left.uris().Get(i) == right.uris().Get(j)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
-bool operator == (const CommandInfo& left, const CommandInfo& right)
-{
- return equals(left, right);
+ return left.has_environment() == right.has_environment() &&
+ (!left.has_environment() || (left.environment() == right.environment())) &&
+ left.value() == right.value();
}
bool operator == (const ExecutorInfo& left, const ExecutorInfo& right)
{
- return equals(left, right);
+ return left.executor_id() == right.executor_id() &&
+ left.has_framework_id() == right.has_framework_id() &&
+ (!left.has_framework_id() ||
+ (left.framework_id() == right.framework_id())) &&
+ left.command() == right.command() &&
+ Resources(left.resources()) == Resources(right.resources()) &&
+ left.has_name() == right.has_name() &&
+ (!left.has_name() || (left.name() == right.name())) &&
+ left.has_source() == right.has_source() &&
+ (!left.has_source() || (left.source() == right.source())) &&
+ left.has_data() == right.has_data() &&
+ (!left.has_data() || (left.data() == right.data()));
}
@@ -84,7 +109,13 @@ bool operator == (const SlaveInfo& left, const SlaveInfo& right)
bool operator == (const MasterInfo& left, const MasterInfo& right)
{
- return equals(left, right);
+ return left.id() == right.id() &&
+ left.ip() == right.ip() &&
+ left.port() == right.port() &&
+ left.has_pid() == right.has_pid() &&
+ (!left.has_pid() || (left.pid() == right.pid())) &&
+ left.has_hostname() == right.has_hostname() &&
+ (!left.has_hostname() || (left.hostname() == right.hostname()));
}
@@ -92,7 +123,14 @@ namespace internal {
bool operator == (const Task& left, const Task& right)
{
- return equals(left, right);
+ return left.name() == right.name() &&
+ left.task_id() == right.task_id() &&
+ left.framework_id() == right.framework_id() &&
+ left.slave_id() == right.slave_id() &&
+ left.state() == right.state() &&
+ Resources(left.resources()) == Resources(right.resources()) &&
+ left.has_executor_id() == right.has_executor_id() &&
+ (!left.has_executor_id() || (left.executor_id() == right.executor_id()));
}
[2/2] git commit: Updated equality check for CommandInfo.
Posted by ji...@apache.org.
Updated equality check for CommandInfo.
Review: https://reviews.apache.org/r/24658
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/30fdabe1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/30fdabe1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/30fdabe1
Branch: refs/heads/master
Commit: 30fdabe1a22dc1cf3f6d11a8161b4add47df02cf
Parents: 31a744e
Author: Jie Yu <yu...@gmail.com>
Authored: Wed Aug 13 10:47:29 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Aug 13 11:33:36 2014 -0700
----------------------------------------------------------------------
src/common/type_utils.cpp | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/30fdabe1/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index c8fc7b3..78bfa94 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -56,9 +56,9 @@ bool operator == (const CommandInfo& left, const CommandInfo& right)
return false;
}
- for (int i=0; i<left.uris().size(); i++) {
+ for (int i = 0; i < left.uris().size(); i++) {
bool found = false;
- for (int j=0; j<right.uris().size(); j++) {
+ for (int j = 0; j < right.uris().size(); j++) {
if (left.uris().Get(i) == right.uris().Get(j)) {
found = true;
break;
@@ -69,9 +69,23 @@ bool operator == (const CommandInfo& left, const CommandInfo& right)
}
}
+ if (left.argv().size() != right.argv().size()) {
+ return false;
+ }
+
+ // The order of argv is important.
+ for (int i = 0; i < left.argv().size(); i++) {
+ if (left.argv().Get(i) != right.argv().Get(i)) {
+ return false;
+ }
+ }
+
return left.has_environment() == right.has_environment() &&
(!left.has_environment() || (left.environment() == right.environment())) &&
- left.value() == right.value();
+ left.has_value() == right.has_value() &&
+ (!left.has_value() || (left.value() == right.value())) &&
+ left.has_shell() == right.has_shell() &&
+ (!left.has_shell() || (left.shell() == right.shell()));
}