You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/01/27 02:21:52 UTC
[2/2] mesos git commit: Introduced `FUTURE_HTTP_*` for filtering HTTP
based events.
Introduced `FUTURE_HTTP_*` for filtering HTTP based events.
This change introduces `FUTURE_HTTP_*` for filtering HTTP based events
similar to the already existing filters for Messages/Dispatch events.
Also, added `FUTURE_HTTP_CALL_*` for union based protobufs.
Review: https://reviews.apache.org/r/42184/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/85d4baa0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/85d4baa0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/85d4baa0
Branch: refs/heads/master
Commit: 85d4baa00c29d8064e0c5ff9fef0f24df1e5e769
Parents: a95829b
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Tue Jan 26 17:21:28 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Tue Jan 26 17:21:28 2016 -0800
----------------------------------------------------------------------
src/tests/mesos.hpp | 147 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/85d4baa0/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index bdecd68..845b637 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -58,6 +58,8 @@
#include <stout/try.hpp>
#include <stout/uuid.hpp>
+#include "common/http.hpp"
+
#include "messages/messages.hpp" // For google::protobuf::Message.
#include "master/detector.hpp"
@@ -1426,6 +1428,22 @@ ACTION_P(SendFrameworkMessage, data)
ExpectNoFutureProtobufs(message, from, to)
+#define FUTURE_HTTP_PROTOBUF(message, path, contentType) \
+ FutureHttp(message, path, contentType)
+
+
+#define DROP_HTTP_PROTOBUF(message, path, contentType) \
+ FutureHttp(message, path, contentType, true)
+
+
+#define DROP_HTTP_PROTOBUFS(message, path, contentType) \
+ DropHttpProtobufs(message, path, contentType)
+
+
+#define EXPECT_NO_FUTURE_HTTP_PROTOBUFS(message, path, contentType) \
+ ExpectNoFutureHttpProtobufs(message, path, contentType)
+
+
// These are specialized versions of {FUTURE,DROP}_PROTOBUF that
// capture a scheduler/executor Call protobuf of the given 'type'.
// Note that we name methods as '*ProtobufUnion()' because these could
@@ -1458,6 +1476,22 @@ ACTION_P(SendFrameworkMessage, data)
process::FutureUnionMessage(message, unionType, from, to, true)
+#define FUTURE_HTTP_CALL(message, unionType, path, contentType) \
+ FutureUnionHttp(message, unionType, path, contentType)
+
+
+#define DROP_HTTP_CALL(message, unionType, path, contentType) \
+ FutureUnionHttp(message, unionType, path, contentType, true)
+
+
+#define DROP_HTTP_CALLS(message, unionType, path, contentType) \
+ DropUnionHttpProtobufs(message, unionType, path, contentType)
+
+
+#define EXPECT_NO_FUTURE_HTTP_CALLS(message, unionType, path, contentType) \
+ ExpectNoFutureUnionHttpProtobufs(message, unionType, path, contentType)
+
+
// Forward declaration.
template <typename T>
T _FutureProtobuf(const process::Message& message);
@@ -1486,6 +1520,48 @@ process::Future<Message> FutureUnionProtobuf(
}
+template <typename Message, typename Path>
+process::Future<Message> FutureHttp(
+ Message message,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ return process::FutureHttpRequest(message, path, deserializer, drop)
+ .then([deserializer](const process::http::Request& request) {
+ return deserializer(request.body).get();
+ });
+}
+
+
+template <typename Message, typename UnionType, typename Path>
+process::Future<Message> FutureUnionHttp(
+ Message message,
+ UnionType unionType,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ return process::FutureUnionHttpRequest(
+ message, unionType, path, deserializer, drop)
+ .then([deserializer](const process::http::Request& request) {
+ return deserializer(request.body).get();
+ });
+}
+
+
template <typename T>
T _FutureProtobuf(const process::Message& message)
{
@@ -1515,6 +1591,41 @@ void DropUnionProtobufs(Message message, UnionType unionType, From from, To to)
}
+template <typename Message, typename Path>
+void DropHttpProtobufs(
+ Message message,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ process::DropHttpRequests(message, path, deserializer);
+}
+
+
+template <typename Message, typename UnionType, typename Path>
+void DropUnionHttpProtobufs(
+ Message message,
+ UnionType unionType,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ process::DropUnionHttpRequests(message, unionType, path, deserializer);
+}
+
+
template <typename T, typename From, typename To>
void ExpectNoFutureProtobufs(T t, From from, To to)
{
@@ -1536,6 +1647,42 @@ void ExpectNoFutureUnionProtobufs(
}
+template <typename Message, typename Path>
+void ExpectNoFutureHttpProtobufs(
+ Message message,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ process::ExpectNoFutureHttpRequests(message, path, deserializer);
+}
+
+
+template <typename Message, typename UnionType, typename Path>
+void ExpectNoFutureUnionHttpProtobufs(
+ Message message,
+ UnionType unionType,
+ Path path,
+ ContentType contentType,
+ bool drop = false)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &message; (void) m; }
+
+ auto deserializer =
+ lambda::bind(&deserialize<Message>, contentType, lambda::_1);
+
+ process::ExpectNoFutureUnionHttpRequests(
+ message, unionType, path, deserializer);
+}
+
+
// This matcher is used to match the task ids of TaskStatus messages.
// Suppose we set up N futures for LaunchTasks and N futures for StatusUpdates.
// (This is a common pattern). We get into a situation where all StatusUpdates