Commit Graph

27 Commits

Author SHA1 Message Date
Avi Kivity
c77761a8b1 messaging: improve serialization for vectors
Various enable_if overload take precedence if a non-const frozen_mutation
is provided (instead of matching the const frozen_mutation& signature).

Provide a non-const frozen_mutation& signature to work around the issue.
2015-07-07 16:48:41 +03:00
Avi Kivity
228762421c messaging: support complex types in vector<> serialization
do_with() required a movable type, but the union U is not movable if the
vector element type is not, with out help from us.
2015-07-07 16:48:41 +03:00
Pekka Enberg
8a897f2979 message/messaging_service: Add versioning stubs
We only support one version for now but it's easier to convert callers
if the APIs are there.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-07 16:27:58 +03:00
Gleb Natapov
e5ab062f05 messaging: fix vector serialization
Hold on U with do_with since having it in capture is incorrect in case
lambda is moved.
2015-07-05 11:58:08 +03:00
Gleb Natapov
4b9661c608 initial read clustering code
Works only if all replicas (participating in CL) has the same live
data. Does not detects mismatch in tombstones (no infrastructure yet).
Does not report timeout yet.
2015-07-01 13:36:30 +03:00
Gleb Natapov
730170ff1a serialize data structures needed for read clustering 2015-07-01 13:36:28 +03:00
Gleb Natapov
d8dcceea09 stop storage and messaging services during exit 2015-06-18 15:13:02 +03:00
Gleb Natapov
89c74707d0 message: terminate all connections while stopping 2015-06-18 15:13:02 +03:00
Asias He
2dd2c8551a messaging_service: Add messageing verb used by streaming 2015-06-17 16:08:37 +08:00
Amnon Heiman
896f562de7 Adding dropped messages counter to messaging_service
This adds a drop messages counter per verb type to the messaging
service. It will be used by the API to return the number of dropped
messages.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-16 14:35:21 +03:00
Amnon Heiman
b236e85961 Add a foreach_client method to the messaging service
The messaging service holds a table of clients which the API needs
information from. This adds a foreach_client method that recieve a
functions and itererate over all the clients calling the given function
on each of them.

This implementation support the current table that holds unique ptr.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-16 14:35:21 +03:00
Gleb Natapov
969134280a initial mutation clustering code 2015-06-15 12:53:10 +03:00
Gleb Natapov
0657396fcb message: add generic std::vector serializer 2015-06-15 12:51:09 +03:00
Gleb Natapov
238a9d5d30 move init_messaging_service from main 2015-06-15 12:48:00 +03:00
Gleb Natapov
699a47342d message: drop tuple<int, long> serializer
It is used only in test and even there it is not needed.
2015-05-31 17:53:51 +03:00
Asias He
898233ddcf Remove redundant const in static constexpr const
From http://en.cppreference.com/w/cpp/language/constexpr:

  A constexpr specifier used in an object declaration implies const.
2015-05-25 13:09:23 +03:00
Gleb Natapov
59f4b9af46 messaging: bind rpc client to listen-address 2015-05-21 15:17:42 +03:00
Gleb Natapov
8d9fb8a96c message: consolidate send_message() and send_message_oneway()
send_message() and send_message_oneway() are almost identical, implement
the later in terms of the former. The patch also fixes send_message() to
work properly with MsgIn = void.

Reviewed-by: Asias He <asias@cloudius-systems.com>
2015-05-13 13:41:24 +03:00
Asias He
cce98e19e4 message: Remove more leftover
class handler_base and handler are not used anymore.
2015-05-10 12:03:27 +03:00
Asias He
f12e955b4e message: Drop register_handler_oneway 2015-05-07 13:16:18 +03:00
Gleb Natapov
1a8c4b75f5 message: do not erase client's rpc call type
Currently we cast rpc call lambda to std::function (to put all lambdas
in one container) which removes its template properties and gives it
strictly typed interface. This is inconvenient since interface may either
receive an object by value (which requires copy during invocation),
or by reference (which require lifetime management), but not both. This
patch changes the implementation to no store lambda in one central
place, but create it with rpc::make_client() call when used. This way
template properties are preserved and send_message() arguments are
forwarded to rpc call with original types.

Reviewed-by: Asias He <asias@cloudius-systems.com>
2015-05-07 13:16:16 +03:00
Gleb Natapov
78d36eabc2 Merge remote-tracking branch 'origin/master' into tmpmerge
message_service: create object using placement new()

Object reference may point to a unit member that was not properly
created, so assign will not work on it. Use placement new() instead.
2015-05-05 10:39:51 +03:00
Asias He
3d36debcf8 message: Do not call remove_rpc_client() under exception
We can not remove the rpc client while the client might still "active".
2015-04-23 14:55:26 +08:00
Asias He
5a54ae3214 gossip: Fix string serializer in messaging_service 2015-04-23 14:55:26 +08:00
Asias He
8ea0d94ece message: Listen on single port 2015-04-20 16:11:01 +08:00
Asias He
7fd4c0a402 message: Allow listen on a specific IP address 2015-04-16 14:58:52 +08:00
Asias He
2f56a360e7 message: Introduce messaging_service
It is built on top of seastar rpc infrastructure. I've sorted out all
the message VERBs which Origin use. All of them can be implemented using
this messaging_service.

Each Verb contains a handler. There are two types of handlers, one
will return a message back to sender, the other will not. The former
can be registered using ms.register_handler(), the latter can be
registered using ms.register_handler_oneway().

Usage example:
To use messaging_service to send a message. All you need is:

messaging_service& ms = get_local_messaging_service();

1) To register a message hander:
   ms.register_handler(messaging_verb::ECHO, [] (int x, long y) {
       print("Server got echo msg = (%d, %ld) \n", x, y);
       std::tuple<int, long> ret(x*x, y*y);
       return make_ready_future<decltype(ret)>(std::move(ret));
   });

   ms.register_handler_oneway(messaging_verb::GOSSIP_SHUTDOWN, [] (empty_msg msg) {
       print("Server got shutdown msg = %s\n", msg);
       return messaging_service::no_wait();
   });

2) To send a message:
    using RetMsg = std::tuple<int, long>;
    return ms.send_message<RetMsg>(messaging_verb::ECHO, id, msg1, msg2).then([] (RetMsg msg) {
        print("Client sent echo got reply = (%d , %ld)\n", std::get<0>(msg), std::get<1>(msg));
        return sleep(100ms).then([]{
            return make_ready_future<>();
        });
    });

    return ms.send_message_oneway<void>(messaging_verb::GOSSIP_SHUTDOWN, std::move(id), std::move(msg)).then([] () {
        print("Client sent gossip_shutdown got reply = void\n");
        return make_ready_future<>();
    });

Tests:
   send to cpu 0
   $ ./message --server 127.0.0.1  --cpuid 0  --smp 2
   send to cpu 1
   $ ./message --server 127.0.0.1  --cpuid 1  --smp 2
2015-04-09 10:54:17 +08:00