Commit Graph

520 Commits

Author SHA1 Message Date
Avi Kivity
5be417175e Merge "snitch creation"
From Vlad:

"Currently database always created a SimpleSnitch and ignores the corresponding parameter
provided by the user. This series fixes this situation:
   - Changes the snitch creation interface to comply the Java-like interface that
     has already been used in a topology_strategy classes family.
   - Fix all the places where a SimpleSnitch has been created ignoring the user configuration."
2015-06-14 17:59:15 +03:00
Avi Kivity
06031ea273 Merge seastar upstream 2015-06-14 17:47:32 +03:00
Gleb Natapov
50b18a56cd test: add semaphore test 2015-06-14 16:03:46 +03:00
Gleb Natapov
1b2bf57a2b move timer out of reactor.hh to its own header 2015-06-14 16:02:16 +03:00
Vlad Zolotarov
03ffaea768 locator: introduce i_endpoint_snitch::create_snitch()
- Kill make_snitch().
   - i_endpoint_snitch::create_snitch() uses the utilities from class_registrator.hh.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-14 15:31:49 +03:00
Gleb Natapov
c2f975bee9 test querying of multiple singular ranges 2015-06-11 15:18:07 +03:00
Pekka Enberg
d088cb8181 Fix keyspace strategy options to preserve key-value ordering
Fix keyspace strategy options to preserve key-value ordering by
switching to std::map. We need this to be able to store the map in
database as JSON because unordered maps can cause the schema merging
code to attempt a keyspace update, which we don't support, even though
the values did not change.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-11 13:02:42 +03:00
Vlad Zolotarov
dc732d95d5 gossiping_property_file_snitch_test: Checks parsing facilities of gossiping_property_file_snitch class
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v2:
   - Added "missing declarations" tests
   - tests/urchin/snitch_property_files: renamed: s/-/_/
   - Reworked to use boost testing facilities
   - Use snitch::stop().
2015-06-09 15:33:38 +03:00
Vlad Zolotarov
a2594015f9 locator: futurize snitch creation
- Forbid explicit snitch creation with constructor.
   - Allow the creation of snitches only with locator::make_snitch() template
     function.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v4:
   - Make sure the snitch is stopped before it's destroyed when _snitch_is_ready
     is returned in an exceptional state.

New in v2:
   - Change snitch_ptr to be std::unique_ptr<i_endpoint_snitch>
   - abstract_replication_strategy::create_replication_strategy(): explicitly
     specify (template) types of create_object() parameters.
   - Re-arrange the loop in marge_keyspaces() so that lambdas that depend on
     "this" complete before there is a chance that "this" gets destroyed.
   - create_keyspace(): Don't add a new keyspace if a keyspace with this name
     already exists.
   - i_endpoint_snitch: added a stop() virtual method
      - Added a stop() pure virtual method.
      - Added an enum class snitch_state and a _state member initialized to snitch_state::initializing,
        added an assert() in a destructor requiring _state to become snitch_state::stopped,
        which should be set when stop() is complete.
   - rack_inferring_snitch: added a stop() method.
   - simple_snitch: added a stop() method.
   - Added stop() methods to abstract_replication_strategy and keyspace.
   - Updated database::stop() to wait for all keyspaces in _keyspaces to stop.
2015-06-09 15:33:38 +03:00
Vlad Zolotarov
ab14716ce8 gossiper: "Start" gossiper on all CPUs and initialize its services only on CPU0
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-09 15:33:38 +03:00
Raphael S. Carvalho
d1ed0744f0 schema: add sstable compressor property
The field compressor is about saying which compressor algorithm
must be used in compression of sstable data file.
This is a small step towards compressed sstable data file.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-09 11:18:56 +03:00
Avi Kivity
b96f2d4cee Merge seastar upstream 2015-06-08 12:02:05 +03:00
Raphael S. Carvalho
d864da71fc core: avoid fsyncing output stream twice
For some reason, I added a fsync call when the file underlying the
stream gets truncated. That happens when flushing a file, which
size isn't aligned to the requested DMA buffer.
Instead, fsync should only be called when closing the stream, so this
patch changes the code to do that.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-08 11:59:22 +03:00
Glauber Costa
d59f65eb91 sstables: test range tombstones
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-08 01:47:13 +03:00
Glauber Costa
26fd9fed14 sstable: test collections
Test writing collections, also includes static collections.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-08 01:47:12 +03:00
Avi Kivity
3d24d49971 Merge seastar upstream 2015-06-07 10:00:48 +03:00
Avi Kivity
27d9446f77 future: fix false-positive when a promise tied to a future that lost its state is destroyed
When a promise that still tracks its future is destroyed, but after
future::get() or future::then() was called, the promise thinks it was
destroyed before generating a value, and fails an assertion.

Fix be detaching the promise from the future as soon as get() or then()
remove the value.
2015-06-06 13:47:44 +03:00
Tomasz Grabiec
4548bd1a65 cql_test_env: Work-around infinite recursion in boost::any
cql_query_test segfaults in debug mode due to infinite recursion (see
trace below). The problem started to appear after Avi's always-defer
change.

It looks like the following boost::any() constructor template is
instantiated when boost::any is copied into a lambda:

        // Perfect forwarding of ValueType
        template<typename ValueType>
        any(ValueType&& value, typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0)
          : content(new holder< typename remove_reference<ValueType>::type >(static_cast<ValueType&&>(value)))
        {
        }

It checks for any& to disable itself on forwarding, but it doesn't
check for const any&. There are (non-template) constructors which take
const any&, but I guess some C++ rule favors the template
version. This results in infinite recursion of constructor invocations
between any() and holder().

Workaround is to make the lambda mutable, so that the argument type is
any& and template doesn't kick in.

Trace:

CU 0x4debed5, DIE 0x4f176e6>, this=0x602000044550) at /usr/include/boost/any.hpp:175
ql_query_test, CU 0x4debed5, DIE 0x4f6c509>, this=0x602000044518) at /usr/include/boost/any.hpp:72
CU 0x4debed5, DIE 0x4f176e6>, this=0x602000044510) at /usr/include/boost/any.hpp:175
ql_query_test, CU 0x4debed5, DIE 0x4f6c509>, this=0x6020000444e8) at /usr/include/boost/any.hpp:72
CU 0x4debed5, DIE 0x4f176e6>, this=0x6020000444e0) at /usr/include/boost/any.hpp:175
oost::any const>, void>::type*) (this=0x7ffff2ffa6f0, value=<unknown type in /home/tgrabiec/src/urchin2/build
/release/tests/urchin/cql_query_test, CU 0x4debed5, DIE 0x4f6c509>) at /usr/include/boost/any.hpp:72
5u> const&, std::vector<boost::any, std::allocator<boost::any> >, std::vector<boost::any, std::allocator<boos
t::any> >, basic_sstring<char, unsigned int, 15u> const&, boost::any)::{lambda(database&)#1}::operator()(data
base&) const::{lambda(std::unique_ptr<mutation_partition const, std::default_delete<mutation_partition> >)#1}
::unique_ptr(std::unique_ptr<mutation_partition const, std::default_delete<mutation_partition> >&&) (this=0x7
ffff2ffa6c0) at tests/urchin/cql_test_env.cc:126
2015-06-05 14:02:58 +02:00
Avi Kivity
3986ad6a11 thread: add seastar::async()
Following std::async(), seastar::async(func) causes func to be executed
in a seastar thread, where it can block using future<>::get().  Whatever
func returns is converted to a future, and returned as async()s return
value.
2015-06-04 20:57:00 +03:00
Asias He
c95364fe31 failure_detector: Start on all cpus
Code calls failure_detector::is_alive on all cpus, so we start
failure_detector on all cpus. However, the internal data of failure_detector
is modified on cpu zero and it is not replicated to non-zero cpus.
This is fine since the user of failure_detector (the gossiper) accesses
it on cpu0 only.
2015-06-04 17:25:20 +08:00
Avi Kivity
7fa17d9880 Merge "range query read path"
Conflicts:
	database.cc
2015-06-04 10:21:48 +03:00
Tomasz Grabiec
3d7049f0de tests: Fix commitlog_test.cc
"file" should not go out of scope until async stat() completes.
2015-06-03 14:12:06 +02:00
Avi Kivity
c9a4289244 tests: fix mutation_test capturing stack variable by value
Worked until now because column_family::for_all_partitions() did not defer.
2015-06-03 12:35:07 +03:00
Nadav Har'El
d42c05b6ad sstable: Pull-style read interface
This patch replaces the sstable read APIs from having "push" style,
to having "pull style".

The sstable read code has two APIs:
 1. An API for sequentially consuming low-level sstable items - sstable
    row's beginning and end, cells, tombstones, etc.
 2. An API for sequentially consuming entire sstable rows in our "mutation"
    format.

Before this patch, both APIs were in "push style": The user supplies
callback functions, and the sstable read code "pushes" to these functions
the desired items (low-level sstable parts, or whole mutations).
However, a push API is very inconvenient for users, like the query
processing code, or the compaction code, which both iterate over mutations.
Such code wants to control its own progression through the iteration -
the user prefers to "pull" the next mutation when it wants it; Moreover,
the user wants to *stop* pulling more mutations if it wants, without
worrying about various continuations that are still scheduled in the
background (the latter concern was especially problematic in the "push"
design).

The modified APIs are:

1. The functions for iterating over mutations, sstable::read_rows() et al.,
   now return a "mutation_reader" object which can be used for iterating
   over the mutation: mutation_reader::read() asks for the next mutation,
   and returns a future to it (or an unassigned value on EOF).
   You can see an example on how it is used in sstable_mutation_test.cc.

2. The functions for consuming low-level sstable items (row begin, cell,
   etc.) are still partially push-style - the items are still fed into
   the consume object - but consumpton now *stops* (instead of defering
   and continuing later, as in the old code) when the consumer asks to.
   The caller can resume the consumption later when it wishes to (in
   this sense, this is a "pull" API, because the user asks for more
   input when it wants to).

This patch does *not* remove input_stream's feature of a consumer
function returning a non-ready future. However, this feature is no longer
used anywhere in our code - the new sstable reader code stops the
consumption when old sstable reader code paused it temporarily with
a non-ready future.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-03 10:55:34 +03:00
Avi Kivity
3bb06a8b87 Merge seastar upstream 2015-06-03 10:24:21 +03:00
Amnon Heiman
38a22d9cd8 json: float and double support
This change how the json formatter handle float and adds double support.
float and double conversion will throw exceptions when try to convert
inf or nan.

It also contains tests for both float and double including inf, -inf and
nan for both float and double.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-03 10:01:00 +03:00
Pekka Enberg
5418e32fc7 map_difference: Simplify difference value
Simplify the return value of map_difference() to return set of keys.
This makes it possible to use the function with value types such as
foreign_ptr<> that are non-copyable.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-03 09:19:00 +03:00
Avi Kivity
5a5c1860d2 Merge seastar upstream 2015-06-02 15:13:42 +03:00
Avi Kivity
f9dd73d57f tests: make httpd test wait for continuations to execute
The reactor may defer them at will.
2015-06-02 15:12:10 +03:00
Avi Kivity
06dd2899f5 tests: convert httpd tests to SEASTAR_TEST_CASE
Some of them use continuations.
2015-06-02 15:12:10 +03:00
Avi Kivity
919260f3bd tests: ensure continuation is executed
The reactor is free not to inline continuations, so run checks inside
the continuation.
2015-06-02 15:12:10 +03:00
Avi Kivity
1b52ca1bef tests: memcache ascii parser: fix use-after-free
The input stream needs to be kept alive until we're done reading.
2015-06-02 15:12:10 +03:00
Avi Kivity
a580bb8000 Merge "write sstables crc and digest files"
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-02 10:05:32 +03:00
Avi Kivity
c96e3834c2 Merge seastar upstream 2015-06-01 19:02:01 +03:00
Raphael S. Carvalho
ddd5ad559e sstables: add initial support to generation of Digest file
Digest file stores adler checksum of data file converted into a
string. Testcase is added.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-01 12:25:02 -03:00
Raphael S. Carvalho
bdd3fe61c5 sstables: add initial support to generation of CRC component
CRC component is composed of chunk size, and a vector of checksums
for each chunk (at most chunk size bytes) composing the data file.
The implementation is about computing the checksum every time the
output stream of data file gets written. A write to output stream
may cross the chunk boundary, so that must be handled properly.
Note that CRC component will only be created if compression isn't
being used.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-01 12:25:01 -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
Gleb Natapov
c5077ce99b tests: add missing header 2015-05-31 15:24:00 +03:00
Nadav Har'El
33270efc39 sstables: make consume_row_end() a future
After commit 3ae81e68a0, we already support
in input_stream::consume() the possibility of the consumer blocking by
returning a future. But the code for sstable consumption had now way to
use this capability. This patch adds a future<> return code for
consume_row_end(), allowing the consumer to pause after reading each
sstable row (but not, currently, after each cell in the row).

We also need to use this capability in read_range_rows(), which wrongly
ignored the future<> returned by the "walker" function - now this future<>
is returned to the sstable reader, and causes it to pause reading until
the future is fulfilled.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-05-28 18:53:32 +03:00
Glauber Costa
c02e3fc16a tests:: fix sstable test files removal for good
The current scheme of creating temporary files inside the current directory is
very fragile.

First, whenever we start writing new files, the test breaks if we forget to
include it in the list of removed files (likely).

Second, because we have to manually delete the files after we're done with
them, we can either forget, or if the test crashes, the final condition may not
run.

Instead of doing that, let's move the files to a separate directory. That makes
it a lot easier to make sure we're deleting all the relevant files, because we
can just wipe out the whole directory.

All tests are then wrapped in a function that makes sure that the proper setup
is in place.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-28 18:03:37 +03:00
Avi Kivity
40e8985f64 Merge "Make migration manager announce new column families"
From Pekka:

"This series wires up migration manager column family announcements in
preparation for eventually storing column family schema in system
tables."
2015-05-27 16:42:00 +03:00
Pekka Enberg
42cfcfb32d database: Remove compose() function
Convert code to use the deserialize() function and drop the duplicate
compose() wrapper that we inherited from Origin.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 16:22:35 +03:00
Pekka Enberg
a388b088c6 map_difference: Parametrize value comparison
If map value type is lw_shared_ptr<T>, for example, we need to be able
to pass our own value comparison function to the difference() function.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 16:22:13 +03:00
Pekka Enberg
5ab968137f cql_test_env: Use CQL for keyspace creation
Use CQL for keyspace creation to make sure the keyspace definition also
exists in system tables.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 14:31:30 +03:00
Avi Kivity
cc94019326 Merge seastar upstream
Added missing includes to tests/urchin/commitlog_test.cc.
2015-05-26 17:08:31 +03:00
Vlad Zolotarov
796c203d68 core: remove #include "reactor.hh" from future-util.hh
When future-util.hh is included in files included in reactor.hh (e.g. file.hh).

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-05-26 15:15:28 +03:00
Glauber Costa
0519dec0d7 sstable tests: remove filter file
It is not being remove, and is thus left as garbage in the sstable directory.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-25 20:47:16 -04:00
Glauber Costa
8b2f5979c9 sstable tests: replace last then statement with finally
Currently, a failed test is leaving files behind.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-25 20:47:16 -04:00
Pekka Enberg
f092f33848 cql_test_env: Create keyspace for all test cases
Make sure keyspace exists for all test cases, not just ones that call
the create_table() helper.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-25 19:31:51 +03:00
Amnon Heiman
6d6872063d http: simplify using the parameters in the request
The parameters in the request holds the path parameters. The current
implementation based on unorder_map has a few downside:

1. Because path parameters are sometime used to mark a file path and
they can extend to multiple url section (may contain /) the value will
always contain the leading slash. Though this is true for files, for
the common case, it would be easier to return the value without it.

2. The []operator of the hash map is non const, this mean that it cannot
be used in the common case where the request object is passed as a const
reference.

3. There is no exists method in an ordered_map - Usually query
parameters are mandatory, still it is usefull to have an easy way of
testing if a parameter is found.

This series wrap the unordered_map implementation in a manner more
suitable for the request.

The [] operator will be const and retrun a copy of the parameter value
without the leading slash.

The at method will keep the old meaning. For clearer code, a path method
was added to indicate that the return value has a leading slash.

A set method is used for assignment.

Older code will continue to work without changes.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-25 15:47:56 +03:00