Commit Graph

3389 Commits

Author SHA1 Message Date
Raphael S. Carvalho
ff52678eb5 sstables: add static method filename to sstable
This function is likely to be duplicated over time, so let's make
it available as a static method of sstable class.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-05-20 13:30:32 -03:00
Raphael S. Carvalho
2e31147c70 sstables: add file_writer
file_writer wraps output_stream<char> around.
file_writer also adds the method offset(), intended to return the current
offset of the stream.
It's also a small step towards compression support where a specialized output
stream is required.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-20 11:27:18 -03:00
Tomasz Grabiec
1c7ed0a86c Merge tag 'avi/cf-cow/v1'
A long running query may use memtables and sstables that are being removed
by memtable flush and sstable compaction paths.  Use copy-on-write to
prevent use-after-free.
2015-05-20 15:29:48 +02:00
Avi Kivity
ff42d58881 db: use CoW to modify the memtable list in column_family
Allow memtables to be removed from a column_family while a running query
continues to use them.
2015-05-20 16:00:00 +03:00
Avi Kivity
1342553fed db: remove column_family::testonly_all_memtables()
Unused and gets in the way.
2015-05-20 15:28:53 +03:00
Tomasz Grabiec
82af574e3f service: Remove const qualifier from client_state getter 2015-05-20 15:24:45 +03:00
Avi Kivity
f8f6e979ef db: use CoW to modify the sstable table in column_family
Allow sstables to be removed from a column_family while a running query
continues to use them.
2015-05-20 15:17:35 +03:00
Avi Kivity
4008347d89 sstable: add generation accessor 2015-05-20 15:11:59 +03:00
Pekka Enberg
866d39b5dc migration_manager: Fail announce_new_keyspace if keyspace already exists
If keyspace already exists, throw a already_exists_exception like Origin
does. Spotted while reading the code.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-20 15:08:24 +03:00
Avi Kivity
f8c8a55bfe Merge seastar upstream 2015-05-20 14:27:40 +03:00
Avi Kivity
788982df33 thrift: improve error messages for exceptions not declared in the thrift interface
When thrift sees an exception that was not declared as part of the interface,
it wraps it using std::exception::what() for the exception text.  This is
often cryptic, so add an "Internal server error" prefix.
2015-05-20 14:26:25 +03:00
Nadav Har'El
eda6a528eb iostream: consume() - fix hung test
The test tests/memcached/test_ascii_parser hung after the change to
consume(). The problem was that consume() notified the consumer of an
EOF by sending it an empty buffer, and then it expected to get back a
message that it shouldn't read more (by setting the unconsumed buffer),
if it didn't, it continued to send empty buffers in a never-ending loops.

So this patch changes consume() to send one empty buffer to the consumer
on the end-of-file, and then stop (regardless of what the consumer returns).

It would have probably made sense to *not* send an empty buffer to the
consumer after the data is done - not even once - but if we change this
behavior, it will break the existing tests.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Tested-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-05-20 14:14:59 +03:00
Pekka Enberg
f34f195860 database: Fix capture by reference in create_keyspace()
We cannot capture keyspace_metadata by reference because it can be
allocated on the stack. Fixes SIGSEGV while running cassandra-stress.
The bug was introduced in commit commit cd35617 ("database: Use
keyspace_metadata for creation functions").

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-20 12:35:55 +03:00
Pekka Enberg
4657b24154 transport: Make CQL server less noisy
The CQL server is really noisy during cassandra-stress run because it
prints out STARTUP message options. Fix that up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-20 11:51:35 +03:00
Gleb Natapov
ddf2167949 net: add new contractor for ipv4_addr
The one that takes IP as a string and port as a number.
2015-05-20 11:38:32 +03:00
Avi Kivity
0b2ba53e15 Merge "bloom filter read support"
Glauber says:

"This is the basic bloom filter implementation. We can read an existing
filter file, but we won't construct one (pending on Index creation)

TODO:
- add the tracker bloom filter (to track its statistics)
- write the filter file"
2015-05-20 10:44:16 +03:00
Avi Kivity
85f23f6894 tests: reindent test_multiple_memtables_multiple_partitions() 2015-05-19 23:48:17 +03:00
Avi Kivity
42a587a954 db: reindent column_family::query() 2015-05-19 23:47:26 +03:00
Avi Kivity
6867ad8fd7 db: reindent column_family::for_all_partitions 2015-05-19 23:46:11 +03:00
Tomasz Grabiec
137b3beb2f Merge tag 'avi/readpath-prep/v1' from seastar-dev.git
From Avi:

"This patchset prepares for adding sstables to the read path.  Because sstables
involve I/O, their APIs return futures, which means that APIs that may call
those sstable APIs also need to return futures.

This patchset uses the two-space indent + do_with + reference aliases trick
to make patches more readable.  Cleanup patches will follow once it is merged."
2015-05-19 20:39:36 +02:00
Avi Kivity
5e759aa2dd Merge "Keyspace creation cleanups"
Pekka says:

"Clean up keyspace creation functions by using keyspace_metadata. While
at it, simplify creation by moving replication strategy initialization
to database.cc. This paves the way for adding keyspace metadata lookup
functionality to database that's needed by migration manager."
2015-05-19 20:06:42 +03:00
Avi Kivity
3ae81e68a0 Merge seastar upstream
Updated sstables::data_consume_rows_context for input_stream::consume()
API change.
2015-05-19 19:57:09 +03:00
Nadav Har'El
c5f61666d3 input_stream::consume() overhaul
Our input_stream::consume() mechanism allows feeding data from an input
stream into a consumer, piece by piece, until the consumer doesn't want
any more. It currently assumed the input can block (when reading from disk),
but the consumption is assumed to be immediate. This patch adds support for
blocking in the consumption function: The consumer now returns a future
which it promises to fulfill after consuming the given buffer.

This patch goes further by somewhat simplifying (?) the interface of the
consumer. Instead of receiving a mysterious "done" lambda the consumer
is supposed to call when done (doesn't want any more input), the consumer
now returns a future<optional<temporary_buffer<char>>, which means:

1. The future is fulfilled when the consumer is done with this buffer
   and either wants more - or wants to stop.

2. If the consumer wants to stop, it returns the *remaining* part of the
   buffer it didn't want to process (this will be pushed back into the
   input stream).

3. If the consumer is not done, and wants to consume more, it returns an
   unset optional.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-05-19 19:33:18 +03:00
Glauber Costa
d03654c3d9 sstables: bloom filter implementation
Use the provided filter instead of always returning true. For existing tables,
this arrives from the bloom filter file. We don't yet fully write a bloom
filter file.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
9d3ef62789 sstables: add convenience constructors for filter type
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
b86218b2ef bloom filter
This comes from Origin, but the changes I had to do are quite large.
These files also represents many files, but I found it to be inconvenient
to keep all the originals, simply because we would end up with way too many
files: one .cc and one .hh per filter + an enveloping .hh so users could include
without knowing which filter to use.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
1c1758150f sstables: change read_simple and write_simple to be able to handle arbitrary parameters
Passing all arguments as template parameters was a nice trick, made possible by
the fact that all fields we were dealing with were part of the sstable
structure.

However, as we progress, it would make sense for some fields to be short-lived.
In that case, the that convenience turns into an inconvenience.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
151feb8b6e bloom_filter: bloom calculations
Helpers to calculate the various parameters of a Bloom Filter

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
b16f1968e7 exceptions: allow for message in unsupported operation
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Glauber Costa
4d92927c75 sstables: calculate filter by key, not token
Origin calculates bloom filter based on the ByteBuffer value of the key,
not the token. As much as they themselves would like this to be different,
that filter ends up on disk, so we must follow it.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-19 11:22:41 -04:00
Avi Kivity
f976a1e905 Merge "Migration manager cleanups"
Pekka says:

"Clean up migration manager in preparation for translating more announce
functions."
2015-05-19 17:27:10 +03:00
Pekka Enberg
2814a65f9c migration_manager: Implement announce_new_column_family() variant
Convert ifdef'd announce_new_column_family() variant by specifying a
default argument.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 17:04:30 +03:00
Pekka Enberg
cf9677fa6f migration_manager: Unify announce_new_keyspace() functions
Use default arguments to unify two announce_new_keyspace() variants.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 17:03:27 +03:00
Pekka Enberg
079d806554 migration_manager: Move implementation to separate file
Move the implementation from header file to a source file.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 16:58:44 +03:00
Pekka Enberg
1284211d30 migration_manager: Remove obsolete Java imports
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 16:48:40 +03:00
Pekka Enberg
8a896e4ed5 cql: Remove obsolete cql3.cc
The cql3.cc file was used to make sure CQL header files were being
compiled in early stages of the translation. It's obsolete now and only
slows down compilation so lets get rid of it.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:58:04 +03:00
Avi Kivity
51b4b360be Merge commitlog RESTful API
Amnon says:

"This series adds the commitlog API. Current functionality is the
list of active files.  After this patch a call to:
http://localhost:10000/commitlog/segments/active
Will return a list of the active commitlog files"
2015-05-19 15:51:34 +03:00
Amnon Heiman
c6723d2f61 Adding the commitlog API implementation
This adds the implementation of the commitlog API.
Current implementation contains:
/commitlog/segments/active
That returns a list of the active file names, and
/commitlog/segments/archiving
Which always return an empty list as we archiving is not supported at
the moment

The doc file is under:
/api-doc/commitlog

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-19 15:27:59 +03:00
Amnon Heiman
8f5c2a3143 API: Add the commitlog API
This contains the commitlog API that is the equivalent of the
CommitLogMbean API.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-19 15:27:59 +03:00
Amnon Heiman
b95dabba38 Expose the segment names in commit log
This adds a method to return a vector with full-path to the active
segment names. It will be used by the API.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-19 15:27:52 +03:00
Pekka Enberg
56d6fdacfe database: Simplify replication strategy initialization
Initialize replication strategy when keyspace is being created now that
we have access to keyspace_metadata.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:27:47 +03:00
Pekka Enberg
cd35617855 database: Use keyspace_metadata for creation functions
Use the keyspace_metadata type for keyspace creation functions. This is
needed to be able to have a mapping from keyspace name to keyspace
metadata for various call-sites.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:27:47 +03:00
Pekka Enberg
f0ad71f9f1 thrift: Fix keyspace metadata init in system_add_keyspace()
Pass replication strategy options to the create_replication_strategy()
function.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:16:14 +03:00
Avi Kivity
db04bba208 db: futurize the single partition query path
Prepare for disk reads.
2015-05-19 15:13:09 +03:00
Avi Kivity
738be63b28 db: define column_family move constructor in .cc
Allows using it from files that do not include sstable.hh.
2015-05-19 15:13:09 +03:00
Avi Kivity
72d721ea56 db: futurize column_family::query() outer loop
In preparation for reading from sstables, allow the outer loop of
column_family::query() (iterating over partition ranges) do defer.
2015-05-19 15:13:06 +03:00
Avi Kivity
d6754823b8 db: conform to sstable naming convention wrt generation 2015-05-19 15:01:29 +03:00
Avi Kivity
05f7c6abd5 sstable: rename convert_row() to read_row()
More reader-friendly.
2015-05-19 15:01:29 +03:00
Amnon Heiman
b795acdf63 Adds the database to the API context
The API needs the database distribute object to get information from it.
This adds a database reference the API context so it would be
available in the API.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-19 13:27:57 +03:00
Avi Kivity
104557b3a0 Merge "Keyspace metadata cleanup"
Pekka says:

"We are going to keep the ks_meta_data class around and use it in core
code like the migration manager. Therefore, clean up the class and move
it to the database.hh where user_types_metadata also is defined in. As a
bonus, this also fixes the circular dependency between ks_meta_data.hh
and database.hh."
2015-05-19 11:39:03 +03:00