Register the handler of gossip verbs using ms::register_handler.
Implement send_gossip using ms::send_message. The handlers are only
placeholders for now. Will implement them later.
A periodic timer (1 seconds) is added to send gossip message
periodically.
This makes it possible to call get_local_failure_detector() in gossiper.
Otherwise there is a cyclic dependency between gms/gossiper.hh and
gms/failure_detector.hh
The on-disk format is about name of the components, where each is
followed by a new line character. The text is encoded using ASCII
code.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
The definition of summary_la at types.hh provides a good explanation
on the on-disk format of the Summary file.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
The current code assumes that the sstring will have the same char_type as the
output_stream. That was working well, until I was forced to change the type of
my basic_sstring to another one that is backed by signed chars.
Of course, the best solution for this would be to change the output_stream (as
well as the input_stream), to take a signed char as well.
And oh boy, have I tried. The data_sink assumes a char type, and when it tries
to allocate a new buffer from it, the buffer will have no other choice than to
be of a char type. Fix that one, and another one appears.
I eventually gave up when the code wouldn't compile because struct fragment has
a char type - and both using a template for such a simple struct, as well as
sprinkling casts all over the place where it is used, sounded like horrible
ideas to me.
It's true that quitters never win, and winners never quit. But for now, my
proposal would be to generalize the write code to accept basic_sstrings of
general types. At least the cast lives in a single place.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
query_options is needlessy organized as a class hierarchy, even though it's
really a simple value type.
Fix by folding all the derived classes into it.
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
All basic_sstring writes the same way. Using sstring as the signature would
require other users that are using other variants of basic_sstring to add their
own signatures.
This general version will cover those use cases as well.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
byteorder.hh's "net::packed<T>" subclassed the basic unaligned<T> and
added a "adjust_endianess" method. This was completely unnecessary:
While ntoh's generic implementation indeed uses that method, we also
have a specialized overload for ntoh(packed<T>), so the generic
implementation would never be used for packed<T> anyway!
So for net::packed<T> we don't need anything more than unaligned<T>,
and can just make it an alias.
As a bonus, the "hton" function will now work also on unaligned<T>
(such as the result of the convenient unaligned_cast<>), not just on
net::packed<T>.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
To support HEAD version of DPDK, we need -mavx/-mavx2 on Seastar CFLAGS.
But we cannot enable it until Host CPU has the feature, so we need to check it.
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
To be more precise, do not take schema_ptr by value.
Fixes crashes in running smp > 1 where mutations applied across shards
(i.e. foreign memory) would cause schema_ptr:s to get out of sync (using
other shards ptr)