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>
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>
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>
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>
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>
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>
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>
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>
"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."
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
Move unavailable_exception to exceptions.hh where other CQL transport
level exceptions are defined in.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
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>