Commit Graph

304 Commits

Author SHA1 Message Date
Avi Kivity
40a0dd1f6f Merge branch 'master' of github.com:cloudius-systems/urchin into db 2015-04-09 12:40:33 +03:00
Avi Kivity
ff9536fffc cql3: de-virtualize query_options
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.
2015-04-09 09:31:48 +02: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
Avi Kivity
f0e10b34d4 tests: clean up test_writetime_and_ttl
- correct comment
- use with_rows()
- use USING WRITETIME syntax instead of hacking up the query_options
2015-04-08 13:28:44 +02:00
Avi Kivity
dad3a3dd38 tests: test cql3 type cast
(text)'foo' is itself.  Wow!
2015-04-08 09:34:45 +02:00
Avi Kivity
e66fb58423 tests: test cql3 collection type syntax in "create table" 2015-04-07 20:14:37 +03:00
Avi Kivity
14d668c07a tests: add WRITETIME test 2015-04-07 16:17:56 +03:00
Avi Kivity
cdab0a5a10 tests: execute_cql() with non-default query options
Needed to test WRITETIME.
2015-04-07 16:17:56 +03:00
Avi Kivity
23e23c0a67 Merge tag 'avi/count-rows-functions/v1' of github.com:cloudius-systems/seastar-dev into db
cql3 COUNT(*) and COUNT(1) conversion
2015-04-07 10:57:16 +03:00
Avi Kivity
30b40bf7b1 db: make bytes even more distinct from sstring
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.
2015-04-07 10:56:19 +03:00
Avi Kivity
50b8ddd62a tests: add test for COUNT(*) and COUNT(1) 2015-04-06 19:09:35 +03:00
Avi Kivity
1017ebf2aa tests: drop at_exit() destruction of the test environment
We already have a ->stop() call in a finally() clause, so the at_exit()
registrations lead to a use-after-free.
2015-04-06 13:00:59 +03:00
Avi Kivity
0cbe2cc8b6 Merge tag 'avi/select-functions/v1' of github.com:cloudius-systems/seastar-dev into urchin
Functions in select path, and aggregate functions.
2015-04-06 10:24:11 +03:00
Avi Kivity
4fca9734c9 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-04-05 20:03:16 +03:00
Nadav Har'El
41190ef31b sstables: test sstables::data_consume_row
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>
2015-04-05 17:48:11 +03:00
Avi Kivity
9e3c41436b cql3: test aggregate functions in select path 2015-04-05 16:07:31 +03:00
Amnon Heiman
53604f1fae Adding file transformers to http
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>
2015-04-05 09:53:33 +03:00
Amnon Heiman
04b5bad2b7 Adding insert replace and erase to sstring
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>
2015-04-05 09:51:28 +03:00
Raphael S. Carvalho
08e5d3ca8b sstables: add support to write the component statistics
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>
2015-04-04 12:51:50 +03:00
Raphael S. Carvalho
6636a751e2 tests: sstables: rename epoch to generation
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-04-04 12:50:45 +03:00
Glauber Costa
939f8c4290 tests: remove "for_testing" suffix
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>
2015-04-03 00:39:15 +03:00
Avi Kivity
1ca426e49b Merge branch 'master' of github.com:cloudius-systems/seastar into urchin
Conflicts:
	configure.py
2015-04-03 00:03:15 +03:00
Glauber Costa
8cbd4e8358 sstable: test internal members
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>
2015-04-02 23:48:35 +03:00
Gleb Natapov
47ac784425 replication strategy
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.
2015-04-02 16:16:39 +02:00
Tomasz Grabiec
66924090c6 Merge tag 'avi/functions/v1'
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
2015-04-02 12:48:21 +02:00
Avi Kivity
5198292165 tests: add function call test
Test now() function.
2015-04-01 21:06:37 +03:00
Calle Wilund
358c370758 Add serializer test 2015-04-01 10:08:00 +02:00
Calle Wilund
9979ee8d45 Modify commit log to use dataoutput
Both internal usage and external interface.
2015-04-01 10:08:00 +02:00
Calle Wilund
d3fe0c5182 Refactor db/keyspace/column_family toplogy
* 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
2015-04-01 10:08:00 +02:00
Calle Wilund
70936e5391 Hash helper test 2015-04-01 09:43:48 +02:00
Avi Kivity
2642f82d89 Merge branch 'tgrabiec/tests' of github.com:cloudius-systems/seastar-dev into db
Use cql_test_env in tests, from Tomasz.
2015-03-31 18:14:24 +03:00
Avi Kivity
62da83f416 Merge branch 'tgrabiec/fixes' of github.com:cloudius-systems/seastar-dev into db
Use cql_test_env in tests, query limit bug fix, IN restriction, from Tomasz.
2015-03-31 17:18:29 +03:00
Raphael S. Carvalho
44735a3c88 sstables: add support to write the component filter
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-31 17:11:00 +03:00
Raphael S. Carvalho
b3175f115d tests: sstables: move code to be reused for other components
Also, semaphore was removed because it's useless there.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-31 17:11:00 +03:00
Tomasz Grabiec
7b6d340d8a tests: Convert all test cases in cql_query_test.cc to use cql_test_env
Reduces duplication.
2015-03-31 15:58:44 +02:00
Tomasz Grabiec
f73524ddaa tests: Add cql_test_env::require_column_has_value()
Copied from cql_query_test.cc.
2015-03-31 15:57:40 +02:00
Tomasz Grabiec
eddb479ec4 tests: Move CQL response assertions to cql_assertions.hh 2015-03-31 15:56:59 +02:00
Tomasz Grabiec
3da0c3035f tests: Add test for querying static row with limit and many ranges 2015-03-30 18:38:26 +02:00
Tomasz Grabiec
d21966ecbc Revert "tests: Use lowres_clock in time_it()"
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.
2015-03-30 18:38:26 +02:00
Amnon Heiman
6512d7f7fb http support query parameter and url encoding
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>
2015-03-30 15:38:41 +03:00
Amnon Heiman
950d921df3 Http server handlers to use future
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>
2015-03-30 15:38:41 +03:00
Amnon Heiman
0faf9cbb56 Adding back, find_last_of and append to sstring
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>
2015-03-30 15:38:41 +03:00
Avi Kivity
f32a9ec123 tests: add collection query path tests 2015-03-30 14:28:16 +03:00
Avi Kivity
aab6d7a173 cql3: convert lists::discarder to C++
And wire it up.
2015-03-30 14:28:16 +03:00
Avi Kivity
a1dab20422 Merge branch 'tgrabiec/deletes' of github.com:cloudius-systems/seastar-dev into db
Delete support, from Tomasz.
2015-03-30 11:24:22 +03:00
Avi Kivity
4d65825f91 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-03-30 11:23:02 +03:00
Tomasz Grabiec
dc019c6da2 tests: Add tests for deletion scenarios 2015-03-30 09:08:26 +02:00
Tomasz Grabiec
ff35be339c tests: cql: Improve error reporting in with_rows() 2015-03-30 09:07:01 +02:00
Shlomi Livne
cbf972c135 tests: set BOOST_TEST_SUITE to the test file name instead of the generic "seastar-tests"
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-03-29 11:54:01 +03:00
Avi Kivity
abcd745539 tests: add discarder test
UPDATE tab SET my_set_or_map = my_set_or_map - { key1, key2 }
2015-03-27 16:10:35 +01:00