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
bytes and sstring are distinct types, since their internal buffers are of
different length, but bytes_view is an alias of sstring_view, which makes
it possible of objects of different types to leak across the abstraction
boundary.
Fix this by making bytes a basic_sstring<int8_t, ...> instead of using char.
int8_t is a 'signed char', which is a distinct type from char, so now
bytes_view is a distinct type from sstring_view.
uint8_t would have been an even better choice, but that diverges from Origin
and would have required an audit.
Test the sstables::data_consume_row() function by consuming a row from
an sstable with known contents, and comparing the expected row key,
deletion time, and for each cell - its name, value and timestamp.
The test tests this on both a compressed and non-compressed sstable
(the contents of the two sstables is the same, except the timestamp
which is different).
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Files transformers are used to replace file content before retrieving
it. Specifically, it is used to return swagger definition files with the
host and protocol replaced.
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
The boost::replace_all uses insert and erase to perform a change, those
method are missing from sstring.
Following the std:string implemntation the implementation of both
functionalities is based on the replace method, either as c string
replace or with templated iterators.
Not all the variation of insert, replace and erase where added, but it
will be possible to add them in the future if needed by calling the
existing functionality.
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This code adds the ability to write statistics to disk.
On-disk format:
uint32_t Size;
struct {
uint32_t metadata_type;
uint32_t offset; /* offset into this file */
} metadata_metadata[Size];
* each metadata_metadata entry corresponds to a metadata
stored in the file.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
The solution we have in tree now in for testing is obviously superior than this.
Let's switch to that.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
We are currently testing internal members of the sstable by specifying a bunch of
friend classes in the sstable structure. We have established that this is not the
ideal solution, but it is working.
My proposal here is to change that slightly: have a placeholder class defined in
sstables.hh, that will then re-export publicly every method it wants to use. (Thanks
Avi for suggesting that)
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This patch converts (for very small value of 'converts') some
replication related classes. Only static topology is supported (it is
created in keyspace::create_replication_strategy()). During mutation
no replication is done, since messaging service is not ready yet,
only endpoints are calculated.
From Avi:
This patchsets completes the conversion of scalar functions (TOKEN is still
missing, and maybe others, but the infrastructure is there).
Conflicts:
database.cc
* database now holds all keyspace + column family object
* column families are mapped by uuid, either generated or explicit
* lookup by name tuples or uuid
* finder functions now return refs + throws on missing obj
This reverts commit e605a0368a.
lowres_clock is not updated when reactor is not running and this
variant of time_it() is not meant to be run in a rector.
Http url encode query parameters by adding a question mark after the uri
with pairs of key=value items.
All values in the url are url decoded.
This add the url encoding and query parameters support
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
The http server handlers can sometimes need to perform async operation,
specifically, when reading files from the disk. To support async
behavior the handlers handle function will return a future, that will be
propagate back, when the future will be ready it will return the reply
to be sent.
When switching from direct function call to future, there is also a need
to switch from references to pointers.
Note that while the request will be discarded, the reply will be
propagate back via the future to the caller.
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This adds the back method that return a reference or const reference to
the last char in an sstring.
find_last_of, which return the index of the last occurance of a char in
the string.
And append with append C string to a string.
The logic and definition are similiar to the std::string.
Note that following the std::string definition, calling back on an empty
string is forbiden and the results are undefined.
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>