Commit Graph

27 Commits

Author SHA1 Message Date
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Asias He
cb92fe75e6 streaming: Introduce get_session helper
To simplify streaming verb handler.

- Use get_session instead of open coded logic to get get_coordinator and
  stream_session in all the verb handlers

- Use throw instead of assert for error handling

- init_receiving_side now returns a shared_ptr<stream_result_future>
2016-01-29 16:31:07 +08:00
Asias He
2f48d402e2 streaming: Remove unused commented code 2016-01-29 16:31:07 +08:00
Asias He
bc4ac5004e streaming: Kill stream_result_future::create_and_register
The helper is used only once in init_sending_side and in
init_receiving_side we do not use create_and_register to create
stream_result_future. Kill the trivial helper to make the code more
consistent.

In addition, rename variables "future" and "f" to sr (streaming_result).
2016-01-25 11:38:13 +08:00
Asias He
face74a8f2 streaming: Rename stream_result_future::init to ::init_sending_side
So we have:

- init_sending_side
  called when the node initiates a stream_session

- init_receiving_side
  called when the node is a receiver of a stream_session initiated by a peer
2016-01-25 11:38:13 +08:00
Asias He
9a346d56b9 streaming: Drop unnecessary parameters in stream_init_message
- from
  We can get it form the rpc::client_info

- session_index
  There will always be one session in stream_coordinator::host_streaming_data with a peer.

- is_for_outgoing
  In cassandra, it initiates two tcp connections, one for incoming stream and one for outgoing stream.
  logger.debug("[Stream #{}] Sending stream init for incoming stream", session.planId());
  logger.debug("[Stream #{}] Sending stream init for outgoing stream", session.planId());
  In scylla, it only initiates one "connection" for sending, the peer initiates another "connection" for receiving.
  So, is_for_outgoing will also be true in scylla, we can drop it.

- keep_ss_table_level
  In scylla, again, we stream mutations instead of sstable file. It is
  not relevant to us.
2016-01-25 11:38:13 +08:00
Asias He
bdd6a69af7 streaming: Drop unused parameters
- int connections_per_host

Scylla does not create connections per stream_session, instead it uses
rpc, thus connections_per_host is not relevant to scylla.

- bool keep_ss_table_level
- int repaired_at

Scylla does not stream sstable files. They are not relevant to scylla.
2016-01-25 11:38:13 +08:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Asias He
59cae82470 streaming: Make stream_plan::execute return a future
Returns a ready future if the stream_plan completes successfully, or a
failed future otherwise.
2015-07-31 16:27:55 +08:00
Asias He
3a5af0a7fb streaming: Fix stream_coordinator::is_receiving
Unlike Origin, We can not use _connections_per_host == 0 to indicate we
are a follower since we set _connections_per_host to 1 for follower too.
2015-07-31 16:27:55 +08:00
Asias He
0e5fa35bd2 streaming: Register to stream_manager in create_and_register 2015-07-21 16:12:54 +08:00
Asias He
1f5feee5f2 streaming: Implement stream_result_future::handle_progress 2015-07-21 16:12:54 +08:00
Asias He
d74e414d09 streaming: Implement stream_result_future::handle_session_complete 2015-07-21 16:12:54 +08:00
Asias He
5e6f84cba8 streaming: Implement stream_result_future::handle_session_prepared
Instead of playing the game of casting between stream_event and derived
class. We overload handle_stream_event with derived stream_event class.

virtual void handle_stream_event(session_complete_event event) {}
virtual void handle_stream_event(progress_event event) {}
virtual void handle_stream_event(session_prepared_event event) {}

Also, make the virtual function non pure virtual, so user can override
the interested event only without defining all of the three.
2015-07-21 16:12:54 +08:00
Asias He
d9b7cb4142 streaming: Enable logger in stream_result_future 2015-07-21 16:12:54 +08:00
Asias He
69ce554a0f streaming: Init session when follower receives a PREPARE_MESSAGE 2015-07-21 16:12:54 +08:00
Asias He
845de56614 streaming: Fix handler of PREPARE_MESSAGE
With this patch, the receiver of PREPARE_MESSAGE can create a session
correctly now.
2015-07-14 20:41:14 +08:00
Asias He
8734213890 streaming: Lookup session 2015-07-14 20:41:14 +08:00
Asias He
fd04337e80 streaming: Wire up register_receiving init_receiving_side
Now stream_result_future can create a stream_coordinator if not
provided.

So
 - On sending side, stream_coordinator is created by stream_plan
 - On receiving side, stream_coordinator is created by stream_result_future
2015-07-14 20:41:14 +08:00
Asias He
d1720ffed1 streaming: Hold a shared_ptr inside stream_plan 2015-07-14 20:41:14 +08:00
Asias He
1828019d60 streaming: Convert StreamManager.java to C++ 2015-07-14 20:41:14 +08:00
Asias He
85d9204d0e streaming: Drop connection_handler
stream_session::stream_session(inet_address peer_, inet_address connecting_,
    int index_, bool keep_ss_table_level_)
    : peer(peer_)
    , connecting(connecting_)
    , conn_handler(shared_from_this())

Calling shared_from_this() inside stream_session's constructor is
problematic. I got

   Exiting on unhandled exception of type 'std::bad_weak_ptr': bad_weak_ptr

exceptions, with

   auto session = std::make_shared<stream_session>(peer, connecting, size, _keep_ss_table_level)

Also, the logic in connection_handler is not very useful for us. The
sending and receiving of messages are handled using messaging_service.
There is no need to add another layer.
2015-07-14 20:41:14 +08:00
Asias He
14ae9e66ae streaming: Use shared_ptr to track back to stream_session
I tried our lw_shared_ptr, the compiler complained endless usage of
incomplete type stream_session. I can not include stream_session.hh
everywhere due to circular dependency.

For now, I'm using std::shared_ptr which works fine.
2015-07-14 20:41:14 +08:00
Asias He
7ae860a43a streaming: Enable init_receiving_side 2015-07-09 15:52:28 +08:00
Asias He
92dd0616fa streaming: Wire up stream_result_future in stream_session 2015-06-30 16:39:12 +08:00
Asias He
212a70f42f streaming: Add constructor for stream_result_future 2015-06-30 16:08:53 +08:00
Asias He
60449c4b59 streaming: Convert StreamResultFuture to C++ 2015-06-30 16:00:56 +08:00