Commit Graph

1979 Commits

Author SHA1 Message Date
Avi Kivity
2f8be37fca atomic_cell_or_collection: allow construction from atomic_cell
Since an atomic_cell has an is-a relationship to atomic_cell_or_collection,
we can allow direct conversion.  Type information is only lost, not added.
2015-03-05 14:03:36 +02:00
Avi Kivity
76d1256565 atomic_cell: add serialize() method
Since atomic_cell is already in serialized form, the implementation is
simple.
2015-03-05 14:03:36 +02:00
Avi Kivity
bb58deadc0 cql3: add virtual destructor to class operation 2015-03-05 14:03:36 +02:00
Avi Kivity
74beb62527 schema: add stringify operation for column_definition 2015-03-05 14:03:35 +02:00
Avi Kivity
853d0b2ca0 abstract_type: implement freeze() 2015-03-05 14:03:35 +02:00
Avi Kivity
7eba98f18c atomic_cell: add missing include 2015-03-05 11:17:43 +02:00
Avi Kivity
5902243dc5 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Global adjustment due to the removal of future<>::rescue().
2015-03-05 11:00:11 +02:00
Tomasz Grabiec
d674cd7deb core: add make_shared(T&&) overload
Allows for code like this:

  auto p = make_shared(object());
2015-03-04 18:49:26 +02:00
Tomasz Grabiec
83963b23d3 Replace rescue() usages with then_wrapped()
They are pretty much the same. This change removes rescue().
2015-03-04 17:34:59 +01:00
Tomasz Grabiec
e36115e1d4 core: add then_wrapped() overload which works with void-returning callbacks 2015-03-04 17:33:38 +01:00
Calle Wilund
7b5193b80c future: deferring finally() callback
Add "finally" continuation overload for functions returning future type that
awaits finishing the continuation in question before continuing the "present"
one. I.e. a wrapper around "then_wrapped" to remove the need to deal with the
original return value.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-03-04 18:09:34 +02:00
Raphael S. Carvalho
89ec1f8f6a slab: Add reclaimer functionality
Basic explanation of the reclaimer algorithm:
- Each slab page has a descriptor containing information about it, such as
refcnt, vector of free objects, link into LRU, etc.
- The LRU list will only contain slab pages which items are unused, so as
to make the reclaiming process faster and easier. Maintaining the LRU of slab
pages has a performance penalty of ~1.3%. Shlomi suggested an approach where
LRU would no longer exist and timestamp would be used instead to keep track of
recency. Reclaimer would then iterate through all slab pages checking for an
unused slab page with the lowest timestamp.
- Reclaimer will get the least-recently-used slab page from the LRU list,
do all the management stuff required, and iterate through the page erasing any
of the items there contained. Once reclaimer was called, it's likely that slab
memory usage is calibrated, thus slab pages shouldn't be allocated anymore.
- Reclaimer is enabled by default but can be disabled by specifying the slab
size using the application parameter --max-slab-size.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-04 17:40:58 +02:00
Nadav Har'El
68d0cd2441 input_stream: remove buf_size parameter
input_stream's constructor had an unused buf_size parameter. Such a
parameter is not needed - whenever the input_stream needs more
data it calls the underlying data_source's get(), and thus only the
data_source gets to decide the buffer size. Moreover, in some
implementations, this read buffer size will be different each time -
e.g., in a chunk-compressed file, the uncompressed chunk's size will
be different each time.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-04 17:39:16 +02:00
Avi Kivity
6d18aa8f20 Decompose database.hh, types.hh into smaller headers
Avoid include hell for new code.
2015-03-04 16:18:48 +02:00
Avi Kivity
a49330095a db: wrap bytes in atomic_cell format
We use bytes for many different things, and it is easy to get confused as
to what format the data is actually in.

Fix that for atomic_cell by proving wrappers.  atomic_cell::one corresponds
to a bytes object holding exactly one atomic cell, and atomic_cell::view is
a bytes_view to an atomic_cell.  The static functions of atomic_cell itself
are privatized to prevent the unwashed masses from using them on the wrong
objects.

Since a row entry can hold either a an atomic cell, or a collection,
depending on the schema, also introduce a variant type
atomic_cell_or_collection and allow the user to pick the type explicitly.
Internally both are stored as bytes object.
2015-03-04 15:49:35 +02:00
Shlomi Livne
1bf71073e6 tests: Add a timeout to limit execution time of tests
Support a timout to assure that we do not have run away tests

Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-03-04 15:06:20 +02:00
Pekka Enberg
d6b5caa1f3 tests: Convert cql_query_test to use Boost.Test
Use Boost.Test so that we can easily specify multiple test cases.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-04 13:16:17 +01:00
Tomasz Grabiec
ee358aa9c1 Fix warnings map to be thread-local
The map is mutated so it should be thread-local. This will make the
warnings printed once per core, but I guess it's not a big deal.
2015-03-04 13:12:12 +01:00
Nadav Har'El
6f2a2529a2 add "double" and "float" types
Implement "double" and "float" cql types.

This implementation doesn't touch serialization.hh (which should be
eventually removed) and rather follows the other examples in types.cc.
It is relatively ugly, because of all the cleverness of our "general"
byte swapping implementation actually works only for integer types, and
we need to get it to work for float/double as well.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-04 10:54:19 +01:00
Avi Kivity
c7a1981525 Merge branch 'asias/gossip' of github.com:cloudius-systems/seastar-dev into db
Initial gossip support, from Asias and Nadav.
2015-03-04 10:31:44 +02:00
Asias He
8e15ed452f gossip: Add gms/gms.cc 2015-03-04 16:08:10 +08:00
Asias He
d5f0ce2663 gossip: Add missing #pragma once 2015-03-04 15:51:35 +08:00
Nadav Har'El
65f8ee2e5c gossip: Convert gms/VersionedValue.java to C++
Left some of the stuff I got tired of converting in #if 0. Most likely
I'll need them later, and convert them then.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-04 15:48:58 +08:00
Asias He
9af0a2925f gossip: Import gms/VersionedValue.java 2015-03-04 15:47:03 +08:00
Tomasz Grabiec
760d4e1d2a Merge branch git@github.com:cloudius-systems/seastar-dev.git penberg/create-keyspace-stmt
From Pekka:

Initial pass at converting create keyspace statement parsing to C++.
2015-03-03 15:40:53 +01:00
Calle Wilund
56dce3df51 Basic rw-lock impl around semaphore.
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-03-03 14:58:58 +02:00
Pekka Enberg
6751f7a305 cql3/Cql.g: Create keyspace statement
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
4b384ef705 cql3/Cql.g: Properties
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
79caf1bc95 cql3: Fix schema_altering_statement::uses_function()
The schema_altering_statement class must implement
cql_statement::uses_function() to be instantiable.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
8e0903fdbd cql3: Convert statements.CreateKeyspaceStatement to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
48f21ff39b cql3: Convert statements.PropertyDefinitions to C++, take 2
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:30:18 +02:00
Nadav Har'El
e7a59652b5 Add comments to schemas in system_keyspace
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 15:18:41 +01:00
Nadav Har'El
8265a13dbd schema: add "comment" string
Add a comment string to a schema, which may be set but is currently
not further used.

The originals Cassandra code has a comment for each of the builtin
schemas, and it's a shame not to remember them.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 15:18:23 +01:00
Nadav Har'El
4d9cf99cd9 start converting LegacySchemaTables.java to C++
Convert the schemas from LegacySchemaTables.java to C++.
Some FIXMEs still left because of types we don't yet support, or
schema features we don't yet support - this will be fixed later.

Note that I put legacy_schema_tables in the "db" namespace, not in the
"schema" namespace where Origin had it. This was the *only* class in
the "schema" package in Origin, and unfortunately in Urchin we can't use
the name "schema" as a namespace, as we already have it as a class.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 15:18:19 +01:00
Nadav Har'El
161de485f7 LegacySchemaTables.java from origin
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 15:18:16 +01:00
Asias He
55a43eb5f9 tcp: Improve retransmit
Do not store the tcp header in unacked queue. When partial ack of a
segment happens, trim off the acked part of a segment. When retransmits,
recalculate the tcp header and retransmit only the unacked part.
2015-03-02 12:36:47 +02:00
Nadav Har'El
6e94cfb3ac system_keyspace - translate more tables to C++
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 10:59:38 +01:00
Pekka Enberg
99a09020e8 types: Fix bytes_type_impl string conversion
Tomek points out that:

  Origin calls org.apache.cassandra.utils.Hex#hexToBytes here, which is
  not what to_bytes() does. BytesType.getSerializer().toString() calls
  ByteBufferUtil.bytesToHex(value), so you should call to_hex() here.

Fix that up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-02 10:38:27 +01:00
Avi Kivity
6379ce5cc3 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-03-01 18:47:54 +02:00
Avi Kivity
3aaac55a7a tcp: fix bad checksum on RST packets
We neglected to set offload_info::needs_csum on reset packets, resuling in
them being ignored by the recipient.  Symptoms include connection attempts
to closed ports (seastar = passive end) hanging instead the active end
understanding the port is closed.
2015-03-01 18:45:35 +02:00
Avi Kivity
1bf214b7df thrift: stop reading on short buffer
Fixes buffer overrun.  Should perhaps be part of read_exactly().
2015-03-01 17:14:25 +02:00
Avi Kivity
1d02b8bc6d Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-03-01 16:52:23 +02:00
Avi Kivity
27913013b1 virtio: tighten rx packets for debug mode
Allocate exactly the available fragment size in order to catch buffer
overflows.

We get similar behaviour in dpdk, since without huge pages, it must copy
the packet into a newly allocated buffer.
2015-03-01 16:42:07 +02:00
Gleb Natapov
590d8da4f1 core: provide "void" promise specialization
Makes it easier to write generic code.
2015-03-01 15:58:36 +02:00
Gleb Natapov
e1aa9f85a1 fix xenstore compilation 2015-03-01 15:29:13 +02:00
Avi Kivity
cefe6a9b3e tcp: fix option parsing
Two bugs:
  1. get_header<type>(offset) was used with size given as the offset
  2. opt_end failed to account for the mandatory tcp header, and thus was
     20 bytes to large, resulting in overflow.
2015-03-01 15:26:46 +02:00
Avi Kivity
f039904d75 Merge branch 'master' into db
Updated usages of std::hash<some_enum_type> to accomodate 25168fc73d.
2015-03-01 15:24:47 +02:00
Avi Kivity
25168fc73d enum: fix std::hash<> non-specialization for enum types
SFINAE only works for substituted template parameters, not any complication
error (or it would be called CEINAE); therefore hash<T> for enums will fail
to compile, given a non-enum, rather than being ignored.

It's not possible to specialize hash<> for enums, since the primary template
does not have en extra Enable template argument for use with enable_if.  We
therefore rename it to enum_hash<> and require users to explicitly define
hash<MyEnum> as inheriting from it.
2015-03-01 13:36:30 +02:00
Avi Kivity
1e5df06f9a shared_ptr: provide default std::hash<> specializations
Folloing std::shared_ptr.
2015-03-01 13:36:17 +02:00
Glauber Costa
eb384236fd iostream: extend eof condition to read_exactly users as well
We currently only signal eof for consume() users. If one is calling
read_exactly, eof will never be signalled.

This might make some sense in continuous streams, but specially when
dealing with files, eof is a natural part of line that can and will
happen all the time. Every "read-until-finish" file-loop will at some
point rely on eof.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-01 09:48:51 +02:00