Skip to content

Commit

Permalink
transport: Keep gossiper on server
Browse files Browse the repository at this point in the history
The gossiper is needed by the transport::event_notifier. There's
already gossiper reference on the transport controller, but it's
a local reference, because controller doesn't need more. This
patch upgrages controller reference to sharded<> and propagates
it further up to the server.

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Nov 25, 2021
1 parent 831f18e commit 4395131
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ int main(int ac, char** av) {
db.revert_initial_system_read_concurrency_boost();
}).get();

cql_transport::controller cql_server_ctl(auth_service, mm_notifier, gossiper.local(), qp, service_memory_limiter, sl_controller, lifecycle_notifier, *cfg);
cql_transport::controller cql_server_ctl(auth_service, mm_notifier, gossiper, qp, service_memory_limiter, sl_controller, lifecycle_notifier, *cfg);

ss.local().register_protocol_server(cql_server_ctl);

Expand Down
6 changes: 3 additions & 3 deletions transport/controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace cql_transport {
static logging::logger logger("cql_server_controller");

controller::controller(sharded<auth::service>& auth, sharded<service::migration_notifier>& mn,
gms::gossiper& gossiper, sharded<cql3::query_processor>& qp, sharded<service::memory_limiter>& ml,
sharded<gms::gossiper>& gossiper, sharded<cql3::query_processor>& qp, sharded<service::memory_limiter>& ml,
sharded<qos::service_level_controller>& sl_controller, sharded<service::endpoint_lifecycle_notifier>& elc_notif,
const db::config& cfg)
: _ops_sem(1)
Expand Down Expand Up @@ -155,7 +155,7 @@ future<> controller::do_start_server() {
}
}

cserver->start(std::ref(_qp), std::ref(_auth_service), std::ref(_mem_limiter), cql_server_config, std::ref(cfg), std::ref(_sl_controller)).get();
cserver->start(std::ref(_qp), std::ref(_auth_service), std::ref(_mem_limiter), cql_server_config, std::ref(cfg), std::ref(_sl_controller), std::ref(_gossiper)).get();
auto on_error = defer([&cserver] { cserver->stop().get(); });

subscribe_server(*cserver).get();
Expand Down Expand Up @@ -235,7 +235,7 @@ future<> controller::unsubscribe_server(sharded<cql_server>& server) {
}

future<> controller::set_cql_ready(bool ready) {
return _gossiper.add_local_application_state(gms::application_state::RPC_READY, gms::versioned_value::cql_ready(ready));
return _gossiper.local().add_local_application_state(gms::application_state::RPC_READY, gms::versioned_value::cql_ready(ready));
}

} // namespace cql_transport
4 changes: 2 additions & 2 deletions transport/controller.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class controller : public protocol_server {
sharded<auth::service>& _auth_service;
sharded<service::migration_notifier>& _mnotifier;
sharded<service::endpoint_lifecycle_notifier>& _lifecycle_notifier;
gms::gossiper& _gossiper;
sharded<gms::gossiper>& _gossiper;
sharded<cql3::query_processor>& _qp;
sharded<service::memory_limiter>& _mem_limiter;
sharded<qos::service_level_controller>& _sl_controller;
Expand All @@ -66,7 +66,7 @@ class controller : public protocol_server {
future<> unsubscribe_server(sharded<cql_server>& server);

public:
controller(sharded<auth::service>&, sharded<service::migration_notifier>&, gms::gossiper&,
controller(sharded<auth::service>&, sharded<service::migration_notifier>&, sharded<gms::gossiper>&,
sharded<cql3::query_processor>&, sharded<service::memory_limiter>&,
sharded<qos::service_level_controller>&, sharded<service::endpoint_lifecycle_notifier>&,
const db::config& cfg);
Expand Down
4 changes: 3 additions & 1 deletion transport/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ event::event_type parse_event_type(const sstring& value)
}

cql_server::cql_server(distributed<cql3::query_processor>& qp, auth::service& auth_service,
service::memory_limiter& ml, cql_server_config config, const db::config& db_cfg, qos::service_level_controller& sl_controller)
service::memory_limiter& ml, cql_server_config config, const db::config& db_cfg,
qos::service_level_controller& sl_controller, gms::gossiper& g)
: server("CQLServer", clogger)
, _query_processor(qp)
, _config(config)
Expand All @@ -162,6 +163,7 @@ cql_server::cql_server(distributed<cql3::query_processor>& qp, auth::service& au
, _notifier(std::make_unique<event_notifier>())
, _auth_service(auth_service)
, _sl_controller(sl_controller)
, _gossiper(g)
{
namespace sm = seastar::metrics;

Expand Down
8 changes: 7 additions & 1 deletion transport/server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ namespace qos {
class service_level_controller;
} // namespace qos

namespace gms {
class gossiper;
}

namespace cql_transport {

class request_reader;
Expand Down Expand Up @@ -168,12 +172,14 @@ private:
transport_stats _stats = {};
auth::service& _auth_service;
qos::service_level_controller& _sl_controller;
gms::gossiper& _gossiper;
public:
cql_server(distributed<cql3::query_processor>& qp, auth::service&,
service::memory_limiter& ml,
cql_server_config config,
const db::config& db_cfg,
qos::service_level_controller& sl_controller);
qos::service_level_controller& sl_controller,
gms::gossiper& g);
public:
using response = cql_transport::response;
service::endpoint_lifecycle_subscriber* get_lifecycle_listener() const noexcept;
Expand Down

0 comments on commit 4395131

Please sign in to comment.