Commit Graph

100 Commits

Author SHA1 Message Date
Avi Kivity
2b4eaf83ab transport: set TCP_NODELAY
Reduces latency.
2015-08-18 15:48:36 +03:00
Paweł Dziepak
944d0e5366 transport: encode tuple types properly
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-17 14:42:21 +02:00
Pekka Enberg
5b9901d693 cql3/query_options: Encapsulate underlying values
Encapsulate the '_values' vector to make it easier to switch the
underlying type from bytes_opt to bytes_view_opt.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-17 09:48:58 +03:00
Vlad Zolotarov
cb55bdbfbc transport: register the correct "current number of open connections" statistics counter source
There are two counters for the "current number of open connections" in the cql_server:
   - _connects: incremented every time a new connection is opened. Should be used for
                a derived statistics of connections/sec
   - _connections: incremented and decremented every time a new connection is opened/closed
                correspondingly.

_connects has been registered as a source for both derived and gauge collectd statistics by
mistake while it had to be registered for a derived counter only and _connections had to be
registered as a source for a gauge counter.

Fixes issue #143

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-16 12:56:11 +03:00
Gleb Natapov
0b3d2de2f1 Fix mutation write timeout exception reporting
Make it compatible with CQL specification
2015-08-12 14:58:48 +03:00
Pekka Enberg
5c99a58b27 transport: Move cql_server and event_notifier to transport namespace
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:36 +03:00
Pekka Enberg
3ab87c216e transport/server: Use pragma once as include guard
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:36 +03:00
Pekka Enberg
a3c194b050 transport/server: Move event_notifier class to separate file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:35 +03:00
Pekka Enberg
3ad4e4e829 transport/server: Move connection class definition to server.hh
Move the connection class to server.hh so that we can move event
notifier implementation to a separate source file.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:09 +03:00
Pekka Enberg
42f865a3de transport/server: Clean up connection class definition
Move member function definitions outside of the class definition in
preparation for moving the latter to a header file.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:25:09 +03:00
Pekka Enberg
d461443bf2 transport/server: Fix error handling in parse_frame()
Throw a protocol exception instead of killing the process with abort().

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
48abeefdda transport/server: Fix connection version mismatch validation
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
bb067782d7 transport/server: Fix CQL binary protocol version validation
We only support up to CQL protocol v3. Fixes #117.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
ad041207a4 transport/server: Catch all request processing errors
We need to also catch exceptions in top-level connection::process() so
that they are converted to proper CQL protocol errors.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:21 +03:00
Pekka Enberg
33ce99b732 transport/event: Move implementation to source file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:28:46 +03:00
Pekka Enberg
fad7b28abf transport/event: Convert ifdef'd assertion
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:23:51 +03:00
Pekka Enberg
ce9f78932e transport/event: Fix class definition indentation
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:21:28 +03:00
Pekka Enberg
4b5a89be69 transport/event: Eliminate ifdef'd code
We do serialization in transport/server.cc and there's no need for
the equals() and hashCode() function so just drop ifdef'd code.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:55:51 +03:00
Pekka Enberg
c706fc9ea8 transport/server: Fix logger format strings
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:55:01 +03:00
Pekka Enberg
c8128de562 transport/server: Hook event notifier to lifecycle events
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:48 +03:00
Pekka Enberg
dc4171e8d7 transport/server: Fix response::write_inet()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Pekka Enberg
096e02469e transport/server: Fix response::write_byte()
The last two arguments to vector::insert() are flipped which causes us
to fill the vector with 'b' bytes of value 0x01. Switch to the single
element insertion variant to fix the issue.

Spotted by dtest push notification tests.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Pekka Enberg
92c813d562 transport/server: Topology and status change event encoding
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Pekka Enberg
f5ac4a3738 transport/event: Convert TopologyChange and StatusChange to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Vlad Zolotarov
a77ca1c29b cql_server::do_accepts(): Use logger.debug() for connection errors logging
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-06 13:03:20 +03:00
Pekka Enberg
e5ca713e72 transport/server: Fix schema change event encoding
We also need to encode the event type in the response message. Fixes the
following dtest breakage:

  cassandra.connection: ERROR: Error decoding response from Cassandra. opcode: 000c; message contents: '\x83\x00\xff\xff\x0c\x00\x00\x00\x17\x00\x07CREATED\x00\x08KEYSPACE\x00\x02ks'
  Traceback (most recent call last):
    File "/usr/lib64/python2.7/site-packages/cassandra/connection.py", line 431, in process_msg
      flags, opcode, body, self.decompressor)
    File "/usr/lib64/python2.7/site-packages/cassandra/protocol.py", line 123, in decode_response
      msg = msg_class.recv_body(body, protocol_version, user_type_map)
    File "/usr/lib64/python2.7/site-packages/cassandra/protocol.py", line 803, in recv_body
      raise NotSupportedError('Unknown event type %r' % event_type)
  NotSupportedError: Unknown event type u'CREATED'

Reported-by: Shlomi Livne <shlomi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 15:16:50 +03:00
Avi Kivity
55ca295154 Merge "Initial CQL event support" from Pekka
"This series implements initial support for CQL events. We introduce
migration_listener hook in migration manager as well as event notifier
in the CQL server that's built on top of it to send out the events via
CQL binary protocol. We also wire up create keyspace events to the
system so subscribed clients are notified when a new keyspace is
created.

There's still more work to be done to support all the events. That
requires some work to restructure existing code so it's better to merge
this initial series now and avoid future code conflicts."
2015-08-05 12:56:37 +03:00
Pekka Enberg
66f7f05eef transport/server: Wire up event notifier to process_register()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:52 +03:00
Pekka Enberg
07c8f0b1ac transport/server: Add read_string_list() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00
Pekka Enberg
27068fe912 transport/server: Event notifier
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00
Pekka Enberg
6e29d51c0a transport/server: Add write_schema_change_event() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00
Vlad Zolotarov
6819ee641b transport: cql_server::connection::process(): return the missing 'return'
Return the 'return' statement removed by mistake in
commit 707f3b25e3.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-04 13:39:52 +03:00
Vlad Zolotarov
707f3b25e3 transport: cql_server::connection: paralellization of cql requests handling
Take the request processing part into the separate function and
run it in parallel for incoming requests.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-04 13:05:46 +03:00
Vlad Zolotarov
86e28bbf5d transport::cql_server::connection::process(): Consume the last future
When process() terminated _ready_to_respond contains the future with the
state of the last I/O operation of this connection. Consume it at the
end of process().

Fixes issue #44

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-02 19:24:13 +03:00
Pekka Enberg
1ae8522e9e transport/server: Fix unknown consistency level error handling
If we receive an unknown consistency level, fail with PROTOCOL_ERROR. If
we're trying to send out an unknown consistency level, fail with
SERVER_ERROR.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 14:02:40 +03:00
Pekka Enberg
c15de0257d transport/server: Fail with PROTOCOL_ERROR on unknown frame version
If we don't recognize a frame version, throw a protocol_exception like
Origin does rather than killing the process.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:59:11 +03:00
Pekka Enberg
d22adbf878 transport/server: Fail gracefully on unknown change and target type
If the switch statements don't match to change or target type
enumerations, throw a invalid_argument exception that's translated to
proper SERVER_ERROR. The error is not triggerable in practice as
change_type and target_type are enumerations. However, the compiler is
unhappy if we don't have them so lets just clean them up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:55:26 +03:00
Pekka Enberg
e2692a9d08 transport/server: Fail gracefully if client asks for frame compression
Throw a runtime_exception which is translated to proper SERVER_ERROR
message rather than killing the process with assert().

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:46:57 +03:00
Pekka Enberg
d0826bc10d transport/server: Fix unknown opcode error handling
If we encounter an unknown opcode, throw a protocol exception rather
than killing the process with assert().

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:44:37 +03:00
Pekka Enberg
980dc910d9 exceptions: Move protocol_exception to exceptions.hh
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:44:20 +03:00
Pekka Enberg
c30afdc3c7 transport/server: Fix error encoding some more
All error messages encode a error message as well. It sometimes pays off
to read the fine print in specs:

"4.2.1. ERROR

   Indicates an error processing a request. The body of the message will be an
   error code ([int]) followed by a [string] error message. Then, depending on
   the exception, more content may follow. The error codes are defined in
   Section 9, along with their additional content if any."

Fixes #32.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 13:00:19 +03:00
Pekka Enberg
dcbf8d5a9c transport/server: Fix UNPREPARED error encoding
Fix UNPREPARED error encoding to follow the CQL transport protocol spec.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:36:53 +02:00
Tomasz Grabiec
ae98a3aae7 Merge branch 'penberg/consistency-level-cleanups/v1' from seastar-dev.git
From Pekka:

This series cleans up consistency_level.hh dependency issues that allow
us to use 'enum consistency_level' cleanly in CQL transport layer
exceptions in exceptions.hh. No functional changes.
2015-07-28 09:56:22 +02:00
Avi Kivity
0f4f5f5bfc transport: collect and expose statistics to collectd 2015-07-28 09:48:27 +02:00
Pekka Enberg
3803e0ed5b exceptions: Move request_timeout_exception to exceptions.hh
Now that consistency level dependency issues are sorted out, move
request_timeout_exception to exceptions.hh.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:06:18 +03:00
Pekka Enberg
0b8c67ed79 exceptions: Move unavailable_exception to exceptions.hh
Move unavailable_exception to exceptions.hh where other CQL transport
level exceptions are defined in.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:06:18 +03:00
Pekka Enberg
826f21643f transport/server: Fix UNAVAILABLE error encoding
This fixes UNAVAILABLE error encoding to follow the CQL binary protocol
spec.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 09:27:52 +03:00
Pekka Enberg
bd55f31982 transport/server: Fix READ_TIMEOUT error encoding
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-27 17:37:49 +03:00
Glauber Costa
b488b06fa4 cql_server: define and call a stop method
All sharded services "should" define a stop method. Calling them is also
a good practice.

Blindly calling it at exit is wrong, but it is less wrong than not calling
it at all, and makes it now equally as wrong as any of the other services.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 11:11:57 -04:00
Paweł Dziepak
fc44658fa7 transport: add varint to type_codec::type_id_to_type
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-22 08:50:54 +03:00