diff --git a/api/api.hh b/api/api.hh index 7cd35365c9..27433596a6 100644 --- a/api/api.hh +++ b/api/api.hh @@ -29,6 +29,7 @@ #include "utils/histogram.hh" #include "http/exception.hh" #include "api_init.hh" +#include "seastarx.hh" namespace api { diff --git a/api/lsa.cc b/api/lsa.cc index a57d872d09..c6bb624a9f 100644 --- a/api/lsa.cc +++ b/api/lsa.cc @@ -29,11 +29,11 @@ namespace api { -static logging::logger logger("lsa-api"); +static logging::logger alogger("lsa-api"); void set_lsa(http_context& ctx, routes& r) { httpd::lsa_json::lsa_compact.set(r, [&ctx](std::unique_ptr req) { - logger.info("Triggering compaction"); + alogger.info("Triggering compaction"); return ctx.db.invoke_on_all([] (database&) { logalloc::shard_tracker().reclaim(std::numeric_limits::max()); }).then([] { diff --git a/api/messaging_service.cc b/api/messaging_service.cc index 6c5d19c0cd..a646d45a1a 100644 --- a/api/messaging_service.cc +++ b/api/messaging_service.cc @@ -27,7 +27,7 @@ #include using namespace httpd::messaging_service_json; -using namespace net; +using namespace netw; namespace api { @@ -120,13 +120,13 @@ void set_messaging_service(http_context& ctx, routes& r) { })); get_version.set(r, [](const_req req) { - return net::get_local_messaging_service().get_raw_version(req.get_query_param("addr")); + return netw::get_local_messaging_service().get_raw_version(req.get_query_param("addr")); }); get_dropped_messages_by_ver.set(r, [](std::unique_ptr req) { shared_ptr> map = make_shared>(num_verb); - return net::get_messaging_service().map_reduce([map](const uint64_t* local_map) mutable { + return netw::get_messaging_service().map_reduce([map](const uint64_t* local_map) mutable { for (auto i = 0; i < num_verb; i++) { (*map)[i]+= local_map[i]; } diff --git a/auth/auth.cc b/auth/auth.cc index 63cf91fc80..8af93f3c9c 100644 --- a/auth/auth.cc +++ b/auth/auth.cc @@ -61,7 +61,7 @@ const sstring auth::auth::USERS_CF("users"); static const sstring USER_NAME("name"); static const sstring SUPER("super"); -static logging::logger logger("auth"); +static logging::logger alogger("auth"); // TODO: configurable using namespace std::chrono_literals; @@ -123,9 +123,9 @@ public: } permissions_cache(const db::config& cfg) - : _cache(cfg.permissions_cache_max_entries(), std::chrono::milliseconds(cfg.permissions_validity_in_ms()), std::chrono::milliseconds(cfg.permissions_update_interval_in_ms()), logger, + : _cache(cfg.permissions_cache_max_entries(), std::chrono::milliseconds(cfg.permissions_validity_in_ms()), std::chrono::milliseconds(cfg.permissions_update_interval_in_ms()), alogger, [] (const key_type& k) { - logger.debug("Refreshing permissions for {}", k.first.name()); + alogger.debug("Refreshing permissions for {}", k.first.name()); return authorizer::get().authorize(::make_shared(k.first), k.second); }) {} @@ -141,11 +141,15 @@ private: cache_type _cache; }; +namespace std { // for ADL, yuch + std::ostream& operator<<(std::ostream& os, const std::pair& p) { os << "{user: " << p.first.name() << ", data_resource: " << p.second << "}"; return os; } +} + static distributed perm_cache; /** @@ -172,7 +176,7 @@ struct waiter { tmr.cancel(); done.set_exception(std::runtime_error("shutting down")); } - logger.trace("Deleting scheduled task"); + alogger.trace("Deleting scheduled task"); } void kill() { } @@ -186,7 +190,7 @@ static std::vector & thread_waiters() { } void auth::auth::schedule_when_up(scheduled_func f) { - logger.trace("Adding scheduled task"); + alogger.trace("Adding scheduled task"); auto & waiters = thread_waiters(); @@ -202,7 +206,7 @@ void auth::auth::schedule_when_up(scheduled_func f) { waiters.erase(i); } }).then([f = std::move(f)] { - logger.trace("Running scheduled task"); + alogger.trace("Running scheduled task"); return f(); }).handle_exception([](auto ep) { return make_ready_future(); @@ -262,12 +266,12 @@ future<> auth::auth::setup() { auto query = sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?) USING TIMESTAMP 0", AUTH_KS, USERS_CF, USER_NAME, SUPER); cql3::get_local_query_processor().process(query, db::consistency_level::ONE, {DEFAULT_SUPERUSER_NAME, true}).then([](auto) { - logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME); + alogger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME); }).handle_exception([](auto ep) { try { std::rethrow_exception(ep); } catch (exceptions::request_execution_exception&) { - logger.warn("Skipped default superuser setup: some nodes were not ready"); + alogger.warn("Skipped default superuser setup: some nodes were not ready"); } }); } diff --git a/auth/authenticated_user.hh b/auth/authenticated_user.hh index 24d004bfe2..b265537532 100644 --- a/auth/authenticated_user.hh +++ b/auth/authenticated_user.hh @@ -43,6 +43,7 @@ #include #include +#include "seastarx.hh" namespace auth { diff --git a/auth/authorizer.hh b/auth/authorizer.hh index 93166d5612..f949d68e5e 100644 --- a/auth/authorizer.hh +++ b/auth/authorizer.hh @@ -51,6 +51,8 @@ #include "permission.hh" #include "data_resource.hh" +#include "seastarx.hh" + namespace auth { class authenticated_user; diff --git a/auth/data_resource.hh b/auth/data_resource.hh index 2b1deb446d..3b365fbda3 100644 --- a/auth/data_resource.hh +++ b/auth/data_resource.hh @@ -45,6 +45,7 @@ #include #include #include +#include "seastarx.hh" namespace auth { diff --git a/auth/default_authorizer.cc b/auth/default_authorizer.cc index ae948ff144..14931801f2 100644 --- a/auth/default_authorizer.cc +++ b/auth/default_authorizer.cc @@ -62,7 +62,7 @@ static const sstring RESOURCE_NAME = "resource"; static const sstring PERMISSIONS_NAME = "permissions"; static const sstring PERMISSIONS_CF = "permissions"; -static logging::logger logger("default_authorizer"); +static logging::logger alogger("default_authorizer"); auth::default_authorizer::default_authorizer() { } @@ -107,7 +107,7 @@ future auth::default_authorizer::authorize( } return make_ready_future(permissions::from_strings(res->one().get_set(PERMISSIONS_NAME))); } catch (exceptions::request_execution_exception& e) { - logger.warn("CassandraAuthorizer failed to authorize {} for {}", user->name(), resource); + alogger.warn("CassandraAuthorizer failed to authorize {} for {}", user->name(), resource); return make_ready_future(permissions::NONE); } }); @@ -196,7 +196,7 @@ future<> auth::default_authorizer::revoke_all(sstring dropped_user) { try { std::rethrow_exception(ep); } catch (exceptions::request_execution_exception& e) { - logger.warn("CassandraAuthorizer failed to revoke all permissions of {}: {}", dropped_user, e); + alogger.warn("CassandraAuthorizer failed to revoke all permissions of {}: {}", dropped_user, e); } }); } @@ -217,13 +217,13 @@ future<> auth::default_authorizer::revoke_all(data_resource resource) { try { std::rethrow_exception(ep); } catch (exceptions::request_execution_exception& e) { - logger.warn("CassandraAuthorizer failed to revoke all permissions on {}: {}", resource, e); + alogger.warn("CassandraAuthorizer failed to revoke all permissions on {}: {}", resource, e); } }); }); } catch (exceptions::request_execution_exception& e) { - logger.warn("CassandraAuthorizer failed to revoke all permissions on {}: {}", resource, e); + alogger.warn("CassandraAuthorizer failed to revoke all permissions on {}: {}", resource, e); return make_ready_future(); } }); diff --git a/auth/password_authenticator.cc b/auth/password_authenticator.cc index 118baee8ea..a65d20a7c3 100644 --- a/auth/password_authenticator.cc +++ b/auth/password_authenticator.cc @@ -61,7 +61,7 @@ static const sstring DEFAULT_USER_NAME = auth::auth::DEFAULT_SUPERUSER_NAME; static const sstring DEFAULT_USER_PASSWORD = auth::auth::DEFAULT_SUPERUSER_NAME; static const sstring CREDENTIALS_CF = "credentials"; -static logging::logger logger("password_authenticator"); +static logging::logger plogger("password_authenticator"); auth::password_authenticator::~password_authenticator() {} @@ -169,7 +169,7 @@ future<> auth::password_authenticator::init() { USER_NAME, SALTED_HASH ), db::consistency_level::ONE, {DEFAULT_USER_NAME, hashpw(DEFAULT_USER_PASSWORD)}).then([](auto) { - logger.info("Created default user '{}'", DEFAULT_USER_NAME); + plogger.info("Created default user '{}'", DEFAULT_USER_NAME); }); } }); @@ -302,7 +302,7 @@ const auth::resource_ids& auth::password_authenticator::protected_resources() co * @throws javax.security.sasl.SaslException */ bytes evaluate_response(bytes_view client_response) override { - logger.debug("Decoding credentials from client token"); + plogger.debug("Decoding credentials from client token"); sstring username, password; diff --git a/auth/permission.hh b/auth/permission.hh index fe6458ad79..6d3e7e5a49 100644 --- a/auth/permission.hh +++ b/auth/permission.hh @@ -44,6 +44,7 @@ #include #include +#include "seastarx.hh" #include "enum_set.hh" namespace auth { diff --git a/bytes.hh b/bytes.hh index db03dcbb71..a4ea9fd82b 100644 --- a/bytes.hh +++ b/bytes.hh @@ -21,6 +21,7 @@ #pragma once +#include "seastarx.hh" #include "core/sstring.hh" #include "hashing.hh" #include diff --git a/caching_options.hh b/caching_options.hh index 3ec409da3b..c7bc37020a 100644 --- a/caching_options.hh +++ b/caching_options.hh @@ -24,6 +24,7 @@ #include #include "exceptions/exceptions.hh" #include "json.hh" +#include "seastarx.hh" class schema; diff --git a/cql3/cql_statement.hh b/cql3/cql_statement.hh index 46c8257b64..8a5e0cb69b 100644 --- a/cql3/cql_statement.hh +++ b/cql3/cql_statement.hh @@ -46,7 +46,7 @@ #include "service/storage_proxy.hh" #include "cql3/query_options.hh" -namespace transport { +namespace cql_transport { namespace messages { @@ -89,7 +89,7 @@ public: * @param state the current query state * @param options options for this query (consistency, variables, pageSize, ...) */ - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& state, const query_options& options) = 0; /** @@ -97,7 +97,7 @@ public: * * @param state the current query state */ - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) = 0; virtual bool uses_function(const sstring& ks_name, const sstring& function_name) const = 0; diff --git a/cql3/error_listener.hh b/cql3/error_listener.hh index b321b3ba57..7cff980832 100644 --- a/cql3/error_listener.hh +++ b/cql3/error_listener.hh @@ -41,6 +41,7 @@ #pragma once +#include "seastarx.hh" #include #include diff --git a/cql3/keyspace_element_name.hh b/cql3/keyspace_element_name.hh index 2eb9292764..f47df2f81f 100644 --- a/cql3/keyspace_element_name.hh +++ b/cql3/keyspace_element_name.hh @@ -42,6 +42,7 @@ #pragma once #include "core/sstring.hh" +#include "seastarx.hh" #include diff --git a/cql3/operator.hh b/cql3/operator.hh index cb64057e53..d9af7ecaec 100644 --- a/cql3/operator.hh +++ b/cql3/operator.hh @@ -44,6 +44,7 @@ #include #include #include "core/sstring.hh" +#include "seastarx.hh" namespace cql3 { diff --git a/cql3/query_processor.cc b/cql3/query_processor.cc index 3e0b528416..e15f5cfa40 100644 --- a/cql3/query_processor.cc +++ b/cql3/query_processor.cc @@ -54,7 +54,7 @@ namespace cql3 { using namespace statements; -using namespace transport::messages; +using namespace cql_transport::messages; logging::logger log("query_processor"); @@ -179,7 +179,7 @@ query_processor::process_statement(::shared_ptr statement, statement->validate(_proxy, client_state); - auto fut = make_ready_future<::shared_ptr>(); + auto fut = make_ready_future<::shared_ptr>(); if (client_state.is_internal()) { fut = statement->execute_internal(_proxy, query_state, options); } else { @@ -196,24 +196,24 @@ query_processor::process_statement(::shared_ptr statement, }); } -future<::shared_ptr> +future<::shared_ptr> query_processor::prepare(const std::experimental::string_view& query_string, service::query_state& query_state) { auto& client_state = query_state.get_client_state(); return prepare(query_string, client_state, client_state.is_thrift()); } -future<::shared_ptr> +future<::shared_ptr> query_processor::prepare(const std::experimental::string_view& query_string, const service::client_state& client_state, bool for_thrift) { auto existing = get_stored_prepared_statement(query_string, client_state.get_raw_keyspace(), for_thrift); if (existing) { - return make_ready_future<::shared_ptr>(existing); + return make_ready_future<::shared_ptr>(existing); } - return futurize<::shared_ptr>::apply([this, &query_string, &client_state, for_thrift] { + return futurize<::shared_ptr>::apply([this, &query_string, &client_state, for_thrift] { auto prepared = get_statement(query_string, client_state); auto bound_terms = prepared->statement->get_bound_terms(); if (bound_terms > std::numeric_limits::max()) { @@ -224,7 +224,7 @@ query_processor::prepare(const std::experimental::string_view& query_string, }); } -::shared_ptr +::shared_ptr query_processor::get_stored_prepared_statement(const std::experimental::string_view& query_string, const sstring& keyspace, bool for_thrift) @@ -246,7 +246,7 @@ query_processor::get_stored_prepared_statement(const std::experimental::string_v } } -future<::shared_ptr> +future<::shared_ptr> query_processor::store_prepared_statement(const std::experimental::string_view& query_string, const sstring& keyspace, std::unique_ptr prepared, @@ -427,7 +427,7 @@ query_processor::process(statements::prepared_statement::checked_weak_ptr p, }); } -future<::shared_ptr> +future<::shared_ptr> query_processor::process_batch(::shared_ptr batch, service::query_state& query_state, query_options& options) diff --git a/cql3/query_processor.hh b/cql3/query_processor.hh index d6014535d5..0e4ed6056c 100644 --- a/cql3/query_processor.hh +++ b/cql3/query_processor.hh @@ -275,7 +275,7 @@ public: } #endif public: - future<::shared_ptr> process_statement(::shared_ptr statement, + future<::shared_ptr> process_statement(::shared_ptr statement, service::query_state& query_state, const query_options& options); #if 0 @@ -286,7 +286,7 @@ public: } #endif - future<::shared_ptr> process(const std::experimental::string_view& query_string, + future<::shared_ptr> process(const std::experimental::string_view& query_string, service::query_state& query_state, query_options& options); #if 0 @@ -434,20 +434,20 @@ public: } #endif - future<::shared_ptr> + future<::shared_ptr> prepare(const std::experimental::string_view& query_string, service::query_state& query_state); - future<::shared_ptr> + future<::shared_ptr> prepare(const std::experimental::string_view& query_string, const service::client_state& client_state, bool for_thrift); static bytes compute_id(const std::experimental::string_view& query_string, const sstring& keyspace); static int32_t compute_thrift_id(const std::experimental::string_view& query_string, const sstring& keyspace); private: - ::shared_ptr + ::shared_ptr get_stored_prepared_statement(const std::experimental::string_view& query_string, const sstring& keyspace, bool for_thrift); - future<::shared_ptr> + future<::shared_ptr> store_prepared_statement(const std::experimental::string_view& query_string, const sstring& keyspace, std::unique_ptr prepared, bool for_thrift); // Erases the statements for which filter returns true. @@ -497,7 +497,7 @@ private: #endif public: - future<::shared_ptr> process_batch(::shared_ptr, + future<::shared_ptr> process_batch(::shared_ptr, service::query_state& query_state, query_options& options); std::unique_ptr get_statement(const std::experimental::string_view& query, diff --git a/cql3/statements/alter_keyspace_statement.cc b/cql3/statements/alter_keyspace_statement.cc index b76413d532..93fed2d8aa 100644 --- a/cql3/statements/alter_keyspace_statement.cc +++ b/cql3/statements/alter_keyspace_statement.cc @@ -89,10 +89,10 @@ void cql3::statements::alter_keyspace_statement::validate(distributed> cql3::statements::alter_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) { +future> cql3::statements::alter_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) { auto old_ksm = service::get_local_storage_proxy().get_db().local().find_keyspace(_name).metadata(); return service::get_local_migration_manager().announce_keyspace_update(_attrs->as_ks_metadata_update(old_ksm), is_local_only).then([this] { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::UPDATED, keyspace()); diff --git a/cql3/statements/alter_keyspace_statement.hh b/cql3/statements/alter_keyspace_statement.hh index 188b60a50b..6cc2d9d584 100644 --- a/cql3/statements/alter_keyspace_statement.hh +++ b/cql3/statements/alter_keyspace_statement.hh @@ -61,7 +61,7 @@ public: future<> check_access(const service::client_state& state) override; void validate(distributed& proxy, const service::client_state& state) override; - future> announce_migration(distributed& proxy, bool is_local_only) override; + future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/alter_table_statement.cc b/cql3/statements/alter_table_statement.cc index be5be6c5d5..32eca0061b 100644 --- a/cql3/statements/alter_table_statement.cc +++ b/cql3/statements/alter_table_statement.cc @@ -166,7 +166,7 @@ static void validate_column_rename(const schema& schema, const column_identifier } } -future> alter_table_statement::announce_migration(distributed& proxy, bool is_local_only) +future> alter_table_statement::announce_migration(distributed& proxy, bool is_local_only) { auto& db = proxy.local().get_db().local(); auto schema = validation::validate_column_family(db, keyspace(), column_family()); @@ -370,7 +370,7 @@ future> alter_table_statement::annou } return service::get_local_migration_manager().announce_column_family_update(cfm.build(), false, std::move(view_updates), is_local_only).then([this] { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::UPDATED, event::schema_change::target_type::TABLE, diff --git a/cql3/statements/alter_table_statement.hh b/cql3/statements/alter_table_statement.hh index 54bb1f7ddc..14b03d25ac 100644 --- a/cql3/statements/alter_table_statement.hh +++ b/cql3/statements/alter_table_statement.hh @@ -78,7 +78,7 @@ public: virtual future<> check_access(const service::client_state& state) override; virtual void validate(distributed& proxy, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/alter_type_statement.cc b/cql3/statements/alter_type_statement.cc index 7c47b68226..8c6b83610d 100644 --- a/cql3/statements/alter_type_statement.cc +++ b/cql3/statements/alter_type_statement.cc @@ -135,14 +135,14 @@ void alter_type_statement::do_announce_migration(database& db, ::keyspace& ks, b } } -future> alter_type_statement::announce_migration(distributed& proxy, bool is_local_only) +future> alter_type_statement::announce_migration(distributed& proxy, bool is_local_only) { return seastar::async([this, &proxy, is_local_only] { auto&& db = proxy.local().get_db().local(); try { auto&& ks = db.find_keyspace(keyspace()); do_announce_migration(db, ks, is_local_only); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::UPDATED, event::schema_change::target_type::TYPE, diff --git a/cql3/statements/alter_type_statement.hh b/cql3/statements/alter_type_statement.hh index 6735bd7488..bd5143baae 100644 --- a/cql3/statements/alter_type_statement.hh +++ b/cql3/statements/alter_type_statement.hh @@ -63,7 +63,7 @@ public: virtual const sstring& keyspace() const override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; class add_or_alter; class renames; diff --git a/cql3/statements/alter_user_statement.cc b/cql3/statements/alter_user_statement.cc index 4f86f65741..c361c99f85 100644 --- a/cql3/statements/alter_user_statement.cc +++ b/cql3/statements/alter_user_statement.cc @@ -92,7 +92,7 @@ future<> cql3::statements::alter_user_statement::check_access(const service::cli }); } -future<::shared_ptr> +future<::shared_ptr> cql3::statements::alter_user_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return auth::auth::is_existing_user(_username).then([this](bool exists) { if (!exists) { @@ -104,7 +104,7 @@ cql3::statements::alter_user_statement::execute(distributed>(); }); + return f.then([] { return make_ready_future<::shared_ptr>(); }); }); } diff --git a/cql3/statements/alter_user_statement.hh b/cql3/statements/alter_user_statement.hh index d05a0616a0..e30eeb1e07 100644 --- a/cql3/statements/alter_user_statement.hh +++ b/cql3/statements/alter_user_statement.hh @@ -62,7 +62,7 @@ public: void validate(distributed&, const service::client_state&) override; future<> check_access(const service::client_state&) override; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/alter_view_statement.cc b/cql3/statements/alter_view_statement.cc index 8cd78f28af..6d494b736b 100644 --- a/cql3/statements/alter_view_statement.cc +++ b/cql3/statements/alter_view_statement.cc @@ -73,7 +73,7 @@ void alter_view_statement::validate(distributed&, const // validated in announce_migration() } -future> alter_view_statement::announce_migration(distributed& proxy, bool is_local_only) +future> alter_view_statement::announce_migration(distributed& proxy, bool is_local_only) { auto&& db = proxy.local().get_db().local(); schema_ptr schema = validation::validate_column_family(db, keyspace(), column_family()); @@ -105,7 +105,7 @@ future> alter_view_statement::announ } return service::get_local_migration_manager().announce_view_update(view_ptr(builder.build()), is_local_only).then([this] { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::UPDATED, diff --git a/cql3/statements/alter_view_statement.hh b/cql3/statements/alter_view_statement.hh index 621089b264..154f9b5c3d 100644 --- a/cql3/statements/alter_view_statement.hh +++ b/cql3/statements/alter_view_statement.hh @@ -63,7 +63,7 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/authentication_statement.cc b/cql3/statements/authentication_statement.cc index 7cd420e4ae..3977e4b900 100644 --- a/cql3/statements/authentication_statement.cc +++ b/cql3/statements/authentication_statement.cc @@ -75,7 +75,7 @@ future<> cql3::statements::authentication_statement::check_access(const service: return make_ready_future<>(); } -future<::shared_ptr> cql3::statements::authentication_statement::execute_internal( +future<::shared_ptr> cql3::statements::authentication_statement::execute_internal( distributed& proxy, service::query_state& state, const query_options& options) { // Internal queries are exclusively on the system keyspace and makes no sense here diff --git a/cql3/statements/authentication_statement.hh b/cql3/statements/authentication_statement.hh index d2dfff9fa3..1dd23a1c4a 100644 --- a/cql3/statements/authentication_statement.hh +++ b/cql3/statements/authentication_statement.hh @@ -66,7 +66,7 @@ public: void validate(distributed&, const service::client_state& state) override; - future<::shared_ptr> + future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) override; }; diff --git a/cql3/statements/authorization_statement.cc b/cql3/statements/authorization_statement.cc index b76a4b07f0..ba881dd819 100644 --- a/cql3/statements/authorization_statement.cc +++ b/cql3/statements/authorization_statement.cc @@ -75,7 +75,7 @@ future<> cql3::statements::authorization_statement::check_access(const service:: return make_ready_future<>(); } -future<::shared_ptr> cql3::statements::authorization_statement::execute_internal( +future<::shared_ptr> cql3::statements::authorization_statement::execute_internal( distributed& proxy, service::query_state& state, const query_options& options) { // Internal queries are exclusively on the system keyspace and makes no sense here diff --git a/cql3/statements/authorization_statement.hh b/cql3/statements/authorization_statement.hh index ffc882e153..36ec2b46bb 100644 --- a/cql3/statements/authorization_statement.hh +++ b/cql3/statements/authorization_statement.hh @@ -70,7 +70,7 @@ public: void validate(distributed&, const service::client_state& state) override; - future<::shared_ptr> + future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) override; protected: diff --git a/cql3/statements/batch_statement.cc b/cql3/statements/batch_statement.cc index 0053f8415d..fac623ddb0 100644 --- a/cql3/statements/batch_statement.cc +++ b/cql3/statements/batch_statement.cc @@ -273,14 +273,14 @@ struct batch_statement_executor { }; static thread_local auto batch_stage = seastar::make_execution_stage("cql3_batch", batch_statement_executor::get()); -future> batch_statement::execute( +future> batch_statement::execute( distributed& storage, service::query_state& state, const query_options& options) { ++_stats.batches; return batch_stage(this, seastar::ref(storage), seastar::ref(state), seastar::cref(options), false, options.get_timestamp(state)); } -future> batch_statement::do_execute( +future> batch_statement::do_execute( distributed& storage, service::query_state& query_state, const query_options& options, bool local, api::timestamp_type now) @@ -299,8 +299,8 @@ future> batch_statement::do_exec return get_mutations(storage, options, local, now, query_state.get_trace_state()).then([this, &storage, &options, tr_state = query_state.get_trace_state()] (std::vector ms) mutable { return execute_without_conditions(storage, std::move(ms), options.get_consistency(), std::move(tr_state)); }).then([] { - return make_ready_future>( - make_shared()); + return make_ready_future>( + make_shared()); }); } @@ -338,7 +338,7 @@ future<> batch_statement::execute_without_conditions( return storage.local().mutate_with_triggers(std::move(mutations), cl, mutate_atomic, std::move(tr_state)); } -future> batch_statement::execute_with_conditions( +future> batch_statement::execute_with_conditions( distributed& storage, const query_options& options, service::query_state& state) @@ -391,7 +391,7 @@ future> batch_statement::execute #endif } -future> batch_statement::execute_internal( +future> batch_statement::execute_internal( distributed& proxy, service::query_state& query_state, const query_options& options) { diff --git a/cql3/statements/batch_statement.hh b/cql3/statements/batch_statement.hh index d7c90a7845..e156bba483 100644 --- a/cql3/statements/batch_statement.hh +++ b/cql3/statements/batch_statement.hh @@ -120,11 +120,11 @@ public: */ static void verify_batch_size(const std::vector& mutations); - virtual future> execute( + virtual future> execute( distributed& storage, service::query_state& state, const query_options& options) override; private: friend class batch_statement_executor; - future> do_execute( + future> do_execute( distributed& storage, service::query_state& query_state, const query_options& options, bool local, api::timestamp_type now); @@ -135,12 +135,12 @@ private: db::consistency_level cl, tracing::trace_state_ptr tr_state); - future> execute_with_conditions( + future> execute_with_conditions( distributed& storage, const query_options& options, service::query_state& state); public: - virtual future> execute_internal( + virtual future> execute_internal( distributed& proxy, service::query_state& query_state, const query_options& options) override; diff --git a/cql3/statements/create_index_statement.cc b/cql3/statements/create_index_statement.cc index c69a9136e3..91403fb88c 100644 --- a/cql3/statements/create_index_statement.cc +++ b/cql3/statements/create_index_statement.cc @@ -202,7 +202,7 @@ void create_index_statement::validate_targets_for_multi_column_index(std::vector } } -future<::shared_ptr> +future<::shared_ptr> create_index_statement::announce_migration(distributed& proxy, bool is_local_only) { if (!service::get_local_storage_service().cluster_supports_indexes()) { throw exceptions::invalid_request_exception("Index support is not enabled"); @@ -233,7 +233,7 @@ create_index_statement::announce_migration(distributed& auto existing_index = schema->find_index_noname(index); if (existing_index) { if (_if_not_exists) { - return make_ready_future<::shared_ptr>(nullptr); + return make_ready_future<::shared_ptr>(nullptr); } else { throw exceptions::invalid_request_exception( sprint("Index %s is a duplicate of existing index %s", index.name(), existing_index.value().name())); @@ -243,7 +243,7 @@ create_index_statement::announce_migration(distributed& builder.with_index(index); return service::get_local_migration_manager().announce_column_family_update( builder.build(), false, {}, is_local_only).then([this]() { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::UPDATED, event::schema_change::target_type::TABLE, diff --git a/cql3/statements/create_index_statement.hh b/cql3/statements/create_index_statement.hh index 88584525d5..04bb06307a 100644 --- a/cql3/statements/create_index_statement.hh +++ b/cql3/statements/create_index_statement.hh @@ -79,7 +79,7 @@ public: future<> check_access(const service::client_state& state) override; void validate(distributed&, const service::client_state& state) override; - future<::shared_ptr> announce_migration(distributed&, bool is_local_only) override; + future<::shared_ptr> announce_migration(distributed&, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; private: diff --git a/cql3/statements/create_keyspace_statement.cc b/cql3/statements/create_keyspace_statement.cc index bef16f5111..627b36353b 100644 --- a/cql3/statements/create_keyspace_statement.cc +++ b/cql3/statements/create_keyspace_statement.cc @@ -101,20 +101,20 @@ void create_keyspace_statement::validate(distributed&, c #endif } -future> create_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) +future> create_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) { return make_ready_future<>().then([this, is_local_only] { return service::get_local_migration_manager().announce_new_keyspace(_attrs->as_ks_metadata(_name), is_local_only); }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::CREATED, this->keyspace()); } catch (const exceptions::already_exists_exception& e) { if (_if_not_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/create_keyspace_statement.hh b/cql3/statements/create_keyspace_statement.hh index cb4ac510e9..13487a32b1 100644 --- a/cql3/statements/create_keyspace_statement.hh +++ b/cql3/statements/create_keyspace_statement.hh @@ -81,7 +81,7 @@ public: */ virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/create_table_statement.cc b/cql3/statements/create_table_statement.cc index cca91533e6..0d8b60b386 100644 --- a/cql3/statements/create_table_statement.cc +++ b/cql3/statements/create_table_statement.cc @@ -89,13 +89,13 @@ std::vector create_table_statement::get_columns() return column_defs; } -future> create_table_statement::announce_migration(distributed& proxy, bool is_local_only) { +future> create_table_statement::announce_migration(distributed& proxy, bool is_local_only) { return make_ready_future<>().then([this, is_local_only] { return service::get_local_migration_manager().announce_new_column_family(get_cf_meta_data(), is_local_only); }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::CREATED, event::schema_change::target_type::TABLE, @@ -103,7 +103,7 @@ future> create_table_statement::anno this->column_family()); } catch (const exceptions::already_exists_exception& e) { if (_if_not_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/create_table_statement.hh b/cql3/statements/create_table_statement.hh index 8fec020356..521ca2be29 100644 --- a/cql3/statements/create_table_statement.hh +++ b/cql3/statements/create_table_statement.hh @@ -100,7 +100,7 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; diff --git a/cql3/statements/create_type_statement.cc b/cql3/statements/create_type_statement.cc index a31a38e64f..ba89003741 100644 --- a/cql3/statements/create_type_statement.cc +++ b/cql3/statements/create_type_statement.cc @@ -129,7 +129,7 @@ inline user_type create_type_statement::create_type(database& db) std::move(field_names), std::move(field_types)); } -future> create_type_statement::announce_migration(distributed& proxy, bool is_local_only) +future> create_type_statement::announce_migration(distributed& proxy, bool is_local_only) { auto&& db = proxy.local().get_db().local(); @@ -138,13 +138,13 @@ future> create_type_statement::annou // Can happen with if_not_exists if (type_exists_in(ks)) { - return make_ready_future<::shared_ptr>(); + return make_ready_future<::shared_ptr>(); } auto type = create_type(db); check_for_duplicate_names(type); return service::get_local_migration_manager().announce_new_type(type, is_local_only).then([this] { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::CREATED, diff --git a/cql3/statements/create_type_statement.hh b/cql3/statements/create_type_statement.hh index 4dd8c02f2d..28159b8737 100644 --- a/cql3/statements/create_type_statement.hh +++ b/cql3/statements/create_type_statement.hh @@ -65,7 +65,7 @@ public: virtual const sstring& keyspace() const override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; diff --git a/cql3/statements/create_user_statement.cc b/cql3/statements/create_user_statement.cc index 28821da464..2967a7b025 100644 --- a/cql3/statements/create_user_statement.cc +++ b/cql3/statements/create_user_statement.cc @@ -64,7 +64,7 @@ void cql3::statements::create_user_statement::validate(distributed continuation, and this is not a continuation method } -future<::shared_ptr> +future<::shared_ptr> cql3::statements::create_user_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return state.get_client_state().user()->is_super().then([this](bool is_super) { if (!is_super) { @@ -75,11 +75,11 @@ cql3::statements::create_user_statement::execute(distributed>(); + make_ready_future<::shared_ptr>(); } return auth::authenticator::get().create(_username, _opts->options()).then([this] { return auth::auth::insert_user(_username, _superuser).then([] { - return make_ready_future<::shared_ptr>(); + return make_ready_future<::shared_ptr>(); }); }); }); diff --git a/cql3/statements/create_user_statement.hh b/cql3/statements/create_user_statement.hh index a5d8624bed..2ca13ae7f3 100644 --- a/cql3/statements/create_user_statement.hh +++ b/cql3/statements/create_user_statement.hh @@ -60,7 +60,7 @@ public: void validate(distributed&, const service::client_state&) override; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/create_view_statement.cc b/cql3/statements/create_view_statement.cc index 7d4ea74dfe..166fac1e2b 100644 --- a/cql3/statements/create_view_statement.cc +++ b/cql3/statements/create_view_statement.cc @@ -139,7 +139,7 @@ static bool validate_primary_key( return false; } -future> create_view_statement::announce_migration(distributed& proxy, bool is_local_only) { +future> create_view_statement::announce_migration(distributed& proxy, bool is_local_only) { // We need to make sure that: // - primary key includes all columns in base table's primary key // - make sure that the select statement does not have anything other than columns @@ -328,7 +328,7 @@ future> create_view_statement::annou }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::CREATED, event::schema_change::target_type::TABLE, @@ -336,7 +336,7 @@ future> create_view_statement::annou this->column_family()); } catch (const exceptions::already_exists_exception& e) { if (_if_not_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/create_view_statement.hh b/cql3/statements/create_view_statement.hh index 4863d677f6..0ae776260c 100644 --- a/cql3/statements/create_view_statement.hh +++ b/cql3/statements/create_view_statement.hh @@ -68,7 +68,7 @@ public: // Functions we need to override to subclass schema_altering_statement virtual future<> check_access(const service::client_state& state) override; virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; // FIXME: continue here. See create_table_statement.hh and CreateViewStatement.java diff --git a/cql3/statements/drop_index_statement.cc b/cql3/statements/drop_index_statement.cc index 6d7e6e281b..2431cb8807 100644 --- a/cql3/statements/drop_index_statement.cc +++ b/cql3/statements/drop_index_statement.cc @@ -77,14 +77,14 @@ void drop_index_statement::validate(distributed&, const // validated in lookup_indexed_table() } -future> drop_index_statement::announce_migration(distributed& proxy, bool is_local_only) +future> drop_index_statement::announce_migration(distributed& proxy, bool is_local_only) { if (!service::get_local_storage_service().cluster_supports_indexes()) { throw exceptions::invalid_request_exception("Index support is not enabled"); } auto cfm = lookup_indexed_table(); if (!cfm) { - return make_ready_future<::shared_ptr>(nullptr); + return make_ready_future<::shared_ptr>(nullptr); } auto builder = schema_builder(cfm); builder.without_index(_index_name); @@ -92,7 +92,7 @@ future> drop_index_statement::announ // Dropping an index is akin to updating the CF // Note that we shouldn't call columnFamily() at this point because the index has been dropped and the call to lookupIndexedTable() // in that method would now throw. - using namespace transport; + using namespace cql_transport; return make_shared(event::schema_change::change_type::UPDATED, event::schema_change::target_type::TABLE, cfm->ks_name(), diff --git a/cql3/statements/drop_index_statement.hh b/cql3/statements/drop_index_statement.hh index db6f8f1ee6..386760c134 100644 --- a/cql3/statements/drop_index_statement.hh +++ b/cql3/statements/drop_index_statement.hh @@ -65,7 +65,7 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; private: diff --git a/cql3/statements/drop_keyspace_statement.cc b/cql3/statements/drop_keyspace_statement.cc index 15460116eb..5d0c52e30c 100644 --- a/cql3/statements/drop_keyspace_statement.cc +++ b/cql3/statements/drop_keyspace_statement.cc @@ -73,20 +73,20 @@ const sstring& drop_keyspace_statement::keyspace() const return _keyspace; } -future> drop_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) +future> drop_keyspace_statement::announce_migration(distributed& proxy, bool is_local_only) { return make_ready_future<>().then([this, is_local_only] { return service::get_local_migration_manager().announce_keyspace_drop(_keyspace, is_local_only); }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::DROPPED, this->keyspace()); } catch (const exceptions::configuration_exception& e) { if (_if_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/drop_keyspace_statement.hh b/cql3/statements/drop_keyspace_statement.hh index c669dd7aaa..bde0978835 100644 --- a/cql3/statements/drop_keyspace_statement.hh +++ b/cql3/statements/drop_keyspace_statement.hh @@ -59,7 +59,7 @@ public: virtual const sstring& keyspace() const override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/drop_table_statement.cc b/cql3/statements/drop_table_statement.cc index 09c0b36e9d..9668fc54db 100644 --- a/cql3/statements/drop_table_statement.cc +++ b/cql3/statements/drop_table_statement.cc @@ -72,14 +72,14 @@ void drop_table_statement::validate(distributed&, const // validated in announce_migration() } -future> drop_table_statement::announce_migration(distributed& proxy, bool is_local_only) +future> drop_table_statement::announce_migration(distributed& proxy, bool is_local_only) { return make_ready_future<>().then([this, is_local_only] { return service::get_local_migration_manager().announce_column_family_drop(keyspace(), column_family(), is_local_only); }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::DROPPED, event::schema_change::target_type::TABLE, @@ -87,7 +87,7 @@ future> drop_table_statement::announ this->column_family()); } catch (const exceptions::configuration_exception& e) { if (_if_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/drop_table_statement.hh b/cql3/statements/drop_table_statement.hh index 286b8ead39..1e1d6865fc 100644 --- a/cql3/statements/drop_table_statement.hh +++ b/cql3/statements/drop_table_statement.hh @@ -58,7 +58,7 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/drop_type_statement.cc b/cql3/statements/drop_type_statement.cc index b8ce984adf..4e9c5b138c 100644 --- a/cql3/statements/drop_type_statement.cc +++ b/cql3/statements/drop_type_statement.cc @@ -140,7 +140,7 @@ const sstring& drop_type_statement::keyspace() const return _name.get_keyspace(); } -future> drop_type_statement::announce_migration(distributed& proxy, bool is_local_only) +future> drop_type_statement::announce_migration(distributed& proxy, bool is_local_only) { auto&& db = proxy.local().get_db().local(); @@ -152,11 +152,11 @@ future> drop_type_statement::announc // Can happen with if_exists if (to_drop == all_types.end()) { - return make_ready_future<::shared_ptr>(); + return make_ready_future<::shared_ptr>(); } return service::get_local_migration_manager().announce_type_drop(to_drop->second, is_local_only).then([this] { - using namespace transport; + using namespace cql_transport; return make_shared( event::schema_change::change_type::DROPPED, diff --git a/cql3/statements/drop_type_statement.hh b/cql3/statements/drop_type_statement.hh index b4824a3683..9bf8d4b7e0 100644 --- a/cql3/statements/drop_type_statement.hh +++ b/cql3/statements/drop_type_statement.hh @@ -61,7 +61,7 @@ public: virtual const sstring& keyspace() const override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/drop_user_statement.cc b/cql3/statements/drop_user_statement.cc index 3a9adcc4cf..5470130473 100644 --- a/cql3/statements/drop_user_statement.cc +++ b/cql3/statements/drop_user_statement.cc @@ -63,7 +63,7 @@ void cql3::statements::drop_user_statement::validate(distributed> +future<::shared_ptr> cql3::statements::drop_user_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return state.get_client_state().user()->is_super().then([this](bool is_super) { if (!is_super) { @@ -75,7 +75,7 @@ cql3::statements::drop_user_statement::execute(distributed>(); + return make_ready_future<::shared_ptr>(); } // clean up permissions after the dropped user. @@ -84,7 +84,7 @@ cql3::statements::drop_user_statement::execute(distributed>(); + return make_ready_future<::shared_ptr>(); }); }); }); diff --git a/cql3/statements/drop_user_statement.hh b/cql3/statements/drop_user_statement.hh index 4f05927ce0..5754f6ab4d 100644 --- a/cql3/statements/drop_user_statement.hh +++ b/cql3/statements/drop_user_statement.hh @@ -56,7 +56,7 @@ public: void validate(distributed&, const service::client_state&) override; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/drop_view_statement.cc b/cql3/statements/drop_view_statement.cc index 4fe020d44f..2b1ae0bac6 100644 --- a/cql3/statements/drop_view_statement.cc +++ b/cql3/statements/drop_view_statement.cc @@ -72,14 +72,14 @@ void drop_view_statement::validate(distributed&, const s // validated in migration_manager::announce_view_drop() } -future> drop_view_statement::announce_migration(distributed& proxy, bool is_local_only) +future> drop_view_statement::announce_migration(distributed& proxy, bool is_local_only) { return make_ready_future<>().then([this, is_local_only] { return service::get_local_migration_manager().announce_view_drop(keyspace(), column_family(), is_local_only); }).then_wrapped([this] (auto&& f) { try { f.get(); - using namespace transport; + using namespace cql_transport; return make_shared(event::schema_change::change_type::DROPPED, event::schema_change::target_type::TABLE, @@ -87,7 +87,7 @@ future> drop_view_statement::announc this->column_family()); } catch (const exceptions::configuration_exception& e) { if (_if_exists) { - return ::shared_ptr(); + return ::shared_ptr(); } throw e; } diff --git a/cql3/statements/drop_view_statement.hh b/cql3/statements/drop_view_statement.hh index 9b45ce9ba0..5caa0aa7da 100644 --- a/cql3/statements/drop_view_statement.hh +++ b/cql3/statements/drop_view_statement.hh @@ -63,7 +63,7 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future> announce_migration(distributed& proxy, bool is_local_only) override; + virtual future> announce_migration(distributed& proxy, bool is_local_only) override; virtual std::unique_ptr prepare(database& db, cql_stats& stats) override; }; diff --git a/cql3/statements/grant_statement.cc b/cql3/statements/grant_statement.cc index 89789519c8..69d39aaf89 100644 --- a/cql3/statements/grant_statement.cc +++ b/cql3/statements/grant_statement.cc @@ -42,9 +42,9 @@ #include "grant_statement.hh" #include "auth/authorizer.hh" -future<::shared_ptr> +future<::shared_ptr> cql3::statements::grant_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return auth::authorizer::get().grant(state.get_client_state().user(), _permissions, _resource, _username).then([] { - return make_ready_future<::shared_ptr>(); + return make_ready_future<::shared_ptr>(); }); } diff --git a/cql3/statements/grant_statement.hh b/cql3/statements/grant_statement.hh index 4bc8ae5335..ef8f14e7cb 100644 --- a/cql3/statements/grant_statement.hh +++ b/cql3/statements/grant_statement.hh @@ -51,7 +51,7 @@ class grant_statement : public permission_altering_statement { public: using permission_altering_statement::permission_altering_statement; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/list_permissions_statement.cc b/cql3/statements/list_permissions_statement.cc index b2463038ec..1a9d29c7fe 100644 --- a/cql3/statements/list_permissions_statement.cc +++ b/cql3/statements/list_permissions_statement.cc @@ -81,7 +81,7 @@ future<> cql3::statements::list_permissions_statement::check_access(const servic } -future<::shared_ptr> +future<::shared_ptr> cql3::statements::list_permissions_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { static auto make_column = [](sstring name) { return ::make_shared(auth::auth::AUTH_KS, "permissions", ::make_shared(std::move(name), true), utf8_type); @@ -125,7 +125,7 @@ cql3::statements::list_permissions_statement::execute(distributed(std::move(rs)); - return ::shared_ptr(std::move(rows)); + auto rows = ::make_shared(std::move(rs)); + return ::shared_ptr(std::move(rows)); }); } diff --git a/cql3/statements/list_permissions_statement.hh b/cql3/statements/list_permissions_statement.hh index b3fd3adf5c..f3239e4970 100644 --- a/cql3/statements/list_permissions_statement.hh +++ b/cql3/statements/list_permissions_statement.hh @@ -63,7 +63,7 @@ public: void validate(distributed&, const service::client_state&) override; future<> check_access(const service::client_state&) override; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/list_users_statement.cc b/cql3/statements/list_users_statement.cc index 724143584f..838b32d8bd 100644 --- a/cql3/statements/list_users_statement.cc +++ b/cql3/statements/list_users_statement.cc @@ -52,7 +52,7 @@ future<> cql3::statements::list_users_statement::check_access(const service::cli return make_ready_future(); } -future<::shared_ptr> +future<::shared_ptr> cql3::statements::list_users_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { auto is = std::make_unique(service::client_state::for_internal_calls()); auto io = std::make_unique(db::consistency_level::QUORUM, std::vector{}); diff --git a/cql3/statements/list_users_statement.hh b/cql3/statements/list_users_statement.hh index 9a13688e64..aa409c695a 100644 --- a/cql3/statements/list_users_statement.hh +++ b/cql3/statements/list_users_statement.hh @@ -52,7 +52,7 @@ class list_users_statement : public authentication_statement { public: void validate(distributed&, const service::client_state&) override; future<> check_access(const service::client_state&) override; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/modification_statement.cc b/cql3/statements/modification_statement.cc index 4408194a80..2bb1ee631e 100644 --- a/cql3/statements/modification_statement.cc +++ b/cql3/statements/modification_statement.cc @@ -353,12 +353,12 @@ struct modification_statement_executor { }; static thread_local auto modify_stage = seastar::make_execution_stage("cql3_modification", modification_statement_executor::get()); -future<::shared_ptr> +future<::shared_ptr> modification_statement::execute(distributed& proxy, service::query_state& qs, const query_options& options) { return modify_stage(this, seastar::ref(proxy), seastar::ref(qs), seastar::cref(options)); } -future<::shared_ptr> +future<::shared_ptr> modification_statement::do_execute(distributed& proxy, service::query_state& qs, const query_options& options) { if (has_conditions() && options.get_protocol_version() == 1) { throw exceptions::invalid_request_exception("Conditional updates are not supported by the protocol version in use. You need to upgrade to a driver using the native protocol v2."); @@ -373,8 +373,8 @@ modification_statement::do_execute(distributed& proxy, s inc_cql_stats(); return execute_without_condition(proxy, qs, options).then([] { - return make_ready_future<::shared_ptr>( - ::shared_ptr{}); + return make_ready_future<::shared_ptr>( + ::shared_ptr{}); }); } @@ -396,7 +396,7 @@ modification_statement::execute_without_condition(distributed> +future<::shared_ptr> modification_statement::execute_with_condition(distributed& proxy, service::query_state& qs, const query_options& options) { fail(unimplemented::cause::LWT); #if 0 @@ -424,7 +424,7 @@ modification_statement::execute_with_condition(distributed> +future<::shared_ptr> modification_statement::execute_internal(distributed& proxy, service::query_state& qs, const query_options& options) { if (has_conditions()) { throw exceptions::unsupported_operation_exception(); @@ -439,8 +439,8 @@ modification_statement::execute_internal(distributed& pr return proxy.local().mutate_locally(std::move(mutations)); }).then( [] { - return make_ready_future<::shared_ptr>( - ::shared_ptr {}); + return make_ready_future<::shared_ptr>( + ::shared_ptr {}); }); } diff --git a/cql3/statements/modification_statement.hh b/cql3/statements/modification_statement.hh index c157de0882..74422311d5 100644 --- a/cql3/statements/modification_statement.hh +++ b/cql3/statements/modification_statement.hh @@ -205,23 +205,23 @@ protected: db::consistency_level cl, tracing::trace_state_ptr trace_state); private: - future<::shared_ptr> + future<::shared_ptr> do_execute(distributed& proxy, service::query_state& qs, const query_options& options); friend class modification_statement_executor; public: bool has_conditions(); - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& qs, const query_options& options) override; - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& qs, const query_options& options) override; private: future<> execute_without_condition(distributed& proxy, service::query_state& qs, const query_options& options); - future<::shared_ptr> + future<::shared_ptr> execute_with_condition(distributed& proxy, service::query_state& qs, const query_options& options); #if 0 diff --git a/cql3/statements/revoke_statement.cc b/cql3/statements/revoke_statement.cc index db5132e3ad..0590cd7e12 100644 --- a/cql3/statements/revoke_statement.cc +++ b/cql3/statements/revoke_statement.cc @@ -42,9 +42,9 @@ #include "revoke_statement.hh" #include "auth/authorizer.hh" -future<::shared_ptr> +future<::shared_ptr> cql3::statements::revoke_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return auth::authorizer::get().revoke(state.get_client_state().user(), _permissions, _resource, _username).then([] { - return make_ready_future<::shared_ptr>(); + return make_ready_future<::shared_ptr>(); }); } diff --git a/cql3/statements/revoke_statement.hh b/cql3/statements/revoke_statement.hh index ac8f9b35e2..0e9019ce54 100644 --- a/cql3/statements/revoke_statement.hh +++ b/cql3/statements/revoke_statement.hh @@ -51,7 +51,7 @@ class revoke_statement : public permission_altering_statement { public: using permission_altering_statement::permission_altering_statement; - future<::shared_ptr> execute(distributed& + future<::shared_ptr> execute(distributed& , service::query_state& , const query_options&) override; }; diff --git a/cql3/statements/schema_altering_statement.hh b/cql3/statements/schema_altering_statement.hh index a935c80170..99e9e35aa2 100644 --- a/cql3/statements/schema_altering_statement.hh +++ b/cql3/statements/schema_altering_statement.hh @@ -55,7 +55,7 @@ namespace cql3 { namespace statements { -namespace messages = transport::messages; +namespace messages = cql_transport::messages; /** * Abstract class for statements that alter the schema. @@ -81,7 +81,7 @@ protected: virtual void prepare_keyspace(const service::client_state& state) override; - virtual future<::shared_ptr> announce_migration(distributed& proxy, bool is_local_only) = 0; + virtual future<::shared_ptr> announce_migration(distributed& proxy, bool is_local_only) = 0; virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& state, const query_options& options) override; diff --git a/cql3/statements/select_statement.cc b/cql3/statements/select_statement.cc index 0c528f23cd..8ad0ee16c8 100644 --- a/cql3/statements/select_statement.cc +++ b/cql3/statements/select_statement.cc @@ -233,7 +233,7 @@ struct select_statement_executor { }; static thread_local auto select_stage = seastar::make_execution_stage("cql3_select", select_statement_executor::get()); -future> +future> select_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) @@ -241,7 +241,7 @@ select_statement::execute(distributed& proxy, return select_stage(this, seastar::ref(proxy), seastar::ref(state), seastar::cref(options)); } -future> +future> select_statement::do_execute(distributed& proxy, service::query_state& state, const query_options& options) @@ -293,8 +293,8 @@ select_statement::do_execute(distributed& proxy, } ).then([&builder] { auto rs = builder.build(); - auto msg = ::make_shared(std::move(rs)); - return make_ready_future>(std::move(msg)); + auto msg = ::make_shared(std::move(rs)); + return make_ready_future>(std::move(msg)); }); }); } @@ -312,12 +312,12 @@ select_statement::do_execute(distributed& proxy, rs->get_metadata().set_has_more_pages(p->state()); } - auto msg = ::make_shared(std::move(rs)); - return make_ready_future>(std::move(msg)); + auto msg = ::make_shared(std::move(rs)); + return make_ready_future>(std::move(msg)); }); } -future> +future> select_statement::execute(distributed& proxy, lw_shared_ptr cmd, dht::partition_range_vector&& partition_ranges, @@ -349,7 +349,7 @@ select_statement::execute(distributed& proxy, } } -future<::shared_ptr> +future<::shared_ptr> select_statement::execute_internal(distributed& proxy, service::query_state& state, const query_options& options) @@ -383,7 +383,7 @@ select_statement::execute_internal(distributed& proxy, } } -shared_ptr +shared_ptr select_statement::process_results(foreign_ptr> results, lw_shared_ptr cmd, const query_options& options, @@ -403,7 +403,7 @@ select_statement::process_results(foreign_ptr> resu } rs->trim(cmd->row_limit); } - return ::make_shared(std::move(rs)); + return ::make_shared(std::move(rs)); } ::shared_ptr select_statement::get_restrictions() const { diff --git a/cql3/statements/select_statement.hh b/cql3/statements/select_statement.hh index d9549f838c..76998f26a7 100644 --- a/cql3/statements/select_statement.hh +++ b/cql3/statements/select_statement.hh @@ -91,7 +91,7 @@ private: query::partition_slice::option_set _opts; cql_stats& _stats; private: - future<::shared_ptr> do_execute(distributed& proxy, + future<::shared_ptr> do_execute(distributed& proxy, service::query_state& state, const query_options& options); friend class select_statement_executor; public: @@ -120,17 +120,17 @@ public: virtual bool depends_on_keyspace(const sstring& ks_name) const; virtual bool depends_on_column_family(const sstring& cf_name) const; - virtual future<::shared_ptr> execute(distributed& proxy, + virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& state, const query_options& options) override; - virtual future<::shared_ptr> execute_internal(distributed& proxy, + virtual future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) override; - future<::shared_ptr> execute(distributed& proxy, + future<::shared_ptr> execute(distributed& proxy, lw_shared_ptr cmd, dht::partition_range_vector&& partition_ranges, service::query_state& state, const query_options& options, gc_clock::time_point now); - shared_ptr process_results(foreign_ptr> results, + shared_ptr process_results(foreign_ptr> results, lw_shared_ptr cmd, const query_options& options, gc_clock::time_point now); #if 0 private ResultMessage.Rows pageAggregateQuery(QueryPager pager, QueryOptions options, int pageSize, long now) diff --git a/cql3/statements/truncate_statement.cc b/cql3/statements/truncate_statement.cc index 7ee5e9963a..f36b2880b0 100644 --- a/cql3/statements/truncate_statement.cc +++ b/cql3/statements/truncate_statement.cc @@ -92,17 +92,17 @@ void truncate_statement::validate(distributed&, const se #endif } -future<::shared_ptr> +future<::shared_ptr> truncate_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { return service::get_local_storage_proxy().truncate_blocking(keyspace(), column_family()).handle_exception([](auto ep) { throw exceptions::truncate_exception(ep); }).then([] { - return ::shared_ptr{}; + return ::shared_ptr{}; }); } -future<::shared_ptr> +future<::shared_ptr> truncate_statement::execute_internal(distributed& proxy, service::query_state& state, const query_options& options) { throw std::runtime_error("unsupported operation"); diff --git a/cql3/statements/truncate_statement.hh b/cql3/statements/truncate_statement.hh index 5c2769f191..6a05b62242 100644 --- a/cql3/statements/truncate_statement.hh +++ b/cql3/statements/truncate_statement.hh @@ -68,10 +68,10 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& state, const query_options& options) override; - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) override; }; diff --git a/cql3/statements/use_statement.cc b/cql3/statements/use_statement.cc index badad33443..a63424752b 100644 --- a/cql3/statements/use_statement.cc +++ b/cql3/statements/use_statement.cc @@ -97,14 +97,14 @@ void use_statement::validate(distributed&, const service { } -future<::shared_ptr> +future<::shared_ptr> use_statement::execute(distributed& proxy, service::query_state& state, const query_options& options) { state.get_client_state().set_keyspace(proxy.local().get_db(), _keyspace); - auto result =::make_shared(_keyspace); - return make_ready_future<::shared_ptr>(result); + auto result =::make_shared(_keyspace); + return make_ready_future<::shared_ptr>(result); } -future<::shared_ptr> +future<::shared_ptr> use_statement::execute_internal(distributed& proxy, service::query_state& state, const query_options& options) { // Internal queries are exclusively on the system keyspace and 'use' is thus useless throw std::runtime_error("unsupported operation"); diff --git a/cql3/statements/use_statement.hh b/cql3/statements/use_statement.hh index 4c9461966e..035be31209 100644 --- a/cql3/statements/use_statement.hh +++ b/cql3/statements/use_statement.hh @@ -69,10 +69,10 @@ public: virtual void validate(distributed&, const service::client_state& state) override; - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute(distributed& proxy, service::query_state& state, const query_options& options) override; - virtual future<::shared_ptr> + virtual future<::shared_ptr> execute_internal(distributed& proxy, service::query_state& state, const query_options& options) override; }; diff --git a/cql3/untyped_result_set.cc b/cql3/untyped_result_set.cc index 33cbcb9796..c417bce669 100644 --- a/cql3/untyped_result_set.cc +++ b/cql3/untyped_result_set.cc @@ -67,7 +67,7 @@ bool cql3::untyped_result_set::row::has(const sstring& name) const { return i != _data.end() && i->second; } -using transport::messages::result_message; +using cql_transport::messages::result_message; cql3::untyped_result_set::untyped_result_set(::shared_ptr msg) : _rows([msg]{ diff --git a/cql3/untyped_result_set.hh b/cql3/untyped_result_set.hh index d5e1f1be00..7678947538 100644 --- a/cql3/untyped_result_set.hh +++ b/cql3/untyped_result_set.hh @@ -142,7 +142,7 @@ public: typedef std::vector rows_type; using const_iterator = rows_type::const_iterator; - untyped_result_set(::shared_ptr); + untyped_result_set(::shared_ptr); untyped_result_set(untyped_result_set&&) = default; const_iterator begin() const { diff --git a/db/batchlog_manager.cc b/db/batchlog_manager.cc index f644db3c2c..be308c1408 100644 --- a/db/batchlog_manager.cc +++ b/db/batchlog_manager.cc @@ -69,7 +69,7 @@ #include "idl/frozen_schema.dist.impl.hh" #include "message/messaging_service.hh" -static logging::logger logger("batchlog_manager"); +static logging::logger blogger("batchlog_manager"); const uint32_t db::batchlog_manager::replay_interval; const uint32_t db::batchlog_manager::page_size; @@ -94,11 +94,11 @@ future<> db::batchlog_manager::do_batch_log_replay() { return bm._cpu++ % smp::count; }); }).then([] (auto dest) { - logger.debug("Batchlog replay on shard {}: starts", dest); + blogger.debug("Batchlog replay on shard {}: starts", dest); return get_batchlog_manager().invoke_on(dest, [] (auto& bm) { return bm.replay_all_failed_batches(); }).then([dest] { - logger.debug("Batchlog replay on shard {}: done", dest); + blogger.debug("Batchlog replay on shard {}: done", dest); }); }).finally([] { return get_batchlog_manager().invoke_on(0, [] (auto& bm) { @@ -117,7 +117,7 @@ future<> db::batchlog_manager::start() { if (engine().cpu_id() == 0) { _timer.set_callback([this] { return do_batch_log_replay().handle_exception([] (auto ep) { - logger.error("Exception in batch replay: {}", ep); + blogger.error("Exception in batch replay: {}", ep); }).finally([this] { _timer.arm(lowres_clock::now() + std::chrono::milliseconds(replay_interval)); }); @@ -188,25 +188,25 @@ future<> db::batchlog_manager::replay_all_failed_batches() { // enough time for the actual write + batchlog entry mutation delivery (two separate requests). auto timeout = get_batch_log_timeout(); if (db_clock::now() < written_at + timeout) { - logger.debug("Skipping replay of {}, too fresh", id); + blogger.debug("Skipping replay of {}, too fresh", id); return make_ready_future<>(); } // check version of serialization format if (!row.has("version")) { - logger.warn("Skipping logged batch because of unknown version"); + blogger.warn("Skipping logged batch because of unknown version"); return make_ready_future<>(); } auto version = row.get_as("version"); - if (version != net::messaging_service::current_version) { - logger.warn("Skipping logged batch because of incorrect version"); + if (version != netw::messaging_service::current_version) { + blogger.warn("Skipping logged batch because of incorrect version"); return make_ready_future<>(); } auto data = row.get_blob("data"); - logger.debug("Replaying batch {}", id); + blogger.debug("Replaying batch {}", id); auto fms = make_lw_shared>(); auto in = ser::as_input_stream(data); @@ -292,7 +292,7 @@ future<> db::batchlog_manager::replay_all_failed_batches() { }; return seastar::with_gate(_gate, [this, batch = std::move(batch)] { - logger.debug("Started replayAllFailedBatches (cpu {})", engine().cpu_id()); + blogger.debug("Started replayAllFailedBatches (cpu {})", engine().cpu_id()); typedef ::shared_ptr page_ptr; sstring query = sprint("SELECT id, data, written_at, version FROM %s.%s LIMIT %d", system_keyspace::NAME, system_keyspace::BATCHLOG, page_size); @@ -332,7 +332,7 @@ future<> db::batchlog_manager::replay_all_failed_batches() { #endif }).then([this] { - logger.debug("Finished replayAllFailedBatches"); + blogger.debug("Finished replayAllFailedBatches"); }); }); } diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 31803174b4..03ebde6b4c 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -62,6 +62,8 @@ #include #include +#include "seastarx.hh" + #include "commitlog.hh" #include "db/config.hh" #include "utils/data_input.hh" @@ -78,7 +80,7 @@ #include "checked-file-impl.hh" #include "disk-error-handler.hh" -static logging::logger logger("commitlog"); +static logging::logger clogger("commitlog"); using namespace std::chrono_literals; @@ -226,7 +228,7 @@ public: ++totals.pending_flushes; if (totals.pending_flushes >= cfg.max_active_flushes) { ++totals.flush_limit_exceeded; - logger.trace("Flush ops overflow: {}. Will block.", totals.pending_flushes); + clogger.trace("Flush ops overflow: {}. Will block.", totals.pending_flushes); } return _flush_semaphore.wait(); } @@ -236,7 +238,7 @@ public: } segment_manager(config c); ~segment_manager() { - logger.trace("Commitlog {} disposed", cfg.commit_log_location); + clogger.trace("Commitlog {} disposed", cfg.commit_log_location); } uint64_t next_id() { @@ -427,11 +429,11 @@ public: clock_type::now()), _pending_ops(true) // want exception propagation { ++_segment_manager->totals.segments_created; - logger.debug("Created new {} segment {}", active ? "active" : "reserve", *this); + clogger.debug("Created new {} segment {}", active ? "active" : "reserve", *this); } ~segment() { if (is_clean()) { - logger.debug("Segment {} is no longer active and will be deleted now", *this); + clogger.debug("Segment {} is no longer active and will be deleted now", *this); ++_segment_manager->totals.segments_destroyed; _segment_manager->totals.total_size_on_disk -= size_on_disk(); _segment_manager->totals.total_size -= (size_on_disk() + _buffer.size()); @@ -439,10 +441,10 @@ public: commit_io_check([] (const char* fname) { ::unlink(fname); }, _file_name.c_str()); } catch (...) { - logger.error("Could not delete segment {}: {}", *this, std::current_exception()); + clogger.error("Could not delete segment {}: {}", *this, std::current_exception()); } } else { - logger.warn("Segment {} is dirty and is left on disk.", *this); + clogger.warn("Segment {} is dirty and is left on disk.", *this); } } @@ -464,7 +466,7 @@ public: auto ms = std::chrono::duration_cast( now - _sync_time).count(); if ((_segment_manager->cfg.commitlog_sync_period_in_ms * 2) < uint64_t(ms)) { - logger.debug("{} needs sync. {} ms elapsed", *this, ms); + clogger.debug("{} needs sync. {} ms elapsed", *this, ms); return true; } return false; @@ -514,7 +516,7 @@ public: pos = _file_pos; } - logger.trace("Syncing {} {} -> {}", *this, _flush_pos, pos); + clogger.trace("Syncing {} {} -> {}", *this, _flush_pos, pos); // Only run the flush when all write ops at lower rp:s // have completed. @@ -531,7 +533,7 @@ public: auto me = shared_from_this(); return begin_flush().then([this, pos]() { if (pos <= _flush_pos) { - logger.trace("{} already synced! ({} < {})", *this, pos, _flush_pos); + clogger.trace("{} already synced! ({} < {})", *this, pos, _flush_pos); return make_ready_future<>(); } return _file.flush().then_wrapped([this, pos](future<> f) { @@ -541,9 +543,9 @@ public: // we fast-fail the whole commit. _flush_pos = std::max(pos, _flush_pos); ++_segment_manager->totals.flush_count; - logger.trace("{} synced to {}", *this, _flush_pos); + clogger.trace("{} synced to {}", *this, _flush_pos); } catch (...) { - logger.error("Failed to flush commits to disk: {}", std::current_exception()); + clogger.error("Failed to flush commits to disk: {}", std::current_exception()); throw; } }); @@ -573,10 +575,10 @@ public: _buffer = _segment_manager->acquire_buffer(k); break; } catch (std::bad_alloc&) { - logger.warn("Could not allocate {} k bytes output buffer ({} k required)", k / 1024, a / 1024); + clogger.warn("Could not allocate {} k bytes output buffer ({} k required)", k / 1024, a / 1024); if (k > a) { k = std::max(a, k / 2); - logger.debug("Trying reduced size: {} k", k / 1024); + clogger.debug("Trying reduced size: {} k", k / 1024); continue; } throw; @@ -647,7 +649,7 @@ public: replay_position rp(_desc.id, position_type(off)); - logger.trace("Writing {} entries, {} k in {} -> {}", num, size, off, off + size); + clogger.trace("Writing {} entries, {} k in {} -> {}", num, size, off, off + size); // The write will be allowed to start now, but flush (below) must wait for not only this, // but all previous write/flush pairs. @@ -668,13 +670,13 @@ public: } // gah, partial write. should always get here with dma chunk sized // "bytes", but lets make sure... - logger.debug("Partial write {}: {}/{} bytes", *this, *written, size); + clogger.debug("Partial write {}: {}/{} bytes", *this, *written, size); *written = align_down(*written, alignment); return make_ready_future(stop_iteration::no); // TODO: retry/ignore/fail/stop - optional behaviour in origin. // we fast-fail the whole commit. } catch (...) { - logger.error("Failed to persist commits to disk for {}: {}", *this, std::current_exception()); + clogger.error("Failed to persist commits to disk for {}: {}", *this, std::current_exception()); throw; } }); @@ -758,7 +760,7 @@ public: }); } else { cycle().discard_result().handle_exception([] (auto ex) { - logger.error("Failed to flush commits to disk: {}", ex); + clogger.error("Failed to flush commits to disk: {}", ex); }); } } @@ -811,7 +813,7 @@ public: // have to do it ourselves. if ((_buf_pos >= (db::commitlog::segment::default_size))) { cycle().discard_result().handle_exception([] (auto ex) { - logger.error("Failed to flush commits to disk: {}", ex); + clogger.error("Failed to flush commits to disk: {}", ex); }); } return make_ready_future(rp); @@ -934,7 +936,7 @@ db::commitlog::segment_manager::segment_manager(config c) { assert(max_size > 0); - logger.trace("Commitlog {} maximum disk size: {} MB / cpu ({} cpus)", + clogger.trace("Commitlog {} maximum disk size: {} MB / cpu ({} cpus)", cfg.commit_log_location, max_disk_size / (1024 * 1024), smp::count); @@ -955,12 +957,12 @@ future<> db::commitlog::segment_manager::replenish_reserve() { return this->allocate_segment(false).then([this](sseg_ptr s) { auto ret = _reserve_segments.push(std::move(s)); if (!ret) { - logger.error("Segment reserve is full! Ignoring and trying to continue, but shouldn't happen"); + clogger.error("Segment reserve is full! Ignoring and trying to continue, but shouldn't happen"); } return make_ready_future<>(); }); }).handle_exception([](std::exception_ptr ep) { - logger.warn("Exception in segment reservation: {}", ep); + clogger.warn("Exception in segment reservation: {}", ep); return sleep(100ms); }); }); @@ -995,7 +997,7 @@ db::commitlog::segment_manager::list_descriptors(sstring dirname) { try { _result.emplace_back(de.name); } catch (std::domain_error& e) { - logger.warn(e.what()); + clogger.warn(e.what()); } } return make_ready_future<>(); @@ -1038,7 +1040,7 @@ future<> db::commitlog::segment_manager::init() { // always run the timer now, since we need to handle segment pre-alloc etc as well. _timer.set_callback(std::bind(&segment_manager::on_timer, this)); auto delay = engine().cpu_id() * std::ceil(double(cfg.commitlog_sync_period_in_ms) / smp::count); - logger.trace("Delaying timer loop {} ms", delay); + clogger.trace("Delaying timer loop {} ms", delay); // We need to wait until we have scanned all other segments to actually start serving new // segments. We are ready now this->_reserve_replenisher = replenish_reserve(); @@ -1129,7 +1131,7 @@ void db::commitlog::segment_manager::flush_segments(bool force) { } }); - logger.debug("Flushing ({}) to {}", force, high); + clogger.debug("Flushing ({}) to {}", force, high); // For each CF id: for each callback c: call c(id, high) for (auto& f : callbacks) { @@ -1137,7 +1139,7 @@ void db::commitlog::segment_manager::flush_segments(bool force) { try { f(id, high); } catch (...) { - logger.error("Exception during flush request {}/{}: {}", id, high, std::current_exception()); + clogger.error("Exception during flush request {}/{}: {}", id, high, std::current_exception()); } } } @@ -1165,7 +1167,7 @@ future db::commitlog::segment_manager: if (_reserve_segments.empty() && (_reserve_segments.max_size() < cfg.max_reserve_segments)) { _reserve_segments.set_max_size(_reserve_segments.max_size() + 1); - logger.debug("Increased segment reserve count to {}", _reserve_segments.max_size()); + clogger.debug("Increased segment reserve count to {}", _reserve_segments.max_size()); } return _reserve_segments.pop_eventually().then([this] (auto s) { _segments.push_back(std::move(s)); @@ -1207,7 +1209,7 @@ future db::commitlog::segment_manager: */ void db::commitlog::segment_manager::discard_completed_segments( const cf_id_type& id, const replay_position& pos) { - logger.debug("Discard completed segments for {}, table {}", pos, id); + clogger.debug("Discard completed segments for {}, table {}", pos, id); for (auto&s : _segments) { s->mark_clean(id, pos); } @@ -1231,19 +1233,19 @@ std::ostream& operator<<(std::ostream& out, const db::replay_position& p) { } void db::commitlog::segment_manager::discard_unused_segments() { - logger.trace("Checking for unused segments ({} active)", _segments.size()); + clogger.trace("Checking for unused segments ({} active)", _segments.size()); auto i = std::remove_if(_segments.begin(), _segments.end(), [=](sseg_ptr s) { if (s->can_delete()) { - logger.debug("Segment {} is unused", *s); + clogger.debug("Segment {} is unused", *s); return true; } if (s->is_still_allocating()) { - logger.debug("Not safe to delete segment {}; still allocating.", s); + clogger.debug("Not safe to delete segment {}; still allocating.", s); } else if (!s->is_clean()) { - logger.debug("Not safe to delete segment {}; dirty is {}", s, segment::cf_mark {*s}); + clogger.debug("Not safe to delete segment {}; dirty is {}", s, segment::cf_mark {*s}); } else { - logger.debug("Not safe to delete segment {}; disk ops pending", s); + clogger.debug("Not safe to delete segment {}; disk ops pending", s); } return false; }); @@ -1262,10 +1264,10 @@ future<> db::commitlog::segment_manager::clear_reserve_segments() { } future<> db::commitlog::segment_manager::sync_all_segments(bool shutdown) { - logger.debug("Issuing sync for all segments ({})", shutdown ? "shutdown" : "active"); + clogger.debug("Issuing sync for all segments ({})", shutdown ? "shutdown" : "active"); return parallel_for_each(_segments, [this, shutdown](sseg_ptr s) { return s->sync(shutdown).then([](sseg_ptr s) { - logger.debug("Synced segment {}", *s); + clogger.debug("Synced segment {}", *s); }); }); } @@ -1313,9 +1315,9 @@ future<> db::commitlog::segment_manager::orphan_all() { * Only use from tests. */ future<> db::commitlog::segment_manager::clear() { - logger.debug("Clearing commitlog"); + clogger.debug("Clearing commitlog"); return shutdown().then([this] { - logger.debug("Clearing all segments"); + clogger.debug("Clearing all segments"); for (auto& s : _segments) { s->mark_clean(); } @@ -1346,7 +1348,7 @@ void db::commitlog::segment_manager::on_timer() { auto cur = totals.total_size_on_disk; if (max != 0 && cur >= max) { _new_counter = 0; - logger.debug("Size on disk {} MB exceeds local maximum {} MB", cur / (1024 * 1024), max / (1024 * 1024)); + clogger.debug("Size on disk {} MB exceeds local maximum {} MB", cur / (1024 * 1024), max / (1024 * 1024)); flush_segments(); } } @@ -1396,7 +1398,7 @@ db::commitlog::segment_manager::buffer_type db::commitlog::segment_manager::acqu if (a == nullptr) { throw std::bad_alloc(); } - logger.trace("Allocated {} k buffer", s / 1024); + clogger.trace("Allocated {} k buffer", s / 1024); return buffer_type(reinterpret_cast(a), s, make_free_deleter(a)); } @@ -1409,7 +1411,7 @@ void db::commitlog::segment_manager::release_buffer(buffer_type&& b) { constexpr const size_t max_temp_buffers = 4; if (_temp_buffers.size() > max_temp_buffers) { - logger.trace("Deleting {} buffers", _temp_buffers.size() - max_temp_buffers); + clogger.trace("Deleting {} buffers", _temp_buffers.size() - max_temp_buffers); _temp_buffers.erase(_temp_buffers.begin() + max_temp_buffers, _temp_buffers.end()); } totals.buffer_list_bytes = boost::accumulate( @@ -1696,7 +1698,7 @@ db::commitlog::read_log_file(file f, commit_load_reader_func next, position_type if (cs != checksum) { // if a chunk header checksum is broken, we shall just assume that all // remaining is as well. We cannot trust the "next" pointer, so... - logger.debug("Checksum error in segment chunk at {}.", pos); + clogger.debug("Checksum error in segment chunk at {}.", pos); corrupt_size += (file_size - pos); return stop(); } @@ -1741,7 +1743,7 @@ db::commitlog::read_log_file(file f, commit_load_reader_func next, position_type if (size < 3 * sizeof(uint32_t) || checksum != crc.checksum()) { auto slack = next - pos; if (size != 0) { - logger.debug("Segment entry at {} has broken header. Skipping to next chunk ({} bytes)", rp, slack); + clogger.debug("Segment entry at {} has broken header. Skipping to next chunk ({} bytes)", rp, slack); corrupt_size += slack; } // size == 0 -> special scylla case: zero padding due to dma blocks @@ -1763,7 +1765,7 @@ db::commitlog::read_log_file(file f, commit_load_reader_func next, position_type // If we're getting a checksum error here, most likely the rest of // the file will be corrupt as well. But it does not hurt to retry. // Just go to the next entry (since "size" in header seemed ok). - logger.debug("Segment entry at {} checksum error. Skipping {} bytes", rp, size); + clogger.debug("Segment entry at {} checksum error. Skipping {} bytes", rp, size); corrupt_size += size; return make_ready_future<>(); } diff --git a/db/commitlog/commitlog.hh b/db/commitlog/commitlog.hh index 1954f39c61..d611e36877 100644 --- a/db/commitlog/commitlog.hh +++ b/db/commitlog/commitlog.hh @@ -50,7 +50,9 @@ #include "replay_position.hh" #include "commitlog_entry.hh" -class file; +namespace seastar { class file; } + +#include "seastarx.hh" namespace db { diff --git a/db/commitlog/commitlog_entry.hh b/db/commitlog/commitlog_entry.hh index ddc9754e07..358e48624d 100644 --- a/db/commitlog/commitlog_entry.hh +++ b/db/commitlog/commitlog_entry.hh @@ -26,8 +26,7 @@ #include "frozen_mutation.hh" #include "schema.hh" #include "utils/data_output.hh" - -namespace stdx = std::experimental; +#include "stdx.hh" class commitlog_entry { stdx::optional _mapping; diff --git a/db/commitlog/commitlog_replayer.cc b/db/commitlog/commitlog_replayer.cc index 2e9bdb2a32..c703568236 100644 --- a/db/commitlog/commitlog_replayer.cc +++ b/db/commitlog/commitlog_replayer.cc @@ -59,7 +59,7 @@ #include "schema_registry.hh" #include "commitlog_entry.hh" -static logging::logger logger("commitlog_replayer"); +static logging::logger rlogger("commitlog_replayer"); class db::commitlog_replayer::impl { struct column_mappings { @@ -161,11 +161,11 @@ future<> db::commitlog_replayer::impl::init() { for (auto& sst : *cfp.second->get_sstables()) { try { auto p = sst->get_stats_metadata().position; - logger.trace("sstable {} -> rp {}", sst->get_filename(), p); + rlogger.trace("sstable {} -> rp {}", sst->get_filename(), p); auto& pp = map[p.shard_id()][uuid]; pp = std::max(pp, p); } catch (...) { - logger.warn("Could not read sstable metadata {}", std::current_exception()); + rlogger.warn("Could not read sstable metadata {}", std::current_exception()); } } // We do this on each cpu, for each CF, which technically is a little wasteful, but the values are @@ -175,7 +175,7 @@ future<> db::commitlog_replayer::impl::init() { // mark the CF as "needed". return db::system_keyspace::get_truncated_position(uuid).then([&map, &uuid](std::vector tpps) { for (auto& p : tpps) { - logger.trace("CF {} truncated at {}", uuid, p); + rlogger.trace("CF {} truncated at {}", uuid, p); auto& pp = map[p.shard_id()][uuid]; pp = std::max(pp, p); } @@ -204,11 +204,11 @@ future<> db::commitlog_replayer::impl::init() { } } for (auto&p : _min_pos) { - logger.debug("minimum position for shard {}: {}", p.first, p.second); + rlogger.debug("minimum position for shard {}: {}", p.first, p.second); } for (auto&p1 : _rpm) { for (auto& p2 : p1.second) { - logger.debug("replay position for shard/uuid {}/{}: {}", p1.first, p2.first, p2.second); + rlogger.debug("replay position for shard/uuid {}/{}: {}", p1.first, p2.first, p2.second); } } }); @@ -222,7 +222,7 @@ db::commitlog_replayer::impl::recover(sstring file) const { auto gp = min_pos(rp.shard_id()); if (rp.id < gp.id) { - logger.debug("skipping replay of fully-flushed {}", file); + rlogger.debug("skipping replay of fully-flushed {}", file); return make_ready_future(); } position_type p = 0; @@ -261,14 +261,14 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer if (!cer.get_column_mapping()) { throw std::runtime_error(sprint("unknown schema version {}", fm.schema_version())); } - logger.debug("new schema version {} in entry {}", fm.schema_version(), rp); + rlogger.debug("new schema version {} in entry {}", fm.schema_version(), rp); cm_it = local_cm.emplace(fm.schema_version(), *cer.get_column_mapping()).first; } const column_mapping& src_cm = cm_it->second; auto shard_id = rp.shard_id(); if (rp < min_pos(shard_id)) { - logger.trace("entry {} is less than global min position. skipping", rp); + rlogger.trace("entry {} is less than global min position. skipping", rp); s->skipped_mutations++; return make_ready_future<>(); } @@ -276,7 +276,7 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer auto uuid = fm.column_family_id(); auto cf_rp = cf_min_pos(uuid, shard_id); if (rp <= cf_rp) { - logger.trace("entry {} at {} is younger than recorded replay position {}. skipping", fm.column_family_id(), rp, cf_rp); + rlogger.trace("entry {} at {} is younger than recorded replay position {}. skipping", fm.column_family_id(), rp, cf_rp); s->skipped_mutations++; return make_ready_future<>(); } @@ -289,8 +289,8 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer // will not do this. auto& cf = db.find_column_family(fm.column_family_id()); - if (logger.is_enabled(logging::log_level::debug)) { - logger.debug("replaying at {} v={} {}:{} at {}", fm.column_family_id(), fm.schema_version(), + if (rlogger.is_enabled(logging::log_level::debug)) { + rlogger.debug("replaying at {} v={} {}:{} at {}", fm.column_family_id(), fm.schema_version(), cf.schema()->ks_name(), cf.schema()->cf_name(), rp); } // Removed forwarding "new" RP. Instead give none/empty. @@ -317,14 +317,14 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer }).handle_exception([s](auto ep) { s->invalid_mutations++; // TODO: write mutation to file like origin. - logger.warn("error replaying: {}", ep); + rlogger.warn("error replaying: {}", ep); }); } catch (no_such_column_family&) { // No such CF now? Origin just ignores this. } catch (...) { s->invalid_mutations++; // TODO: write mutation to file like origin. - logger.warn("error replaying: {}", std::current_exception()); + rlogger.warn("error replaying: {}", std::current_exception()); } return make_ready_future<>(); @@ -353,7 +353,7 @@ future db::commitlog_replayer::create_replayer(seastar:: future<> db::commitlog_replayer::recover(std::vector files) { typedef std::unordered_multimap shard_file_map; - logger.info("Replaying {}", join(", ", files)); + rlogger.info("Replaying {}", join(", ", files)); // pre-compute work per shard already. auto map = ::make_lw_shared(); @@ -373,12 +373,12 @@ future<> db::commitlog_replayer::recover(std::vector files) { auto range = map->equal_range(id); return do_for_each(range.first, range.second, [this, total](const std::pair& p) { auto&f = p.second; - logger.debug("Replaying {}", f); + rlogger.debug("Replaying {}", f); return _impl->recover(f).then([f, total](impl::stats stats) { if (stats.corrupt_bytes != 0) { - logger.warn("Corrupted file: {}. {} bytes skipped.", f, stats.corrupt_bytes); + rlogger.warn("Corrupted file: {}. {} bytes skipped.", f, stats.corrupt_bytes); } - logger.debug("Log replay of {} complete, {} replayed mutations ({} invalid, {} skipped)" + rlogger.debug("Log replay of {} complete, {} replayed mutations ({} invalid, {} skipped)" , f , stats.applied_mutations , stats.invalid_mutations @@ -391,7 +391,7 @@ future<> db::commitlog_replayer::recover(std::vector files) { }); }); }, impl::stats(), std::plus()).then([](impl::stats totals) { - logger.info("Log replay complete, {} replayed mutations ({} invalid, {} skipped)" + rlogger.info("Log replay complete, {} replayed mutations ({} invalid, {} skipped)" , totals.applied_mutations , totals.invalid_mutations , totals.skipped_mutations diff --git a/db/config.cc b/db/config.cc index 9ddab597ed..1ce67932ea 100644 --- a/db/config.cc +++ b/db/config.cc @@ -34,7 +34,7 @@ #include "log.hh" #include -static logging::logger logger("config"); +static logging::logger clogger("config"); db::config::config() : @@ -364,32 +364,32 @@ void db::config::read_from_yaml(const char* yaml) { auto label = node.first.as(); auto i = values.find(label); if (i == values.end()) { - logger.warn("Unknown option {} ignored.", label); + clogger.warn("Unknown option {} ignored.", label); continue; } if (i->second->source() > config_source::SettingsFile) { - logger.debug("Option {} already set by commandline. ignored.", label); + clogger.debug("Option {} already set by commandline. ignored.", label); continue; } switch (i->second->status()) { case value_status::Invalid: - logger.warn("Option {} is not applicable. Ignoring.", label); + clogger.warn("Option {} is not applicable. Ignoring.", label); continue; case value_status::Unused: - logger.warn("Option {} is not (yet) used.", label); + clogger.warn("Option {} is not (yet) used.", label); break; default: break; } if (node.second.IsNull()) { - logger.debug("Option {}, empty value. Skipping.", label); + clogger.debug("Option {}, empty value. Skipping.", label); continue; } // Still, a syntax error is an error warning, not a fail try { (*i->second)(node.second); } catch (...) { - logger.error("Option {}, exception while converting value.", label); + clogger.error("Option {}, exception while converting value.", label); } } @@ -400,7 +400,7 @@ void db::config::read_from_yaml(const char* yaml) { if (p.second->source() > config_source::None) { continue; } - logger.debug("Option {} not set", p.first); + clogger.debug("Option {} not set", p.first); } } diff --git a/db/config.hh b/db/config.hh index 34ca54ecee..516dd806cb 100644 --- a/db/config.hh +++ b/db/config.hh @@ -27,8 +27,9 @@ #include #include "core/sstring.hh" #include "core/future.hh" +#include "seastarx.hh" -class file; +namespace seastar { class file; } namespace db { diff --git a/db/index/secondary_index.hh b/db/index/secondary_index.hh index b5a758d0fc..43fdcb2083 100644 --- a/db/index/secondary_index.hh +++ b/db/index/secondary_index.hh @@ -42,6 +42,7 @@ #pragma once #include "core/sstring.hh" +#include "seastarx.hh" namespace db { namespace index { diff --git a/db/legacy_schema_migrator.cc b/db/legacy_schema_migrator.cc index 4f1de0ba4f..14481a6e29 100644 --- a/db/legacy_schema_migrator.cc +++ b/db/legacy_schema_migrator.cc @@ -54,7 +54,7 @@ #include "cql3/query_processor.hh" #include "utils/joinpoint.hh" -static seastar::logger logger("legacy_schema_migrator"); +static seastar::logger mlogger("legacy_schema_migrator"); namespace db { namespace legacy_schema_migrator { @@ -377,7 +377,7 @@ public: builder.set_compaction_strategy(sstables::compaction_strategy::type(strategy)); } catch (const exceptions::configuration_exception& e) { // If compaction strategy class isn't supported, fallback to size tiered. - logger.warn("Falling back to size-tiered compaction strategy after the problem: {}", e.what()); + mlogger.warn("Falling back to size-tiered compaction strategy after the problem: {}", e.what()); builder.set_compaction_strategy(sstables::compaction_strategy_type::size_tiered); } } @@ -526,7 +526,7 @@ public: } future<> truncate_legacy_tables() { - logger.info("Truncating legacy schema tables"); + mlogger.info("Truncating legacy schema tables"); return do_with(utils::make_joinpoint([] { return db_clock::now();}),[this](auto& tsf) { return _qp.db().invoke_on_all([&tsf](database& db) { return parallel_for_each(legacy_schema_tables, [&db, &tsf](const sstring& cfname) { @@ -537,7 +537,7 @@ public: } future<> store_keyspaces_in_new_schema_tables() { - logger.info("Moving {} keyspaces from legacy schema tables to the new schema keyspace ({})", + mlogger.info("Moving {} keyspaces from legacy schema tables to the new schema keyspace ({})", _keyspaces.size(), db::schema_tables::v3::NAME); std::vector mutations; @@ -597,7 +597,7 @@ public: .then(std::bind(&migrator::flush_schemas, this)) .then(std::bind(&migrator::truncate_legacy_tables, this)) .then(std::bind(&migrator::unload_legacy_tables, this)) - .then([] { logger.info("Completed migration of legacy schema tables"); }); + .then([] { mlogger.info("Completed migration of legacy schema tables"); }); }); } diff --git a/db/schema_tables.cc b/db/schema_tables.cc index 5493926c33..c40553d1a9 100644 --- a/db/schema_tables.cc +++ b/db/schema_tables.cc @@ -80,7 +80,7 @@ using namespace std::chrono_literals; namespace db { namespace schema_tables { -logging::logger logger("schema_tables"); +logging::logger slogger("schema_tables"); struct push_back_and_return { std::vector muts; @@ -808,16 +808,16 @@ future> merge_keyspaces(distributed& p auto diff = difference(before, after, indirect_equal_to>()); for (auto&& key : diff.entries_only_on_left) { - logger.info("Dropping keyspace {}", key); + slogger.info("Dropping keyspace {}", key); dropped.emplace(key); } for (auto&& key : diff.entries_only_on_right) { auto&& value = after[key]; - logger.info("Creating keyspace {}", key); + slogger.info("Creating keyspace {}", key); created.emplace_back(schema_result_value_type{key, std::move(value)}); } for (auto&& key : diff.entries_differing) { - logger.info("Altering keyspace {}", key); + slogger.info("Altering keyspace {}", key); altered.emplace_back(key); } return do_with(std::move(created), [&proxy, altered = std::move(altered)] (auto& created) mutable { @@ -867,17 +867,17 @@ static schema_diff diff_table_or_view(distributed& proxy auto diff = difference(before, after); for (auto&& key : diff.entries_only_on_left) { auto&& s = proxy.local().get_db().local().find_schema(key.keyspace_name, key.table_name); - logger.info("Dropping {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); + slogger.info("Dropping {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); d.dropped.emplace_back(schema_diff::dropped_schema{s}); } for (auto&& key : diff.entries_only_on_right) { auto s = create_schema(std::move(after.at(key))); - logger.info("Creating {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); + slogger.info("Creating {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); d.created.emplace_back(s); } for (auto&& key : diff.entries_differing) { auto s = create_schema(std::move(after.at(key))); - logger.info("Altering {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); + slogger.info("Altering {}.{} id={} version={}", s->ks_name(), s->cf_name(), s->id(), s->version()); d.altered.emplace_back(s); } return d; @@ -1760,7 +1760,7 @@ static void prepare_builder_from_table_row(schema_builder& builder, const query: map.erase(i); } catch (const exceptions::configuration_exception& e) { // If compaction strategy class isn't supported, fallback to size tiered. - logger.warn("Falling back to size-tiered compaction strategy after the problem: {}", e.what()); + slogger.warn("Falling back to size-tiered compaction strategy after the problem: {}", e.what()); builder.set_compaction_strategy(sstables::compaction_strategy_type::size_tiered); } } @@ -2343,7 +2343,7 @@ future> make_drop_view_mutations(lw_shared_ptr qctx = {}; namespace system_keyspace { -static logging::logger logger("system_keyspace"); +static logging::logger slogger("system_keyspace"); static const api::timestamp_type creation_timestamp = api::new_timestamp(); api::timestamp_type schema_creation_timestamp() { @@ -947,7 +947,7 @@ static future<> setup_version() { sstring(dht::global_partitioner().name()), a.addr(), utils::fb_utilities::get_broadcast_address().addr(), - net::get_local_messaging_service().listen_address().addr(), + netw::get_local_messaging_service().listen_address().addr(), service::storage_service::get_config_supported_features() ).discard_result(); }); @@ -1045,7 +1045,7 @@ future<> setup(distributed& db, distributed& qp }).then([] { return db::schema_tables::save_system_keyspace_schema(); }).then([] { - return net::get_messaging_service().invoke_on_all([] (auto& ms){ + return netw::get_messaging_service().invoke_on_all([] (auto& ms){ return ms.init_local_preferred_ip_cache(); }); }); @@ -1129,7 +1129,7 @@ static future get_truncation_record(utils::UUID cf_id) { if (buf.size() & 1) { // new record. if (buf[0] != current_version) { - logger.warn("Found truncation record of unknown version {}. Ignoring.", int(buf[0])); + slogger.warn("Found truncation record of unknown version {}. Ignoring.", int(buf[0])); continue; } e = ser::deserialize_from_buffer(buf, boost::type(), 1); @@ -1143,7 +1143,7 @@ static future get_truncation_record(utils::UUID cf_id) { // struct (and official serial size) is 64+32. data_input in(buf); - logger.debug("Reading old type record"); + slogger.debug("Reading old type record"); while (in.avail() > sizeof(db_clock::rep)) { auto id = in.read(); auto pos = in.read(); @@ -1161,7 +1161,7 @@ static future get_truncation_record(utils::UUID cf_id) { // This is useless to us, because the only usage for this // data is commit log and batch replay, and we cannot replay // either from origin anyway. - logger.warn("Error reading truncation record for {}. " + slogger.warn("Error reading truncation record for {}. " "Most likely this is data from a cassandra instance." "Make sure you have cleared commit and batch logs before upgrading.", uuid @@ -1427,7 +1427,7 @@ future<> force_blocking_flush(sstring cfname) { * 3. files are present but you can't read them: bad */ future<> check_health() { - using namespace transport::messages; + using namespace cql_transport::messages; sstring req = sprint("SELECT cluster_name FROM system.%s WHERE key=?", LOCAL); return execute_cql(req, sstring(LOCAL)).then([] (::shared_ptr msg) { if (msg->empty() || !msg->one().has("cluster_name")) { @@ -1589,7 +1589,7 @@ void make(database& db, bool durable, bool volatile_testing_only) { } future get_local_host_id() { - using namespace transport::messages; + using namespace cql_transport::messages; sstring req = sprint("SELECT host_id FROM system.%s WHERE key=?", LOCAL); return execute_cql(req, sstring(LOCAL)).then([] (::shared_ptr msg) { auto new_id = [] { @@ -1738,7 +1738,7 @@ future increment_and_get_generation() { int stored_generation = rs->one().template get_as("gossip_generation") + 1; int now = service::get_generation_number(); if (stored_generation >= now) { - logger.warn("Using stored Gossip Generation {} as it is greater than current system time {}." + slogger.warn("Using stored Gossip Generation {} as it is greater than current system time {}." "See CASSANDRA-3654 if you experience problems", stored_generation, now); generation = stored_generation; } else { diff --git a/db/view/view.cc b/db/view/view.cc index 36cdf380f6..a44a5b18f7 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -55,7 +55,7 @@ #include "service/storage_service.hh" #include "view_info.hh" -static logging::logger logger("view"); +static logging::logger vlogger("view"); view_info::view_info(const schema& schema, const raw_view_info& raw_view_info) : _schema(schema) @@ -831,7 +831,7 @@ void mutate_MV(const dht::token& base_token, // Note also that mutate_locally(mut) copies mut (in // frozen from) so don't need to increase its lifetime. service::get_local_storage_proxy().mutate_locally(mut).handle_exception([] (auto ep) { - logger.error("Error applying local view update: {}", ep); + vlogger.error("Error applying local view update: {}", ep); }); } else { #if 0 @@ -849,7 +849,7 @@ void mutate_MV(const dht::token& base_token, // Note we don't wait for the asynchronous operation to complete // FIXME: need to extend mut's lifetime??? service::get_local_storage_proxy().send_to_endpoint(mut, *paired_endpoint, db::write_type::VIEW).handle_exception([paired_endpoint] (auto ep) { - logger.error("Error applying view update to {}: {}", *paired_endpoint, ep); + vlogger.error("Error applying view update to {}: {}", *paired_endpoint, ep); });; } } else { @@ -857,7 +857,7 @@ void mutate_MV(const dht::token& base_token, //if there are no paired endpoints there are probably range movements going on, //so we write to the local batchlog to replay later if (pendingEndpoints.isEmpty()) - logger.warn("Received base materialized view mutation for key {} that does not belong " + + vlogger.warn("Received base materialized view mutation for key {} that does not belong " + "to this node. There is probably a range movement happening (move or decommission)," + "but this node hasn't updated its ring metadata yet. Adding mutation to " + "local batchlog to be replayed later.", diff --git a/dht/boot_strapper.cc b/dht/boot_strapper.cc index 8aa6f9b92d..a15c4404e1 100644 --- a/dht/boot_strapper.cc +++ b/dht/boot_strapper.cc @@ -42,12 +42,12 @@ #include "gms/failure_detector.hh" #include "log.hh" -static logging::logger logger("boot_strapper"); +static logging::logger blogger("boot_strapper"); namespace dht { future<> boot_strapper::bootstrap() { - logger.debug("Beginning bootstrap process: sorted_tokens={}", _token_metadata.sorted_tokens()); + blogger.debug("Beginning bootstrap process: sorted_tokens={}", _token_metadata.sorted_tokens()); auto streamer = make_lw_shared(_db, _token_metadata, _tokens, _address, "Bootstrap"); streamer->add_source_filter(std::make_unique(gms::get_local_failure_detector())); @@ -55,7 +55,7 @@ future<> boot_strapper::bootstrap() { auto& ks = _db.local().find_keyspace(keyspace_name); auto& strategy = ks.get_replication_strategy(); dht::token_range_vector ranges = strategy.get_pending_address_ranges(_token_metadata, _tokens, _address); - logger.debug("Will stream keyspace={}, ranges={}", keyspace_name, ranges); + blogger.debug("Will stream keyspace={}, ranges={}", keyspace_name, ranges); streamer->add_ranges(keyspace_name, ranges); } @@ -74,7 +74,7 @@ std::unordered_set boot_strapper::get_bootstrap_tokens(token_metadata met auto initial_tokens = db.get_initial_tokens(); // if user specified tokens, use those if (initial_tokens.size() > 0) { - logger.debug("tokens manually specified as {}", initial_tokens); + blogger.debug("tokens manually specified as {}", initial_tokens); std::unordered_set tokens; for (auto& token_string : initial_tokens) { auto token = dht::global_partitioner().from_sstring(token_string); @@ -83,7 +83,7 @@ std::unordered_set boot_strapper::get_bootstrap_tokens(token_metadata met } tokens.insert(token); } - logger.debug("Get manually specified bootstrap_tokens={}", tokens); + blogger.debug("Get manually specified bootstrap_tokens={}", tokens); return tokens; } @@ -93,11 +93,11 @@ std::unordered_set boot_strapper::get_bootstrap_tokens(token_metadata met } if (num_tokens == 1) { - logger.warn("Picking random token for a single vnode. You should probably add more vnodes; failing that, you should probably specify the token manually"); + blogger.warn("Picking random token for a single vnode. You should probably add more vnodes; failing that, you should probably specify the token manually"); } auto tokens = get_random_tokens(metadata, num_tokens); - logger.debug("Get random bootstrap_tokens={}", tokens); + blogger.debug("Get random bootstrap_tokens={}", tokens); return tokens; } diff --git a/disk-error-handler.hh b/disk-error-handler.hh index 597b26f877..3ff1c9918a 100644 --- a/disk-error-handler.hh +++ b/disk-error-handler.hh @@ -27,6 +27,8 @@ #include "utils/exceptions.hh" #include +#include "seastarx.hh" + namespace bs2 = boost::signals2; using disk_error_signal_type = bs2::signal_type>::type; diff --git a/gms/application_state.cc b/gms/application_state.cc index a6c77a64bc..fd32e829b6 100644 --- a/gms/application_state.cc +++ b/gms/application_state.cc @@ -42,6 +42,7 @@ #include #include #include +#include "seastarx.hh" namespace gms { diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 052187bc0f..7ffda5d8b7 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -72,7 +72,7 @@ constexpr int64_t gossiper::MAX_GENERATION_DIFFERENCE; distributed _the_gossiper; -net::msg_addr gossiper::get_msg_addr(inet_address to) { +netw::msg_addr gossiper::get_msg_addr(inet_address to) { return msg_addr{to, _default_cpuid}; } @@ -293,7 +293,7 @@ void gossiper::init_messaging_service_handler() { } _ms_registered = true; ms().register_gossip_digest_syn([] (const rpc::client_info& cinfo, gossip_digest_syn syn_msg) { - auto from = net::messaging_service::get_source(cinfo); + auto from = netw::messaging_service::get_source(cinfo); smp::submit_to(0, [from, syn_msg = std::move(syn_msg)] () mutable { auto& gossiper = gms::get_local_gossiper(); return gossiper.handle_syn_msg(from, std::move(syn_msg)); @@ -303,7 +303,7 @@ void gossiper::init_messaging_service_handler() { return messaging_service::no_wait(); }); ms().register_gossip_digest_ack([] (const rpc::client_info& cinfo, gossip_digest_ack msg) { - auto from = net::messaging_service::get_source(cinfo); + auto from = netw::messaging_service::get_source(cinfo); smp::submit_to(0, [from, msg = std::move(msg)] () mutable { auto& gossiper = gms::get_local_gossiper(); return gossiper.handle_ack_msg(from, std::move(msg)); @@ -339,7 +339,7 @@ void gossiper::init_messaging_service_handler() { } void gossiper::uninit_messaging_service_handler() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.unregister_gossip_echo(); ms.unregister_gossip_shutdown(); ms.unregister_gossip_digest_syn(); @@ -1057,7 +1057,7 @@ std::unordered_map& gms::gossiper::get_endpoint_st } bool gossiper::uses_host_id(inet_address endpoint) { - if (net::get_local_messaging_service().knows_version(endpoint)) { + if (netw::get_local_messaging_service().knows_version(endpoint)) { return true; } else if (get_endpoint_state_for_endpoint(endpoint)->get_application_state(application_state::NET_VERSION)) { return true; diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 228fcfbc45..f743c967fc 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -84,11 +84,11 @@ class gossiper : public i_failure_detection_event_listener, public seastar::asyn public: using clk = std::chrono::system_clock; private: - using messaging_verb = net::messaging_verb; - using messaging_service = net::messaging_service; - using msg_addr = net::msg_addr; - net::messaging_service& ms() { - return net::get_local_messaging_service(); + using messaging_verb = netw::messaging_verb; + using messaging_service = netw::messaging_service; + using msg_addr = netw::msg_addr; + netw::messaging_service& ms() { + return netw::get_local_messaging_service(); } void init_messaging_service_handler(); void uninit_messaging_service_handler(); diff --git a/gms/versioned_value.cc b/gms/versioned_value.cc index 08bc893518..5941321192 100644 --- a/gms/versioned_value.cc +++ b/gms/versioned_value.cc @@ -54,7 +54,7 @@ constexpr const char* versioned_value::SHUTDOWN; constexpr const char* versioned_value::REMOVAL_COORDINATOR; versioned_value versioned_value::factory::network_version() { - return versioned_value(sprint("%s",net::messaging_service::current_version)); + return versioned_value(sprint("%s",netw::messaging_service::current_version)); } } diff --git a/hashing.hh b/hashing.hh index b69084b033..424f3cc1f5 100644 --- a/hashing.hh +++ b/hashing.hh @@ -26,6 +26,7 @@ #include #include #include +#include "seastarx.hh" // // This hashing differs from std::hash<> in that it decouples knowledge about diff --git a/init.cc b/init.cc index 25beb6a717..54886a4e9b 100644 --- a/init.cc +++ b/init.cc @@ -57,8 +57,8 @@ void init_ms_fd_gossiper(sstring listen_address_in { const auto listen = gms::inet_address::lookup(listen_address_in).get0(); - using encrypt_what = net::messaging_service::encrypt_what; - using compress_what = net::messaging_service::compress_what; + using encrypt_what = netw::messaging_service::encrypt_what; + using compress_what = netw::messaging_service::compress_what; using namespace seastar::tls; encrypt_what ew = encrypt_what::none; @@ -102,10 +102,10 @@ void init_ms_fd_gossiper(sstring listen_address_in // Init messaging_service // Delay listening messaging_service until gossip message handlers are registered bool listen_now = false; - net::get_messaging_service().start(listen, storage_port, ew, cw, ssl_storage_port, creds, sltba, listen_now).get(); + netw::get_messaging_service().start(listen, storage_port, ew, cw, ssl_storage_port, creds, sltba, listen_now).get(); // #293 - do not stop anything - //engine().at_exit([] { return net::get_messaging_service().stop(); }); + //engine().at_exit([] { return netw::get_messaging_service().stop(); }); // Init failure_detector gms::get_failure_detector().start(std::move(phi)).get(); // #293 - do not stop anything diff --git a/json.hh b/json.hh index 23e72791aa..92d2a2028d 100644 --- a/json.hh +++ b/json.hh @@ -25,6 +25,7 @@ #include +namespace seastar { // FIXME: not ours namespace json { template @@ -60,3 +61,5 @@ inline std::map to_map(const sstring& raw) { } } + +} diff --git a/lister.cc b/lister.cc index 5a0284dffc..8dd821d726 100644 --- a/lister.cc +++ b/lister.cc @@ -4,7 +4,7 @@ #include "disk-error-handler.hh" #include "checked-file-impl.hh" -static seastar::logger logger("lister"); +static seastar::logger llogger("lister"); lister::lister(file f, dir_entry_types type, walker_type walker, filter_type filter, lister::path dir, lister::show_hidden do_show_hidden) : _f(std::move(f)) diff --git a/lister.hh b/lister.hh index f4a2b2e4f5..cace29df87 100644 --- a/lister.hh +++ b/lister.hh @@ -27,6 +27,8 @@ #include #include +#include "seastarx.hh" + class lister final { public: using path = boost::filesystem::path; diff --git a/locator/gossiping_property_file_snitch.cc b/locator/gossiping_property_file_snitch.cc index a93cb2c083..c0a7b3c44b 100644 --- a/locator/gossiping_property_file_snitch.cc +++ b/locator/gossiping_property_file_snitch.cc @@ -136,7 +136,7 @@ future<> gossiping_property_file_snitch::gossiper_starting() { auto& g = get_local_gossiper(); auto& ss = get_local_storage_service(); - auto local_internal_addr = net::get_local_messaging_service().listen_address(); + auto local_internal_addr = netw::get_local_messaging_service().listen_address(); std::ostringstream ostrm; ostrm<get_datacenter(public_address) == _local_dc && @@ -75,10 +75,10 @@ private: // ...then update messaging_service cache and reset the currently // open connections to this endpoint on all shards... // - net::get_messaging_service().invoke_on_all([public_address, local_address] (auto& local_ms) { + netw::get_messaging_service().invoke_on_all([public_address, local_address] (auto& local_ms) { local_ms.cache_preferred_ip(public_address, local_address); - net::msg_addr id = { + netw::msg_addr id = { .addr = public_address }; local_ms.remove_rpc_client(id); diff --git a/locator/token_metadata.cc b/locator/token_metadata.cc index 184cc164f4..1df0d156da 100644 --- a/locator/token_metadata.cc +++ b/locator/token_metadata.cc @@ -34,7 +34,7 @@ namespace locator { -static logging::logger logger("token_metadata"); +static logging::logger tlogger("token_metadata"); template static void remove_by_value(C& container, V value) { @@ -129,7 +129,7 @@ void token_metadata::update_normal_tokens(std::unordered_map(t, endpoint)); should_sort_tokens |= prev.second; // new token inserted -> sort if (prev.first->second != endpoint) { - logger.warn("Token {} changing ownership from {} to {}", t, prev.first->second, endpoint); + tlogger.warn("Token {} changing ownership from {} to {}", t, prev.first->second, endpoint); prev.first->second = endpoint; } } @@ -199,7 +199,7 @@ void token_metadata::update_host_id(const UUID& host_id, inet_address endpoint) UUID storedId = _endpoint_to_host_id_map.get(endpoint); // if ((storedId != null) && (!storedId.equals(host_id))) - logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, host_id); + tlogger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, host_id); #endif _endpoint_to_host_id_map[endpoint] = host_id; } @@ -447,7 +447,7 @@ void token_metadata::calculate_pending_ranges(abstract_replication_strategy& str std::unordered_multimap, inet_address> new_pending_ranges; if (_bootstrap_tokens.empty() && _leaving_endpoints.empty() && _moving_endpoints.empty()) { - logger.debug("No bootstrapping, leaving or moving nodes -> empty pending ranges for {}", keyspace_name); + tlogger.debug("No bootstrapping, leaving or moving nodes -> empty pending ranges for {}", keyspace_name); set_pending_ranges(keyspace_name, std::move(new_pending_ranges)); return; } @@ -535,8 +535,8 @@ void token_metadata::calculate_pending_ranges(abstract_replication_strategy& str set_pending_ranges(keyspace_name, std::move(new_pending_ranges)); - if (logger.is_enabled(logging::log_level::debug)) { - logger.debug("Pending ranges: {}", (_pending_ranges.empty() ? "" : print_pending_ranges())); + if (tlogger.is_enabled(logging::log_level::debug)) { + tlogger.debug("Pending ranges: {}", (_pending_ranges.empty() ? "" : print_pending_ranges())); } } sstring token_metadata::print_pending_ranges() { diff --git a/main.cc b/main.cc index ded71b8a74..49b10992ca 100644 --- a/main.cc +++ b/main.cc @@ -588,7 +588,7 @@ int main(int ac, char** av) { streaming::stream_session::init_streaming_service(db).get(); api::set_server_stream_manager(ctx).get(); // Start handling REPAIR_CHECKSUM_RANGE messages - net::get_messaging_service().invoke_on_all([&db] (auto& ms) { + netw::get_messaging_service().invoke_on_all([&db] (auto& ms) { ms.register_repair_checksum_range([&db] (sstring keyspace, sstring cf, dht::token_range range, rpc::optional hash_version) { auto hv = hash_version ? *hash_version : repair_checksum::legacy; return do_with(std::move(keyspace), std::move(cf), std::move(range), diff --git a/memtable.cc b/memtable.cc index 3e4469f3c1..77dab4a5a0 100644 --- a/memtable.cc +++ b/memtable.cc @@ -23,8 +23,7 @@ #include "database.hh" #include "frozen_mutation.hh" #include "sstable_mutation_readers.hh" - -namespace stdx = std::experimental; +#include "stdx.hh" memtable::memtable(schema_ptr schema, dirty_memory_manager& dmm, memtable_list* memtable_list) : logalloc::region(dmm.region_group()) diff --git a/message/messaging_service.cc b/message/messaging_service.cc index d4bde8685f..938bd49242 100644 --- a/message/messaging_service.cc +++ b/message/messaging_service.cc @@ -75,8 +75,9 @@ #include "rpc/lz4_compressor.hh" #include "rpc/multi_algo_compressor_factory.hh" #include "partition_range_compat.hh" +#include "stdx.hh" -namespace net { +namespace netw { // thunk from rpc serializers to generate serializers template @@ -106,7 +107,7 @@ lw_shared_ptr read(serializer s, Input& in, boost::type>) { return make_lw_shared(read(s, in, boost::type())); } -static logging::logger logger("messaging_service"); +static logging::logger mlogger("messaging_service"); static logging::logger rpc_logger("rpc"); using inet_address = gms::inet_address; @@ -278,9 +279,9 @@ void messaging_service::start_listen() { // Do this on just cpu 0, to avoid duplicate logs. if (engine().cpu_id() == 0) { if (_server_tls[0]) { - logger.info("Starting Encrypted Messaging Service on SSL port {}", _ssl_port); + mlogger.info("Starting Encrypted Messaging Service on SSL port {}", _ssl_port); } - logger.info("Starting Messaging Service on port {}", _port); + mlogger.info("Starting Messaging Service on port {}", _port); } } @@ -526,7 +527,7 @@ void messaging_service::remove_rpc_client_one(clients_map& clients, msg_addr id, // client->stop() is over. // client->stop().finally([id, client, ms = shared_from_this()] { - logger.debug("dropped connection to {}", id.addr); + mlogger.debug("dropped connection to {}", id.addr); }).discard_result(); } } @@ -606,7 +607,6 @@ auto send_message_timeout(messaging_service* ms, messaging_verb verb, msg_addr i template auto send_message_timeout_and_retry(messaging_service* ms, messaging_verb verb, msg_addr id, std::chrono::seconds timeout, int nr_retry, std::chrono::seconds wait, MsgOut... msg) { - namespace stdx = std::experimental; using MsgInTuple = typename futurize_t::value_type; return do_with(int(nr_retry), std::move(msg)..., [ms, verb, id, timeout, wait, nr_retry] (auto& retry, const auto&... messages) { return repeat_until_value([ms, verb, id, timeout, wait, nr_retry, &retry, &messages...] { @@ -616,35 +616,35 @@ auto send_message_timeout_and_retry(messaging_service* ms, messaging_verb verb, try { MsgInTuple ret = f.get(); if (retry != nr_retry) { - logger.info("Retry verb={} to {}, retry={}: OK", vb, id, retry); + mlogger.info("Retry verb={} to {}, retry={}: OK", vb, id, retry); } return make_ready_future>(std::move(ret)); } catch (rpc::timeout_error) { - logger.info("Retry verb={} to {}, retry={}: timeout in {} seconds", vb, id, retry, timeout.count()); + mlogger.info("Retry verb={} to {}, retry={}: timeout in {} seconds", vb, id, retry, timeout.count()); throw; } catch (rpc::closed_error) { - logger.info("Retry verb={} to {}, retry={}: {}", vb, id, retry, std::current_exception()); + mlogger.info("Retry verb={} to {}, retry={}: {}", vb, id, retry, std::current_exception()); // Stop retrying if retry reaches 0 or message service is shutdown // or the remote node is removed from gossip (on_remove()) retry--; if (retry == 0) { - logger.debug("Retry verb={} to {}, retry={}: stop retrying: retry == 0", vb, id, retry); + mlogger.debug("Retry verb={} to {}, retry={}: stop retrying: retry == 0", vb, id, retry); throw; } if (ms->is_stopping()) { - logger.debug("Retry verb={} to {}, retry={}: stop retrying: messaging_service is stopped", + mlogger.debug("Retry verb={} to {}, retry={}: stop retrying: messaging_service is stopped", vb, id, retry); throw; } if (!gms::get_local_gossiper().is_known_endpoint(id.addr)) { - logger.debug("Retry verb={} to {}, retry={}: stop retrying: node is removed from the cluster", + mlogger.debug("Retry verb={} to {}, retry={}: stop retrying: node is removed from the cluster", vb, id, retry); throw; } return sleep_abortable(wait).then([] { return make_ready_future>(stdx::nullopt); }).handle_exception([vb, id, retry] (std::exception_ptr ep) { - logger.debug("Retry verb={} to {}, retry={}: stop retrying: {}", vb, id, retry, ep); + mlogger.debug("Retry verb={} to {}, retry={}: stop retrying: {}", vb, id, retry, ep); return make_exception_future>(ep); }); } catch (...) { @@ -740,7 +740,7 @@ void messaging_service::register_gossip_echo(std::function ()>&& func) register_handler(this, messaging_verb::GOSSIP_ECHO, std::move(func)); } void messaging_service::unregister_gossip_echo() { - _rpc->unregister_handler(net::messaging_verb::GOSSIP_ECHO); + _rpc->unregister_handler(netw::messaging_verb::GOSSIP_ECHO); } future<> messaging_service::send_gossip_echo(msg_addr id) { return send_message_timeout(this, messaging_verb::GOSSIP_ECHO, std::move(id), 3000ms); @@ -750,7 +750,7 @@ void messaging_service::register_gossip_shutdown(std::functionunregister_handler(net::messaging_verb::GOSSIP_SHUTDOWN); + _rpc->unregister_handler(netw::messaging_verb::GOSSIP_SHUTDOWN); } future<> messaging_service::send_gossip_shutdown(msg_addr id, inet_address from) { return send_message_oneway(this, messaging_verb::GOSSIP_SHUTDOWN, std::move(id), std::move(from)); @@ -761,7 +761,7 @@ void messaging_service::register_gossip_digest_syn(std::functionunregister_handler(net::messaging_verb::GOSSIP_DIGEST_SYN); + _rpc->unregister_handler(netw::messaging_verb::GOSSIP_DIGEST_SYN); } future<> messaging_service::send_gossip_digest_syn(msg_addr id, gossip_digest_syn msg) { return send_message_oneway(this, messaging_verb::GOSSIP_DIGEST_SYN, std::move(id), std::move(msg)); @@ -772,7 +772,7 @@ void messaging_service::register_gossip_digest_ack(std::functionunregister_handler(net::messaging_verb::GOSSIP_DIGEST_ACK); + _rpc->unregister_handler(netw::messaging_verb::GOSSIP_DIGEST_ACK); } future<> messaging_service::send_gossip_digest_ack(msg_addr id, gossip_digest_ack msg) { return send_message_oneway(this, messaging_verb::GOSSIP_DIGEST_ACK, std::move(id), std::move(msg)); @@ -783,27 +783,27 @@ void messaging_service::register_gossip_digest_ack2(std::functionunregister_handler(net::messaging_verb::GOSSIP_DIGEST_ACK2); + _rpc->unregister_handler(netw::messaging_verb::GOSSIP_DIGEST_ACK2); } future<> messaging_service::send_gossip_digest_ack2(msg_addr id, gossip_digest_ack2 msg) { return send_message_oneway(this, messaging_verb::GOSSIP_DIGEST_ACK2, std::move(id), std::move(msg)); } void messaging_service::register_definitions_update(std::function fm)>&& func) { - register_handler(this, net::messaging_verb::DEFINITIONS_UPDATE, std::move(func)); + register_handler(this, netw::messaging_verb::DEFINITIONS_UPDATE, std::move(func)); } void messaging_service::unregister_definitions_update() { - _rpc->unregister_handler(net::messaging_verb::DEFINITIONS_UPDATE); + _rpc->unregister_handler(netw::messaging_verb::DEFINITIONS_UPDATE); } future<> messaging_service::send_definitions_update(msg_addr id, std::vector fm) { return send_message_oneway(this, messaging_verb::DEFINITIONS_UPDATE, std::move(id), std::move(fm)); } void messaging_service::register_migration_request(std::function> ()>&& func) { - register_handler(this, net::messaging_verb::MIGRATION_REQUEST, std::move(func)); + register_handler(this, netw::messaging_verb::MIGRATION_REQUEST, std::move(func)); } void messaging_service::unregister_migration_request() { - _rpc->unregister_handler(net::messaging_verb::MIGRATION_REQUEST); + _rpc->unregister_handler(netw::messaging_verb::MIGRATION_REQUEST); } future> messaging_service::send_migration_request(msg_addr id) { return send_message>(this, messaging_verb::MIGRATION_REQUEST, std::move(id)); @@ -811,10 +811,10 @@ future> messaging_service::send_migration_request(m void messaging_service::register_mutation(std::function (const rpc::client_info&, rpc::opt_time_point, frozen_mutation fm, std::vector forward, inet_address reply_to, unsigned shard, response_id_type response_id, rpc::optional> trace_info)>&& func) { - register_handler(this, net::messaging_verb::MUTATION, std::move(func)); + register_handler(this, netw::messaging_verb::MUTATION, std::move(func)); } void messaging_service::unregister_mutation() { - _rpc->unregister_handler(net::messaging_verb::MUTATION); + _rpc->unregister_handler(netw::messaging_verb::MUTATION); } future<> messaging_service::send_mutation(msg_addr id, clock_type::time_point timeout, const frozen_mutation& fm, std::vector forward, inet_address reply_to, unsigned shard, response_id_type response_id, std::experimental::optional trace_info) { @@ -823,86 +823,86 @@ future<> messaging_service::send_mutation(msg_addr id, clock_type::time_point ti } void messaging_service::register_counter_mutation(std::function (const rpc::client_info&, rpc::opt_time_point, std::vector fms, db::consistency_level cl, stdx::optional trace_info)>&& func) { - register_handler(this, net::messaging_verb::COUNTER_MUTATION, std::move(func)); + register_handler(this, netw::messaging_verb::COUNTER_MUTATION, std::move(func)); } void messaging_service::unregister_counter_mutation() { - _rpc->unregister_handler(net::messaging_verb::COUNTER_MUTATION); + _rpc->unregister_handler(netw::messaging_verb::COUNTER_MUTATION); } future<> messaging_service::send_counter_mutation(msg_addr id, clock_type::time_point timeout, std::vector fms, db::consistency_level cl, stdx::optional trace_info) { return send_message_timeout(this, messaging_verb::COUNTER_MUTATION, std::move(id), timeout, std::move(fms), cl, std::move(trace_info)); } void messaging_service::register_mutation_done(std::function (const rpc::client_info& cinfo, unsigned shard, response_id_type response_id)>&& func) { - register_handler(this, net::messaging_verb::MUTATION_DONE, std::move(func)); + register_handler(this, netw::messaging_verb::MUTATION_DONE, std::move(func)); } void messaging_service::unregister_mutation_done() { - _rpc->unregister_handler(net::messaging_verb::MUTATION_DONE); + _rpc->unregister_handler(netw::messaging_verb::MUTATION_DONE); } future<> messaging_service::send_mutation_done(msg_addr id, unsigned shard, response_id_type response_id) { return send_message_oneway(this, messaging_verb::MUTATION_DONE, std::move(id), std::move(shard), std::move(response_id)); } void messaging_service::register_read_data(std::function>> (const rpc::client_info&, query::read_command cmd, compat::wrapping_partition_range pr, rpc::optional oda)>&& func) { - register_handler(this, net::messaging_verb::READ_DATA, std::move(func)); + register_handler(this, netw::messaging_verb::READ_DATA, std::move(func)); } void messaging_service::unregister_read_data() { - _rpc->unregister_handler(net::messaging_verb::READ_DATA); + _rpc->unregister_handler(netw::messaging_verb::READ_DATA); } future messaging_service::send_read_data(msg_addr id, clock_type::time_point timeout, const query::read_command& cmd, const dht::partition_range& pr, query::digest_algorithm da) { return send_message_timeout(this, messaging_verb::READ_DATA, std::move(id), timeout, cmd, pr, da); } void messaging_service::register_get_schema_version(std::function(unsigned, table_schema_version)>&& func) { - register_handler(this, net::messaging_verb::GET_SCHEMA_VERSION, std::move(func)); + register_handler(this, netw::messaging_verb::GET_SCHEMA_VERSION, std::move(func)); } void messaging_service::unregister_get_schema_version() { - _rpc->unregister_handler(net::messaging_verb::GET_SCHEMA_VERSION); + _rpc->unregister_handler(netw::messaging_verb::GET_SCHEMA_VERSION); } future messaging_service::send_get_schema_version(msg_addr dst, table_schema_version v) { return send_message(this, messaging_verb::GET_SCHEMA_VERSION, dst, static_cast(dst.cpu_id), v); } void messaging_service::register_schema_check(std::function()>&& func) { - register_handler(this, net::messaging_verb::SCHEMA_CHECK, std::move(func)); + register_handler(this, netw::messaging_verb::SCHEMA_CHECK, std::move(func)); } void messaging_service::unregister_schema_check() { - _rpc->unregister_handler(net::messaging_verb::SCHEMA_CHECK); + _rpc->unregister_handler(netw::messaging_verb::SCHEMA_CHECK); } future messaging_service::send_schema_check(msg_addr dst) { - return send_message(this, net::messaging_verb::SCHEMA_CHECK, dst); + return send_message(this, netw::messaging_verb::SCHEMA_CHECK, dst); } void messaging_service::register_read_mutation_data(std::function>> (const rpc::client_info&, query::read_command cmd, compat::wrapping_partition_range pr)>&& func) { - register_handler(this, net::messaging_verb::READ_MUTATION_DATA, std::move(func)); + register_handler(this, netw::messaging_verb::READ_MUTATION_DATA, std::move(func)); } void messaging_service::unregister_read_mutation_data() { - _rpc->unregister_handler(net::messaging_verb::READ_MUTATION_DATA); + _rpc->unregister_handler(netw::messaging_verb::READ_MUTATION_DATA); } future messaging_service::send_read_mutation_data(msg_addr id, clock_type::time_point timeout, const query::read_command& cmd, const dht::partition_range& pr) { return send_message_timeout(this, messaging_verb::READ_MUTATION_DATA, std::move(id), timeout, cmd, pr); } void messaging_service::register_read_digest(std::function (const rpc::client_info&, query::read_command cmd, compat::wrapping_partition_range pr)>&& func) { - register_handler(this, net::messaging_verb::READ_DIGEST, std::move(func)); + register_handler(this, netw::messaging_verb::READ_DIGEST, std::move(func)); } void messaging_service::unregister_read_digest() { - _rpc->unregister_handler(net::messaging_verb::READ_DIGEST); + _rpc->unregister_handler(netw::messaging_verb::READ_DIGEST); } future> messaging_service::send_read_digest(msg_addr id, clock_type::time_point timeout, const query::read_command& cmd, const dht::partition_range& pr) { - return send_message_timeout>>(this, net::messaging_verb::READ_DIGEST, std::move(id), timeout, cmd, pr); + return send_message_timeout>>(this, netw::messaging_verb::READ_DIGEST, std::move(id), timeout, cmd, pr); } // Wrapper for TRUNCATE void messaging_service::register_truncate(std::function (sstring, sstring)>&& func) { - register_handler(this, net::messaging_verb::TRUNCATE, std::move(func)); + register_handler(this, netw::messaging_verb::TRUNCATE, std::move(func)); } void messaging_service::unregister_truncate() { - _rpc->unregister_handler(net::messaging_verb::TRUNCATE); + _rpc->unregister_handler(netw::messaging_verb::TRUNCATE); } future<> messaging_service::send_truncate(msg_addr id, std::chrono::milliseconds timeout, sstring ks, sstring cf) { - return send_message_timeout(this, net::messaging_verb::TRUNCATE, std::move(id), std::move(timeout), std::move(ks), std::move(cf)); + return send_message_timeout(this, netw::messaging_verb::TRUNCATE, std::move(id), std::move(timeout), std::move(ks), std::move(cf)); } // Wrapper for REPLICATION_FINISHED diff --git a/message/messaging_service.hh b/message/messaging_service.hh index f858351473..2b0160aad6 100644 --- a/message/messaging_service.hh +++ b/message/messaging_service.hh @@ -76,7 +76,7 @@ using wrapping_partition_range = wrapping_range; } -namespace net { +namespace netw { /* All verb handler identifiers */ enum class messaging_verb : int32_t { @@ -111,19 +111,19 @@ enum class messaging_verb : int32_t { LAST = 24, }; -} // namespace net +} // namespace netw namespace std { template <> -class hash { +class hash { public: - size_t operator()(const net::messaging_verb& x) const { + size_t operator()(const netw::messaging_verb& x) const { return hash()(int32_t(x)); } }; } // namespace std -namespace net { +namespace netw { struct serializer {}; @@ -145,7 +145,7 @@ public: struct rpc_protocol_server_wrapper; struct shard_info; - using msg_addr = net::msg_addr; + using msg_addr = netw::msg_addr; using inet_address = gms::inet_address; using UUID = utils::UUID; using clients_map = std::unordered_map; @@ -359,4 +359,4 @@ inline messaging_service& get_local_messaging_service() { return _the_messaging_service.local(); } -} // namespace net +} // namespace netw diff --git a/message/messaging_service_fwd.hh b/message/messaging_service_fwd.hh index b576240efc..40938ad1b0 100644 --- a/message/messaging_service_fwd.hh +++ b/message/messaging_service_fwd.hh @@ -21,7 +21,7 @@ #pragma once -namespace net { +namespace netw { struct msg_addr; enum class messaging_verb; diff --git a/mutation_reader.cc b/mutation_reader.cc index 6f61c69719..584c3f50b4 100644 --- a/mutation_reader.cc +++ b/mutation_reader.cc @@ -26,8 +26,7 @@ #include "mutation_reader.hh" #include "core/future-util.hh" #include "utils/move.hh" - -namespace stdx = std::experimental; +#include "stdx.hh" template T move_and_clear(T& obj) { diff --git a/query-result.hh b/query-result.hh index ef3a491480..254ea02c4f 100644 --- a/query-result.hh +++ b/query-result.hh @@ -28,8 +28,7 @@ #include "md5_hasher.hh" #include #include - -namespace stdx = std::experimental; +#include "seastarx.hh" namespace query { diff --git a/range_tombstone.hh b/range_tombstone.hh index 9d34e22a50..79fe526762 100644 --- a/range_tombstone.hh +++ b/range_tombstone.hh @@ -28,9 +28,9 @@ #include "keys.hh" #include "tombstone.hh" #include "clustering_bounds_comparator.hh" +#include "stdx.hh" namespace bi = boost::intrusive; -namespace stdx = std::experimental; class position_in_partition_view; diff --git a/repair/repair.cc b/repair/repair.cc index 7eec803774..987b8770f8 100644 --- a/repair/repair.cc +++ b/repair/repair.cc @@ -38,7 +38,7 @@ #include #include -static logging::logger logger("repair"); +static logging::logger rlogger("repair"); struct failed_range { sstring cf; @@ -84,19 +84,19 @@ public: return sp_in.execute().discard_result().then([this] { return sp_out.execute().discard_result(); }).handle_exception([] (auto ep) { - logger.warn("repair's stream failed: {}", ep); + rlogger.warn("repair's stream failed: {}", ep); return make_exception_future(ep); }); } bool check_failed_ranges() { if (failed_ranges.empty()) { - logger.info("repair {} completed successfully", id); + rlogger.info("repair {} completed successfully", id); return true; } else { for (auto& frange: failed_ranges) { - logger.debug("repair cf {} range {} failed", frange.cf, frange.range); + rlogger.debug("repair cf {} range {} failed", frange.cf, frange.range); } - logger.info("repair {} failed - {} ranges failed", id, failed_ranges.size()); + rlogger.info("repair {} failed - {} ranges failed", id, failed_ranges.size()); return false; } } @@ -567,7 +567,7 @@ static future<> repair_cf_range(repair_info& ri, break; } } - logger.debug("target_partitions={}, estimated_partitions={}, ranges.size={}, range={} -> ranges={}", + rlogger.debug("target_partitions={}, estimated_partitions={}, ranges.size={}, range={} -> ranges={}", ri.target_partitions, estimated_partitions, ranges.size(), range, ranges); return do_with(seastar::gate(), true, std::move(cf), std::move(ranges), @@ -586,8 +586,8 @@ static future<> repair_cf_range(repair_info& ri, checksums.push_back(checksum_range(ri.db, ri.keyspace, cf, range, checksum_type)); for (auto&& neighbor : neighbors) { checksums.push_back( - net::get_local_messaging_service().send_repair_checksum_range( - net::msg_addr{neighbor}, ri.keyspace, cf, range, checksum_type)); + netw::get_local_messaging_service().send_repair_checksum_range( + netw::msg_addr{neighbor}, ri.keyspace, cf, range, checksum_type)); } completion.enter(); @@ -601,7 +601,7 @@ static future<> repair_cf_range(repair_info& ri, std::vector live_neighbors_checksum; for (unsigned i = 0; i < checksums.size(); i++) { if (checksums[i].failed()) { - logger.warn( + rlogger.warn( "Checksum of range {} on {} failed: {}", range, (i ? neighbors[i-1] : @@ -711,7 +711,7 @@ static future<> repair_cf_range(repair_info& ri, } } if (!(live_neighbors_in.empty() && live_neighbors_out.empty())) { - logger.info("Found differing range {} on nodes {}, in = {}, out = {}", range, + rlogger.info("Found differing range {} on nodes {}, in = {}, out = {}", range, live_neighbors, live_neighbors_in, live_neighbors_out); ri.request_transfer_ranges(cf, range, live_neighbors_in, live_neighbors_out); return make_ready_future<>(); @@ -725,7 +725,7 @@ static future<> repair_cf_range(repair_info& ri, // tell the caller. success = false; ri.failed_ranges.push_back(failed_range{cf, range}); - logger.warn("Failed sync of range {}: {}", range, eptr); + rlogger.warn("Failed sync of range {}: {}", range, eptr); }).finally([&completion] { parallelism_semaphore.signal(1); completion.leave(); // notify do_for_each that we're done @@ -734,7 +734,7 @@ static future<> repair_cf_range(repair_info& ri, }).finally([&success, &completion] { return completion.close().then([&success] { if (!success) { - logger.warn("Checksum or sync of partial range failed"); + rlogger.warn("Checksum or sync of partial range failed"); } // We probably want the repair contiunes even if some // ranges fail to do the checksum. We need to set the @@ -752,7 +752,7 @@ static future<> repair_cf_range(repair_info& ri, static future<> repair_range(repair_info& ri, const dht::token_range& range) { auto id = utils::UUID_gen::get_time_UUID(); return do_with(get_neighbors(ri.db.local(), ri.keyspace, range, ri.data_centers, ri.hosts), [&ri, range, id] (const auto& neighbors) { - logger.debug("[repair #{}] new session: will sync {} on range {} for {}.{}", id, neighbors, range, ri.keyspace, ri.cfs); + rlogger.debug("[repair #{}] new session: will sync {} on range {} for {}.{}", id, neighbors, range, ri.keyspace, ri.cfs); return do_for_each(ri.cfs.begin(), ri.cfs.end(), [&ri, &neighbors, range] (auto&& cf) { return repair_cf_range(ri, cf, range, neighbors); }); @@ -977,7 +977,7 @@ static future<> repair_ranges(repair_info ri) { }).then([&ri] { repair_tracker.done(ri.id, ri.check_failed_ranges()); }).handle_exception([&ri] (std::exception_ptr eptr) { - logger.info("repair {} failed - {}", ri.id, eptr); + rlogger.info("repair {} failed - {}", ri.id, eptr); repair_tracker.done(ri.id, false); }); }); @@ -999,7 +999,7 @@ static int do_repair_start(seastar::sharded& db, sstring keyspace, // that "Nothing to repair for keyspace '...'". We don't have such a case // yet. Real ids returned by next_repair_command() will be >= 1. int id = repair_tracker.next_repair_command(); - logger.info("starting user-requested repair for keyspace {}, repair id {}, options {}", keyspace, id, options_map); + rlogger.info("starting user-requested repair for keyspace {}, repair id {}, options {}", keyspace, id, options_map); repair_tracker.start(id); @@ -1011,7 +1011,7 @@ static int do_repair_start(seastar::sharded& db, sstring keyspace, if (options.ranges.size()) { ranges = options.ranges; } else if (options.primary_range) { - logger.info("primary-range repair"); + rlogger.info("primary-range repair"); // when "primary_range" option is on, neither data_centers nor hosts // may be set, except data_centers may contain only local DC (-local) #if 0 @@ -1095,10 +1095,10 @@ future repair_get_status(seastar::sharded& db, int id) } future<> repair_shutdown(seastar::sharded& db) { - logger.info("Starting shutdown of repair"); + rlogger.info("Starting shutdown of repair"); return db.invoke_on(0, [] (database& localdb) { return repair_tracker.shutdown().then([] { - logger.info("Completed shutdown of repair"); + rlogger.info("Completed shutdown of repair"); }); }); } diff --git a/row_cache.cc b/row_cache.cc index 93aec165cf..7d78210eef 100644 --- a/row_cache.cc +++ b/row_cache.cc @@ -30,12 +30,12 @@ #include "utils/move.hh" #include #include +#include "stdx.hh" using namespace std::chrono_literals; -namespace stdx = std::experimental; -static logging::logger logger("cache"); +static logging::logger clogger("cache"); thread_local seastar::thread_scheduling_group row_cache::_update_thread_scheduling_group(1ms, 0.2); diff --git a/schema_registry.cc b/schema_registry.cc index 945fb3a428..6c80e1694b 100644 --- a/schema_registry.cc +++ b/schema_registry.cc @@ -25,7 +25,7 @@ #include "log.hh" -static logging::logger logger("schema_registry"); +static logging::logger slogger("schema_registry"); static thread_local schema_registry registry; @@ -58,7 +58,7 @@ schema_ptr schema_registry::learn(const schema_ptr& s) { if (i != _entries.end()) { return i->second->get_schema(); } - logger.debug("Learning about version {} of {}.{}", s->version(), s->ks_name(), s->cf_name()); + slogger.debug("Learning about version {} of {}.{}", s->version(), s->ks_name(), s->cf_name()); auto e_ptr = make_lw_shared(s->version(), *this); auto loaded_s = e_ptr->load(frozen_schema(s)); _entries.emplace(s->version(), e_ptr); @@ -135,7 +135,7 @@ schema_ptr schema_registry_entry::load(frozen_schema fs) { _schema_promise = {}; } _state = state::LOADED; - logger.trace("Loaded {} = {}", _version, *s); + slogger.trace("Loaded {} = {}", _version, *s); return s; } @@ -144,11 +144,11 @@ future schema_registry_entry::start_loading(async_schema_loader load auto f = _loader(_version); auto sf = _schema_promise.get_shared_future(); _state = state::LOADING; - logger.trace("Loading {}", _version); + slogger.trace("Loading {}", _version); f.then_wrapped([self = shared_from_this(), this] (future&& f) { _loader = {}; if (_state != state::LOADING) { - logger.trace("Loading of {} aborted", _version); + slogger.trace("Loading of {} aborted", _version); return; } try { @@ -158,7 +158,7 @@ future schema_registry_entry::start_loading(async_schema_loader load std::throw_with_nested(schema_version_loading_failed(_version)); } } catch (...) { - logger.debug("Loading of {} failed: {}", _version, std::current_exception()); + slogger.debug("Loading of {} failed: {}", _version, std::current_exception()); _schema_promise.set_exception(std::current_exception()); _registry._entries.erase(_version); } @@ -168,7 +168,7 @@ future schema_registry_entry::start_loading(async_schema_loader load schema_ptr schema_registry_entry::get_schema() { if (!_schema) { - logger.trace("Activating {}", _version); + slogger.trace("Activating {}", _version); auto s = _frozen_schema->unfreeze(); if (s->version() != _version) { throw std::runtime_error(sprint("Unfrozen schema version doesn't match entry version (%s): %s", _version, *s)); @@ -182,13 +182,13 @@ schema_ptr schema_registry_entry::get_schema() { } void schema_registry_entry::detach_schema() noexcept { - logger.trace("Deactivating {}", _version); + slogger.trace("Deactivating {}", _version); _schema = nullptr; // TODO: keep the entry for a while (timer) try { _registry._entries.erase(_version); } catch (...) { - logger.error("Failed to erase schema version {}: {}", _version, std::current_exception()); + slogger.error("Failed to erase schema version {}: {}", _version, std::current_exception()); } } @@ -204,7 +204,7 @@ future<> schema_registry_entry::maybe_sync(std::function()> syncer) { case schema_registry_entry::sync_state::SYNCING: return _synced_promise.get_shared_future(); case schema_registry_entry::sync_state::NOT_SYNCED: { - logger.debug("Syncing {}", _version); + slogger.debug("Syncing {}", _version); _synced_promise = {}; auto f = do_with(std::move(syncer), [] (auto& syncer) { return syncer(); @@ -216,11 +216,11 @@ future<> schema_registry_entry::maybe_sync(std::function()> syncer) { return; } if (f.failed()) { - logger.debug("Syncing of {} failed", _version); + slogger.debug("Syncing of {} failed", _version); _sync_state = schema_registry_entry::sync_state::NOT_SYNCED; _synced_promise.set_exception(f.get_exception()); } else { - logger.debug("Synced {}", _version); + slogger.debug("Synced {}", _version); _sync_state = schema_registry_entry::sync_state::SYNCED; _synced_promise.set_value(); } @@ -241,7 +241,7 @@ void schema_registry_entry::mark_synced() { _synced_promise.set_value(); } _sync_state = sync_state::SYNCED; - logger.debug("Marked {} as synced", _version); + slogger.debug("Marked {} as synced", _version); } schema_registry& local_schema_registry() { diff --git a/seastar b/seastar index f726938f4d..8aef5f569a 160000 --- a/seastar +++ b/seastar @@ -1 +1 @@ -Subproject commit f726938f4d7ef52ebf9eb977f73fa98122699058 +Subproject commit 8aef5f569a3653e2bf407b49da76a89c7c512eb8 diff --git a/seastarx.hh b/seastarx.hh new file mode 100644 index 0000000000..be002be49a --- /dev/null +++ b/seastarx.hh @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 ScyllaDB + */ + +/* + * This file is part of Scylla. + * + * Scylla is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Scylla is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Scylla. If not, see . + */ + +#pragma once + +#include // avoid conflict between ::socket and seastar::socket + +namespace seastar { + +template +class shared_ptr; + +template +shared_ptr make_shared(A&&... a); + +} + + +using namespace seastar; +using seastar::shared_ptr; +using seastar::make_shared; diff --git a/service/load_broadcaster.cc b/service/load_broadcaster.cc index 8f7b1e6994..c12c9769a2 100644 --- a/service/load_broadcaster.cc +++ b/service/load_broadcaster.cc @@ -44,7 +44,7 @@ namespace service { constexpr std::chrono::milliseconds load_broadcaster::BROADCAST_INTERVAL; -logging::logger logger("load_broadcaster"); +logging::logger llogger("load_broadcaster"); void load_broadcaster::start_broadcasting() { _done = make_ready_future<>(); @@ -53,7 +53,7 @@ void load_broadcaster::start_broadcasting() { // after that send every BROADCAST_INTERVAL. _timer.set_callback([this] { - logger.debug("Disseminating load info ..."); + llogger.debug("Disseminating load info ..."); _done = _db.map_reduce0([](database& db) { int64_t res = 0; for (auto i : db.get_column_families()) { diff --git a/service/migration_manager.cc b/service/migration_manager.cc index 51c419e6f5..f8bbbefe8b 100644 --- a/service/migration_manager.cc +++ b/service/migration_manager.cc @@ -51,7 +51,7 @@ namespace service { -static logging::logger logger("migration_manager"); +static logging::logger mlogger("migration_manager"); distributed _the_migration_manager; @@ -72,19 +72,19 @@ future<> migration_manager::stop() void migration_manager::init_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.register_definitions_update([this] (const rpc::client_info& cinfo, std::vector m) { - auto src = net::messaging_service::get_source(cinfo); + auto src = netw::messaging_service::get_source(cinfo); do_with(std::move(m), get_local_shared_storage_proxy(), [src] (const std::vector& mutations, shared_ptr& p) { return service::get_local_migration_manager().merge_schema_from(src, mutations); }).then_wrapped([src] (auto&& f) { if (f.failed()) { - logger.error("Failed to update definitions from {}: {}", src, f.get_exception()); + mlogger.error("Failed to update definitions from {}: {}", src, f.get_exception()); } else { - logger.debug("Applied definitions update from {}.", src); + mlogger.debug("Applied definitions update from {}.", src); } }); - return net::messaging_service::no_wait(); + return netw::messaging_service::no_wait(); }); ms.register_migration_request([this] () { return db::schema_tables::convert_schema_to_mutations(get_storage_proxy()).finally([p = get_local_shared_storage_proxy()] { @@ -98,7 +98,7 @@ void migration_manager::init_messaging_service() void migration_manager::uninit_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.unregister_migration_request(); ms.unregister_definitions_update(); ms.unregister_schema_check(); @@ -156,13 +156,13 @@ future<> migration_manager::maybe_schedule_schema_pull(const utils::UUID& their_ auto& proxy = get_local_storage_proxy(); auto& db = proxy.get_db().local(); if (db.get_version() == their_version || !should_pull_schema_from(endpoint)) { - logger.debug("Not pulling schema because versions match or shouldPullSchemaFrom returned false"); + mlogger.debug("Not pulling schema because versions match or shouldPullSchemaFrom returned false"); return make_ready_future<>(); } if (db.get_version() == database::empty_version || runtime::get_uptime() < migration_delay) { // If we think we may be bootstrapping or have recently started, submit MigrationTask immediately - logger.debug("Submitting migration task for {}", endpoint); + mlogger.debug("Submitting migration task for {}", endpoint); return submit_migration_task(endpoint); } else { // Include a delay to make sure we have a chance to apply any changes being @@ -172,17 +172,17 @@ future<> migration_manager::maybe_schedule_schema_pull(const utils::UUID& their_ auto& gossiper = gms::get_local_gossiper(); auto ep_state = gossiper.get_endpoint_state_for_endpoint(endpoint); if (!ep_state) { - logger.debug("epState vanished for {}, not submitting migration task", endpoint); + mlogger.debug("epState vanished for {}, not submitting migration task", endpoint); return make_ready_future<>(); } const auto& value = ep_state->get_application_state(gms::application_state::SCHEMA); utils::UUID current_version{value->value}; auto& db = proxy.get_db().local(); if (db.get_version() == current_version) { - logger.debug("not submitting migration task for {} because our versions match", endpoint); + mlogger.debug("not submitting migration task for {} because our versions match", endpoint); return make_ready_future<>(); } - logger.debug("submitting migration task for {}", endpoint); + mlogger.debug("submitting migration task for {}", endpoint); return submit_migration_task(endpoint); }); } @@ -193,9 +193,9 @@ future<> migration_manager::submit_migration_task(const gms::inet_address& endpo return service::migration_task::run_may_throw(get_storage_proxy(), endpoint); } -future<> migration_manager::merge_schema_from(net::messaging_service::msg_addr id) +future<> migration_manager::merge_schema_from(netw::messaging_service::msg_addr id) { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); return ms.send_migration_request(std::move(id)).then([this, id] (std::vector mutations) { return do_with(std::move(mutations), [this, id] (auto&& mutations) { return this->merge_schema_from(id, mutations); @@ -203,9 +203,9 @@ future<> migration_manager::merge_schema_from(net::messaging_service::msg_addr i }); } -future<> migration_manager::merge_schema_from(net::messaging_service::msg_addr src, const std::vector& mutations) +future<> migration_manager::merge_schema_from(netw::messaging_service::msg_addr src, const std::vector& mutations) { - logger.debug("Applying schema mutations from {}", src); + mlogger.debug("Applying schema mutations from {}", src); return map_reduce(mutations, [src](const frozen_mutation& fm) { // schema table's schema is not syncable so just use get_schema_definition() return get_schema_definition(fm.schema_version(), src).then([&fm](schema_ptr s) { @@ -226,9 +226,9 @@ bool migration_manager::should_pull_schema_from(const gms::inet_address& endpoin * Don't request schema from nodes with a differnt or unknonw major version (may have incompatible schema) * Don't request schema from fat clients */ - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); return ms.knows_version(endpoint) - && ms.get_raw_version(endpoint) == net::messaging_service::current_version + && ms.get_raw_version(endpoint) == netw::messaging_service::current_version && !gms::get_local_gossiper().is_gossip_only_member(endpoint); } @@ -239,7 +239,7 @@ future<> migration_manager::notify_create_keyspace(const lw_shared_ptron_create_keyspace(name); } catch (...) { - logger.warn("Create keyspace notification failed {}: {}", name, std::current_exception()); + mlogger.warn("Create keyspace notification failed {}: {}", name, std::current_exception()); } } }); @@ -253,7 +253,7 @@ future<> migration_manager::notify_create_column_family(const schema_ptr& cfm) { try { listener->on_create_column_family(ks_name, cf_name); } catch (...) { - logger.warn("Create column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); + mlogger.warn("Create column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); } } }); @@ -267,7 +267,7 @@ future<> migration_manager::notify_create_user_type(const user_type& type) { try { listener->on_create_user_type(ks_name, type_name); } catch (...) { - logger.warn("Create user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); + mlogger.warn("Create user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); } } }); @@ -281,7 +281,7 @@ future<> migration_manager::notify_create_view(const view_ptr& view) { try { listener->on_create_view(ks_name, view_name); } catch (...) { - logger.warn("Create view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); + mlogger.warn("Create view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); } } }); @@ -308,7 +308,7 @@ future<> migration_manager::notify_update_keyspace(const lw_shared_ptron_update_keyspace(name); } catch (...) { - logger.warn("Update keyspace notification failed {}: {}", name, std::current_exception()); + mlogger.warn("Update keyspace notification failed {}: {}", name, std::current_exception()); } } }); @@ -322,7 +322,7 @@ future<> migration_manager::notify_update_column_family(const schema_ptr& cfm, b try { listener->on_update_column_family(ks_name, cf_name, columns_changed); } catch (...) { - logger.warn("Update column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); + mlogger.warn("Update column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); } } }); @@ -336,7 +336,7 @@ future<> migration_manager::notify_update_user_type(const user_type& type) { try { listener->on_update_user_type(ks_name, type_name); } catch (...) { - logger.warn("Update user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); + mlogger.warn("Update user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); } } }); @@ -350,7 +350,7 @@ future<> migration_manager::notify_update_view(const view_ptr& view, bool column try { listener->on_update_view(ks_name, view_name, columns_changed); } catch (...) { - logger.warn("Update view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); + mlogger.warn("Update view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); } } }); @@ -376,7 +376,7 @@ future<> migration_manager::notify_drop_keyspace(const sstring& ks_name) { try { listener->on_drop_keyspace(ks_name); } catch (...) { - logger.warn("Drop keyspace notification failed {}: {}", ks_name, std::current_exception()); + mlogger.warn("Drop keyspace notification failed {}: {}", ks_name, std::current_exception()); } } }); @@ -390,7 +390,7 @@ future<> migration_manager::notify_drop_column_family(const schema_ptr& cfm) { try { listener->on_drop_column_family(ks_name, cf_name); } catch (...) { - logger.warn("Drop column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); + mlogger.warn("Drop column family notification failed {}.{}: {}", ks_name, cf_name, std::current_exception()); } } }); @@ -404,7 +404,7 @@ future<> migration_manager::notify_drop_user_type(const user_type& type) { try { listener->on_drop_user_type(ks_name, type_name); } catch (...) { - logger.warn("Drop user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); + mlogger.warn("Drop user type notification failed {}.{}: {}", ks_name, type_name, std::current_exception()); } } }); @@ -418,7 +418,7 @@ future<> migration_manager::notify_drop_view(const view_ptr& view) { try { listener->on_drop_view(ks_name, view_name); } catch (...) { - logger.warn("Drop view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); + mlogger.warn("Drop view notification failed {}.{}: {}", ks_name, view_name, std::current_exception()); } } }); @@ -448,7 +448,7 @@ future<> migration_manager::announce_keyspace_update(lw_shared_ptrname())) { throw exceptions::configuration_exception(sprint("Cannot update non existing keyspace '%s'.", ksm->name())); } - logger.info("Update Keyspace: {}", ksm); + mlogger.info("Update Keyspace: {}", ksm); auto mutations = db::schema_tables::make_create_keyspace_mutations(ksm, timestamp); return announce(std::move(mutations), announce_locally); } @@ -465,7 +465,7 @@ future<> migration_manager::announce_new_keyspace(lw_shared_ptrname())) { throw exceptions::already_exists_exception{ksm->name()}; } - logger.info("Create new Keyspace: {}", ksm); + mlogger.info("Create new Keyspace: {}", ksm); auto mutations = db::schema_tables::make_create_keyspace_mutations(ksm, timestamp); return announce(std::move(mutations), announce_locally); } @@ -480,7 +480,7 @@ future<> migration_manager::announce_new_column_family(schema_ptr cfm, bool anno if (db.has_schema(cfm->ks_name(), cfm->cf_name())) { throw exceptions::already_exists_exception(cfm->ks_name(), cfm->cf_name()); } - logger.info("Create new ColumnFamily: {}", cfm); + mlogger.info("Create new ColumnFamily: {}", cfm); return db::schema_tables::make_create_table_mutations(keyspace.metadata(), cfm, api::new_timestamp()) .then([announce_locally, this] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -502,14 +502,14 @@ future<> migration_manager::announce_column_family_update(schema_ptr cfm, bool f #if 0 oldCfm.validateCompatility(cfm); #endif - logger.info("Update table '{}.{}' From {} To {}", cfm->ks_name(), cfm->cf_name(), *old_schema, *cfm); + mlogger.info("Update table '{}.{}' From {} To {}", cfm->ks_name(), cfm->cf_name(), *old_schema, *cfm); auto&& keyspace = db.find_keyspace(cfm->ks_name()).metadata(); return db::schema_tables::make_update_table_mutations(keyspace, old_schema, cfm, ts, from_thrift) .then([announce_locally, keyspace, ts, view_updates = std::move(view_updates)] (auto&& mutations) { return map_reduce(view_updates, [keyspace = std::move(keyspace), ts] (auto&& view) { auto& old_view = keyspace->cf_meta_data().at(view->cf_name()); - logger.info("Update view '{}.{}' From {} To {}", view->ks_name(), view->cf_name(), *old_view, *view); + mlogger.info("Update view '{}.{}' From {} To {}", view->ks_name(), view->cf_name(), *old_view, *view); return db::schema_tables::make_update_view_mutations(keyspace, view_ptr(old_view), std::move(view), ts); }, std::move(mutations), [] (auto&& result, auto&& view_mutations) { @@ -536,26 +536,26 @@ static future<> do_announce_new_type(user_type new_type, bool announce_locally) } future<> migration_manager::announce_new_type(user_type new_type, bool announce_locally) { - logger.info("Create new User Type: {}", new_type->get_name_as_string()); + mlogger.info("Create new User Type: {}", new_type->get_name_as_string()); return do_announce_new_type(new_type, announce_locally); } future<> migration_manager::announce_type_update(user_type updated_type, bool announce_locally) { - logger.info("Update User Type: {}", updated_type->get_name_as_string()); + mlogger.info("Update User Type: {}", updated_type->get_name_as_string()); return do_announce_new_type(updated_type, announce_locally); } #if 0 public static void announceNewFunction(UDFunction udf, boolean announceLocally) { - logger.info(String.format("Create scalar function '%s'", udf.name())); + mlogger.info(String.format("Create scalar function '%s'", udf.name())); KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace); announce(LegacySchemaTables.makeCreateFunctionMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally); } public static void announceNewAggregate(UDAggregate udf, boolean announceLocally) { - logger.info(String.format("Create aggregate function '%s'", udf.name())); + mlogger.info(String.format("Create aggregate function '%s'", udf.name())); KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace); announce(LegacySchemaTables.makeCreateAggregateMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally); } @@ -573,7 +573,7 @@ public static void announceKeyspaceUpdate(KSMetaData ksm, boolean announceLocall if (oldKsm == null) throw new ConfigurationException(String.format("Cannot update non existing keyspace '%s'.", ksm.name)); - logger.info(String.format("Update Keyspace '%s' From %s To %s", ksm.name, oldKsm, ksm)); + mlogger.info(String.format("Update Keyspace '%s' From %s To %s", ksm.name, oldKsm, ksm)); announce(LegacySchemaTables.makeCreateKeyspaceMutation(ksm, FBUtilities.timestampMicros()), announceLocally); } @@ -593,7 +593,7 @@ public static void announceColumnFamilyUpdate(CFMetaData cfm, boolean fromThrift oldCfm.validateCompatility(cfm); - logger.info(String.format("Update table '%s/%s' From %s To %s", cfm.ksName, cfm.cfName, oldCfm, cfm)); + mlogger.info(String.format("Update table '%s/%s' From %s To %s", cfm.ksName, cfm.cfName, oldCfm, cfm)); announce(LegacySchemaTables.makeUpdateTableMutation(ksm, oldCfm, cfm, FBUtilities.timestampMicros(), fromThrift), announceLocally); } #endif @@ -605,7 +605,7 @@ future<> migration_manager::announce_keyspace_drop(const sstring& ks_name, bool throw exceptions::configuration_exception(sprint("Cannot drop non existing keyspace '%s'.", ks_name)); } auto& keyspace = db.find_keyspace(ks_name); - logger.info("Drop Keyspace '{}'", ks_name); + mlogger.info("Drop Keyspace '{}'", ks_name); auto&& mutations = db::schema_tables::make_drop_keyspace_mutations(keyspace.metadata(), api::new_timestamp()); return announce(std::move(mutations), announce_locally); } @@ -627,7 +627,7 @@ future<> migration_manager::announce_column_family_drop(const sstring& ks_name, "Cannot drop table when materialized views still depend on it (%s.{%s})", ks_name, ::join(", ", views | boost::adaptors::transformed([](auto&& v) { return v->cf_name(); })))); } - logger.info("Drop table '{}.{}'", schema->ks_name(), schema->cf_name()); + mlogger.info("Drop table '{}.{}'", schema->ks_name(), schema->cf_name()); return db::schema_tables::make_drop_table_mutations(db.find_keyspace(ks_name).metadata(), schema, api::new_timestamp()) .then([announce_locally] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -641,7 +641,7 @@ future<> migration_manager::announce_type_drop(user_type dropped_type, bool anno { auto& db = get_local_storage_proxy().get_db().local(); auto&& keyspace = db.find_keyspace(dropped_type->_keyspace); - logger.info("Drop User Type: {}", dropped_type->get_name_as_string()); + mlogger.info("Drop User Type: {}", dropped_type->get_name_as_string()); return db::schema_tables::make_drop_type_mutations(keyspace.metadata(), dropped_type, api::new_timestamp()) .then([announce_locally] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -659,7 +659,7 @@ future<> migration_manager::announce_new_view(view_ptr view, bool announce_local if (keyspace->cf_meta_data().find(view->cf_name()) != keyspace->cf_meta_data().end()) { throw exceptions::already_exists_exception(view->ks_name(), view->cf_name()); } - logger.info("Create new view: {}", view); + mlogger.info("Create new view: {}", view); return db::schema_tables::make_create_view_mutations(keyspace, std::move(view), api::new_timestamp()) .then([announce_locally] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -684,7 +684,7 @@ future<> migration_manager::announce_view_update(view_ptr view, bool announce_lo #if 0 oldCfm.validateCompatility(cfm); #endif - logger.info("Update view '{}.{}' From {} To {}", view->ks_name(), view->cf_name(), *old_view, *view); + mlogger.info("Update view '{}.{}' From {} To {}", view->ks_name(), view->cf_name(), *old_view, *view); return db::schema_tables::make_update_view_mutations(std::move(keyspace), view_ptr(old_view), std::move(view), api::new_timestamp()) .then([announce_locally] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -706,7 +706,7 @@ future<> migration_manager::announce_view_drop(const sstring& ks_name, throw exceptions::invalid_request_exception("Cannot use DROP MATERIALIZED VIEW on Table"); } auto keyspace = db.find_keyspace(ks_name).metadata(); - logger.info("Drop view '{}.{}'", view->ks_name(), view->cf_name()); + mlogger.info("Drop view '{}.{}'", view->ks_name(), view->cf_name()); return db::schema_tables::make_drop_view_mutations(std::move(keyspace), view_ptr(std::move(view)), api::new_timestamp()) .then([announce_locally] (auto&& mutations) { return announce(std::move(mutations), announce_locally); @@ -720,14 +720,14 @@ future<> migration_manager::announce_view_drop(const sstring& ks_name, #if 0 public static void announceFunctionDrop(UDFunction udf, boolean announceLocally) { - logger.info(String.format("Drop scalar function overload '%s' args '%s'", udf.name(), udf.argTypes())); + mlogger.info(String.format("Drop scalar function overload '%s' args '%s'", udf.name(), udf.argTypes())); KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace); announce(LegacySchemaTables.makeDropFunctionMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally); } public static void announceAggregateDrop(UDAggregate udf, boolean announceLocally) { - logger.info(String.format("Drop aggregate function overload '%s' args '%s'", udf.name(), udf.argTypes())); + mlogger.info(String.format("Drop aggregate function overload '%s' args '%s'", udf.name(), udf.argTypes())); KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace); announce(LegacySchemaTables.makeDropAggregateMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally); } @@ -755,9 +755,9 @@ future<> migration_manager::announce(std::vector mutations, bool annou future<> migration_manager::push_schema_mutation(const gms::inet_address& endpoint, const std::vector& schema) { - net::messaging_service::msg_addr id{endpoint, 0}; + netw::messaging_service::msg_addr id{endpoint, 0}; auto fm = std::vector(schema.begin(), schema.end()); - return net::get_local_messaging_service().send_definitions_update(id, std::move(fm)); + return netw::get_local_messaging_service().send_definitions_update(id, std::move(fm)); } // Returns a future on the local application of the schema @@ -768,9 +768,9 @@ future<> migration_manager::announce(std::vector schema) { return parallel_for_each(live_members.begin(), live_members.end(), [&schema](auto& endpoint) { // only push schema to nodes with known and equal versions if (endpoint != utils::fb_utilities::get_broadcast_address() && - net::get_local_messaging_service().knows_version(endpoint) && - net::get_local_messaging_service().get_raw_version(endpoint) == - net::messaging_service::current_version) { + netw::get_local_messaging_service().knows_version(endpoint) && + netw::get_local_messaging_service().get_raw_version(endpoint) == + netw::messaging_service::current_version) { return push_schema_mutation(endpoint, schema); } else { return make_ready_future<>(); @@ -788,7 +788,7 @@ future<> migration_manager::announce(std::vector schema) { future<> migration_manager::passive_announce(utils::UUID version) { return gms::get_gossiper().invoke_on(0, [version] (auto&& gossiper) { auto& ss = service::get_local_storage_service(); - logger.debug("Gossiping my schema version {}", version); + mlogger.debug("Gossiping my schema version {}", version); return gossiper.add_local_application_state(gms::application_state::SCHEMA, ss.value_factory.schema(version)); }); } @@ -802,13 +802,13 @@ future<> migration_manager::passive_announce(utils::UUID version) { */ public static void resetLocalSchema() throws IOException { - logger.info("Starting local schema reset..."); + mlogger.info("Starting local schema reset..."); - logger.debug("Truncating schema tables..."); + mlogger.debug("Truncating schema tables..."); LegacySchemaTables.truncateSchemaTables(); - logger.debug("Clearing local schema keyspace definitions..."); + mlogger.debug("Clearing local schema keyspace definitions..."); Schema.instance.clear(); @@ -820,13 +820,13 @@ public static void resetLocalSchema() throws IOException { if (shouldPullSchemaFrom(node)) { - logger.debug("Requesting schema from {}", node); + mlogger.debug("Requesting schema from {}", node); FBUtilities.waitOnFuture(submitMigrationTask(node)); break; } } - logger.info("Local schema reset is complete."); + mlogger.info("Local schema reset is complete."); } public static class MigrationsSerializer implements IVersionedSerializer> @@ -866,7 +866,7 @@ public static class MigrationsSerializer implements IVersionedSerializer maybe_sync(const schema_ptr& s, net::messaging_service::msg_addr endpoint) { +static future<> maybe_sync(const schema_ptr& s, netw::messaging_service::msg_addr endpoint) { if (s->is_synced()) { return make_ready_future<>(); } @@ -874,7 +874,7 @@ static future<> maybe_sync(const schema_ptr& s, net::messaging_service::msg_addr return s->registry_entry()->maybe_sync([s, endpoint] { auto merge = [gs = global_schema_ptr(s), endpoint] { schema_ptr s = gs.get(); - logger.debug("Syncing schema of {}.{} (v={}) with {}", s->ks_name(), s->cf_name(), s->version(), endpoint); + mlogger.debug("Syncing schema of {}.{} (v={}) with {}", s->ks_name(), s->cf_name(), s->version(), endpoint); return get_local_migration_manager().merge_schema_from(endpoint); }; @@ -891,19 +891,19 @@ static future<> maybe_sync(const schema_ptr& s, net::messaging_service::msg_addr }); } -future get_schema_definition(table_schema_version v, net::messaging_service::msg_addr dst) { +future get_schema_definition(table_schema_version v, netw::messaging_service::msg_addr dst) { return local_schema_registry().get_or_load(v, [dst] (table_schema_version v) { - logger.debug("Requesting schema {} from {}", v, dst); - auto& ms = net::get_local_messaging_service(); + mlogger.debug("Requesting schema {} from {}", v, dst); + auto& ms = netw::get_local_messaging_service(); return ms.send_get_schema_version(dst, v); }); } -future get_schema_for_read(table_schema_version v, net::messaging_service::msg_addr dst) { +future get_schema_for_read(table_schema_version v, netw::messaging_service::msg_addr dst) { return get_schema_definition(v, dst); } -future get_schema_for_write(table_schema_version v, net::messaging_service::msg_addr dst) { +future get_schema_for_write(table_schema_version v, netw::messaging_service::msg_addr dst) { return get_schema_definition(v, dst).then([dst] (schema_ptr s) { return maybe_sync(s, dst).then([s] { return s; diff --git a/service/migration_manager.hh b/service/migration_manager.hh index d9966d934b..b635029ff6 100644 --- a/service/migration_manager.hh +++ b/service/migration_manager.hh @@ -74,11 +74,11 @@ public: // Fetches schema from remote node and applies it locally. // Differs from submit_migration_task() in that all errors are propagated. - future<> merge_schema_from(net::msg_addr); + future<> merge_schema_from(netw::msg_addr); // Merge mutations received from src. // Keep mutations alive around whole async operation. - future<> merge_schema_from(net::msg_addr src, const std::vector& mutations); + future<> merge_schema_from(netw::msg_addr src, const std::vector& mutations); future<> notify_create_keyspace(const lw_shared_ptr& ksm); future<> notify_create_column_family(const schema_ptr& cfm); @@ -159,16 +159,16 @@ inline migration_manager& get_local_migration_manager() { // Returns schema of given version, either from cache or from remote node identified by 'from'. // Doesn't affect current node's schema in any way. -future get_schema_definition(table_schema_version, net::msg_addr from); +future get_schema_definition(table_schema_version, netw::msg_addr from); // Returns schema of given version, either from cache or from remote node identified by 'from'. // The returned schema may not be synchronized. See schema::is_synced(). // Intended to be used in the read path. -future get_schema_for_read(table_schema_version, net::msg_addr from); +future get_schema_for_read(table_schema_version, netw::msg_addr from); // Returns schema of given version, either from cache or from remote node identified by 'from'. // Ensures that this node is synchronized with the returned schema. See schema::is_synced(). // Intended to be used in the write path, which relies on synchronized schema. -future get_schema_for_write(table_schema_version, net::msg_addr from); +future get_schema_for_write(table_schema_version, netw::msg_addr from); } diff --git a/service/migration_task.cc b/service/migration_task.cc index e5e7f11cc9..f20ac2c5d0 100644 --- a/service/migration_task.cc +++ b/service/migration_task.cc @@ -49,20 +49,20 @@ namespace service { -static logging::logger logger("migration_task"); +static logging::logger mlogger("migration_task"); future<> migration_task::run_may_throw(distributed& proxy, const gms::inet_address& endpoint) { if (!gms::get_failure_detector().local().is_alive(endpoint)) { - logger.error("Can't send migration request: node {} is down.", endpoint); + mlogger.error("Can't send migration request: node {} is down.", endpoint); return make_ready_future<>(); } - net::messaging_service::msg_addr id{endpoint, 0}; + netw::messaging_service::msg_addr id{endpoint, 0}; return service::get_local_migration_manager().merge_schema_from(id).handle_exception([](std::exception_ptr e) { try { std::rethrow_exception(e); } catch (const exceptions::configuration_exception& e) { - logger.error("Configuration exception merging remote schema: {}", e.what()); + mlogger.error("Configuration exception merging remote schema: {}", e.what()); } }); } diff --git a/service/pager/paging_state.cc b/service/pager/paging_state.cc index 54e5a977f9..09fcfbc3ea 100644 --- a/service/pager/paging_state.cc +++ b/service/pager/paging_state.cc @@ -61,7 +61,7 @@ service::pager::paging_state::paging_state(partition_key pk, std::experimental:: return nullptr; } - if (data.value().size() < sizeof(uint32_t) || le_to_cpu(*unaligned_cast(data.value().begin())) != net::messaging_service::current_version) { + if (data.value().size() < sizeof(uint32_t) || le_to_cpu(*unaligned_cast(data.value().begin())) != netw::messaging_service::current_version) { throw exceptions::protocol_exception("Invalid value for the paging state"); } @@ -81,6 +81,6 @@ service::pager::paging_state::paging_state(partition_key pk, std::experimental:: bytes_opt service::pager::paging_state::serialize() const { bytes b = ser::serialize_to_buffer(*this, sizeof(uint32_t)); // put serialization format id - *unaligned_cast(b.begin()) = cpu_to_le(net::messaging_service::current_version); + *unaligned_cast(b.begin()) = cpu_to_le(netw::messaging_service::current_version); return {std::move(b)}; } diff --git a/service/pager/query_pagers.cc b/service/pager/query_pagers.cc index 79c2e651cd..d0ecc3411d 100644 --- a/service/pager/query_pagers.cc +++ b/service/pager/query_pagers.cc @@ -45,7 +45,7 @@ #include "log.hh" #include "to_string.hh" -static logging::logger logger("paging"); +static logging::logger qlogger("paging"); class service::pager::query_pagers::impl : public query_pager { public: @@ -85,7 +85,7 @@ private: auto reversed = _cmd->slice.options.contains(); - logger.trace("PKey={}, CKey={}, reversed={}", dpk, _last_ckey, reversed); + qlogger.trace("PKey={}, CKey={}, reversed={}", dpk, _last_ckey, reversed); // Note: we're assuming both that the ranges are checked // and "cql-compliant", and that storage_proxy will process @@ -114,7 +114,7 @@ private: ; if (remove) { - logger.trace("Remove range {}", *i); + qlogger.trace("Remove range {}", *i); i = ranges.erase(i); continue; } @@ -123,12 +123,12 @@ private: ? range_type(i->start(), bound_type{ lo, inclusive }) : range_type( bound_type{ lo, inclusive }, i->end(), i->is_singular()) ; - logger.trace("Modify range {} -> {}", *i, r); + qlogger.trace("Modify range {} -> {}", *i, r); *i = std::move(r); } ++i; } - logger.trace("Result ranges {}", ranges); + qlogger.trace("Result ranges {}", ranges); }; // Because of #1446 we don't have a comparator to use with @@ -154,14 +154,14 @@ private: while (it != ranges.end()) { auto range = bound_view::from_range(*it); if (cmp(end_bound(range), lo) || eq(end_bound(range).prefix, lo)) { - logger.trace("Remove ck range {}", *it); + qlogger.trace("Remove ck range {}", *it); it = ranges.erase(it); continue; } else if (cmp(start_bound(range), lo)) { assert(cmp(lo, end_bound(range))); auto r = reversed ? range_type(it->start(), bound_type { lo, false }) : range_type(bound_type { lo, false }, it->end()); - logger.trace("Modify ck range {} -> {}", *it, r); + qlogger.trace("Modify ck range {} -> {}", *it, r); *it = std::move(r); } ++it; @@ -197,7 +197,7 @@ private: } _cmd->row_limit = max_rows; - logger.debug("Fetching {}, page size={}, max_rows={}", + qlogger.debug("Fetching {}, page size={}, max_rows={}", _cmd->cf_id, page_size, max_rows ); @@ -243,7 +243,7 @@ private: throw std::logic_error("Should not reach!"); } void accept_new_partition(const partition_key& key, uint32_t row_count) { - logger.trace("Accepting partition: {} ({})", key, row_count); + qlogger.trace("Accepting partition: {} ({})", key, row_count); total_rows += std::max(row_count, 1u); last_pkey = key; last_ckey = { }; @@ -281,13 +281,13 @@ private: _last_pkey = v.last_pkey; _last_ckey = v.last_ckey; - logger.debug("Fetched {} rows, max_remain={} {}", v.total_rows, _max, _exhausted ? "(exh)" : ""); + qlogger.debug("Fetched {} rows, max_remain={} {}", v.total_rows, _max, _exhausted ? "(exh)" : ""); if (_last_pkey) { - logger.debug("Last partition key: {}", *_last_pkey); + qlogger.debug("Last partition key: {}", *_last_pkey); } if (_has_clustering_keys && _last_ckey) { - logger.debug("Last clustering key: {}", *_last_ckey); + qlogger.debug("Last clustering key: {}", *_last_ckey); } } @@ -345,7 +345,7 @@ bool service::pager::query_pagers::may_need_paging(uint32_t page_size, auto est = est_max_rows(); auto need_paging = est > page_size; - logger.debug("Query of {}, page_size={}, limit={} {}", cmd.cf_id, page_size, + qlogger.debug("Query of {}, page_size={}, limit={} {}", cmd.cf_id, page_size, cmd.row_limit, need_paging ? "requires paging" : "does not require paging"); diff --git a/service/priority_manager.hh b/service/priority_manager.hh index 737563561b..44c732ec7f 100644 --- a/service/priority_manager.hh +++ b/service/priority_manager.hh @@ -22,6 +22,8 @@ #include #include +#include "seastarx.hh" + namespace service { class priority_manager { ::io_priority_class _commitlog_priority; diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index ed2bf59314..b755c6938f 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -79,7 +79,7 @@ namespace service { -static logging::logger logger("storage_proxy"); +static logging::logger slogger("storage_proxy"); static logging::logger qlogger("query_result"); static logging::logger mlogger("mutation_data"); @@ -254,7 +254,7 @@ public: } void on_timeout() { if (_cl_achieved) { - logger.trace("Write is not acknowledged by {} replicas after achieving CL", get_targets()); + slogger.trace("Write is not acknowledged by {} replicas after achieving CL", get_targets()); } _timedout = true; } @@ -375,7 +375,7 @@ storage_proxy::response_id_type storage_proxy::register_response_handler(shared_ auto hints = hint_to_dead_endpoints(e.handler->_mutation_holder, e.handler->get_targets()); e.handler->signal(hints); if (e.handler->_cl == db::consistency_level::ANY && hints) { - logger.trace("Wrote hint to satisfy CL.ANY after no replicas acknowledged the write"); + slogger.trace("Wrote hint to satisfy CL.ANY after no replicas acknowledged the write"); } } @@ -1036,7 +1036,7 @@ storage_proxy::create_write_response_handler(const mutation& m, db::consistency_ std::vector pending_endpoints = get_local_storage_service().get_token_metadata().pending_endpoints_for(m.token(), keyspace_name); - logger.trace("creating write handler for token: {} natural: {} pending: {}", m.token(), natural_endpoints, pending_endpoints); + slogger.trace("creating write handler for token: {} natural: {} pending: {}", m.token(), natural_endpoints, pending_endpoints); tracing::trace(tr_state, "Creating write handler for token: {} natural: {} pending: {}", m.token(), natural_endpoints ,pending_endpoints); // filter out naturale_endpoints from pending_endpoint if later is not yet updated during node join @@ -1064,7 +1064,7 @@ storage_proxy::create_write_response_handler(const mutation& m, db::consistency_ std::partition_copy(all.begin(), all.end(), std::inserter(live_endpoints, live_endpoints.begin()), std::back_inserter(dead_endpoints), std::bind1st(std::mem_fn(&gms::failure_detector::is_alive), &gms::get_local_failure_detector())); - logger.trace("creating write handler with live: {} dead: {}", live_endpoints, dead_endpoints); + slogger.trace("creating write handler with live: {} dead: {}", live_endpoints, dead_endpoints); tracing::trace(tr_state, "Creating write handler with live: {} dead: {}", live_endpoints, dead_endpoints); db::assure_sufficient_live_nodes(cl, ks, live_endpoints, pending_endpoints); @@ -1078,7 +1078,7 @@ storage_proxy::create_write_response_handler(const std::unordered_map(m); - logger.trace("creating write handler for read repair token: {} endpoint: {}", mh->token(), endpoints); + slogger.trace("creating write handler for read repair token: {} endpoint: {}", mh->token(), endpoints); tracing::trace(tr_state, "Creating write handler for read repair token: {} endpoint: {}", mh->token(), endpoints); auto keyspace_name = mh->schema()->ks_name(); @@ -1151,23 +1151,23 @@ future<> storage_proxy::mutate_end(future<> mutate_result, utils::latency_counte return make_ready_future<>(); } catch (no_such_keyspace& ex) { tracing::trace(trace_state, "Mutation failed: write to non existing keyspace: {}", ex.what()); - logger.trace("Write to non existing keyspace: {}", ex.what()); + slogger.trace("Write to non existing keyspace: {}", ex.what()); return make_exception_future<>(std::current_exception()); } catch(mutation_write_timeout_exception& ex) { // timeout tracing::trace(trace_state, "Mutation failed: write timeout; received {:d} of {:d} required replies", ex.received, ex.block_for); - logger.debug("Write timeout; received {} of {} required replies", ex.received, ex.block_for); + slogger.debug("Write timeout; received {} of {} required replies", ex.received, ex.block_for); _stats.write_timeouts.mark(); return make_exception_future<>(std::current_exception()); } catch (exceptions::unavailable_exception& ex) { tracing::trace(trace_state, "Mutation failed: unavailable"); _stats.write_unavailables.mark(); - logger.trace("Unavailable"); + slogger.trace("Unavailable"); return make_exception_future<>(std::current_exception()); } catch(overloaded_exception& ex) { tracing::trace(trace_state, "Mutation failed: overloaded"); _stats.write_unavailables.mark(); - logger.trace("Overloaded"); + slogger.trace("Overloaded"); return make_exception_future<>(std::current_exception()); } catch (...) { tracing::trace(trace_state, "Mutation failed: unknown reason"); @@ -1206,7 +1206,7 @@ future<> storage_proxy::mutate_counters(Range&& mutations, db::consistency_level return make_ready_future<>(); } - logger.trace("mutate_counters cl={}", cl); + slogger.trace("mutate_counters cl={}", cl); mlogger.trace("counter mutations={}", mutations); @@ -1248,8 +1248,8 @@ future<> storage_proxy::mutate_counters(Range&& mutations, db::consistency_level return std::move(m.fm); })); - auto& ms = net::get_local_messaging_service(); - auto msg_addr = net::messaging_service::msg_addr{ endpoint_and_mutations.first, 0 }; + auto& ms = netw::get_local_messaging_service(); + auto msg_addr = netw::messaging_service::msg_addr{ endpoint_and_mutations.first, 0 }; tracing::trace(tr_state, "Enqueuing counter update to {}", msg_addr); f = ms.send_counter_mutation(msg_addr, timeout, std::move(fms), cl, tracing::make_trace_info(tr_state)); } @@ -1305,7 +1305,7 @@ storage_proxy::mutate_internal(Range mutations, db::consistency_level cl, bool c return make_ready_future<>(); } - logger.trace("mutate cl={}", cl); + slogger.trace("mutate cl={}", cl); mlogger.trace("mutations={}", mutations); // If counters is set it means that we are replicating counter shards. There @@ -1404,7 +1404,7 @@ storage_proxy::mutate_atomically(std::vector mutations, db::consistenc }); } future<> sync_write_to_batchlog() { - auto m = db::get_batchlog_manager().local().get_batch_log_mutation_for(_mutations, _batch_uuid, net::messaging_service::current_version); + auto m = db::get_batchlog_manager().local().get_batch_log_mutation_for(_mutations, _batch_uuid, netw::messaging_service::current_version); tracing::trace(_trace_state, "Sending a batchlog write mutation"); return send_batchlog_mutation(std::move(m)); }; @@ -1418,7 +1418,7 @@ storage_proxy::mutate_atomically(std::vector mutations, db::consistenc tracing::trace(_trace_state, "Sending a batchlog remove mutation"); return send_batchlog_mutation(std::move(m), db::consistency_level::ANY).handle_exception([] (std::exception_ptr eptr) { - logger.error("Failed to remove mutations from batchlog: {}", eptr); + slogger.error("Failed to remove mutations from batchlog: {}", eptr); }); }; @@ -1518,14 +1518,14 @@ void storage_proxy::send_to_live_endpoints(storage_proxy::response_id_type respo // lambda for applying mutation remotely auto rmutate = [this, handler_ptr, timeout, response_id, my_address] (gms::inet_address coordinator, std::vector&& forward, const frozen_mutation& m) { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); auto msize = m.representation().size(); _stats.queued_write_bytes += msize; auto& tr_state = handler_ptr->get_trace_state(); tracing::trace(tr_state, "Sending a mutation to /{}", coordinator); - return ms.send_mutation(net::messaging_service::msg_addr{coordinator, 0}, timeout, m, + return ms.send_mutation(netw::messaging_service::msg_addr{coordinator, 0}, timeout, m, std::move(forward), my_address, engine().cpu_id(), response_id, tracing::make_trace_info(tr_state)).finally([this, p = shared_from_this(), h = std::move(handler_ptr), msize] { _stats.queued_write_bytes -= msize; unthrottle(); @@ -1572,7 +1572,7 @@ void storage_proxy::send_to_live_endpoints(storage_proxy::response_id_type respo // from lmutate(). Ignore so that logs are not flooded // database total_writes_timedout counter was incremented. } catch(...) { - logger.error("exception during mutation write to {}: {}", coordinator, std::current_exception()); + slogger.error("exception during mutation write to {}: {}", coordinator, std::current_exception()); } }); } @@ -1610,14 +1610,14 @@ bool storage_proxy::submit_hint(std::unique_ptr& mh, gms::inet_ int ttl = HintedHandOffManager.calculateHintTTL(mutation); if (ttl > 0) { - logger.debug("Adding hint for {}", target); + slogger.debug("Adding hint for {}", target); writeHintForMutation(mutation, System.currentTimeMillis(), ttl, target); // Notify the handler only for CL == ANY if (responseHandler != null && responseHandler.consistencyLevel == ConsistencyLevel.ANY) responseHandler.response(null); } else { - logger.debug("Skipped writing hint for {} (ttl {})", target, ttl); + slogger.debug("Skipped writing hint for {} (ttl {})", target, ttl); } } }; @@ -1829,7 +1829,7 @@ public: } // do nothing other than log for now, request will timeout eventually - logger.error("Exception when communicating with {}: {}", ep, why); + slogger.error("Exception when communicating with {}: {}", ep, why); } }; @@ -2427,9 +2427,9 @@ protected: tracing::trace(_trace_state, "read_mutation_data: querying locally"); return _proxy->query_mutations_locally(_schema, cmd, _partition_range, _trace_state); } else { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); tracing::trace(_trace_state, "read_mutation_data: sending a message to /{}", ep); - return ms.send_read_mutation_data(net::messaging_service::msg_addr{ep, 0}, timeout, *cmd, _partition_range).then([this, ep](reconcilable_result&& result) { + return ms.send_read_mutation_data(netw::messaging_service::msg_addr{ep, 0}, timeout, *cmd, _partition_range).then([this, ep](reconcilable_result&& result) { tracing::trace(_trace_state, "read_mutation_data: got response from /{}", ep); return make_foreign(::make_lw_shared(std::move(result))); }); @@ -2442,10 +2442,10 @@ protected: auto qrr = want_digest ? query::result_request::result_and_digest : query::result_request::only_result; return _proxy->query_singular_local(_schema, _cmd, _partition_range, qrr, _trace_state); } else { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); tracing::trace(_trace_state, "read_data: sending a message to /{}", ep); auto da = want_digest ? query::digest_algorithm::MD5 : query::digest_algorithm::none; - return ms.send_read_data(net::messaging_service::msg_addr{ep, 0}, timeout, *_cmd, _partition_range, da).then([this, ep](query::result&& result) { + return ms.send_read_data(netw::messaging_service::msg_addr{ep, 0}, timeout, *_cmd, _partition_range, da).then([this, ep](query::result&& result) { tracing::trace(_trace_state, "read_data: got response from /{}", ep); return make_foreign(::make_lw_shared(std::move(result))); }); @@ -2457,9 +2457,9 @@ protected: tracing::trace(_trace_state, "read_digest: querying locally"); return _proxy->query_singular_local_digest(_schema, _cmd, _partition_range, _trace_state); } else { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); tracing::trace(_trace_state, "read_digest: sending a message to /{}", ep); - return ms.send_read_digest(net::messaging_service::msg_addr{ep, 0}, timeout, *_cmd, _partition_range).then([this, ep] (query::result_digest d, rpc::optional t) { + return ms.send_read_digest(netw::messaging_service::msg_addr{ep, 0}, timeout, *_cmd, _partition_range).then([this, ep] (query::result_digest d, rpc::optional t) { tracing::trace(_trace_state, "read_digest: got response from /{}", ep); return make_ready_future(d, t ? t.value() : api::missing_timestamp); }); @@ -2588,7 +2588,7 @@ protected: _retry_cmd->slice.options.remove(); } - logger.trace("Retrying query with command {} (previous is {})", *_retry_cmd, *cmd); + slogger.trace("Retrying query with command {} (previous is {})", *_retry_cmd, *cmd); reconcile(cl, timeout, _retry_cmd); } } catch (...) { @@ -2759,14 +2759,14 @@ db::read_repair_decision storage_proxy::new_read_repair_decision(const schema& s db::read_repair_decision repair_decision = new_read_repair_decision(*schema); std::vector target_replicas = db::filter_for_query(cl, ks, all_replicas, repair_decision); - logger.trace("creating read executor for token {} with all: {} targets: {} rp decision: {}", token, all_replicas, target_replicas, repair_decision); + slogger.trace("creating read executor for token {} with all: {} targets: {} rp decision: {}", token, all_replicas, target_replicas, repair_decision); tracing::trace(trace_state, "Creating read executor for token {} with all: {} targets: {} repair decision: {}", token, all_replicas, target_replicas, repair_decision); // Throw UAE early if we don't have enough replicas. try { db::assure_sufficient_live_nodes(cl, ks, target_replicas); } catch (exceptions::unavailable_exception& ex) { - logger.debug("Read unavailable: cl={} required {} alive {}", ex.consistency, ex.required, ex.alive); + slogger.debug("Read unavailable: cl={} required {} alive {}", ex.consistency, ex.required, ex.alive); _stats.read_unavailables.mark(); throw; } @@ -2810,13 +2810,13 @@ db::read_repair_decision storage_proxy::new_read_repair_decision(const schema& s if (!good_replica(extra_replica)) { auto it = boost::range::find_if(all_replicas, std::move(good_replica)); if (it == all_replicas.end()) { - logger.trace("read executor no extra target to speculate"); + slogger.trace("read executor no extra target to speculate"); return ::make_shared(schema, p, cmd, std::move(pr), cl, block_for, std::move(target_replicas), std::move(trace_state)); } extra_replica = *it; } target_replicas.push_back(extra_replica); - logger.trace("creating read executor with extra target {}", extra_replica); + slogger.trace("creating read executor with extra target {}", extra_replica); } if (retry_type == speculative_retry::type::ALWAYS) { @@ -2847,14 +2847,14 @@ void storage_proxy::handle_read_error(std::exception_ptr eptr, bool range) { try { std::rethrow_exception(eptr); } catch (read_timeout_exception& ex) { - logger.debug("Read timeout: received {} of {} required replies, data {}present", ex.received, ex.block_for, ex.data_present ? "" : "not "); + slogger.debug("Read timeout: received {} of {} required replies, data {}present", ex.received, ex.block_for, ex.data_present ? "" : "not "); if (range) { _stats.range_slice_timeouts.mark(); } else { _stats.read_timeouts.mark(); } } catch (...) { - logger.debug("Error during read query {}", eptr); + slogger.debug("Error during read query {}", eptr); } } @@ -2942,11 +2942,11 @@ storage_proxy::query_partition_key_range_concurrent(storage_proxy::clock_type::t filtered_endpoints = std::move(filtered_merged); ++i; } - logger.trace("creating range read executor with targets {}", filtered_endpoints); + slogger.trace("creating range read executor with targets {}", filtered_endpoints); try { db::assure_sufficient_live_nodes(cl, ks, filtered_endpoints); } catch(exceptions::unavailable_exception& ex) { - logger.debug("Read unavailable: cl={} required {} alive {}", ex.consistency, ex.required, ex.alive); + slogger.debug("Read unavailable: cl={} required {} alive {}", ex.consistency, ex.required, ex.alive); _stats.range_slice_unavailables.mark(); throw; } @@ -2965,7 +2965,7 @@ storage_proxy::query_partition_key_range_concurrent(storage_proxy::clock_type::t cl, cmd, concurrency_factor, timeout, remaining_row_count, remaining_partition_count, trace_state = std::move(trace_state)] (foreign_ptr>&& result) mutable { if (!result->row_count() || !result->partition_count()) { - logger.error("no row count in query result, should not happen here"); + slogger.error("no row count in query result, should not happen here"); result->calculate_counts(cmd->slice); } remaining_row_count -= result->row_count().value(); @@ -3019,7 +3019,7 @@ storage_proxy::query_partition_key_range(lw_shared_ptr cmd, std::vector>> results; results.reserve(ranges.size()/concurrency_factor + 1); - logger.debug("Estimated result rows per range: {}; requested rows: {}, ranges.size(): {}; concurrent range requests: {}", + slogger.debug("Estimated result rows per range: {}; requested rows: {}, ranges.size(): {}; concurrent range requests: {}", result_rows_per_range, cmd->row_limit, ranges.size(), concurrency_factor); return query_partition_key_range_concurrent(timeout, std::move(results), cmd, cl, ranges.begin(), std::move(ranges), concurrency_factor, @@ -3042,17 +3042,17 @@ storage_proxy::query(schema_ptr s, dht::partition_range_vector&& partition_ranges, db::consistency_level cl, tracing::trace_state_ptr trace_state) { - if (logger.is_enabled(logging::log_level::trace) || qlogger.is_enabled(logging::log_level::trace)) { + if (slogger.is_enabled(logging::log_level::trace) || qlogger.is_enabled(logging::log_level::trace)) { static thread_local int next_id = 0; auto query_id = next_id++; - logger.trace("query {}.{} cmd={}, ranges={}, id={}", s->ks_name(), s->cf_name(), *cmd, partition_ranges, query_id); + slogger.trace("query {}.{} cmd={}, ranges={}, id={}", s->ks_name(), s->cf_name(), *cmd, partition_ranges, query_id); return do_query(s, cmd, std::move(partition_ranges), cl, std::move(trace_state)).then([query_id, cmd, s] (foreign_ptr>&& res) { if (res->buf().is_linearized()) { res->calculate_counts(cmd->slice); - logger.trace("query_result id={}, size={}, rows={}, partitions={}", query_id, res->buf().size(), *res->row_count(), *res->partition_count()); + slogger.trace("query_result id={}, size={}, rows={}, partitions={}", query_id, res->buf().size(), *res->row_count(), *res->partition_count()); } else { - logger.trace("query_result id={}, size={}", query_id, res->buf().size()); + slogger.trace("query_result id={}, size={}", query_id, res->buf().size()); } qlogger.trace("id={}, {}", query_id, res->pretty_printer(s, cmd->slice)); return std::move(res); @@ -3369,12 +3369,12 @@ bool storage_proxy::should_hint(gms::inet_address ep) noexcept { } future<> storage_proxy::truncate_blocking(sstring keyspace, sstring cfname) { - logger.debug("Starting a blocking truncate operation on keyspace {}, CF {}", keyspace, cfname); + slogger.debug("Starting a blocking truncate operation on keyspace {}, CF {}", keyspace, cfname); auto& gossiper = gms::get_local_gossiper(); if (!gossiper.get_unreachable_token_owners().empty()) { - logger.info("Cannot perform truncate, some hosts are down"); + slogger.info("Cannot perform truncate, some hosts are down"); // Since the truncate operation is so aggressive and is typically only // invoked by an admin, for simplicity we require that all nodes are up // to perform the operation. @@ -3386,18 +3386,18 @@ future<> storage_proxy::truncate_blocking(sstring keyspace, sstring cfname) { } auto all_endpoints = gossiper.get_live_token_owners(); - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); auto timeout = std::chrono::milliseconds(_db.local().get_config().truncate_request_timeout_in_ms()); - logger.trace("Enqueuing truncate messages to hosts {}", all_endpoints); + slogger.trace("Enqueuing truncate messages to hosts {}", all_endpoints); return parallel_for_each(all_endpoints, [keyspace, cfname, &ms, timeout](auto ep) { - return ms.send_truncate(net::messaging_service::msg_addr{ep, 0}, timeout, keyspace, cfname); + return ms.send_truncate(netw::messaging_service::msg_addr{ep, 0}, timeout, keyspace, cfname); }).handle_exception([cfname](auto ep) { try { std::rethrow_exception(ep); } catch (rpc::timeout_error& e) { - logger.trace("Truncation of {} timed out: {}", cfname, e.what()); + slogger.trace("Truncation of {} timed out: {}", cfname, e.what()); } catch (...) { throw; } @@ -3540,7 +3540,7 @@ future<> storage_proxy::truncate_blocking(sstring keyspace, sstring cfname) { public void verifyNoHintsInProgress() { if (getHintsInProgress() > 0) - logger.warn("Some hints were not written before shutdown. This is not supposed to happen. You should (a) run repair, and (b) file a bug report"); + slogger.warn("Some hints were not written before shutdown. This is not supposed to happen. You should (a) run repair, and (b) file a bug report"); } public Long getRpcTimeout() { return DatabaseDescriptor.getRpcTimeout(); } @@ -3580,9 +3580,9 @@ future<> storage_proxy::truncate_blocking(sstring keyspace, sstring cfname) { #endif void storage_proxy::init_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.register_counter_mutation([] (const rpc::client_info& cinfo, rpc::opt_time_point t, std::vector fms, db::consistency_level cl, stdx::optional trace_info) { - auto src_addr = net::messaging_service::get_source(cinfo); + auto src_addr = netw::messaging_service::get_source(cinfo); tracing::trace_state_ptr trace_state_ptr; if (trace_info) { @@ -3607,7 +3607,7 @@ void storage_proxy::init_messaging_service() { }); ms.register_mutation([] (const rpc::client_info& cinfo, rpc::opt_time_point t, frozen_mutation in, std::vector forward, gms::inet_address reply_to, unsigned shard, storage_proxy::response_id_type response_id, rpc::optional> trace_info) { tracing::trace_state_ptr trace_state_ptr; - auto src_addr = net::messaging_service::get_source(cinfo); + auto src_addr = netw::messaging_service::get_source(cinfo); if (trace_info && *trace_info) { tracing::trace_info& tr_info = **trace_info; @@ -3635,14 +3635,14 @@ void storage_proxy::init_messaging_service() { return p->mutate_locally(std::move(s), m, timeout); }); }).then([reply_to, shard, response_id, trace_state_ptr] () { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); // We wait for send_mutation_done to complete, otherwise, if reply_to is busy, we will accumulate // lots of unsent responses, which can OOM our shard. // // Usually we will return immediately, since this work only involves appending data to the connection // send buffer. tracing::trace(trace_state_ptr, "Sending mutation_done to /{}", reply_to); - return ms.send_mutation_done(net::messaging_service::msg_addr{reply_to, shard}, shard, response_id).then_wrapped([] (future<> f) { + return ms.send_mutation_done(netw::messaging_service::msg_addr{reply_to, shard}, shard, response_id).then_wrapped([] (future<> f) { f.ignore_ready_future(); }); }).handle_exception([reply_to, shard, &p] (std::exception_ptr eptr) { @@ -3656,12 +3656,12 @@ void storage_proxy::init_messaging_service() { } catch (...) { // ignore } - logger.log(l, "Failed to apply mutation from {}#{}: {}", reply_to, shard, eptr); + slogger.log(l, "Failed to apply mutation from {}#{}: {}", reply_to, shard, eptr); }), parallel_for_each(forward.begin(), forward.end(), [reply_to, shard, response_id, &m, &p, trace_state_ptr, timeout] (gms::inet_address forward) { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); tracing::trace(trace_state_ptr, "Forwarding a mutation to /{}", forward); - return ms.send_mutation(net::messaging_service::msg_addr{forward, 0}, timeout, m, {}, reply_to, shard, response_id, tracing::make_trace_info(trace_state_ptr)).then_wrapped([&p] (future<> f) { + return ms.send_mutation(netw::messaging_service::msg_addr{forward, 0}, timeout, m, {}, reply_to, shard, response_id, tracing::make_trace_info(trace_state_ptr)).then_wrapped([&p] (future<> f) { if (f.failed()) { ++p->_stats.forwarding_errors; }; @@ -3671,7 +3671,7 @@ void storage_proxy::init_messaging_service() { ).then_wrapped([trace_state_ptr] (future, future<>>>&& f) { // ignore ressult, since we'll be returning them via MUTATION_DONE verbs tracing::trace(trace_state_ptr, "Mutation handling is done"); - return net::messaging_service::no_wait(); + return netw::messaging_service::no_wait(); }); }); }); @@ -3679,12 +3679,12 @@ void storage_proxy::init_messaging_service() { auto& from = cinfo.retrieve_auxiliary("baddr"); return get_storage_proxy().invoke_on(shard, [from, response_id] (storage_proxy& sp) { sp.got_response(response_id, from); - return net::messaging_service::no_wait(); + return netw::messaging_service::no_wait(); }); }); ms.register_read_data([] (const rpc::client_info& cinfo, query::read_command cmd, compat::wrapping_partition_range pr, rpc::optional oda) { tracing::trace_state_ptr trace_state_ptr; - auto src_addr = net::messaging_service::get_source(cinfo); + auto src_addr = netw::messaging_service::get_source(cinfo); if (cmd.trace_info) { trace_state_ptr = tracing::tracing::get_local_tracing_instance().create_session(*cmd.trace_info); tracing::begin(trace_state_ptr); @@ -3718,7 +3718,7 @@ void storage_proxy::init_messaging_service() { }); ms.register_read_mutation_data([] (const rpc::client_info& cinfo, query::read_command cmd, compat::wrapping_partition_range pr) { tracing::trace_state_ptr trace_state_ptr; - auto src_addr = net::messaging_service::get_source(cinfo); + auto src_addr = netw::messaging_service::get_source(cinfo); if (cmd.trace_info) { trace_state_ptr = tracing::tracing::get_local_tracing_instance().create_session(*cmd.trace_info); tracing::begin(trace_state_ptr); @@ -3746,7 +3746,7 @@ void storage_proxy::init_messaging_service() { }); ms.register_read_digest([] (const rpc::client_info& cinfo, query::read_command cmd, compat::wrapping_partition_range pr) { tracing::trace_state_ptr trace_state_ptr; - auto src_addr = net::messaging_service::get_source(cinfo); + auto src_addr = netw::messaging_service::get_source(cinfo); if (cmd.trace_info) { trace_state_ptr = tracing::tracing::get_local_tracing_instance().create_session(*cmd.trace_info); tracing::begin(trace_state_ptr); @@ -3779,14 +3779,14 @@ void storage_proxy::init_messaging_service() { ms.register_get_schema_version([] (unsigned shard, table_schema_version v) { return get_storage_proxy().invoke_on(shard, [v] (auto&& sp) { - logger.debug("Schema version request for {}", v); + slogger.debug("Schema version request for {}", v); return local_schema_registry().get_frozen(v); }); }); } void storage_proxy::uninit_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.unregister_mutation(); ms.unregister_mutation_done(); ms.unregister_read_data(); diff --git a/service/storage_service.cc b/service/storage_service.cc index 0676510e69..67b51b027e 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -78,7 +78,7 @@ using inet_address = gms::inet_address; namespace service { -static logging::logger logger("storage_service"); +static logging::logger slogger("storage_service"); static const sstring RANGE_TOMBSTONES_FEATURE = "RANGE_TOMBSTONES"; static const sstring LARGE_PARTITIONS_FEATURE = "LARGE_PARTITIONS"; @@ -165,7 +165,7 @@ std::experimental::optional get_replace_node() { return utils::UUID(replace_node); } catch (...) { auto msg = sprint("Unable to parse %s as host-id", replace_node); - logger.error("{}", msg); + slogger.error("{}", msg); throw std::runtime_error(msg); } } @@ -195,12 +195,12 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints std::map app_states; if (db::system_keyspace::was_decommissioned()) { if (db().local().get_config().override_decommission()) { - logger.warn("This node was decommissioned, but overriding by operator request."); + slogger.warn("This node was decommissioned, but overriding by operator request."); db::system_keyspace::set_bootstrap_state(db::system_keyspace::bootstrap_state::COMPLETED).get(); } else { auto msg = sstring("This node was decommissioned and will not rejoin the ring unless override_decommission=true has been set," "or all existing data is removed and the node is bootstrapped again"); - logger.error(msg.c_str()); + slogger.error(msg.c_str()); throw std::runtime_error(msg.c_str()); } } @@ -227,9 +227,9 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints auto seeds = gms::get_local_gossiper().get_seeds(); auto my_ep = get_broadcast_address(); auto peer_features = db::system_keyspace::load_peer_features().get0(); - logger.info("load_peer_features: peer_features size={}", peer_features.size()); + slogger.info("load_peer_features: peer_features size={}", peer_features.size()); for (auto& x : peer_features) { - logger.info("load_peer_features: peer={}, supported_features={}", x.first, x.second); + slogger.info("load_peer_features: peer={}, supported_features={}", x.first, x.second); } auto local_features = get_config_supported_features(); @@ -237,18 +237,18 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints // This node is a seed node if (peer_features.empty()) { // This is a competely new seed node, skip the check - logger.info("Checking remote features skipped, since this node is a new seed node which knows nothing about the cluster"); + slogger.info("Checking remote features skipped, since this node is a new seed node which knows nothing about the cluster"); } else { // This is a existing seed node if (seeds.size() == 1) { // This node is the only seed node, check features with system table - logger.info("Checking remote features with system table, since this node is the only seed node"); + slogger.info("Checking remote features with system table, since this node is the only seed node"); gossiper.check_knows_remote_features(local_features, peer_features); } else { // More than one seed node in the seed list, do shadow round with other seed nodes bool ok; try { - logger.info("Checking remote features with gossip"); + slogger.info("Checking remote features with gossip"); gossiper.do_shadow_round().get(); ok = true; } catch (...) { @@ -264,7 +264,7 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints } } else { // Check features with system table - logger.info("Checking remote features with gossip failed, fallback to check with system table"); + slogger.info("Checking remote features with gossip failed, fallback to check with system table"); gossiper.check_knows_remote_features(local_features, peer_features); } } @@ -274,7 +274,7 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints // Do shadow round to check if this node knows all the features // advertised by all other nodes, otherwise this node is too old // (missing features) to join the cluser. - logger.info("Checking remote features with gossip"); + slogger.info("Checking remote features with gossip"); gossiper.do_shadow_round().get(); gossiper.check_knows_remote_features(local_features); gossiper.reset_endpoint_state_map(); @@ -300,7 +300,7 @@ void storage_service::prepare_to_join(std::vector loaded_endpoints app_states.emplace(gms::application_state::RPC_ADDRESS, value_factory.rpcaddress(broadcast_rpc_address)); app_states.emplace(gms::application_state::RELEASE_VERSION, value_factory.release_version()); app_states.emplace(gms::application_state::SUPPORTED_FEATURES, value_factory.supported_features(features)); - logger.info("Starting up server gossip"); + slogger.info("Starting up server gossip"); auto& gossiper = gms::get_local_gossiper(); gossiper.register_(this->shared_from_this()); @@ -340,17 +340,17 @@ void storage_service::join_token_ring(int delay) { // We attempted to replace this with a schema-presence check, but you need a meaningful sleep // to get schema info from gossip which defeats the purpose. See CASSANDRA-4427 for the gory details. std::unordered_set current; - logger.debug("Bootstrap variables: {} {} {} {}", + slogger.debug("Bootstrap variables: {} {} {} {}", is_auto_bootstrap(), db::system_keyspace::bootstrap_in_progress(), db::system_keyspace::bootstrap_complete(), get_seeds().count(get_broadcast_address())); if (is_auto_bootstrap() && !db::system_keyspace::bootstrap_complete() && get_seeds().count(get_broadcast_address())) { - logger.info("This node will not auto bootstrap because it is configured to be a seed node."); + slogger.info("This node will not auto bootstrap because it is configured to be a seed node."); } if (should_bootstrap()) { if (db::system_keyspace::bootstrap_in_progress()) { - logger.warn("Detected previous bootstrap failure; retrying"); + slogger.warn("Detected previous bootstrap failure; retrying"); } else { db::system_keyspace::set_bootstrap_state(db::system_keyspace::bootstrap_state::IN_PROGRESS).get(); } @@ -359,7 +359,7 @@ void storage_service::join_token_ring(int delay) { for (int i = 0; i < delay; i += 1000) { // if we see schema, we can proceed to the next check directly if (_db.local().get_version() != database::empty_version) { - logger.debug("got schema: {}", _db.local().get_version()); + slogger.debug("got schema: {}", _db.local().get_version()); break; } sleep(std::chrono::seconds(1)).get(); @@ -374,7 +374,7 @@ void storage_service::join_token_ring(int delay) { set_mode(mode::JOINING, "waiting for pending range calculation", true); update_pending_ranges().get(); set_mode(mode::JOINING, "calculation complete, ready to bootstrap", true); - logger.debug("... got ring + schema info"); + slogger.debug("... got ring + schema info"); auto t = gms::gossiper::clk::now(); while (get_property_rangemovement() && @@ -382,7 +382,7 @@ void storage_service::join_token_ring(int delay) { !_token_metadata.get_leaving_endpoints().empty() || !_token_metadata.get_moving_endpoints().empty())) { auto elapsed = std::chrono::duration_cast(gms::gossiper::clk::now() - t).count(); - logger.info("Checking bootstrapping/leaving/moving nodes: tokens {}, leaving {}, moving {}, sleep 1 second and check again ({} seconds elapsed)", + slogger.info("Checking bootstrapping/leaving/moving nodes: tokens {}, leaving {}, moving {}, sleep 1 second and check again ({} seconds elapsed)", _token_metadata.get_bootstrap_tokens().size(), _token_metadata.get_leaving_endpoints().size(), _token_metadata.get_moving_endpoints().size(), @@ -401,7 +401,7 @@ void storage_service::join_token_ring(int delay) { } update_pending_ranges().get(); } - logger.info("Checking bootstrapping/leaving/moving nodes: ok"); + slogger.info("Checking bootstrapping/leaving/moving nodes: ok"); if (!db().local().is_replacing()) { if (_token_metadata.is_member(get_broadcast_address())) { @@ -441,7 +441,7 @@ void storage_service::join_token_ring(int delay) { // bootstrap will block until finished if (_is_bootstrap_mode) { auto err = sprint("We are not supposed in bootstrap mode any more"); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } } else { @@ -452,22 +452,22 @@ void storage_service::join_token_ring(int delay) { if (initial_tokens.size() < 1) { _bootstrap_tokens = boot_strapper::get_random_tokens(_token_metadata, num_tokens); if (num_tokens == 1) { - logger.warn("Generated random token {}. Random tokens will result in an unbalanced ring; see http://wiki.apache.org/cassandra/Operations", _bootstrap_tokens); + slogger.warn("Generated random token {}. Random tokens will result in an unbalanced ring; see http://wiki.apache.org/cassandra/Operations", _bootstrap_tokens); } else { - logger.info("Generated random tokens. tokens are {}", _bootstrap_tokens); + slogger.info("Generated random tokens. tokens are {}", _bootstrap_tokens); } } else { for (auto token_string : initial_tokens) { auto token = dht::global_partitioner().from_sstring(token_string); _bootstrap_tokens.insert(token); } - logger.info("Saved tokens not found. Using configuration value: {}", _bootstrap_tokens); + slogger.info("Saved tokens not found. Using configuration value: {}", _bootstrap_tokens); } } else { if (_bootstrap_tokens.size() != num_tokens) { throw std::runtime_error(sprint("Cannot change the number of tokens from %ld to %ld", _bootstrap_tokens.size(), num_tokens)); } else { - logger.info("Using saved tokens {}", _bootstrap_tokens); + slogger.info("Using saved tokens {}", _bootstrap_tokens); } } } @@ -500,11 +500,11 @@ void storage_service::join_token_ring(int delay) { } if (_token_metadata.sorted_tokens().empty()) { auto err = sprint("join_token_ring: Sorted token in token_metadata is empty"); - logger.error(err.c_str()); + slogger.error(err.c_str()); throw std::runtime_error(err); } } else { - logger.info("Startup complete, but write survey mode is active, not becoming an active ring member. Use JMX (StorageService->joinRing()) to finalize ring joining."); + slogger.info("Startup complete, but write survey mode is active, not becoming an active ring member. Use JMX (StorageService->joinRing()) to finalize ring joining."); } } @@ -512,17 +512,17 @@ future<> storage_service::join_ring() { return run_with_api_lock(sstring("join_ring"), [] (storage_service& ss) { return seastar::async([&ss] { if (!ss._joined) { - logger.info("Joining ring by operator request"); + slogger.info("Joining ring by operator request"); ss.join_token_ring(0); } else if (ss._is_survey_mode) { auto tokens = db::system_keyspace::get_saved_tokens().get0(); ss.set_tokens(std::move(tokens)); db::system_keyspace::set_bootstrap_state(db::system_keyspace::bootstrap_state::COMPLETED).get(); ss._is_survey_mode = false; - logger.info("Leaving write survey mode and joining ring at operator request"); + slogger.info("Leaving write survey mode and joining ring at operator request"); if (ss._token_metadata.sorted_tokens().empty()) { auto err = sprint("join_ring: Sorted token in token_metadata is empty"); - logger.error(err.c_str()); + slogger.error(err.c_str()); throw std::runtime_error(err); } auth::auth::setup().get(); @@ -554,7 +554,7 @@ void storage_service::bootstrap(std::unordered_set tokens) { _token_metadata.update_normal_tokens(tokens, get_broadcast_address()); auto replace_addr = db().local().get_replace_address(); if (replace_addr) { - logger.debug("Removing replaced endpoint {} from system.peers", *replace_addr); + slogger.debug("Removing replaced endpoint {} from system.peers", *replace_addr); db::system_keyspace::remove_endpoint(*replace_addr).get(); } } @@ -564,7 +564,7 @@ void storage_service::bootstrap(std::unordered_set tokens) { set_mode(mode::JOINING, "Starting to bootstrap...", true); dht::boot_strapper bs(_db, get_broadcast_address(), tokens, _token_metadata); bs.bootstrap().get(); // handles token update - logger.info("Bootstrap completed! for the tokens {}", tokens); + slogger.info("Bootstrap completed! for the tokens {}", tokens); } sstring @@ -632,11 +632,11 @@ storage_service::get_range_to_address_map(const sstring& keyspace, } void storage_service::handle_state_bootstrap(inet_address endpoint) { - logger.debug("endpoint={} handle_state_bootstrap", endpoint); + slogger.debug("endpoint={} handle_state_bootstrap", endpoint); // explicitly check for TOKENS, because a bootstrapping node might be bootstrapping in legacy mode; that is, not using vnodes and no token specified auto tokens = get_tokens_for(endpoint); - logger.debug("Node {} state bootstrapping, token {}", endpoint, tokens); + slogger.debug("Node {} state bootstrapping, token {}", endpoint, tokens); // if this node is present in token metadata, either we have missed intermediate states // or the node had crashed. Print warning if needed, clear obsolete stuff and @@ -648,7 +648,7 @@ void storage_service::handle_state_bootstrap(inet_address endpoint) { // common (not enough time for gossip to spread). Therefore we report only the // former in the log. if (!_token_metadata.is_leaving(endpoint)) { - logger.info("Node {} state jump to bootstrap", endpoint); + slogger.info("Node {} state jump to bootstrap", endpoint); } _token_metadata.remove_endpoint(endpoint); } @@ -663,7 +663,7 @@ void storage_service::handle_state_bootstrap(inet_address endpoint) { } void storage_service::handle_state_normal(inet_address endpoint) { - logger.debug("endpoint={} handle_state_normal", endpoint); + slogger.debug("endpoint={} handle_state_normal", endpoint); auto tokens = get_tokens_for(endpoint); auto& gossiper = gms::get_local_gossiper(); @@ -672,10 +672,10 @@ void storage_service::handle_state_normal(inet_address endpoint) { std::unordered_set local_tokens_to_remove; std::unordered_set endpoints_to_remove; - logger.debug("Node {} state normal, token {}", endpoint, tokens); + slogger.debug("Node {} state normal, token {}", endpoint, tokens); if (_token_metadata.is_member(endpoint)) { - logger.info("Node {} state jump to normal", endpoint); + slogger.info("Node {} state jump to normal", endpoint); } update_peer_info(endpoint); @@ -687,20 +687,20 @@ void storage_service::handle_state_normal(inet_address endpoint) { db().local().get_replace_address() && gossiper.get_endpoint_state_for_endpoint(db().local().get_replace_address().value()) && (host_id == gossiper.get_host_id(db().local().get_replace_address().value()))) { - logger.warn("Not updating token metadata for {} because I am replacing it", endpoint); + slogger.warn("Not updating token metadata for {} because I am replacing it", endpoint); } else { if (existing && *existing != endpoint) { if (*existing == get_broadcast_address()) { - logger.warn("Not updating host ID {} for {} because it's mine", host_id, endpoint); + slogger.warn("Not updating host ID {} for {} because it's mine", host_id, endpoint); _token_metadata.remove_endpoint(endpoint); endpoints_to_remove.insert(endpoint); } else if (gossiper.compare_endpoint_startup(endpoint, *existing) > 0) { - logger.warn("Host ID collision for {} between {} and {}; {} is the new owner", host_id, *existing, endpoint, endpoint); + slogger.warn("Host ID collision for {} between {} and {}; {} is the new owner", host_id, *existing, endpoint, endpoint); _token_metadata.remove_endpoint(*existing); endpoints_to_remove.insert(*existing); _token_metadata.update_host_id(host_id, endpoint); } else { - logger.warn("Host ID collision for {} between {} and {}; ignored {}", host_id, *existing, endpoint, endpoint); + slogger.warn("Host ID collision for {} between {} and {}; ignored {}", host_id, *existing, endpoint, endpoint); _token_metadata.remove_endpoint(endpoint); endpoints_to_remove.insert(endpoint); } @@ -714,16 +714,16 @@ void storage_service::handle_state_normal(inet_address endpoint) { // we don't want to update if this node is responsible for the token and it has a later startup time than endpoint. auto current_owner = _token_metadata.get_endpoint(t); if (!current_owner) { - logger.debug("handle_state_normal: New node {} at token {}", endpoint, t); + slogger.debug("handle_state_normal: New node {} at token {}", endpoint, t); tokens_to_update_in_metadata.insert(t); tokens_to_update_in_system_keyspace.insert(t); } else if (endpoint == *current_owner) { - logger.debug("handle_state_normal: endpoint={} == current_owner={} token {}", endpoint, *current_owner, t); + slogger.debug("handle_state_normal: endpoint={} == current_owner={} token {}", endpoint, *current_owner, t); // set state back to normal, since the node may have tried to leave, but failed and is now back up tokens_to_update_in_metadata.insert(t); tokens_to_update_in_system_keyspace.insert(t); } else if (gossiper.compare_endpoint_startup(endpoint, *current_owner) > 0) { - logger.debug("handle_state_normal: endpoint={} > current_owner={}, token {}", endpoint, *current_owner, t); + slogger.debug("handle_state_normal: endpoint={} > current_owner={}, token {}", endpoint, *current_owner, t); tokens_to_update_in_metadata.insert(t); tokens_to_update_in_system_keyspace.insert(t); // currentOwner is no longer current, endpoint is. Keep track of these moves, because when @@ -732,17 +732,17 @@ void storage_service::handle_state_normal(inet_address endpoint) { auto rg = ep_to_token_copy.equal_range(*current_owner); for (auto it = rg.first; it != rg.second; it++) { if (it->second == t) { - logger.info("handle_state_normal: remove endpoint={} token={}", *current_owner, t); + slogger.info("handle_state_normal: remove endpoint={} token={}", *current_owner, t); ep_to_token_copy.erase(it); } } if (ep_to_token_copy.count(*current_owner) < 1) { - logger.info("handle_state_normal: endpoints_to_remove endpoint={}", *current_owner); + slogger.info("handle_state_normal: endpoints_to_remove endpoint={}", *current_owner); endpoints_to_remove.insert(*current_owner); } - logger.info("handle_state_normal: Nodes {} and {} have the same token {}. {} is the new owner", endpoint, *current_owner, t, endpoint); + slogger.info("handle_state_normal: Nodes {} and {} have the same token {}. {} is the new owner", endpoint, *current_owner, t, endpoint); } else { - logger.info("handle_state_normal: Nodes {} and {} have the same token {}. Ignoring {}", endpoint, *current_owner, t, endpoint); + slogger.info("handle_state_normal: Nodes {} and {} have the same token {}. Ignoring {}", endpoint, *current_owner, t, endpoint); } } @@ -761,13 +761,13 @@ void storage_service::handle_state_normal(inet_address endpoint) { gossiper.replacement_quarantine(ep); // quarantine locally longer than normally; see CASSANDRA-8260 } } - logger.debug("handle_state_normal: endpoint={} tokens_to_update_in_system_keyspace = {}", endpoint, tokens_to_update_in_system_keyspace); + slogger.debug("handle_state_normal: endpoint={} tokens_to_update_in_system_keyspace = {}", endpoint, tokens_to_update_in_system_keyspace); if (!tokens_to_update_in_system_keyspace.empty()) { db::system_keyspace::update_tokens(endpoint, tokens_to_update_in_system_keyspace).then_wrapped([endpoint] (auto&& f) { try { f.get(); } catch (...) { - logger.error("handle_state_normal: fail to update tokens for {}: {}", endpoint, std::current_exception()); + slogger.error("handle_state_normal: fail to update tokens for {}: {}", endpoint, std::current_exception()); } return make_ready_future<>(); }).get(); @@ -783,7 +783,7 @@ void storage_service::handle_state_normal(inet_address endpoint) { try { subscriber->on_move(endpoint); } catch (...) { - logger.warn("Move notification failed {}: {}", endpoint, std::current_exception()); + slogger.warn("Move notification failed {}: {}", endpoint, std::current_exception()); } } }).get(); @@ -793,40 +793,40 @@ void storage_service::handle_state_normal(inet_address endpoint) { try { subscriber->on_join_cluster(endpoint); } catch (...) { - logger.warn("Join cluster notification failed {}: {}", endpoint, std::current_exception()); + slogger.warn("Join cluster notification failed {}: {}", endpoint, std::current_exception()); } } }).get(); } update_pending_ranges().get(); - if (logger.is_enabled(logging::log_level::debug)) { + if (slogger.is_enabled(logging::log_level::debug)) { auto ver = _token_metadata.get_ring_version(); for (auto& x : _token_metadata.get_token_to_endpoint()) { - logger.debug("handle_state_normal: token_metadata.ring_version={}, token={} -> endpoint={}", ver, x.first, x.second); + slogger.debug("handle_state_normal: token_metadata.ring_version={}, token={} -> endpoint={}", ver, x.first, x.second); } } } void storage_service::handle_state_leaving(inet_address endpoint) { - logger.debug("endpoint={} handle_state_leaving", endpoint); + slogger.debug("endpoint={} handle_state_leaving", endpoint); auto tokens = get_tokens_for(endpoint); - logger.debug("Node {} state leaving, tokens {}", endpoint, tokens); + slogger.debug("Node {} state leaving, tokens {}", endpoint, tokens); // If the node is previously unknown or tokens do not match, update tokenmetadata to // have this node as 'normal' (it must have been using this token before the // leave). This way we'll get pending ranges right. if (!_token_metadata.is_member(endpoint)) { - logger.info("Node {} state jump to leaving", endpoint); + slogger.info("Node {} state jump to leaving", endpoint); _token_metadata.update_normal_tokens(tokens, endpoint); } else { auto tokens_ = _token_metadata.get_tokens(endpoint); std::set tmp(tokens.begin(), tokens.end()); if (!std::includes(tokens_.begin(), tokens_.end(), tmp.begin(), tmp.end())) { - logger.warn("Node {} 'leaving' token mismatch. Long network partition?", endpoint); - logger.debug("tokens_={}, tokens={}", tokens_, tmp); + slogger.warn("Node {} 'leaving' token mismatch. Long network partition?", endpoint); + slogger.debug("tokens_={}, tokens={}", tokens_, tmp); _token_metadata.update_normal_tokens(tokens, endpoint); } } @@ -838,40 +838,40 @@ void storage_service::handle_state_leaving(inet_address endpoint) { } void storage_service::handle_state_left(inet_address endpoint, std::vector pieces) { - logger.debug("endpoint={} handle_state_left", endpoint); + slogger.debug("endpoint={} handle_state_left", endpoint); if (pieces.size() < 2) { - logger.warn("Fail to handle_state_left endpoint={} pieces={}", endpoint, pieces); + slogger.warn("Fail to handle_state_left endpoint={} pieces={}", endpoint, pieces); return; } auto tokens = get_tokens_for(endpoint); - logger.debug("Node {} state left, tokens {}", endpoint, tokens); + slogger.debug("Node {} state left, tokens {}", endpoint, tokens); excise(tokens, endpoint, extract_expire_time(pieces)); } void storage_service::handle_state_moving(inet_address endpoint, std::vector pieces) { - logger.debug("endpoint={} handle_state_moving", endpoint); + slogger.debug("endpoint={} handle_state_moving", endpoint); if (pieces.size() < 2) { - logger.warn("Fail to handle_state_moving endpoint={} pieces={}", endpoint, pieces); + slogger.warn("Fail to handle_state_moving endpoint={} pieces={}", endpoint, pieces); return; } auto token = dht::global_partitioner().from_sstring(pieces[1]); - logger.debug("Node {} state moving, new token {}", endpoint, token); + slogger.debug("Node {} state moving, new token {}", endpoint, token); _token_metadata.add_moving_endpoint(token, endpoint); update_pending_ranges().get(); } void storage_service::handle_state_removing(inet_address endpoint, std::vector pieces) { - logger.debug("endpoint={} handle_state_removing", endpoint); + slogger.debug("endpoint={} handle_state_removing", endpoint); if (pieces.empty()) { - logger.warn("Fail to handle_state_removing endpoint={} pieces={}", endpoint, pieces); + slogger.warn("Fail to handle_state_removing endpoint={} pieces={}", endpoint, pieces); return; } if (endpoint == get_broadcast_address()) { - logger.info("Received removenode gossip about myself. Is this node rejoining after an explicit removenode?"); + slogger.info("Received removenode gossip about myself. Is this node rejoining after an explicit removenode?"); try { drain().get(); } catch (...) { - logger.error("Fail to drain: {}", std::current_exception()); + slogger.error("Fail to drain: {}", std::current_exception()); throw; } return; @@ -884,7 +884,7 @@ void storage_service::handle_state_removing(inet_address endpoint, std::vectorget_application_state(application_state::REMOVAL_COORDINATOR); if (!value) { auto err = sprint("Can not find application_state for endpoint=%s", endpoint); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } std::vector coordinator; boost::split(coordinator, value->value, boost::is_any_of(sstring(versioned_value::DELIMITER_STR))); if (coordinator.size() != 2) { auto err = sprint("Can not split REMOVAL_COORDINATOR for endpoint=%s, value=%s", endpoint, value->value); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } UUID host_id(coordinator[1]); @@ -913,7 +913,7 @@ void storage_service::handle_state_removing(inet_address endpoint, std::vectoron_up(endpoint); } catch (...) { - logger.warn("Up notification failed {}: {}", endpoint, std::current_exception()); + slogger.warn("Up notification failed {}: {}", endpoint, std::current_exception()); } } }).get(); @@ -958,16 +958,16 @@ void storage_service::on_alive(gms::inet_address endpoint, gms::endpoint_state s } void storage_service::before_change(gms::inet_address endpoint, gms::endpoint_state current_state, gms::application_state new_state_key, const gms::versioned_value& new_value) { - logger.debug("endpoint={} before_change: new app_state={}, new versioned_value={}", endpoint, new_state_key, new_value); + slogger.debug("endpoint={} before_change: new app_state={}, new versioned_value={}", endpoint, new_state_key, new_value); } void storage_service::on_change(inet_address endpoint, application_state state, const versioned_value& value) { - logger.debug("endpoint={} on_change: app_state={}, versioned_value={}", endpoint, state, value); + slogger.debug("endpoint={} on_change: app_state={}, versioned_value={}", endpoint, state, value); if (state == application_state::STATUS) { std::vector pieces; boost::split(pieces, value.value, boost::is_any_of(sstring(versioned_value::DELIMITER_STR))); if (pieces.empty()) { - logger.warn("Fail to split status in on_change: endpoint={}, app_state={}, value={}", endpoint, state, value); + slogger.warn("Fail to split status in on_change: endpoint={}, app_state={}, value={}", endpoint, state, value); } sstring move_name = pieces[0]; if (move_name == sstring(versioned_value::STATUS_BOOTSTRAPPING)) { @@ -989,14 +989,14 @@ void storage_service::on_change(inet_address endpoint, application_state state, auto& gossiper = gms::get_local_gossiper(); auto ep_state = gossiper.get_endpoint_state_for_endpoint(endpoint); if (!ep_state || gossiper.is_dead_state(*ep_state)) { - logger.debug("Ignoring state change for dead or unknown endpoint: {}", endpoint); + slogger.debug("Ignoring state change for dead or unknown endpoint: {}", endpoint); return; } if (get_token_metadata().is_member(endpoint)) { do_update_system_peers_table(endpoint, state, value); if (state == application_state::SCHEMA) { get_local_migration_manager().schedule_schema_pull(endpoint, *ep_state).handle_exception([endpoint] (auto ep) { - logger.warn("Failed to pull schema from {}: {}", endpoint, ep); + slogger.warn("Failed to pull schema from {}: {}", endpoint, ep); }); } } @@ -1006,27 +1006,27 @@ void storage_service::on_change(inet_address endpoint, application_state state, void storage_service::on_remove(gms::inet_address endpoint) { - logger.debug("endpoint={} on_remove", endpoint); + slogger.debug("endpoint={} on_remove", endpoint); _token_metadata.remove_endpoint(endpoint); update_pending_ranges().get(); } void storage_service::on_dead(gms::inet_address endpoint, gms::endpoint_state state) { - logger.debug("endpoint={} on_dead", endpoint); - net::get_local_messaging_service().remove_rpc_client(net::msg_addr{endpoint, 0}); + slogger.debug("endpoint={} on_dead", endpoint); + netw::get_local_messaging_service().remove_rpc_client(netw::msg_addr{endpoint, 0}); get_storage_service().invoke_on_all([endpoint] (auto&& ss) { for (auto&& subscriber : ss._lifecycle_subscribers) { try { subscriber->on_down(endpoint); } catch (...) { - logger.warn("Down notification failed {}: {}", endpoint, std::current_exception()); + slogger.warn("Down notification failed {}: {}", endpoint, std::current_exception()); } } }).get(); } void storage_service::on_restart(gms::inet_address endpoint, gms::endpoint_state state) { - logger.debug("endpoint={} on_restart", endpoint); + slogger.debug("endpoint={} on_restart", endpoint); // If we have restarted before the node was even marked down, we need to reset the connection pool if (state.is_alive()) { on_dead(endpoint, state); @@ -1040,7 +1040,7 @@ static void update_table(gms::inet_address endpoint, sstring col, T value) { try { f.get(); } catch (...) { - logger.error("fail to update {} for {}: {}", col, endpoint, std::current_exception()); + slogger.error("fail to update {} for {}: {}", col, endpoint, std::current_exception()); } return make_ready_future<>(); }).get(); @@ -1048,7 +1048,7 @@ static void update_table(gms::inet_address endpoint, sstring col, T value) { // Runs inside seastar::async context void storage_service::do_update_system_peers_table(gms::inet_address endpoint, const application_state& state, const versioned_value& value) { - logger.debug("Update system.peers table: endpoint={}, app_state={}, versioned_value={}", endpoint, state, value); + slogger.debug("Update system.peers table: endpoint={}, app_state={}, versioned_value={}", endpoint, state, value); if (state == application_state::RELEASE_VERSION) { update_table(endpoint, "release_version", value.value); } else if (state == application_state::DC) { @@ -1061,7 +1061,7 @@ void storage_service::do_update_system_peers_table(gms::inet_address endpoint, c try { ep = gms::inet_address(value.value); } catch (...) { - logger.error("fail to update {} for {}: invalid rcpaddr {}", col, endpoint, value.value); + slogger.error("fail to update {} for {}: invalid rcpaddr {}", col, endpoint, value.value); return; } update_table(endpoint, col, ep.addr()); @@ -1104,7 +1104,7 @@ sstring storage_service::get_application_state_value(inet_address endpoint, appl std::unordered_set storage_service::get_tokens_for(inet_address endpoint) { auto tokens_string = get_application_state_value(endpoint, application_state::TOKENS); - logger.trace("endpoint={}, tokens_string={}", endpoint, tokens_string); + slogger.trace("endpoint={}, tokens_string={}", endpoint, tokens_string); if (tokens_string.size() == 0) { return {}; // boost::split produces one element for emty string } @@ -1113,7 +1113,7 @@ std::unordered_set storage_service::get_tokens_for(inet_address boost::split(tokens, tokens_string, boost::is_any_of(";")); for (auto str : tokens) { auto t = dht::global_partitioner().from_sstring(str); - logger.trace("endpoint={}, token_str={} token={}", endpoint, str, t); + slogger.trace("endpoint={}, token_str={} token={}", endpoint, str, t); ret.emplace(std::move(t)); } return ret; @@ -1121,7 +1121,7 @@ std::unordered_set storage_service::get_tokens_for(inet_address // Runs inside seastar::async context void storage_service::set_tokens(std::unordered_set tokens) { - logger.debug("Setting tokens to {}", tokens); + slogger.debug("Setting tokens to {}", tokens); db::system_keyspace::update_tokens(tokens).get(); _token_metadata.update_normal_tokens(tokens, get_broadcast_address()); auto local_tokens = get_local_tokens().get0(); @@ -1151,24 +1151,24 @@ static stdx::optional> drain_in_progress; future<> storage_service::stop_transport() { return run_with_no_api_lock([] (storage_service& ss) { return seastar::async([&ss] { - logger.info("Stop transport: starts"); + slogger.info("Stop transport: starts"); gms::stop_gossiping().get(); - logger.info("Stop transport: stop_gossiping done"); + slogger.info("Stop transport: stop_gossiping done"); ss.shutdown_client_servers().get(); - logger.info("Stop transport: shutdown rpc and cql server done"); + slogger.info("Stop transport: shutdown rpc and cql server done"); ss.do_stop_ms().get(); - logger.info("Stop transport: shutdown messaging_service done"); + slogger.info("Stop transport: shutdown messaging_service done"); ss.do_stop_stream_manager().get(); - logger.info("Stop transport: shutdown stream_manager done"); + slogger.info("Stop transport: shutdown stream_manager done"); auth::auth::shutdown().get(); - logger.info("Stop transport: auth shutdown"); + slogger.info("Stop transport: auth shutdown"); - logger.info("Stop transport: done"); + slogger.info("Stop transport: done"); }); }); } @@ -1179,25 +1179,25 @@ future<> storage_service::drain_on_shutdown() { return std::move(*drain_in_progress); } return seastar::async([&ss] { - logger.info("Drain on shutdown: starts"); + slogger.info("Drain on shutdown: starts"); ss.stop_transport().get(); - logger.info("Drain on shutdown: stop_transport done"); + slogger.info("Drain on shutdown: stop_transport done"); tracing::tracing::tracing_instance().invoke_on_all([] (auto& tr) { return tr.shutdown(); }).get(); tracing::tracing::tracing_instance().stop().get(); - logger.info("Drain on shutdown: tracing is stopped"); + slogger.info("Drain on shutdown: tracing is stopped"); ss.flush_column_families(); - logger.info("Drain on shutdown: flush column_families done"); + slogger.info("Drain on shutdown: flush column_families done"); ss.db().invoke_on_all([] (auto& db) { return db.commitlog()->shutdown(); }).get(); - logger.info("Drain on shutdown: shutdown commitlog done"); + slogger.info("Drain on shutdown: shutdown commitlog done"); // NOTE: We currently don't destory migration_manager nor // storage_service in scylla, so when we reach here @@ -1206,7 +1206,7 @@ future<> storage_service::drain_on_shutdown() { // process. service::get_local_migration_manager().unregister_listener(&ss); - logger.info("Drain on shutdown: done"); + slogger.info("Drain on shutdown: done"); }); }); #if 0 @@ -1253,7 +1253,7 @@ future<> storage_service::drain_on_shutdown() { { JVMStabilityInspector.inspectThrowable(t); // don't let this stop us from shutting down the commitlog and other thread pools - logger.warn("Caught exception while waiting for memtable flushes during shutdown hook", t); + slogger.warn("Caught exception while waiting for memtable flushes during shutdown hook", t); } CommitLog.instance.shutdownBlocking(); @@ -1261,7 +1261,7 @@ future<> storage_service::drain_on_shutdown() { // wait for miscellaneous tasks like sstable and commitlog segment deletion ScheduledExecutors.nonPeriodicTasks.shutdown(); if (!ScheduledExecutors.nonPeriodicTasks.awaitTermination(1, TimeUnit.MINUTES)) - logger.warn("Miscellaneous task executor still busy after one minute; proceeding with shutdown"); + slogger.warn("Miscellaneous task executor still busy after one minute; proceeding with shutdown"); } }, "StorageServiceShutdownHook"); Runtime.getRuntime().addShutdownHook(drainOnShutdown); @@ -1275,9 +1275,9 @@ future<> storage_service::init_server(int delay) { }).get(); auto& gossiper = gms::get_local_gossiper(); #if 0 - logger.info("Cassandra version: {}", FBUtilities.getReleaseVersionString()); - logger.info("Thrift API version: {}", cassandraConstants.VERSION); - logger.info("CQL supported versions: {} (default: {})", StringUtils.join(ClientState.getCQLSupportedVersion(), ","), ClientState.DEFAULT_CQL_VERSION); + slogger.info("Cassandra version: {}", FBUtilities.getReleaseVersionString()); + slogger.info("Thrift API version: {}", cassandraConstants.VERSION); + slogger.info("CQL supported versions: {} (default: {})", StringUtils.join(ClientState.getCQLSupportedVersion(), ","), ClientState.DEFAULT_CQL_VERSION); #endif _initialized = true; @@ -1300,16 +1300,16 @@ future<> storage_service::init_server(int delay) { std::vector loaded_endpoints; if (get_property_load_ring_state()) { - logger.info("Loading persisted ring state"); + slogger.info("Loading persisted ring state"); auto loaded_tokens = db::system_keyspace::load_tokens().get0(); auto loaded_host_ids = db::system_keyspace::load_host_ids().get0(); for (auto& x : loaded_tokens) { - logger.debug("Loaded tokens: endpoint={}, tokens={}", x.first, x.second); + slogger.debug("Loaded tokens: endpoint={}, tokens={}", x.first, x.second); } for (auto& x : loaded_host_ids) { - logger.debug("Loaded host_id: endpoint={}, uuid={}", x.first, x.second); + slogger.debug("Loaded host_id: endpoint={}, uuid={}", x.first, x.second); } for (auto x : loaded_tokens) { @@ -1347,7 +1347,7 @@ future<> storage_service::init_server(int delay) { gossiper.add_local_application_state(gms::application_state::TOKENS, value_factory.tokens(tokens)).get(); gossiper.add_local_application_state(gms::application_state::STATUS, value_factory.hibernate(true)).get(); } - logger.info("Not joining ring as requested. Use JMX (StorageService->joinRing()) to initiate ring joining"); + slogger.info("Not joining ring as requested. Use JMX (StorageService->joinRing()) to initiate ring joining"); } get_storage_service().invoke_on_all([] (auto& ss) { @@ -1380,7 +1380,7 @@ future<> storage_service::replicate_tm_and_ep_map(shared_ptr g0) return get_storage_service().invoke_on_all([](storage_service& local_ss) { if (!gms::get_gossiper().local_is_initialized()) { auto err = sprint("replicate_to_all_cores is called before gossiper is fully initialized"); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } }).then([this, g0] { @@ -1401,13 +1401,13 @@ future<> storage_service::replicate_to_all_cores() { // when gossiper has already been initialized. if (engine().cpu_id() != 0) { auto err = sprint("replicate_to_all_cores is not ran on cpu zero"); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } if (!gms::get_gossiper().local_is_initialized()) { auto err = sprint("replicate_to_all_cores is called before gossiper on shard0 is initialized"); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } @@ -1435,7 +1435,7 @@ future<> storage_service::replicate_to_all_cores() { _replicate_task.signal(); f.get(); } catch (...) { - logger.error("Fail to replicate _token_metadata"); + slogger.error("Fail to replicate _token_metadata"); } return make_ready_future<>(); }); @@ -1458,7 +1458,7 @@ future<> storage_service::stop() { } future<> storage_service::check_for_endpoint_collision() { - logger.debug("Starting shadow gossip round to check for endpoint collision"); + slogger.debug("Starting shadow gossip round to check for endpoint collision"); #if 0 if (!MessagingService.instance().isListening()) MessagingService.instance().listen(FBUtilities.getLocalAddress()); @@ -1468,7 +1468,7 @@ future<> storage_service::check_for_endpoint_collision() { auto t = gms::gossiper::clk::now(); bool found_bootstrapping_node = false; do { - logger.info("Checking remote features with gossip"); + slogger.info("Checking remote features with gossip"); gossiper.do_shadow_round().get(); gossiper.check_knows_remote_features(get_config_supported_features()); auto addr = get_broadcast_address(); @@ -1483,7 +1483,7 @@ future<> storage_service::check_for_endpoint_collision() { if (state.empty()) { continue; } - logger.debug("Checking bootstrapping/leaving/moving nodes: node={}, status={} (check_for_endpoint_collision)", x.first, state); + slogger.debug("Checking bootstrapping/leaving/moving nodes: node={}, status={} (check_for_endpoint_collision)", x.first, state); if (state == sstring(versioned_value::STATUS_BOOTSTRAPPING) || state == sstring(versioned_value::STATUS_LEAVING) || state == sstring(versioned_value::STATUS_MOVING)) { @@ -1494,7 +1494,7 @@ future<> storage_service::check_for_endpoint_collision() { gossiper.reset_endpoint_state_map(); found_bootstrapping_node = true; auto elapsed = std::chrono::duration_cast(gms::gossiper::clk::now() - t).count(); - logger.info("Checking bootstrapping/leaving/moving nodes: node={}, status={}, sleep 1 second and check again ({} seconds elapsed) (check_for_endpoint_collision)", x.first, state, elapsed); + slogger.info("Checking bootstrapping/leaving/moving nodes: node={}, status={}, sleep 1 second and check again ({} seconds elapsed) (check_for_endpoint_collision)", x.first, state, elapsed); sleep(std::chrono::seconds(1)).get(); break; } @@ -1502,7 +1502,7 @@ future<> storage_service::check_for_endpoint_collision() { } } } while (found_bootstrapping_node); - logger.info("Checking bootstrapping/leaving/moving nodes: ok (check_for_endpoint_collision)"); + slogger.info("Checking bootstrapping/leaving/moving nodes: ok (check_for_endpoint_collision)"); gossiper.reset_endpoint_state_map(); }); } @@ -1515,7 +1515,7 @@ void storage_service::remove_endpoint(inet_address endpoint) { try { f.get(); } catch (...) { - logger.error("fail to remove endpoint={}: {}", endpoint, std::current_exception()); + slogger.error("fail to remove endpoint={}: {}", endpoint, std::current_exception()); } return make_ready_future<>(); }).get(); @@ -1526,7 +1526,7 @@ future> storage_service::prepare_replacement_info() { throw std::runtime_error(sprint("replace_address is empty")); } auto replace_address = db().local().get_replace_address().value(); - logger.info("Gathering node replacement information for {}", replace_address); + slogger.info("Gathering node replacement information for {}", replace_address); // if (!MessagingService.instance().isListening()) // MessagingService.instance().listen(FBUtilities.getLocalAddress()); @@ -1536,7 +1536,7 @@ future> storage_service::prepare_replacement_info() { } // make magic happen - logger.info("Checking remote features with gossip"); + slogger.info("Checking remote features with gossip"); return gms::get_local_gossiper().do_shadow_round().then([this, replace_address] { auto& gossiper = gms::get_local_gossiper(); gossiper.check_knows_remote_features(get_config_supported_features()); @@ -1654,9 +1654,9 @@ void storage_service::set_mode(mode m, bool log) { void storage_service::set_mode(mode m, sstring msg, bool log) { _operation_mode = m; if (log) { - logger.info("{}: {}", m, msg); + slogger.info("{}: {}", m, msg); } else { - logger.debug("{}: {}", m, msg); + slogger.debug("{}: {}", m, msg); } } @@ -1665,7 +1665,7 @@ future> storage_service::get_local_tokens() { // should not be called before initServer sets this if (tokens.empty()) { auto err = sprint("get_local_tokens: tokens is empty"); - logger.error(err.c_str()); + slogger.error(err.c_str()); throw std::runtime_error(err); } return tokens; @@ -1686,7 +1686,7 @@ future>> storage_service::descr auto live_hosts = gms::get_local_gossiper().get_live_members(); std::unordered_map> results; return map_reduce(std::move(live_hosts), [] (auto host) { - auto f0 = net::get_messaging_service().local().send_schema_check(net::msg_addr{ host, 0 }); + auto f0 = netw::get_messaging_service().local().send_schema_check(netw::msg_addr{ host, 0 }); return std::move(f0).then_wrapped([host] (auto f) { if (f.failed()) { return std::pair>(host, stdx::nullopt); @@ -1706,7 +1706,7 @@ future>> storage_service::descr // we're done: the results map is ready to return to the client. the rest is just debug logging: auto it_unreachable = results.find(UNREACHABLE); if (it_unreachable != results.end()) { - logger.debug("Hosts not in agreement. Didn't get a response from everybody: {}", ::join( ",", it_unreachable->second)); + slogger.debug("Hosts not in agreement. Didn't get a response from everybody: {}", ::join( ",", it_unreachable->second)); } auto my_version = get_local_storage_service().get_schema_version(); for (auto&& entry : results) { @@ -1715,11 +1715,11 @@ future>> storage_service::descr continue; } for (auto&& host : entry.second) { - logger.debug("{} disagrees ({})", host, entry.first); + slogger.debug("{} disagrees ({})", host, entry.first); } } if (results.size() == 1) { - logger.debug("Schemas are in agreement."); + slogger.debug("Schemas are in agreement."); } return results; }); @@ -1749,7 +1749,7 @@ future<> storage_service::start_gossiping() { return run_with_api_lock(sstring("start_gossiping"), [] (storage_service& ss) { return seastar::async([&ss] { if (!ss._initialized) { - logger.warn("Starting gossip by operator request"); + slogger.warn("Starting gossip by operator request"); ss.set_gossip_tokens(ss.get_local_tokens().get0()); gms::get_local_gossiper().force_newer_generation(); gms::get_local_gossiper().start_gossiping(get_generation_number()).then([&ss] { @@ -1763,7 +1763,7 @@ future<> storage_service::start_gossiping() { future<> storage_service::stop_gossiping() { return run_with_api_lock(sstring("stop_gossiping"), [] (storage_service& ss) { if (ss._initialized) { - logger.warn("Stopping gossip by operator request"); + slogger.warn("Stopping gossip by operator request"); return gms::stop_gossiping().then([&ss] { ss._initialized = false; }); @@ -1777,10 +1777,10 @@ future<> storage_service::do_stop_ms() { return make_ready_future<>(); } _ms_stopped = true; - return net::get_messaging_service().invoke_on_all([] (auto& ms) { + return netw::get_messaging_service().invoke_on_all([] (auto& ms) { return ms.stop(); }).then([] { - logger.info("messaging_service stopped"); + slogger.info("messaging_service stopped"); }); } @@ -1792,7 +1792,7 @@ future<> storage_service::do_stop_stream_manager() { return streaming::get_stream_manager().invoke_on_all([] (auto& sm) { return sm.stop(); }).then([] { - logger.info("stream_manager stopped"); + slogger.info("stream_manager stopped"); }); } @@ -1977,7 +1977,7 @@ future<> storage_service::start_rpc_server() { return tserver->invoke_on_all(&thrift_server::listen, ipv4_addr{ip, port}, keepalive); }); }).then([addr, port] { - logger.info("Thrift server listening on {}:{} ...", addr, port); + slogger.info("Thrift server listening on {}:{} ...", addr, port); }); }); } @@ -1989,7 +1989,7 @@ future<> storage_service::do_stop_rpc_server() { // FIXME: thrift_server::stop() doesn't kill existing connections and wait for them // Note: We must capture tserver so that it will not be freed before tserver->stop return tserver->stop().then([tserver] { - logger.info("Thrift server stopped"); + slogger.info("Thrift server stopped"); }); } return make_ready_future<>(); @@ -2012,7 +2012,7 @@ future<> storage_service::start_native_transport() { if (ss._cql_server) { return make_ready_future<>(); } - auto cserver = make_shared>(); + auto cserver = make_shared>(); ss._cql_server = cserver; auto& cfg = ss._db.local().get_config(); @@ -2020,7 +2020,7 @@ future<> storage_service::start_native_transport() { auto addr = cfg.rpc_address(); auto ceo = cfg.client_encryption_options(); auto keepalive = cfg.rpc_keepalive(); - transport::cql_load_balance lb = transport::parse_load_balance(cfg.load_balance()); + cql_transport::cql_load_balance lb = cql_transport::parse_load_balance(cfg.load_balance()); return seastar::net::dns::resolve_name(addr).then([cserver, addr, port, lb, keepalive, ceo = std::move(ceo)] (seastar::net::inet_address ip) { return cserver->start(std::ref(service::get_storage_proxy()), std::ref(cql3::get_query_processor()), lb).then([cserver, port, addr, ip, ceo, keepalive]() { // #293 - do not stop anything @@ -2050,14 +2050,14 @@ future<> storage_service::start_native_transport() { f = f.then([cred, f = ceo.at("truststore")] { return cred->set_x509_trust_file(f, seastar::tls::x509_crt_format::PEM); }); } - logger.info("Enabling encrypted CQL connections between client and server"); + slogger.info("Enabling encrypted CQL connections between client and server"); } return f.then([cserver, addr, cred = std::move(cred), keepalive] { - return cserver->invoke_on_all(&transport::cql_server::listen, addr, cred, keepalive); + return cserver->invoke_on_all(&cql_transport::cql_server::listen, addr, cred, keepalive); }); }); }).then([addr, port] { - logger.info("Starting listening for CQL clients on {}:{}...", addr, port); + slogger.info("Starting listening for CQL clients on {}:{}...", addr, port); }); }); } @@ -2069,7 +2069,7 @@ future<> storage_service::do_stop_native_transport() { // FIXME: cql_server::stop() doesn't kill existing connections and wait for them // Note: We must capture cserver so that it will not be freed before cserver->stop return cserver->stop().then([cserver] { - logger.info("CQL server stopped"); + slogger.info("CQL server stopped"); }); } return make_ready_future<>(); @@ -2113,34 +2113,34 @@ future<> storage_service::decommission() { } } - logger.info("DECOMMISSIONING: starts"); + slogger.info("DECOMMISSIONING: starts"); ss.start_leaving().get(); // FIXME: long timeout = Math.max(RING_DELAY, BatchlogManager.instance.getBatchlogTimeout()); auto timeout = ss.get_ring_delay(); ss.set_mode(mode::LEAVING, sprint("sleeping %s ms for batch processing and pending range setup", timeout.count()), true); sleep(timeout).get(); - logger.info("DECOMMISSIONING: unbootstrap starts"); + slogger.info("DECOMMISSIONING: unbootstrap starts"); ss.unbootstrap(); - logger.info("DECOMMISSIONING: unbootstrap done"); + slogger.info("DECOMMISSIONING: unbootstrap done"); ss.shutdown_client_servers().get(); - logger.info("DECOMMISSIONING: shutdown rpc and cql server done"); + slogger.info("DECOMMISSIONING: shutdown rpc and cql server done"); db::get_batchlog_manager().invoke_on_all([] (auto& bm) { return bm.stop(); }).get(); - logger.info("DECOMMISSIONING: stop batchlog_manager done"); + slogger.info("DECOMMISSIONING: stop batchlog_manager done"); gms::stop_gossiping().get(); - logger.info("DECOMMISSIONING: stop_gossiping done"); + slogger.info("DECOMMISSIONING: stop_gossiping done"); ss.do_stop_ms().get(); - logger.info("DECOMMISSIONING: stop messaging_service done"); + slogger.info("DECOMMISSIONING: stop messaging_service done"); // StageManager.shutdownNow(); db::system_keyspace::set_bootstrap_state(db::system_keyspace::bootstrap_state::DECOMMISSIONED).get(); - logger.info("DECOMMISSIONING: set_bootstrap_state done"); + slogger.info("DECOMMISSIONING: set_bootstrap_state done"); ss.set_mode(mode::DECOMMISSIONED, true); - logger.info("DECOMMISSIONING: done"); + slogger.info("DECOMMISSIONING: done"); // let op be responsible for killing the process }); }); @@ -2149,7 +2149,7 @@ future<> storage_service::decommission() { future<> storage_service::removenode(sstring host_id_string) { return run_with_api_lock(sstring("removenode"), [host_id_string] (storage_service& ss) mutable { return seastar::async([&ss, host_id_string] { - logger.debug("removenode: host_id = {}", host_id_string); + slogger.debug("removenode: host_id = {}", host_id_string); auto my_address = ss.get_broadcast_address(); auto& tm = ss._token_metadata; auto local_host_id = tm.get_host_id(my_address); @@ -2163,7 +2163,7 @@ future<> storage_service::removenode(sstring host_id_string) { auto tokens = tm.get_tokens(endpoint); - logger.debug("removenode: endpoint = {}", endpoint); + slogger.debug("removenode: endpoint = {}", endpoint); if (endpoint == my_address) { throw std::runtime_error("Cannot remove self"); @@ -2175,7 +2175,7 @@ future<> storage_service::removenode(sstring host_id_string) { // A leaving endpoint that is dead is already being removed. if (tm.is_leaving(endpoint)) { - logger.warn("Node {} is already being removed, continuing removal anyway", endpoint); + slogger.warn("Node {} is already being removed, continuing removal anyway", endpoint); } if (!ss._replicating_nodes.empty()) { @@ -2188,7 +2188,7 @@ future<> storage_service::removenode(sstring host_id_string) { auto& ks = ss.db().local().find_keyspace(keyspace_name); // if the replication factor is 1 the data is lost so we shouldn't wait for confirmation if (ks.get_replication_strategy().get_replication_factor() == 1) { - logger.warn("keyspace={} has replication factor 1, the data is probably lost", keyspace_name); + slogger.warn("keyspace={} has replication factor 1, the data is probably lost", keyspace_name); continue; } @@ -2202,11 +2202,11 @@ future<> storage_service::removenode(sstring host_id_string) { if (fd.is_alive(ep)) { ss._replicating_nodes.emplace(ep); } else { - logger.warn("Endpoint {} is down and will not receive data for re-replication of {}", ep, endpoint); + slogger.warn("Endpoint {} is down and will not receive data for re-replication of {}", ep, endpoint); } } } - logger.info("removenode: endpoint = {}, replicating_nodes = {}", endpoint, ss._replicating_nodes); + slogger.info("removenode: endpoint = {}, replicating_nodes = {}", endpoint, ss._replicating_nodes); ss._removing_node = endpoint; tm.add_leaving_endpoint(endpoint); ss.update_pending_ranges().get(); @@ -2220,7 +2220,7 @@ future<> storage_service::removenode(sstring host_id_string) { // when it completes, the node will be removed from _replicating_nodes, // and we wait for _replicating_nodes to become empty below ss.restore_replica_count(endpoint, my_address).handle_exception([endpoint, my_address] (auto ep) { - logger.info("Failed to restore_replica_count for node {} on node {}", endpoint, my_address); + slogger.info("Failed to restore_replica_count for node {} on node {}", endpoint, my_address); }); // wait for ReplicationFinishedVerbHandler to signal we're done @@ -2284,7 +2284,7 @@ future<> storage_service::drain() { return run_with_api_lock(sstring("drain"), [] (storage_service& ss) { return seastar::async([&ss] { if (ss._operation_mode == mode::DRAINED) { - logger.warn("Cannot drain node (did it already happen?)"); + slogger.warn("Cannot drain node (did it already happen?)"); return; } if (drain_in_progress) { @@ -2362,10 +2362,10 @@ future> storage_service::get_load_map() { if (lb) { for (auto& x : lb->get_load_info()) { load_map.emplace(sprint("%s", x.first), x.second); - logger.debug("get_load_map endpoint={}, load={}", x.first, x.second); + slogger.debug("get_load_map endpoint={}, load={}", x.first, x.second); } } else { - logger.debug("load_broadcaster is not set yet!"); + slogger.debug("load_broadcaster is not set yet!"); } load_map.emplace(sprint("%s", ss.get_broadcast_address()), ss.get_load()); return load_map; @@ -2375,7 +2375,7 @@ future> storage_service::get_load_map() { future<> storage_service::rebuild(sstring source_dc) { return run_with_api_lock(sstring("rebuild"), [source_dc] (storage_service& ss) { - logger.info("rebuild from dc: {}", source_dc == "" ? "(any dc)" : source_dc); + slogger.info("rebuild from dc: {}", source_dc == "" ? "(any dc)" : source_dc); auto streamer = make_lw_shared(ss._db, ss._token_metadata, ss.get_broadcast_address(), "Rebuild"); streamer->add_source_filter(std::make_unique(gms::get_local_failure_detector())); if (source_dc != "") { @@ -2389,7 +2389,7 @@ future<> storage_service::rebuild(sstring source_dc) { auto state = f.get0(); } catch (...) { // This is used exclusively through JMX, so log the full trace but only throw a simple RTE - logger.error("Error while rebuilding node: {}", std::current_exception()); + slogger.error("Error while rebuilding node: {}", std::current_exception()); throw std::runtime_error(sprint("Error while rebuilding node: %s", std::current_exception())); } return make_ready_future<>(); @@ -2416,7 +2416,7 @@ std::unordered_multimap storage_service::get_cha // First get all ranges the leaving endpoint is responsible for auto ranges = get_ranges_for_endpoint(keyspace_name, endpoint); - logger.debug("Node {} ranges [{}]", endpoint, ranges); + slogger.debug("Node {} ranges [{}]", endpoint, ranges); std::unordered_map> current_replica_endpoints; @@ -2453,7 +2453,7 @@ std::unordered_multimap storage_service::get_cha for (auto it = rg.first; it != rg.second; it++) { const dht::token_range& range_ = it->first; std::vector& current_eps = it->second; - logger.debug("range={}, current_replica_endpoints={}, new_replica_endpoints={}", range_, current_eps, new_replica_endpoints); + slogger.debug("range={}, current_replica_endpoints={}, new_replica_endpoints={}", range_, current_eps, new_replica_endpoints); for (auto ep : it->second) { auto beg = new_replica_endpoints.begin(); auto end = new_replica_endpoints.end(); @@ -2461,11 +2461,11 @@ std::unordered_multimap storage_service::get_cha } } - if (logger.is_enabled(logging::log_level::debug)) { + if (slogger.is_enabled(logging::log_level::debug)) { if (new_replica_endpoints.empty()) { - logger.debug("Range {} already in all replicas", r); + slogger.debug("Range {} already in all replicas", r); } else { - logger.debug("Range {} will be responsibility of {}", r, new_replica_endpoints); + slogger.debug("Range {} will be responsibility of {}", r, new_replica_endpoints); } } for (auto& ep : new_replica_endpoints) { @@ -2483,12 +2483,12 @@ void storage_service::unbootstrap() { auto non_system_keyspaces = _db.local().get_non_system_keyspaces(); for (const auto& keyspace_name : non_system_keyspaces) { auto ranges_mm = get_changed_ranges_for_leaving(keyspace_name, get_broadcast_address()); - if (logger.is_enabled(logging::log_level::debug)) { + if (slogger.is_enabled(logging::log_level::debug)) { std::vector> ranges; for (auto& x : ranges_mm) { ranges.push_back(x.first); } - logger.debug("Ranges needing transfer for keyspace={} are [{}]", keyspace_name, ranges); + slogger.debug("Ranges needing transfer for keyspace={} are [{}]", keyspace_name, ranges); } ranges_to_stream.emplace(keyspace_name, std::move(ranges_mm)); } @@ -2497,7 +2497,7 @@ void storage_service::unbootstrap() { auto stream_success = stream_ranges(ranges_to_stream); // Wait for batch log to complete before streaming hints. - logger.debug("waiting for batch log processing."); + slogger.debug("waiting for batch log processing."); // Start with BatchLog replay, which may create hints but no writes since this is no longer a valid endpoint. db::get_local_batchlog_manager().do_batch_log_replay().get(); @@ -2506,15 +2506,15 @@ void storage_service::unbootstrap() { auto hints_success = stream_hints(); // wait for the transfer runnables to signal the latch. - logger.debug("waiting for stream acks."); + slogger.debug("waiting for stream acks."); try { stream_success.get(); hints_success.get(); } catch (...) { - logger.warn("unbootstrap fails to stream : {}", std::current_exception()); + slogger.warn("unbootstrap fails to stream : {}", std::current_exception()); throw; } - logger.debug("stream acks all received."); + slogger.debug("stream acks all received."); leave_ring(); } @@ -2546,7 +2546,7 @@ future<> storage_service::restore_replica_count(inet_address endpoint, inet_addr for (auto& m : maps) { auto source = m.first; auto ranges = m.second; - logger.debug("Requesting from {} ranges {}", source, ranges); + slogger.debug("Requesting from {} ranges {}", source, ranges); sp->request_ranges(source, keyspace_name, ranges); } } @@ -2555,7 +2555,7 @@ future<> storage_service::restore_replica_count(inet_address endpoint, inet_addr auto state = f.get0(); return this->send_replication_notification(notify_endpoint); } catch (...) { - logger.warn("Streaming to restore replica count failed: {}", std::current_exception()); + slogger.warn("Streaming to restore replica count failed: {}", std::current_exception()); // We still want to send the notification return this->send_replication_notification(notify_endpoint); } @@ -2565,7 +2565,7 @@ future<> storage_service::restore_replica_count(inet_address endpoint, inet_addr // Runs inside seastar::async context void storage_service::excise(std::unordered_set tokens, inet_address endpoint) { - logger.info("Removing tokens {} for {}", tokens, endpoint); + slogger.info("Removing tokens {} for {}", tokens, endpoint); // FIXME: HintedHandOffManager.instance.deleteHintsForEndpoint(endpoint); remove_endpoint(endpoint); _token_metadata.remove_endpoint(endpoint); @@ -2576,7 +2576,7 @@ void storage_service::excise(std::unordered_set tokens, inet_address endp try { subscriber->on_leave_cluster(endpoint); } catch (...) { - logger.warn("Leave cluster notification failed {}: {}", endpoint, std::current_exception()); + slogger.warn("Leave cluster notification failed {}: {}", endpoint, std::current_exception()); } } }).get(); @@ -2593,20 +2593,20 @@ future<> storage_service::send_replication_notification(inet_address remote) { // notify the remote token auto done = make_shared(false); auto local = get_broadcast_address(); - logger.debug("Notifying {} of replication completion", remote); + slogger.debug("Notifying {} of replication completion", remote); return do_until( [done, remote] { return *done || !gms::get_local_failure_detector().is_alive(remote); }, [done, remote, local] { - auto& ms = net::get_local_messaging_service(); - net::msg_addr id{remote, 0}; + auto& ms = netw::get_local_messaging_service(); + netw::msg_addr id{remote, 0}; return ms.send_replication_finished(id, local).then_wrapped([id, done] (auto&& f) { try { f.get(); *done = true; } catch (...) { - logger.warn("Fail to send REPLICATION_FINISHED to {}: {}", id, std::current_exception()); + slogger.warn("Fail to send REPLICATION_FINISHED to {}: {}", id, std::current_exception()); } }); } @@ -2616,14 +2616,14 @@ future<> storage_service::send_replication_notification(inet_address remote) { future<> storage_service::confirm_replication(inet_address node) { return run_with_no_api_lock([node] (storage_service& ss) { auto removing_node = bool(ss._removing_node) ? sprint("%s", *ss._removing_node) : "NONE"; - logger.info("Got confirm_replication from {}, removing_node {}", node, removing_node); + slogger.info("Got confirm_replication from {}, removing_node {}", node, removing_node); // replicatingNodes can be empty in the case where this node used to be a removal coordinator, // but restarted before all 'replication finished' messages arrived. In that case, we'll // still go ahead and acknowledge it. if (!ss._replicating_nodes.empty()) { ss._replicating_nodes.erase(node); } else { - logger.info("Received unexpected REPLICATION_FINISHED message from {}. Was this node recently a removal coordinator?", node); + slogger.info("Received unexpected REPLICATION_FINISHED message from {}. Was this node recently a removal coordinator?", node); } }); } @@ -2638,7 +2638,7 @@ void storage_service::leave_ring() { auto expire_time = gossiper.compute_expire_time().time_since_epoch().count(); gossiper.add_local_application_state(gms::application_state::STATUS, value_factory.left(get_local_tokens().get0(), expire_time)).get(); auto delay = std::max(get_ring_delay(), gms::gossiper::INTERVAL); - logger.info("Announcing that I have left the ring for {}ms", delay.count()); + slogger.info("Announcing that I have left the ring for {}ms", delay.count()); sleep(delay).get(); } @@ -2676,9 +2676,9 @@ storage_service::stream_ranges(std::unordered_mapexecute().discard_result().then([sp] { - logger.info("stream_ranges successful"); + slogger.info("stream_ranges successful"); }).handle_exception([] (auto ep) { - logger.info("stream_ranges failed: {}", ep); + slogger.info("stream_ranges failed: {}", ep); return make_exception_future(std::runtime_error("stream_ranges failed")); }); } @@ -2701,7 +2701,7 @@ future<> storage_service::stream_hints() { candidates.erase(std::remove_if(beg, end, remove_fn), end); if (candidates.empty()) { - logger.warn("Unable to stream hints since no live endpoints seen"); + slogger.warn("Unable to stream hints since no live endpoints seen"); throw std::runtime_error("Unable to stream hints since no live endpoints seen"); } else { // stream to the closest peer as chosen by the snitch @@ -2712,16 +2712,16 @@ future<> storage_service::stream_hints() { // stream all hints -- range list will be a singleton of "the entire ring" dht::token_range_vector ranges = {dht::token_range::make_open_ended_both_sides()}; - logger.debug("stream_hints: ranges={}", ranges); + slogger.debug("stream_hints: ranges={}", ranges); auto sp = make_lw_shared("Hints"); std::vector column_families = { db::system_keyspace::HINTS }; auto keyspace = db::system_keyspace::NAME; sp->transfer_ranges(hints_destination_host, keyspace, ranges, column_families); return sp->execute().discard_result().then([sp] { - logger.info("stream_hints successful"); + slogger.info("stream_hints successful"); }).handle_exception([] (auto ep) { - logger.info("stream_hints failed: {}", ep); + slogger.info("stream_hints failed: {}", ep); return make_exception_future(std::runtime_error("stream_hints failed")); }); } @@ -2765,7 +2765,7 @@ future<> storage_service::load_new_sstables(sstring ks_name, sstring cf_name) { _loading_new_sstables = true; } - logger.info("Loading new SSTables for {}.{}...", ks_name, cf_name); + slogger.info("Loading new SSTables for {}.{}...", ks_name, cf_name); // First, we need to stop SSTable creation for that CF in all shards. This is a really horrible // thing to do, because under normal circumnstances this can make dirty memory go up to the point @@ -2821,10 +2821,10 @@ future<> storage_service::load_new_sstables(sstring ks_name, sstring cf_name) { try { new_tables = f.get0(); } catch(std::exception& e) { - logger.error("Loading of new tables failed to {}.{} due to {}", ks_name, cf_name, e.what()); + slogger.error("Loading of new tables failed to {}.{} due to {}", ks_name, cf_name, e.what()); eptr = std::current_exception(); } catch(...) { - logger.error("Loading of new tables failed to {}.{} due to unexpected reason", ks_name, cf_name); + slogger.error("Loading of new tables failed to {}.{} due to unexpected reason", ks_name, cf_name); eptr = std::current_exception(); } @@ -2832,11 +2832,11 @@ future<> storage_service::load_new_sstables(sstring ks_name, sstring cf_name) { new_gen = new_tables.back().generation; } - logger.debug("Now accepting writes for sstables with generation larger or equal than {}", new_gen); + slogger.debug("Now accepting writes for sstables with generation larger or equal than {}", new_gen); return _db.invoke_on_all([ks_name, cf_name, new_gen] (database& db) { auto& cf = db.find_column_family(ks_name, cf_name); auto disabled = std::chrono::duration_cast(cf.enable_sstable_write(new_gen)).count(); - logger.info("CF {}.{} at shard {} had SSTables writes disabled for {} usec", ks_name, cf_name, engine().cpu_id(), disabled); + slogger.info("CF {}.{} at shard {} had SSTables writes disabled for {} usec", ks_name, cf_name, engine().cpu_id(), disabled); return make_ready_future<>(); }).then([new_tables = std::move(new_tables), eptr = std::move(eptr)] { if (eptr) { @@ -2848,7 +2848,7 @@ future<> storage_service::load_new_sstables(sstring ks_name, sstring cf_name) { auto f = distributed_loader::flush_upload_dir(_db, ks_name, cf_name); return f.then([new_tables = std::move(new_tables), ks_name, cf_name] (std::vector new_tables_from_upload) mutable { if (new_tables.empty() && new_tables_from_upload.empty()) { - logger.info("No new SSTables were found for {}.{}", ks_name, cf_name); + slogger.info("No new SSTables were found for {}.{}", ks_name, cf_name); } // merge new sstables found in both column family and upload directories, if any. new_tables.insert(new_tables.end(), new_tables_from_upload.begin(), new_tables_from_upload.end()); @@ -2856,7 +2856,7 @@ future<> storage_service::load_new_sstables(sstring ks_name, sstring cf_name) { }); }).then([this, ks_name, cf_name] (std::vector new_tables) { return distributed_loader::load_new_sstables(_db, ks_name, cf_name, std::move(new_tables)).then([ks_name, cf_name] { - logger.info("Done loading new SSTables for {}.{} for all shards", ks_name, cf_name); + slogger.info("Done loading new SSTables for {}.{} for all shards", ks_name, cf_name); }); }).finally([this] { _loading_new_sstables = false; @@ -2897,7 +2897,7 @@ storage_service::get_new_source_ranges(const sstring& keyspace_name, const dht:: if (std::find(sources.begin(), sources.end(), my_address) != sources.end()) { auto err = sprint("get_new_source_ranges: sources=%s, my_address=%s", sources, my_address); - logger.warn(err.c_str()); + slogger.warn(err.c_str()); throw std::runtime_error(err); } @@ -2949,11 +2949,11 @@ storage_service::calculate_stream_and_fetch_ranges(const dht::token_range_vector } } - if (logger.is_enabled(logging::log_level::debug)) { - logger.debug("current = {}", current); - logger.debug("updated = {}", updated); - logger.debug("to_stream = {}", to_stream); - logger.debug("to_fetch = {}", to_fetch); + if (slogger.is_enabled(logging::log_level::debug)) { + slogger.debug("current = {}", current); + slogger.debug("updated = {}", updated); + slogger.debug("to_stream = {}", to_stream); + slogger.debug("to_fetch = {}", to_fetch); } return std::pair, std::unordered_set>(to_stream, to_fetch); @@ -2970,7 +2970,7 @@ void storage_service::range_relocator::calculate_to_from_streams(std::unordered_ auto token_meta_clone = ss._token_metadata.clone_only_token_map(); for (auto keyspace : keyspace_names) { - logger.debug("Calculating ranges to stream and request for keyspace {}", keyspace); + slogger.debug("Calculating ranges to stream and request for keyspace {}", keyspace); for (auto new_token : new_tokens) { // replication strategy of the current keyspace (aka table) auto& ks = ss._db.local().find_keyspace(keyspace); @@ -3068,7 +3068,7 @@ void storage_service::range_relocator::calculate_to_from_streams(std::unordered_ auto end_token = to_stream.end() ? to_stream.end()->value() : dht::maximum_token(); std::vector current_endpoints = strategy.calculate_natural_endpoints(end_token, token_meta_clone); std::vector new_endpoints = strategy.calculate_natural_endpoints(end_token, token_meta_clone_all_settled); - logger.debug("Range: {} Current endpoints: {} New endpoints: {}", to_stream, current_endpoints, new_endpoints); + slogger.debug("Range: {} Current endpoints: {} New endpoints: {}", to_stream, current_endpoints, new_endpoints); std::sort(current_endpoints.begin(), current_endpoints.end()); std::sort(new_endpoints.begin(), new_endpoints.end()); @@ -3076,7 +3076,7 @@ void storage_service::range_relocator::calculate_to_from_streams(std::unordered_ std::set_difference(new_endpoints.begin(), new_endpoints.end(), current_endpoints.begin(), current_endpoints.end(), std::back_inserter(diff)); for (auto address : diff) { - logger.debug("Range {} has new owner {}", to_stream, address); + slogger.debug("Range {} has new owner {}", to_stream, address); endpoint_ranges.emplace(address, to_stream); } } @@ -3088,7 +3088,7 @@ void storage_service::range_relocator::calculate_to_from_streams(std::unordered_ for (auto& x : endpoint_ranges_map) { auto& address = x.first; auto& ranges = x.second; - logger.debug("Will stream range {} of keyspace {} to endpoint {}", ranges , keyspace, address); + slogger.debug("Will stream range {} of keyspace {} to endpoint {}", ranges , keyspace, address); _stream_plan.transfer_ranges(address, keyspace, ranges); } @@ -3103,12 +3103,12 @@ void storage_service::range_relocator::calculate_to_from_streams(std::unordered_ for (auto& x : work_map) { auto& address = x.first; auto& ranges = x.second; - logger.debug("Will request range {} of keyspace {} from endpoint {}", ranges, keyspace, address); + slogger.debug("Will request range {} of keyspace {} from endpoint {}", ranges, keyspace, address); _stream_plan.request_ranges(address, keyspace, ranges); } - if (logger.is_enabled(logging::log_level::debug)) { + if (slogger.is_enabled(logging::log_level::debug)) { for (auto& x : work) { - logger.debug("Keyspace {}: work map ep = {} --> range = {}", keyspace, x.first, x.second); + slogger.debug("Keyspace {}: work map ep = {} --> range = {}", keyspace, x.first, x.second); } } } @@ -3128,7 +3128,7 @@ future<> storage_service::move(token new_token) { // This doesn't make any sense in a vnodes environment. if (ss.get_token_metadata().get_tokens(local_address).size() > 1) { - logger.error("Invalid request to move(Token); This node has more than one token and cannot be moved thusly."); + slogger.error("Invalid request to move(Token); This node has more than one token and cannot be moved thusly."); throw std::runtime_error("This node has more than one token and cannot be moved thusly."); } @@ -3164,7 +3164,7 @@ future<> storage_service::move(token new_token) { ss.set_tokens(std::unordered_set{new_token}); // setting new token as we have everything settled - logger.debug("Successfully moved to new token {}", *(ss.get_local_tokens().get0().begin())); + slogger.debug("Successfully moved to new token {}", *(ss.get_local_tokens().get0().begin())); }); }); } @@ -3237,7 +3237,7 @@ std::map storage_service::get_token_to_endpoint_map() { std::chrono::milliseconds storage_service::get_ring_delay() { auto ring_delay = _db.local().get_config().ring_delay_ms(); - logger.trace("Set RING_DELAY to {}ms", ring_delay); + slogger.trace("Set RING_DELAY to {}ms", ring_delay); return std::chrono::milliseconds(ring_delay); } @@ -3252,7 +3252,7 @@ void storage_service::do_update_pending_ranges() { auto& strategy = ks.get_replication_strategy(); get_local_storage_service().get_token_metadata().calculate_pending_ranges(strategy, keyspace_name); } - // logger.debug("finished calculation for {} keyspaces in {}ms", keyspaces.size(), System.currentTimeMillis() - start); + // slogger.debug("finished calculation for {} keyspaces in {}ms", keyspaces.size(), System.currentTimeMillis() - start); } future<> storage_service::update_pending_ranges() { @@ -3269,19 +3269,19 @@ future<> storage_service::update_pending_ranges() { future<> storage_service::keyspace_changed(const sstring& ks_name) { // Update pending ranges since keyspace can be changed after we calculate pending ranges. return update_pending_ranges().handle_exception([ks_name] (auto ep) { - logger.warn("Failed to update pending ranges for ks = {}: {}", ks_name, ep); + slogger.warn("Failed to update pending ranges for ks = {}: {}", ks_name, ep); }); } void storage_service::init_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.register_replication_finished([] (gms::inet_address from) { return get_local_storage_service().confirm_replication(from); }); } void storage_service::uninit_messaging_service() { - auto& ms = net::get_local_messaging_service(); + auto& ms = netw::get_local_messaging_service(); ms.unregister_replication_finished(); } @@ -3290,7 +3290,7 @@ static std::atomic isolated = { false }; void storage_service::do_isolate_on_error(disk_error type) { if (!isolated.exchange(true)) { - logger.warn("Shutting down communications due to I/O errors until operator intervention"); + slogger.warn("Shutting down communications due to I/O errors until operator intervention"); // isolated protect us against multiple stops service::get_local_storage_service().stop_transport(); } @@ -3322,7 +3322,7 @@ future<> storage_service::force_remove_completion() { ss._force_remove_completion = true; while (!ss._operation_in_progress.empty()) { // Wait removenode operation to complete - logger.info("Operation {} is in progress, wait for it to complete", ss._operation_in_progress); + slogger.info("Operation {} is in progress, wait for it to complete", ss._operation_in_progress); sleep(std::chrono::seconds(1)).get(); } ss._force_remove_completion = false; @@ -3332,14 +3332,14 @@ future<> storage_service::force_remove_completion() { try { if (!ss._replicating_nodes.empty() || !ss._token_metadata.get_leaving_endpoints().empty()) { auto leaving = ss._token_metadata.get_leaving_endpoints(); - logger.warn("Removal not confirmed for {}, Leaving={}", join(",", ss._replicating_nodes), leaving); + slogger.warn("Removal not confirmed for {}, Leaving={}", join(",", ss._replicating_nodes), leaving); for (auto endpoint : leaving) { utils::UUID host_id; auto tokens = ss._token_metadata.get_tokens(endpoint); try { host_id = ss._token_metadata.get_host_id(endpoint); } catch (...) { - logger.warn("No host_id is found for endpoint {}", endpoint); + slogger.warn("No host_id is found for endpoint {}", endpoint); continue; } gms::get_local_gossiper().advertise_token_removed(endpoint, host_id).get(); @@ -3349,7 +3349,7 @@ future<> storage_service::force_remove_completion() { ss._replicating_nodes.clear(); ss._removing_node = std::experimental::nullopt; } else { - logger.warn("No tokens to force removal on, call 'removenode' first"); + slogger.warn("No tokens to force removal on, call 'removenode' first"); } ss._operation_in_progress = {}; } catch (...) { diff --git a/service/storage_service.hh b/service/storage_service.hh index a1310fa7de..e011d592c7 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -60,7 +60,7 @@ #include "disk-error-handler.hh" #include "gms/feature.hh" -namespace transport { +namespace cql_transport { class cql_server; } class thrift_server; @@ -121,7 +121,7 @@ private: // ever arise. bool _loading_new_sstables = false; shared_ptr _lb; - shared_ptr> _cql_server; + shared_ptr> _cql_server; shared_ptr> _thrift_server; sstring _operation_in_progress; bool _force_remove_completion = false; diff --git a/sstables/atomic_deletion.hh b/sstables/atomic_deletion.hh index bc05f726a4..2ee8c488a1 100644 --- a/sstables/atomic_deletion.hh +++ b/sstables/atomic_deletion.hh @@ -48,6 +48,8 @@ #include #include +#include "seastarx.hh" + namespace sstables { struct sstable_to_delete { diff --git a/sstables/compaction.cc b/sstables/compaction.cc index 6038322018..d842dfa18f 100644 --- a/sstables/compaction.cc +++ b/sstables/compaction.cc @@ -67,7 +67,7 @@ namespace sstables { -logging::logger logger("compaction"); +logging::logger clogger("compaction"); class sstable_reader final : public ::mutation_reader::impl { shared_sstable _sst; @@ -79,7 +79,7 @@ public: {} virtual future operator()() override { return _reader.read().handle_exception([sst = _sst] (auto ep) { - logger.error("Compaction found an exception when reading sstable {} : {}", + clogger.error("Compaction found an exception when reading sstable {} : {}", sst->get_filename(), ep); return make_exception_future(ep); }); @@ -124,7 +124,7 @@ static void delete_sstables_for_interrupted_compaction(std::vectorget_filename(), ks, cf); + clogger.debug("Deleting sstable {} of interrupted compaction for {}.{}", sst->get_filename(), ks, cf); sst->mark_for_deletion(); } } @@ -348,11 +348,11 @@ public: } void report_start(const sstring& formatted_msg) const override { - logger.info("Compacting {}", formatted_msg); + clogger.info("Compacting {}", formatted_msg); } void report_finish(const sstring& formatted_msg, std::chrono::time_point ended_at) const override { - logger.info("Compacted {}", formatted_msg); + clogger.info("Compacted {}", formatted_msg); // skip update if running without a query context, for example, when running a test case. if (!db::qctx) { @@ -414,11 +414,11 @@ public: } void report_start(const sstring& formatted_msg) const override { - logger.info("Cleaning {}", formatted_msg); + clogger.info("Cleaning {}", formatted_msg); } void report_finish(const sstring& formatted_msg, std::chrono::time_point ended_at) const override { - logger.info("Cleaned {}", formatted_msg); + clogger.info("Cleaned {}", formatted_msg); } std::function filter_func() const override { @@ -452,11 +452,11 @@ public: } void report_start(const sstring& formatted_msg) const override { - logger.info("Resharding {}", formatted_msg); + clogger.info("Resharding {}", formatted_msg); } void report_finish(const sstring& formatted_msg, std::chrono::time_point ended_at) const override { - logger.info("Resharded {}", formatted_msg); + clogger.info("Resharded {}", formatted_msg); } sstable_writer* select_sstable_writer(const dht::decorated_key& dk) override { @@ -546,7 +546,7 @@ reshard_sstables(std::vector sstables, column_family& cf, std::f std::vector get_fully_expired_sstables(column_family& cf, std::vector& compacting, int32_t gc_before) { - logger.debug("Checking droppable sstables in {}.{}", cf.schema()->ks_name(), cf.schema()->cf_name()); + clogger.debug("Checking droppable sstables in {}.{}", cf.schema()->ks_name(), cf.schema()->cf_name()); if (compacting.empty()) { return {}; @@ -574,13 +574,13 @@ get_fully_expired_sstables(column_family& cf, std::vectorgeneration(), candidate->get_stats_metadata().max_local_deletion_time, gc_before); // A fully expired sstable which has an ancestor undeleted shouldn't be compacted because // expired data won't be purged because undeleted sstables are taken into account when // calculating max purgeable timestamp, and not doing it could lead to a compaction loop. if (candidate->get_stats_metadata().max_local_deletion_time < gc_before && !has_undeleted_ancestor(candidate)) { - logger.debug("Adding candidate of generation {} to list of possibly expired sstables", candidate->generation()); + clogger.debug("Adding candidate of generation {} to list of possibly expired sstables", candidate->generation()); candidates.push_back(candidate); } else { min_timestamp = std::min(min_timestamp, candidate->get_stats_metadata().min_timestamp); @@ -594,7 +594,7 @@ get_fully_expired_sstables(column_family& cf, std::vectorget_stats_metadata().max_timestamp >= min_timestamp) { it = candidates.erase(it); } else { - logger.debug("Dropping expired SSTable {} (maxLocalDeletionTime={}, gcBefore={})", + clogger.debug("Dropping expired SSTable {} (maxLocalDeletionTime={}, gcBefore={})", candidate->get_filename(), candidate->get_stats_metadata().max_local_deletion_time, gc_before); it++; } diff --git a/sstables/compaction_strategy.cc b/sstables/compaction_strategy.cc index 85021a14c0..c64eba953d 100644 --- a/sstables/compaction_strategy.cc +++ b/sstables/compaction_strategy.cc @@ -57,7 +57,7 @@ logging::logger date_tiered_manifest::logger = logging::logger("DateTieredCompac namespace sstables { -extern logging::logger logger; +extern logging::logger clogger; class incremental_selector_impl { public: @@ -341,7 +341,7 @@ compaction_strategy_impl::get_resharding_jobs(column_family& cf, std::vector jobs; shard_id reshard_at_current = 0; - logger.debug("Trying to get resharding jobs for {}.{}...", cf.schema()->ks_name(), cf.schema()->cf_name()); + clogger.debug("Trying to get resharding jobs for {}.{}...", cf.schema()->ks_name(), cf.schema()->cf_name()); for (auto& candidate : candidates) { auto level = candidate->get_sstable_level(); jobs.push_back(resharding_descriptor{{std::move(candidate)}, std::numeric_limits::max(), reshard_at_current++ % smp::count, level}); @@ -711,10 +711,10 @@ public: auto tmp_value = size_tiered_compaction_strategy_options::get_value(options, SSTABLE_SIZE_OPTION); _max_sstable_size_in_mb = property_definitions::to_int(SSTABLE_SIZE_OPTION, tmp_value, DEFAULT_MAX_SSTABLE_SIZE_IN_MB); if (_max_sstable_size_in_mb >= 1000) { - logger.warn("Max sstable size of {}MB is configured; having a unit of compaction this large is probably a bad idea", + clogger.warn("Max sstable size of {}MB is configured; having a unit of compaction this large is probably a bad idea", _max_sstable_size_in_mb); } else if (_max_sstable_size_in_mb < 50) { - logger.warn("Max sstable size of {}MB is configured. Testing done for CASSANDRA-5727 indicates that performance improves up to 160MB", + clogger.warn("Max sstable size of {}MB is configured. Testing done for CASSANDRA-5727 indicates that performance improves up to 160MB", _max_sstable_size_in_mb); } _compaction_counter.resize(leveled_manifest::MAX_LEVELS); @@ -760,7 +760,7 @@ compaction_descriptor leveled_compaction_strategy::get_sstables_for_compaction(c return sstables::compaction_descriptor(); } - logger.debug("leveled: Compacting {} out of {} sstables", candidate.sstables.size(), cfs.get_sstables()->size()); + clogger.debug("leveled: Compacting {} out of {} sstables", candidate.sstables.size(), cfs.get_sstables()->size()); return std::move(candidate); } @@ -859,7 +859,7 @@ public: virtual compaction_descriptor get_sstables_for_compaction(column_family& cfs, std::vector candidates) override { auto gc_before = gc_clock::now() - cfs.schema()->gc_grace_seconds(); auto sstables = _manifest.get_next_sstables(cfs, candidates, gc_before); - logger.debug("datetiered: Compacting {} out of {} sstables", sstables.size(), candidates.size()); + clogger.debug("datetiered: Compacting {} out of {} sstables", sstables.size(), candidates.size()); if (sstables.empty()) { return sstables::compaction_descriptor(); } diff --git a/sstables/compress.cc b/sstables/compress.cc index 7e5c8e83a7..87f1fc401a 100644 --- a/sstables/compress.cc +++ b/sstables/compress.cc @@ -33,8 +33,7 @@ #include #include "unimplemented.hh" - -namespace stdx = std::experimental; +#include "stdx.hh" namespace sstables { diff --git a/stdx.hh b/stdx.hh index 487e6ba3f9..a579a7977f 100644 --- a/stdx.hh +++ b/stdx.hh @@ -23,5 +23,4 @@ #pragma once namespace std { namespace experimental {} } - -namespace stdx = std::experimental; +inline namespace seastar { namespace stdx = std::experimental; } diff --git a/streamed_mutation.hh b/streamed_mutation.hh index 23263fa11b..55392ed9b2 100644 --- a/streamed_mutation.hh +++ b/streamed_mutation.hh @@ -26,7 +26,7 @@ #include -namespace stdx = std::experimental; +#include "stdx.hh" // mutation_fragments are the objects that streamed_mutation are going to // stream. They can represent: diff --git a/streaming/stream_session.cc b/streaming/stream_session.cc index 2159a1363a..20d191355c 100644 --- a/streaming/stream_session.cc +++ b/streaming/stream_session.cc @@ -115,7 +115,7 @@ void stream_session::init_messaging_service_handler() { }); }); ms().register_stream_mutation([] (const rpc::client_info& cinfo, UUID plan_id, frozen_mutation fm, unsigned dst_cpu_id, rpc::optional fragmented_opt) { - auto from = net::messaging_service::get_source(cinfo); + auto from = netw::messaging_service::get_source(cinfo); auto fragmented = fragmented_opt && *fragmented_opt; return do_with(std::move(fm), [plan_id, from, fragmented] (const auto& fm) { auto fm_size = fm.representation().size(); @@ -478,7 +478,7 @@ void stream_session::start() { close_session(stream_session_state::COMPLETE); return; } - auto connecting = net::get_local_messaging_service().get_preferred_ip(peer); + auto connecting = netw::get_local_messaging_service().get_preferred_ip(peer); if (peer == connecting) { sslog.info("[Stream #{}] Starting streaming to {}", plan_id(), peer); } else { diff --git a/streaming/stream_session.hh b/streaming/stream_session.hh index 4b8ad4b9e8..df39032b68 100644 --- a/streaming/stream_session.hh +++ b/streaming/stream_session.hh @@ -128,9 +128,9 @@ class stream_result_future; */ class stream_session : public enable_shared_from_this { private: - using messaging_verb = net::messaging_verb; - using messaging_service = net::messaging_service; - using msg_addr = net::msg_addr; + using messaging_verb = netw::messaging_verb; + using messaging_service = netw::messaging_service; + using msg_addr = netw::msg_addr; using inet_address = gms::inet_address; using UUID = utils::UUID; using token = dht::token; @@ -138,8 +138,8 @@ private: static void init_messaging_service_handler(); static distributed* _db; public: - static net::messaging_service& ms() { - return net::get_local_messaging_service(); + static netw::messaging_service& ms() { + return netw::get_local_messaging_service(); } static database& get_local_db() { return _db->local(); } static distributed& get_db() { return *_db; }; diff --git a/streaming/stream_session_state.cc b/streaming/stream_session_state.cc index c69145c36b..21441789f1 100644 --- a/streaming/stream_session_state.cc +++ b/streaming/stream_session_state.cc @@ -42,6 +42,7 @@ #include #include #include +#include "seastarx.hh" namespace streaming { diff --git a/streaming/stream_transfer_task.cc b/streaming/stream_transfer_task.cc index b66e164f38..2a041ac3b6 100644 --- a/streaming/stream_transfer_task.cc +++ b/streaming/stream_transfer_task.cc @@ -70,14 +70,14 @@ struct send_info { utils::UUID plan_id; utils::UUID cf_id; dht::partition_range_vector prs; - net::messaging_service::msg_addr id; + netw::messaging_service::msg_addr id; uint32_t dst_cpu_id; size_t mutations_nr{0}; semaphore mutations_done{0}; bool error_logged = false; mutation_reader reader; send_info(database& db_, utils::UUID plan_id_, utils::UUID cf_id_, - dht::partition_range_vector prs_, net::messaging_service::msg_addr id_, + dht::partition_range_vector prs_, netw::messaging_service::msg_addr id_, uint32_t dst_cpu_id_) : db(db_) , plan_id(plan_id_) @@ -94,7 +94,7 @@ future<> do_send_mutations(lw_shared_ptr si, frozen_mutation fm, bool return get_local_stream_manager().mutation_send_limiter().wait().then([si, fragmented, fm = std::move(fm)] () mutable { sslog.debug("[Stream #{}] SEND STREAM_MUTATION to {}, cf_id={}", si->plan_id, si->id, si->cf_id); auto fm_size = fm.representation().size(); - net::get_local_messaging_service().send_stream_mutation(si->id, si->plan_id, std::move(fm), si->dst_cpu_id, fragmented).then([si, fm_size] { + netw::get_local_messaging_service().send_stream_mutation(si->id, si->plan_id, std::move(fm), si->dst_cpu_id, fragmented).then([si, fm_size] { sslog.debug("[Stream #{}] GOT STREAM_MUTATION Reply from {}", si->plan_id, si->id.addr); get_local_stream_manager().update_progress(si->plan_id, si->id.addr, progress_info::direction::OUT, fm_size); si->mutations_done.signal(); @@ -139,7 +139,7 @@ void stream_transfer_task::start() { auto cf_id = this->cf_id; auto dst_cpu_id = session->dst_cpu_id; auto& schema = session->get_local_db().find_column_family(cf_id).schema(); - auto id = net::messaging_service::msg_addr{session->peer, session->dst_cpu_id}; + auto id = netw::messaging_service::msg_addr{session->peer, session->dst_cpu_id}; sslog.debug("[Stream #{}] stream_transfer_task: cf_id={}", plan_id, cf_id); sort_and_merge_ranges(); _shard_ranges = dht::split_ranges_to_shards(_ranges, *schema); diff --git a/supervisor.hh b/supervisor.hh index 2342020237..a8d120f288 100644 --- a/supervisor.hh +++ b/supervisor.hh @@ -22,6 +22,7 @@ #pragma once #include +#include "seastarx.hh" class supervisor { public: diff --git a/tests/batchlog_manager_test.cc b/tests/batchlog_manager_test.cc index cdd1e95f5c..9eca326958 100644 --- a/tests/batchlog_manager_test.cc +++ b/tests/batchlog_manager_test.cc @@ -64,7 +64,7 @@ SEASTAR_TEST_CASE(test_execute_batch) { using namespace std::chrono_literals; - auto version = net::messaging_service::current_version; + auto version = netw::messaging_service::current_version; auto bm = bp.get_batch_log_mutation_for({ m }, s->id(), version, db_clock::now() - db_clock::duration(3h)); return qp.proxy().local().mutate_locally(bm).then([&bp] () mutable { diff --git a/tests/cql_assertions.cc b/tests/cql_assertions.cc index c0a0226245..9c9ba409ca 100644 --- a/tests/cql_assertions.cc +++ b/tests/cql_assertions.cc @@ -31,7 +31,7 @@ static inline void fail(sstring msg) { throw std::runtime_error(msg); } -rows_assertions::rows_assertions(shared_ptr rows) +rows_assertions::rows_assertions(shared_ptr rows) : _rows(rows) { } @@ -113,16 +113,16 @@ rows_assertions::with_rows_ignore_order(std::initializer_list msg) +result_msg_assertions::result_msg_assertions(shared_ptr msg) : _msg(msg) { } rows_assertions result_msg_assertions::is_rows() { - auto rows = dynamic_pointer_cast(_msg); + auto rows = dynamic_pointer_cast(_msg); BOOST_REQUIRE(rows); return rows_assertions(rows); } -result_msg_assertions assert_that(shared_ptr msg) { +result_msg_assertions assert_that(shared_ptr msg) { return result_msg_assertions(msg); } diff --git a/tests/cql_assertions.hh b/tests/cql_assertions.hh index d3ca6a882d..79c6b73ced 100644 --- a/tests/cql_assertions.hh +++ b/tests/cql_assertions.hh @@ -28,9 +28,9 @@ #include "core/future.hh" class rows_assertions { - shared_ptr _rows; + shared_ptr _rows; public: - rows_assertions(shared_ptr rows); + rows_assertions(shared_ptr rows); rows_assertions with_size(size_t size); rows_assertions is_empty(); rows_assertions with_row(std::initializer_list values); @@ -42,13 +42,13 @@ public: }; class result_msg_assertions { - shared_ptr _msg; + shared_ptr _msg; public: - result_msg_assertions(shared_ptr msg); + result_msg_assertions(shared_ptr msg); rows_assertions is_rows(); }; -result_msg_assertions assert_that(shared_ptr msg); +result_msg_assertions assert_that(shared_ptr msg); template void assert_that_failed(future& f) diff --git a/tests/cql_query_test.cc b/tests/cql_query_test.cc index 70c92c0f5b..604651bf04 100644 --- a/tests/cql_query_test.cc +++ b/tests/cql_query_test.cc @@ -422,7 +422,7 @@ SEASTAR_TEST_CASE(test_limit_is_respected_across_partitions) { // Determine partition order return e.execute_cql("select k from cf;"); }).then([&e](auto msg) { - auto rows = dynamic_pointer_cast(msg); + auto rows = dynamic_pointer_cast(msg); BOOST_REQUIRE(rows); std::vector keys; for (auto&& row : rows->rs().rows()) { @@ -481,7 +481,7 @@ SEASTAR_TEST_CASE(test_partitions_have_consistent_ordering_in_range_query) { // Determine partition order return e.execute_cql("select k from cf;"); }).then([&e](auto msg) { - auto rows = dynamic_pointer_cast(msg); + auto rows = dynamic_pointer_cast(msg); BOOST_REQUIRE(rows); std::vector keys; for (auto&& row : rows->rs().rows()) { @@ -562,7 +562,7 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) { // Determine partition order return e.execute_cql("select k, token(k) from cf;"); }).then([&e](auto msg) { - auto rows = dynamic_pointer_cast(msg); + auto rows = dynamic_pointer_cast(msg); BOOST_REQUIRE(rows); std::vector keys; std::vector tokens; @@ -972,8 +972,8 @@ SEASTAR_TEST_CASE(test_functions) { return e.execute_cql("insert into cf (p1, c1, tu) values ('key1', 3, now());").discard_result(); }).then([&e] { return e.execute_cql("select tu from cf where p1 in ('key1');"); - }).then([&e] (shared_ptr msg) { - using namespace transport::messages; + }).then([&e] (shared_ptr msg) { + using namespace cql_transport::messages; struct validator : result_message::visitor { std::vector res; virtual void visit(const result_message::void_message&) override { throw "bad"; } @@ -996,7 +996,7 @@ SEASTAR_TEST_CASE(test_functions) { BOOST_REQUIRE_EQUAL(boost::distance(v.res | boost::adaptors::uniqued), 3); }).then([&] { return e.execute_cql("select sum(c1), count(c1) from cf where p1 = 'key1';"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_size(1) .with_row({ @@ -1005,7 +1005,7 @@ SEASTAR_TEST_CASE(test_functions) { }); }).then([&] { return e.execute_cql("select count(*) from cf where p1 = 'key1';"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_size(1) .with_row({ @@ -1013,7 +1013,7 @@ SEASTAR_TEST_CASE(test_functions) { }); }).then([&] { return e.execute_cql("select count(1) from cf where p1 = 'key1';"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_size(1) .with_row({ @@ -1024,7 +1024,7 @@ SEASTAR_TEST_CASE(test_functions) { return e.execute_cql("insert into cf (p1, c1) values ((text)'key2', 7);").discard_result(); }).then([&e] { return e.execute_cql("select c1 from cf where p1 = 'key2';"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_size(1) .with_row({ @@ -1042,7 +1042,7 @@ SEASTAR_TEST_CASE(test_writetime_and_ttl) { return e.execute_cql(q).discard_result(); }).then([&e] { return e.execute_cql("select writetime(i) from cf where p1 in ('key1');"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_rows({{ {long_type->decompose(int64_t(the_timestamp))}, @@ -1082,7 +1082,7 @@ SEASTAR_TEST_CASE(test_tuples) { return e.execute_cql("insert into cf (id, t) values (1, (1001, 2001, 'abc1'));").discard_result(); }).then([&e] { return e.execute_cql("select t from cf where id = 1;"); - }).then([&e, tt] (shared_ptr msg) { + }).then([&e, tt] (shared_ptr msg) { assert_that(msg).is_rows() .with_rows({{ {tt->decompose(make_tuple_value(tt, tuple_type_impl::native_type({int32_t(1001), int64_t(2001), sstring("abc1")})))}, @@ -1108,7 +1108,7 @@ SEASTAR_TEST_CASE(test_user_type) { return e.execute_cql("insert into cf (id, t) values (1, (1001, 2001, 'abc1'));").discard_result(); }).then([&e] { return e.execute_cql("select t.my_int, t.my_bigint, t.my_text from cf where id = 1;"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_rows({ {int32_type->decompose(int32_t(1001)), long_type->decompose(int64_t(2001)), utf8_type->decompose(sstring("abc1"))}, @@ -1117,7 +1117,7 @@ SEASTAR_TEST_CASE(test_user_type) { return e.execute_cql("update cf set t = { my_int: 1002, my_bigint: 2002, my_text: 'abc2' } where id = 1;").discard_result(); }).then([&e] { return e.execute_cql("select t.my_int, t.my_bigint, t.my_text from cf where id = 1;"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows() .with_rows({ {int32_type->decompose(int32_t(1002)), long_type->decompose(int64_t(2002)), utf8_type->decompose(sstring("abc2"))}, @@ -1126,7 +1126,7 @@ SEASTAR_TEST_CASE(test_user_type) { return e.execute_cql("insert into cf (id, t) values (2, (frozen)(2001, 3001, 'abc4'));").discard_result(); }).then([&e] { return e.execute_cql("select t from cf where id = 2;"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { auto ut = user_type_impl::get_instance("ks", to_bytes("ut1"), {to_bytes("my_int"), to_bytes("my_bigint"), to_bytes("my_text")}, {int32_type, long_type, utf8_type}); @@ -1153,7 +1153,7 @@ SEASTAR_TEST_CASE(test_select_multiple_ranges) { ).discard_result(); }).then([&e] { return e.execute_cql("select r1 from cf where p1 in ('key1', 'key2');"); - }).then([&e] (shared_ptr msg) { + }).then([&e] (shared_ptr msg) { assert_that(msg).is_rows().with_size(2).with_row({ {int32_type->decompose(100)} }).with_row({ diff --git a/tests/cql_test_env.cc b/tests/cql_test_env.cc index 329a1eedab..a172fafd9d 100644 --- a/tests/cql_test_env.cc +++ b/tests/cql_test_env.cc @@ -102,14 +102,14 @@ public: single_node_cql_env(::shared_ptr> db) : _db(db) { } - virtual future<::shared_ptr> execute_cql(const sstring& text) override { + virtual future<::shared_ptr> execute_cql(const sstring& text) override { auto qs = make_query_state(); return local_qp().process(text, *qs, cql3::query_options::DEFAULT).finally([qs, this] { _core_local.local().client_state.merge(qs->get_client_state()); }); } - virtual future<::shared_ptr> execute_cql( + virtual future<::shared_ptr> execute_cql( const sstring& text, std::unique_ptr qo) override { @@ -129,7 +129,7 @@ public: }); } - virtual future<::shared_ptr> execute_prepared( + virtual future<::shared_ptr> execute_prepared( bytes id, std::vector values) override { @@ -281,7 +281,7 @@ public: boost::filesystem::create_directories(cfg->commitlog_directory().c_str()); const gms::inet_address listen("127.0.0.1"); - auto& ms = net::get_messaging_service(); + auto& ms = netw::get_messaging_service(); ms.start(listen, std::move(7000)).get(); auto stop_ms = defer([&ms] { ms.stop().get(); }); diff --git a/tests/cql_test_env.hh b/tests/cql_test_env.hh index 0b5883af77..ffd66d4b66 100644 --- a/tests/cql_test_env.hh +++ b/tests/cql_test_env.hh @@ -54,14 +54,14 @@ class cql_test_env { public: virtual ~cql_test_env() {}; - virtual future<::shared_ptr> execute_cql(const sstring& text) = 0; + virtual future<::shared_ptr> execute_cql(const sstring& text) = 0; - virtual future<::shared_ptr> execute_cql( + virtual future<::shared_ptr> execute_cql( const sstring& text, std::unique_ptr qo) = 0; virtual future prepare(sstring query) = 0; - virtual future<::shared_ptr> execute_prepared( + virtual future<::shared_ptr> execute_prepared( bytes id, std::vector values) = 0; virtual future<> create_table(std::function schema_maker) = 0; diff --git a/tests/flush_queue_test.cc b/tests/flush_queue_test.cc index f5573e9631..d4957e24a3 100644 --- a/tests/flush_queue_test.cc +++ b/tests/flush_queue_test.cc @@ -28,6 +28,7 @@ #include #include +#include "seastarx.hh" #include "tests/test-utils.hh" #include "utils/flush_queue.hh" #include "log.hh" diff --git a/tests/gossip.cc b/tests/gossip.cc index 93f04fd545..58c797eaa9 100644 --- a/tests/gossip.cc +++ b/tests/gossip.cc @@ -75,9 +75,9 @@ int main(int ac, char ** av) { locator::i_endpoint_snitch::create_snitch("SimpleSnitch").then([&db] { return service::init_storage_service(db); }).then([vv, listen, config] { - return net::get_messaging_service().start(listen); + return netw::get_messaging_service().start(listen); }).then([config] { - auto& server = net::get_local_messaging_service(); + auto& server = netw::get_local_messaging_service(); auto port = server.port(); auto listen = server.listen_address(); print("Messaging server listening on ip %s port %d ...\n", listen, port); diff --git a/tests/gossip_test.cc b/tests/gossip_test.cc index 9e4888c360..1613597fa8 100644 --- a/tests/gossip_test.cc +++ b/tests/gossip_test.cc @@ -44,7 +44,7 @@ SEASTAR_TEST_CASE(test_boot_shutdown){ locator::i_endpoint_snitch::create_snitch("SimpleSnitch").get(); service::get_storage_service().start(std::ref(db)).get(); db.start().get(); - net::get_messaging_service().start(gms::inet_address("127.0.0.1")).get(); + netw::get_messaging_service().start(gms::inet_address("127.0.0.1")).get(); gms::get_failure_detector().start().get(); gms::get_gossiper().start().get(); @@ -52,7 +52,7 @@ SEASTAR_TEST_CASE(test_boot_shutdown){ gms::get_failure_detector().stop().get(); db.stop().get(); service::get_storage_service().stop().get(); - net::get_messaging_service().stop().get(); + netw::get_messaging_service().stop().get(); locator::i_endpoint_snitch::stop_snitch().get(); }); } diff --git a/tests/idl_test.cc b/tests/idl_test.cc index 4f7f33fe27..f66540b030 100644 --- a/tests/idl_test.cc +++ b/tests/idl_test.cc @@ -35,10 +35,11 @@ #include "disk-error-handler.hh" +#include "stdx.hh" + thread_local disk_error_signal_type commit_error; thread_local disk_error_signal_type general_disk_error; -namespace stdx = std::experimental; struct simple_compound { // TODO: change this to test for #905 diff --git a/tests/message.cc b/tests/message.cc index 96ac04bb7c..2239db5b6a 100644 --- a/tests/message.cc +++ b/tests/message.cc @@ -37,7 +37,7 @@ thread_local disk_error_signal_type commit_error; thread_local disk_error_signal_type general_disk_error; using namespace std::chrono_literals; -using namespace net; +using namespace netw; class tester { private: @@ -48,7 +48,7 @@ public: tester() : ms(get_local_messaging_service()) { } - using msg_addr = net::messaging_service::msg_addr; + using msg_addr = netw::messaging_service::msg_addr; using inet_address = gms::inet_address; using endpoint_state = gms::endpoint_state; msg_addr get_msg_addr() { @@ -69,7 +69,7 @@ public: ms.register_gossip_digest_syn([this] (const rpc::client_info& cinfo, gms::gossip_digest_syn msg) { print("Server got syn msg = %s\n", msg); - auto from = net::messaging_service::get_source(cinfo); + auto from = netw::messaging_service::get_source(cinfo); auto ep1 = inet_address("1.1.1.1"); auto ep2 = inet_address("2.2.2.2"); int32_t gen = 800; @@ -91,7 +91,7 @@ public: ms.register_gossip_digest_ack([this] (const rpc::client_info& cinfo, gms::gossip_digest_ack msg) { print("Server got ack msg = %s\n", msg); - auto from = net::messaging_service::get_source(cinfo); + auto from = netw::messaging_service::get_source(cinfo); // Prepare gossip_digest_ack2 message auto ep1 = inet_address("3.3.3.3"); std::map eps{ @@ -188,10 +188,10 @@ int main(int ac, char ** av) { } const gms::inet_address listen = gms::inet_address(config["listen-address"].as()); utils::fb_utilities::set_broadcast_address(listen); - net::get_messaging_service().start(listen).then([config, api_port, stay_alive] () { + netw::get_messaging_service().start(listen).then([config, api_port, stay_alive] () { auto testers = new distributed; testers->start().then([testers]{ - auto& server = net::get_local_messaging_service(); + auto& server = netw::get_local_messaging_service(); auto port = server.port(); std::cout << "Messaging server listening on port " << port << " ...\n"; return testers->invoke_on_all(&tester::init_handler); @@ -217,7 +217,7 @@ int main(int ac, char ** av) { print("=============TEST DONE===========\n"); testers->stop().then([testers] { delete testers; - net::get_messaging_service().stop().then([]{ + netw::get_messaging_service().stop().then([]{ engine().exit(0); }); }); diff --git a/tests/network_topology_strategy_test.cc b/tests/network_topology_strategy_test.cc index de07f32e32..da957aecf2 100644 --- a/tests/network_topology_strategy_test.cc +++ b/tests/network_topology_strategy_test.cc @@ -36,7 +36,7 @@ thread_local disk_error_signal_type commit_error; thread_local disk_error_signal_type general_disk_error; -static logging::logger logger("NetworkTopologyStrategyLogger"); +static logging::logger nlogger("NetworkTopologyStrategyLogger"); using namespace locator; @@ -46,7 +46,7 @@ struct ring_point { }; void print_natural_endpoints(double point, const std::vector v) { - logger.debug("Natural endpoints for a token {}:", point); + nlogger.debug("Natural endpoints for a token {}:", point); std::string str; std::ostringstream strm(str); @@ -54,7 +54,7 @@ void print_natural_endpoints(double point, const std::vector v) { strm< heavy_origin_test() { tokens[address].emplace(token{dht::token::kind::key, {(int8_t*)d2t(token_point / total_eps).data(), 8}}); - logger.debug("adding node {} at {}", address, token_point); + nlogger.debug("adding node {} at {}", address, token_point); token_point++; } diff --git a/tests/perf/perf.hh b/tests/perf/perf.hh index 90468814e6..8093202b1b 100644 --- a/tests/perf/perf.hh +++ b/tests/perf/perf.hh @@ -24,6 +24,7 @@ #include "core/print.hh" #include "core/future-util.hh" #include "core/distributed.hh" +#include "seastarx.hh" #include #include diff --git a/tests/perf/perf_fast_forward.cc b/tests/perf/perf_fast_forward.cc index 7ea7a140eb..c0941b4dcc 100644 --- a/tests/perf/perf_fast_forward.cc +++ b/tests/perf/perf_fast_forward.cc @@ -406,7 +406,7 @@ static void drop_keyspace_if_exists(cql_test_env& env, sstring name) { static table_config read_config(cql_test_env& env, const sstring& name) { auto msg = env.execute_cql(sprint("select n_rows, value_size from ks.config where name = '%s'", name)).get0(); - auto rows = dynamic_pointer_cast(msg); + auto rows = dynamic_pointer_cast(msg); if (rows->rs().size() < 1) { throw std::runtime_error("config not found. Did you run --populate ?"); } diff --git a/tests/test_services.hh b/tests/test_services.hh index 1427974566..f24fc1d530 100644 --- a/tests/test_services.hh +++ b/tests/test_services.hh @@ -33,7 +33,7 @@ public: storage_service_for_tests() { auto thread = seastar::thread_impl::get(); assert(thread); - net::get_messaging_service().start(gms::inet_address("127.0.0.1")).get(); + netw::get_messaging_service().start(gms::inet_address("127.0.0.1")).get(); service::get_storage_service().start(std::ref(_db)).get(); service::get_storage_service().invoke_on_all([] (auto& ss) { ss.enable_all_features(); @@ -41,7 +41,7 @@ public: } ~storage_service_for_tests() { service::get_storage_service().stop().get(); - net::get_messaging_service().stop().get(); + netw::get_messaging_service().stop().get(); _db.stop().get(); } }; diff --git a/thrift/handler.cc b/thrift/handler.cc index 606684248c..b0468def0f 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -55,7 +55,7 @@ using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; -using namespace ::apache::thrift::transport; +namespace thrift_transport = ::apache::thrift::transport; using namespace ::apache::thrift::async; using namespace ::cassandra; @@ -909,28 +909,28 @@ public: throw make_exception("CQL2 is not supported"); } - class cql3_result_visitor final : public ::transport::messages::result_message::visitor { + class cql3_result_visitor final : public cql_transport::messages::result_message::visitor { CqlResult _result; public: const CqlResult& result() const { return _result; } - virtual void visit(const ::transport::messages::result_message::void_message&) override { + virtual void visit(const cql_transport::messages::result_message::void_message&) override { _result.__set_type(CqlResultType::VOID); } - virtual void visit(const ::transport::messages::result_message::set_keyspace& m) override { + virtual void visit(const cql_transport::messages::result_message::set_keyspace& m) override { _result.__set_type(CqlResultType::VOID); } - virtual void visit(const ::transport::messages::result_message::prepared::cql& m) override { + virtual void visit(const cql_transport::messages::result_message::prepared::cql& m) override { throw make_exception("Cannot convert prepared query result to CqlResult"); } - virtual void visit(const ::transport::messages::result_message::prepared::thrift& m) override { + virtual void visit(const cql_transport::messages::result_message::prepared::thrift& m) override { throw make_exception("Cannot convert prepared query result to CqlResult"); } - virtual void visit(const ::transport::messages::result_message::schema_change& m) override { + virtual void visit(const cql_transport::messages::result_message::schema_change& m) override { _result.__set_type(CqlResultType::VOID); } - virtual void visit(const ::transport::messages::result_message::rows& m) override { + virtual void visit(const cql_transport::messages::result_message::rows& m) override { _result = to_thrift_result(m.rs()); } }; @@ -955,16 +955,16 @@ public: throw make_exception("CQL2 is not supported"); } - class prepared_result_visitor final : public ::transport::messages::result_message::visitor_base { + class prepared_result_visitor final : public cql_transport::messages::result_message::visitor_base { CqlPreparedResult _result; public: const CqlPreparedResult& result() const { return _result; } - virtual void visit(const ::transport::messages::result_message::prepared::cql& m) override { + virtual void visit(const cql_transport::messages::result_message::prepared::cql& m) override { throw std::runtime_error("Unexpected result message type."); } - virtual void visit(const ::transport::messages::result_message::prepared::thrift& m) override { + virtual void visit(const cql_transport::messages::result_message::prepared::thrift& m) override { _result.__set_itemId(m.get_id()); auto& names = m.metadata()->names(); _result.__set_count(names.size()); diff --git a/thrift/server.cc b/thrift/server.cc index 723ed99363..6a05390578 100644 --- a/thrift/server.cc +++ b/thrift/server.cc @@ -42,7 +42,7 @@ #include #include -static logging::logger logger("thrift"); +static logging::logger tlogger("thrift"); using namespace apache::thrift; using namespace apache::thrift::transport; @@ -189,7 +189,7 @@ thrift_server::do_accepts(int which, bool keepalive) { try { f.get(); } catch (std::exception& ex) { - logger.debug("request error {}", ex.what()); + tlogger.debug("request error {}", ex.what()); } }); do_accepts(which, keepalive); diff --git a/to_string.hh b/to_string.hh index 3203f6c068..a1b9cb568e 100644 --- a/to_string.hh +++ b/to_string.hh @@ -28,11 +28,7 @@ #include #include -template -static inline -sstring join(sstring delimiter, const PrintableRange& items) { - return join(delimiter, items.begin(), items.end()); -} +#include "seastarx.hh" template static inline @@ -48,6 +44,12 @@ sstring join(sstring delimiter, Iterator begin, Iterator end) { return oss.str(); } +template +static inline +sstring join(sstring delimiter, const PrintableRange& items) { + return join(delimiter, items.begin(), items.end()); +} + namespace std { template diff --git a/tracing/trace_keyspace_helper.cc b/tracing/trace_keyspace_helper.cc index 36768e16f0..0888fb1ab6 100644 --- a/tracing/trace_keyspace_helper.cc +++ b/tracing/trace_keyspace_helper.cc @@ -47,7 +47,7 @@ namespace tracing { -static logging::logger logger("trace_keyspace_helper"); +static logging::logger tlogger("trace_keyspace_helper"); const sstring trace_keyspace_helper::KEYSPACE_NAME("system_traces"); const sstring trace_keyspace_helper::SESSIONS("sessions"); @@ -218,13 +218,13 @@ void trace_keyspace_helper::write_one_session_records(lw_shared_ptr trace_keyspace_helper::apply_events_mutation(lw_shared_ptrsession_id, events_records.size()); + tlogger.trace("{}: storing {} events records", records->session_id, events_records.size()); std::vector> modifications(events_records.size(), _events.insert_stmt()); std::vector> values; @@ -336,7 +336,7 @@ future<> trace_keyspace_helper::apply_events_mutation(lw_shared_ptr{}, false, cql3::query_options::specific_options::DEFAULT, cql_serialization_format::latest()), std::move(values)), cql3::statements::batch_statement(cql3::statements::batch_statement::type::UNLOGGED, std::move(modifications), cql3::attributes::none(), qp.get_cql_stats()), [this] (auto& batch_options, auto& batch) { - return batch.execute(service::get_storage_proxy(), _dummy_query_state, batch_options).then([] (shared_ptr res) { return now(); }); + return batch.execute(service::get_storage_proxy(), _dummy_query_state, batch_options).then([] (shared_ptr res) { return now(); }); } ); }); @@ -368,13 +368,13 @@ future<> trace_keyspace_helper::flush_one_session_mutations(lw_shared_ptrsession_id); + tlogger.trace("{}: going to store a session event", records->session_id); return _sessions.insert(make_session_mutation_data, *records).then([this, records] { if (!records->do_log_slow_query) { return now(); } auto start_time_id = utils::UUID_gen::get_time_UUID(make_monotonic_UUID_tp(_slow_query_last_nanos, records->session_rec.started_at)); - logger.trace("{}: going to store a slow query event", records->session_id); + tlogger.trace("{}: going to store a slow query event", records->session_id); return _slow_query_log.insert(make_slow_query_mutation_data, *records, start_time_id); }); } else { @@ -397,7 +397,7 @@ future<> trace_keyspace_helper::table_helper::cache_table_info() { _insert_stmt = nullptr; } - return cql3::get_local_query_processor().prepare(_insert_cql, _ks_helper.get_dummy_qs().get_client_state(), false).then([this] (shared_ptr msg_ptr) { + return cql3::get_local_query_processor().prepare(_insert_cql, _ks_helper.get_dummy_qs().get_client_state(), false).then([this] (shared_ptr msg_ptr) { _prepared_stmt = std::move(msg_ptr->get_prepared()); shared_ptr cql_stmt = _prepared_stmt->statement; _insert_stmt = dynamic_pointer_cast(cql_stmt); diff --git a/transport/event.cc b/transport/event.cc index ae53797fce..2849d9c874 100644 --- a/transport/event.cc +++ b/transport/event.cc @@ -41,7 +41,7 @@ #include "transport/event.hh" -namespace transport { +namespace cql_transport { event::event(const event_type& type_) : type{type_} diff --git a/transport/event.hh b/transport/event.hh index 6a2519b830..5a89967d3a 100644 --- a/transport/event.hh +++ b/transport/event.hh @@ -49,7 +49,7 @@ #include #include -namespace transport { +namespace cql_transport { class event { public: diff --git a/transport/event_notifier.cc b/transport/event_notifier.cc index 806dc702d7..60ac30ffc8 100644 --- a/transport/event_notifier.cc +++ b/transport/event_notifier.cc @@ -22,9 +22,9 @@ #include "transport/server.hh" #include "core/gate.hh" -namespace transport { +namespace cql_transport { -static logging::logger logger("event_notifier"); +static logging::logger elogger("event_notifier"); cql_server::event_notifier::event_notifier(uint16_t port) : _port{port} @@ -56,7 +56,7 @@ void cql_server::event_notifier::unregister_connection(cql_server::connection* c void cql_server::event_notifier::on_create_keyspace(const sstring& ks_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::CREATED, @@ -69,7 +69,7 @@ void cql_server::event_notifier::on_create_keyspace(const sstring& ks_name) void cql_server::event_notifier::on_create_column_family(const sstring& ks_name, const sstring& cf_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::CREATED, @@ -84,7 +84,7 @@ void cql_server::event_notifier::on_create_column_family(const sstring& ks_name, void cql_server::event_notifier::on_create_user_type(const sstring& ks_name, const sstring& type_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::CREATED, @@ -103,18 +103,18 @@ void cql_server::event_notifier::on_create_view(const sstring& ks_name, const ss void cql_server::event_notifier::on_create_function(const sstring& ks_name, const sstring& function_name) { - logger.warn("{} event ignored", __func__); + elogger.warn("{} event ignored", __func__); } void cql_server::event_notifier::on_create_aggregate(const sstring& ks_name, const sstring& aggregate_name) { - logger.warn("{} event ignored", __func__); + elogger.warn("{} event ignored", __func__); } void cql_server::event_notifier::on_update_keyspace(const sstring& ks_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::UPDATED, @@ -127,7 +127,7 @@ void cql_server::event_notifier::on_update_keyspace(const sstring& ks_name) void cql_server::event_notifier::on_update_column_family(const sstring& ks_name, const sstring& cf_name, bool columns_changed) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::UPDATED, @@ -142,7 +142,7 @@ void cql_server::event_notifier::on_update_column_family(const sstring& ks_name, void cql_server::event_notifier::on_update_user_type(const sstring& ks_name, const sstring& type_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::UPDATED, @@ -161,18 +161,18 @@ void cql_server::event_notifier::on_update_view(const sstring& ks_name, const ss void cql_server::event_notifier::on_update_function(const sstring& ks_name, const sstring& function_name) { - logger.warn("%s event ignored", __func__); + elogger.warn("%s event ignored", __func__); } void cql_server::event_notifier::on_update_aggregate(const sstring& ks_name, const sstring& aggregate_name) { - logger.warn("%s event ignored", __func__); + elogger.warn("%s event ignored", __func__); } void cql_server::event_notifier::on_drop_keyspace(const sstring& ks_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::DROPPED, @@ -185,7 +185,7 @@ void cql_server::event_notifier::on_drop_keyspace(const sstring& ks_name) void cql_server::event_notifier::on_drop_column_family(const sstring& ks_name, const sstring& cf_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::DROPPED, @@ -200,7 +200,7 @@ void cql_server::event_notifier::on_drop_column_family(const sstring& ks_name, c void cql_server::event_notifier::on_drop_user_type(const sstring& ks_name, const sstring& type_name) { for (auto&& conn : _schema_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_schema_change_event(event::schema_change{ event::schema_change::change_type::DROPPED, @@ -219,18 +219,18 @@ void cql_server::event_notifier::on_drop_view(const sstring& ks_name, const sstr void cql_server::event_notifier::on_drop_function(const sstring& ks_name, const sstring& function_name) { - logger.warn("%s event ignored", __func__); + elogger.warn("%s event ignored", __func__); } void cql_server::event_notifier::on_drop_aggregate(const sstring& ks_name, const sstring& aggregate_name) { - logger.warn("%s event ignored", __func__); + elogger.warn("%s event ignored", __func__); } void cql_server::event_notifier::on_join_cluster(const gms::inet_address& endpoint) { for (auto&& conn : _topology_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_topology_change_event(event::topology_change::new_node(endpoint, _port))); }); @@ -240,7 +240,7 @@ void cql_server::event_notifier::on_join_cluster(const gms::inet_address& endpoi void cql_server::event_notifier::on_leave_cluster(const gms::inet_address& endpoint) { for (auto&& conn : _topology_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_topology_change_event(event::topology_change::removed_node(endpoint, _port))); }); @@ -250,7 +250,7 @@ void cql_server::event_notifier::on_leave_cluster(const gms::inet_address& endpo void cql_server::event_notifier::on_move(const gms::inet_address& endpoint) { for (auto&& conn : _topology_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_topology_change_event(event::topology_change::moved_node(endpoint, _port))); }); @@ -263,7 +263,7 @@ void cql_server::event_notifier::on_up(const gms::inet_address& endpoint) _last_status_change[endpoint] = event::status_change::status_type::UP; if (!was_up) { for (auto&& conn : _status_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_status_change_event(event::status_change::node_up(endpoint, _port))); }); @@ -277,7 +277,7 @@ void cql_server::event_notifier::on_down(const gms::inet_address& endpoint) _last_status_change[endpoint] = event::status_change::status_type::DOWN; if (!was_down) { for (auto&& conn : _status_change_listeners) { - using namespace transport; + using namespace cql_transport; with_gate(conn->_pending_requests_gate, [&] { return conn->write_response(conn->make_status_change_event(event::status_change::node_down(endpoint, _port))); }); diff --git a/transport/messages/result_message.hh b/transport/messages/result_message.hh index 3ed4ff66fd..0b66778150 100644 --- a/transport/messages/result_message.hh +++ b/transport/messages/result_message.hh @@ -31,7 +31,7 @@ #include "core/shared_ptr.hh" #include "core/sstring.hh" -namespace transport { +namespace cql_transport { namespace messages { @@ -124,7 +124,7 @@ public: return _id; } - static const bytes& get_id(::shared_ptr prepared) { + static const bytes& get_id(::shared_ptr prepared) { auto msg_cql = dynamic_pointer_cast(prepared); if (msg_cql == nullptr) { throw std::bad_cast(); diff --git a/transport/messages/result_message_base.hh b/transport/messages/result_message_base.hh index 90b735eb48..6cb0f4db36 100644 --- a/transport/messages/result_message_base.hh +++ b/transport/messages/result_message_base.hh @@ -22,7 +22,7 @@ #pragma once -namespace transport { +namespace cql_transport { namespace messages { class result_message { diff --git a/transport/messages_fwd.hh b/transport/messages_fwd.hh index 04698caf7e..319b3c823f 100644 --- a/transport/messages_fwd.hh +++ b/transport/messages_fwd.hh @@ -21,7 +21,7 @@ #pragma once -namespace transport { +namespace cql_transport { namespace messages { diff --git a/transport/server.cc b/transport/server.cc index 111412581d..d51c1abbae 100644 --- a/transport/server.cc +++ b/transport/server.cc @@ -56,9 +56,9 @@ #include #include -namespace transport { +namespace cql_transport { -static logging::logger logger("cql_server"); +static logging::logger clogger("cql_server"); struct cql_frame_error : std::exception { const char* what() const throw () override { @@ -296,17 +296,17 @@ future<> cql_server::stop() { _stopping = true; size_t nr = 0; size_t nr_total = _listeners.size(); - logger.debug("cql_server: abort accept nr_total={}", nr_total); + clogger.debug("cql_server: abort accept nr_total={}", nr_total); for (auto&& l : _listeners) { l.abort_accept(); - logger.debug("cql_server: abort accept {} out of {} done", ++nr, nr_total); + clogger.debug("cql_server: abort accept {} out of {} done", ++nr, nr_total); } auto nr_conn = make_lw_shared(0); auto nr_conn_total = _connections_list.size(); - logger.debug("cql_server: shutdown connection nr_total={}", nr_conn_total); + clogger.debug("cql_server: shutdown connection nr_total={}", nr_conn_total); return parallel_for_each(_connections_list.begin(), _connections_list.end(), [nr_conn, nr_conn_total] (auto&& c) { return c.shutdown().then([nr_conn, nr_conn_total] { - logger.debug("cql_server: shutdown connection {} out of {} done", ++(*nr_conn), nr_conn_total); + clogger.debug("cql_server: shutdown connection {} out of {} done", ++(*nr_conn), nr_conn_total); }); }).then([this] { service::get_local_storage_service().unregister_subscriber(_notifier.get()); @@ -359,7 +359,7 @@ cql_server::do_accepts(int which, bool keepalive) { try { f.get(); } catch (...) { - logger.debug("connection error: {}", std::current_exception()); + clogger.debug("connection error: {}", std::current_exception()); } }); do_accepts(which, keepalive); @@ -367,7 +367,7 @@ cql_server::do_accepts(int which, bool keepalive) { try { f.get(); } catch (...) { - logger.warn("acccept failed: {}", std::current_exception()); + clogger.warn("acccept failed: {}", std::current_exception()); do_accepts(which, keepalive); } }); @@ -664,7 +664,7 @@ future<> cql_server::connection::process_request() { // Keep buf alive. }); }).handle_exception([] (std::exception_ptr ex) { - logger.error("request processing failed: {}", ex); + clogger.error("request processing failed: {}", ex); }); return make_ready_future<>(); diff --git a/transport/server.hh b/transport/server.hh index b47ceeaf0a..d1701297a7 100644 --- a/transport/server.hh +++ b/transport/server.hh @@ -43,7 +43,7 @@ class registrations; class database; -namespace transport { +namespace cql_transport { enum class cql_compression { none, @@ -185,10 +185,10 @@ private: shared_ptr make_error(int16_t stream, exceptions::exception_code err, sstring msg, const tracing::trace_state_ptr& tr_state); shared_ptr make_ready(int16_t stream, const tracing::trace_state_ptr& tr_state); shared_ptr make_supported(int16_t stream, const tracing::trace_state_ptr& tr_state); - shared_ptr make_result(int16_t stream, shared_ptr msg, const tracing::trace_state_ptr& tr_state, bool skip_metadata = false); - shared_ptr make_topology_change_event(const transport::event::topology_change& event); - shared_ptr make_status_change_event(const transport::event::status_change& event); - shared_ptr make_schema_change_event(const transport::event::schema_change& event); + shared_ptr make_result(int16_t stream, shared_ptr msg, const tracing::trace_state_ptr& tr_state, bool skip_metadata = false); + shared_ptr make_topology_change_event(const cql_transport::event::topology_change& event); + shared_ptr make_status_change_event(const cql_transport::event::status_change& event); + shared_ptr make_schema_change_event(const cql_transport::event::schema_change& event); shared_ptr make_autheticate(int16_t, const sstring&, const tracing::trace_state_ptr& tr_state); shared_ptr make_auth_success(int16_t, bytes, const tracing::trace_state_ptr& tr_state); shared_ptr make_auth_challenge(int16_t, bytes, const tracing::trace_state_ptr& tr_state); @@ -248,7 +248,7 @@ class cql_server::event_notifier : public service::migration_listener, std::unordered_map _last_status_change; public: event_notifier(uint16_t port); - void register_event(transport::event::event_type et, cql_server::connection* conn); + void register_event(cql_transport::event::event_type et, cql_server::connection* conn); void unregister_connection(cql_server::connection* conn); virtual void on_create_keyspace(const sstring& ks_name) override; diff --git a/unimplemented.cc b/unimplemented.cc index f38d573a71..2a11b1b9de 100644 --- a/unimplemented.cc +++ b/unimplemented.cc @@ -24,12 +24,13 @@ #include "core/sstring.hh" #include "core/enum.hh" #include "log.hh" +#include "seastarx.hh" namespace unimplemented { static thread_local std::unordered_map _warnings; -static logging::logger logger("unimplemented"); +static logging::logger ulogger("unimplemented"); std::ostream& operator<<(std::ostream& out, cause c) { switch(c) { @@ -69,7 +70,7 @@ void warn(cause c) { auto i = _warnings.find(c); if (i == _warnings.end()) { _warnings.insert({c, true}); - logger.debug("{}", c); + ulogger.debug("{}", c); } } diff --git a/unimplemented.hh b/unimplemented.hh index 0bbed4e4aa..5af255c5e4 100644 --- a/unimplemented.hh +++ b/unimplemented.hh @@ -67,6 +67,6 @@ void warn(cause what); namespace std { template <> -struct hash : enum_hash {}; +struct hash : seastar::enum_hash {}; } diff --git a/utils/dynamic_bitset.cc b/utils/dynamic_bitset.cc index 82dd1548be..998ecd3779 100644 --- a/utils/dynamic_bitset.cc +++ b/utils/dynamic_bitset.cc @@ -22,6 +22,7 @@ #include #include "utils/dynamic_bitset.hh" +#include "seastarx.hh" namespace utils { @@ -162,4 +163,4 @@ void dynamic_bitset::resize(size_t n, bool set) _bits_count = n; } -} \ No newline at end of file +} diff --git a/utils/exponential_backoff_retry.hh b/utils/exponential_backoff_retry.hh index 6bbeae1ec5..186f32027e 100644 --- a/utils/exponential_backoff_retry.hh +++ b/utils/exponential_backoff_retry.hh @@ -23,6 +23,7 @@ #pragma once #include "core/sleep.hh" +#include "seastarx.hh" #include // Implements retry policy that exponentially increases sleep time between retries. diff --git a/utils/file_lock.hh b/utils/file_lock.hh index 5b44cf99f0..d25def263d 100644 --- a/utils/file_lock.hh +++ b/utils/file_lock.hh @@ -26,6 +26,8 @@ #include #include +#include "seastarx.hh" + namespace utils { class file_lock { public: diff --git a/utils/histogram.hh b/utils/histogram.hh index a4a35fae5f..098229d4f5 100644 --- a/utils/histogram.hh +++ b/utils/histogram.hh @@ -26,6 +26,8 @@ #include #include "core/timer.hh" #include +#include "seastarx.hh" + namespace utils { /** * An exponentially-weighted moving average. diff --git a/utils/large_bitset.cc b/utils/large_bitset.cc index dadf9c392d..202af20f3b 100644 --- a/utils/large_bitset.cc +++ b/utils/large_bitset.cc @@ -22,6 +22,7 @@ #include "large_bitset.hh" #include #include +#include "seastarx.hh" large_bitset::large_bitset(size_t nr_bits) : _nr_bits(nr_bits) { auto nr_blocks = align_up(nr_bits, bits_per_block()) / bits_per_block(); diff --git a/utils/log_histogram.hh b/utils/log_histogram.hh index 08282cb4e6..aae659a88c 100644 --- a/utils/log_histogram.hh +++ b/utils/log_histogram.hh @@ -27,6 +27,7 @@ #include #include #include +#include "seastarx.hh" namespace bi = boost::intrusive; diff --git a/utils/logalloc.cc b/utils/logalloc.cc index 073335b680..36a6353419 100644 --- a/utils/logalloc.cc +++ b/utils/logalloc.cc @@ -73,7 +73,7 @@ namespace logalloc { struct segment; -static logging::logger logger("lsa"); +static logging::logger llogger("lsa"); static logging::logger timing_logger("lsa-timing"); static thread_local tracker tracker_instance; @@ -320,7 +320,7 @@ public: if (_segments.size()) { free(_base); } - logger.debug("Removed zone @{}", this); + llogger.debug("Removed zone @{}", this); } segment_zone(const segment_zone&) = delete; segment_zone& operator=(const segment_zone&) = delete; @@ -387,7 +387,7 @@ std::unique_ptr segment_zone::try_creating_zone() } try { zone = std::make_unique(static_cast(ptr), size); - logger.debug("Creating new zone @{}, size: {}", zone.get(), size); + llogger.debug("Creating new zone @{}, size: {}", zone.get(), size); next_attempt_size = std::min(std::max(size << 1, minimum_size), maximum_size); while (size--) { auto seg = zone->segment_from_position(size); @@ -398,7 +398,7 @@ std::unique_ptr segment_zone::try_creating_zone() free(ptr); } } - logger.trace("Failed to create zone"); + llogger.trace("Failed to create zone"); next_attempt_size = minimum_size; return zone; } @@ -438,7 +438,7 @@ size_t segment_zone::shrink_by(size_t delta) delta = std::min(delta, free_segment_count()); auto new_size = segment_count() - delta; - logger.debug("Shrinking zone @{} by {} segments (total: {})", this, delta, new_size); + llogger.debug("Shrinking zone @{} by {} segments (total: {})", this, delta, new_size); _segments.resize(new_size); // Seastar allocator guarantees that realloc shrinks buffer in place. auto ptr = realloc(_base, new_size << segment::size_shift); @@ -544,7 +544,7 @@ size_t segment_pool::reclaim_segments(size_t target) { return 0; } - logger.debug("Trying to reclaim {} segments form {} zones ({} full)", target, + llogger.debug("Trying to reclaim {} segments form {} zones ({} full)", target, _all_zones.size(), _all_zones.size() - _not_full_zones.size()); // Reclamation. Migrate segments to lower addresses and shrink zones. @@ -589,7 +589,7 @@ size_t segment_pool::reclaim_segments(size_t target) { }); // FIXME: merge adjacent zones to reduce memory footprint of zone metadata - logger.debug("Reclaimed {} segments (requested {}), {} zones left", + llogger.debug("Reclaimed {} segments (requested {}), {} zones left", reclaimed_segments, target, _all_zones.size()); return reclaimed_segments; } @@ -649,7 +649,7 @@ segment* segment_pool::allocate_segment() } } while (shard_tracker().get_impl().compact_and_evict(shard_tracker().reclamation_step() * segment::size)); if (shard_tracker().should_abort_on_bad_alloc()) { - logger.error("Aborting due to segment allocation failure"); + llogger.error("Aborting due to segment allocation failure"); abort(); } return nullptr; @@ -751,7 +751,7 @@ void segment_pool::free_segment(segment* seg) noexcept { } void segment_pool::free_segment(segment* seg, segment_descriptor& desc) noexcept { - logger.trace("Releasing segment {}", seg); + llogger.trace("Releasing segment {}", seg); desc._lsa_managed = false; desc._region = nullptr; free_or_restore_to_reserve(seg); @@ -1149,7 +1149,7 @@ private: auto pos =_active->at(_active_offset); desc.encode(pos); } - logger.trace("Closing segment {}, used={}, waste={} [B]", _active, _active->occupancy(), segment::size - _active_offset); + llogger.trace("Closing segment {}, used={}, waste={} [B]", _active, _active->occupancy(), segment::size - _active_offset); _closed_occupancy += _active->occupancy(); _segment_descs.push(shard_segment_pool.descriptor(_active)); @@ -1421,7 +1421,7 @@ public: _segment_descs.pop_one_of_largest(); _closed_occupancy -= desc.occupancy(); segment* seg = shard_segment_pool.segment_from(desc); - logger.debug("Compacting segment {} from region {}, {}", seg, id(), seg->occupancy()); + llogger.debug("Compacting segment {} from region {}, {}", seg, id(), seg->occupancy()); compact(seg, desc); shard_segment_pool.on_segment_compaction(); } @@ -1467,7 +1467,7 @@ public: // Invalidates references to allocated objects. void full_compaction() { compaction_lock _(*this); - logger.debug("Full compaction, {}", occupancy()); + llogger.debug("Full compaction, {}", occupancy()); close_and_open(); segment_descriptor_hist all; std::swap(all, _segment_descs); @@ -1477,7 +1477,7 @@ public: all.pop_one_of_largest(); compact(shard_segment_pool.segment_from(desc), desc); } - logger.debug("Done, {}", occupancy()); + llogger.debug("Done, {}", occupancy()); } allocation_strategy& allocator() { @@ -1681,16 +1681,16 @@ occupancy_stats tracker::impl::occupancy() { void tracker::impl::reclaim_all_free_segments() { - logger.debug("Reclaiming all free segments"); + llogger.debug("Reclaiming all free segments"); shard_segment_pool.trim_emergency_reserve_to_max(); shard_segment_pool.reclaim_all_free_segments(); - logger.debug("Reclamation done"); + llogger.debug("Reclamation done"); } void tracker::impl::full_compaction() { reclaiming_lock _(*this); - logger.debug("Full compaction on all regions, {}", region_occupancy()); + llogger.debug("Full compaction on all regions, {}", region_occupancy()); for (region_impl* r : _regions) { if (r->reclaiming_enabled()) { @@ -1698,7 +1698,7 @@ void tracker::impl::full_compaction() { } } - logger.debug("Compaction done, {}", region_occupancy()); + llogger.debug("Compaction done, {}", region_occupancy()); } static void reclaim_from_evictable(region::impl& r, size_t target_mem_in_use) { @@ -1710,21 +1710,21 @@ static void reclaim_from_evictable(region::impl& r, size_t target_mem_in_use) { break; } auto used_target = used - std::min(used, deficit - std::min(deficit, occupancy.free_space())); - logger.debug("Evicting {} bytes from region {}, occupancy={}", used - used_target, r.id(), r.occupancy()); + llogger.debug("Evicting {} bytes from region {}, occupancy={}", used - used_target, r.id(), r.occupancy()); while (r.occupancy().used_space() > used_target || !r.is_compactible()) { if (r.evict_some() == memory::reclaiming_result::reclaimed_nothing) { - logger.debug("Unable to evict more, evicted {} bytes", used - r.occupancy().used_space()); + llogger.debug("Unable to evict more, evicted {} bytes", used - r.occupancy().used_space()); return; } if (shard_segment_pool.total_memory_in_use() <= target_mem_in_use) { - logger.debug("Target met after evicting {} bytes", used - r.occupancy().used_space()); + llogger.debug("Target met after evicting {} bytes", used - r.occupancy().used_space()); return; } if (r.empty()) { return; } } - logger.debug("Compacting after evicting {} bytes", used - r.occupancy().used_space()); + llogger.debug("Compacting after evicting {} bytes", used - r.occupancy().used_space()); r.compact(); } } @@ -1858,7 +1858,7 @@ size_t tracker::impl::compact_and_evict_locked(size_t memory_to_release) { size_t mem_in_use = shard_segment_pool.total_memory_in_use(); auto target_mem = mem_in_use - std::min(mem_in_use, memory_to_release - mem_released); - logger.debug("Compacting, requested {} bytes, {} bytes in use, target is {}", + llogger.debug("Compacting, requested {} bytes, {} bytes in use, target is {}", memory_to_release, mem_in_use, target_mem); // Allow dipping into reserves while compacting @@ -1873,10 +1873,10 @@ size_t tracker::impl::compact_and_evict_locked(size_t memory_to_release) { boost::range::make_heap(_regions, cmp); - if (logger.is_enabled(logging::log_level::debug)) { - logger.debug("Occupancy of regions:"); + if (llogger.is_enabled(logging::log_level::debug)) { + llogger.debug("Occupancy of regions:"); for (region::impl* r : _regions) { - logger.debug(" - {}: min={}, avg={}", r->id(), r->min_occupancy(), r->compactible_occupancy()); + llogger.debug(" - {}: min={}, avg={}", r->id(), r->min_occupancy(), r->compactible_occupancy()); } } @@ -1885,7 +1885,7 @@ size_t tracker::impl::compact_and_evict_locked(size_t memory_to_release) { region::impl* r = _regions.back(); if (!r->is_compactible()) { - logger.trace("Unable to release segments, no compactible pools."); + llogger.trace("Unable to release segments, no compactible pools."); break; } @@ -1897,7 +1897,7 @@ size_t tracker::impl::compact_and_evict_locked(size_t memory_to_release) { auto released_during_compaction = mem_in_use - shard_segment_pool.total_memory_in_use(); if (shard_segment_pool.total_memory_in_use() > target_mem) { - logger.debug("Considering evictable regions."); + llogger.debug("Considering evictable regions."); // FIXME: Fair eviction for (region::impl* r : _regions) { if (r->is_evictable()) { @@ -1911,7 +1911,7 @@ size_t tracker::impl::compact_and_evict_locked(size_t memory_to_release) { mem_released += mem_in_use - shard_segment_pool.total_memory_in_use(); - logger.debug("Released {} bytes (wanted {}), {} during compaction, {} from reserve", + llogger.debug("Released {} bytes (wanted {}), {} during compaction, {} from reserve", mem_released, memory_to_release, released_during_compaction, released_from_reserve); return mem_released; @@ -1925,14 +1925,14 @@ bool segment_pool::migrate_segment(segment* src, segment_zone& src_zone, auto& src_desc = descriptor(src); auto& dst_desc = descriptor(dst); - logger.debug("Migrating segment {} (zone @{}) to {} (zone @{}) (region @{})", + llogger.debug("Migrating segment {} (zone @{}) to {} (zone @{}) (region @{})", src, &src_zone, dst, &dst_zone, src_desc._region); dst_desc._zone = &dst_zone; assert(src_desc._zone == &src_zone); if (src_desc._region) { if (!src_desc._region->reclaiming_enabled()) { - logger.trace("Cannot move segment {}", src); + llogger.trace("Cannot move segment {}", src); return false; } dst_desc._lsa_managed = true; @@ -1983,12 +1983,12 @@ bool segment_zone::migrate_segments(segment_zone& dst_zone, size_t to_migrate) void tracker::impl::register_region(region::impl* r) { reclaiming_lock _(*this); _regions.push_back(r); - logger.debug("Registered region @{} with id={}", r, r->id()); + llogger.debug("Registered region @{} with id={}", r, r->id()); } void tracker::impl::unregister_region(region::impl* r) { reclaiming_lock _(*this); - logger.debug("Unregistering region, id={}", r->id()); + llogger.debug("Unregistering region, id={}", r->id()); _regions.erase(std::remove(_regions.begin(), _regions.end(), r)); } @@ -2037,7 +2037,7 @@ tracker::impl::impl() { tracker::impl::~impl() { if (!_regions.empty()) { for (auto&& r : _regions) { - logger.error("Region with id={} not unregistered!", r->id()); + llogger.error("Region with id={} not unregistered!", r->id()); } abort(); } @@ -2194,10 +2194,10 @@ void allocating_section::guard::enter(allocating_section& self) { void allocating_section::on_alloc_failure() { if (shard_segment_pool.allocation_failure_flag()) { _lsa_reserve *= 2; // FIXME: decay? - logger.debug("LSA allocation failure, increasing reserve in section {} to {} segments", this, _lsa_reserve); + llogger.debug("LSA allocation failure, increasing reserve in section {} to {} segments", this, _lsa_reserve); } else { _std_reserve *= 2; // FIXME: decay? - logger.debug("Standard allocator failure, increasing head-room in section {} to {} [B]", this, _std_reserve); + llogger.debug("Standard allocator failure, increasing head-room in section {} to {} [B]", this, _std_reserve); } } diff --git a/utils/logalloc.hh b/utils/logalloc.hh index db1a0c1d8c..3b5691892d 100644 --- a/utils/logalloc.hh +++ b/utils/logalloc.hh @@ -32,6 +32,7 @@ #include #include "allocation_strategy.hh" #include +#include "seastarx.hh" namespace logalloc { diff --git a/utils/phased_barrier.hh b/utils/phased_barrier.hh index df21222c12..8328032ad7 100644 --- a/utils/phased_barrier.hh +++ b/utils/phased_barrier.hh @@ -25,6 +25,7 @@ #include #include #include +#include "seastarx.hh" namespace utils { diff --git a/utils/rate_limiter.hh b/utils/rate_limiter.hh index 9874e34adc..6d1a4c0d68 100644 --- a/utils/rate_limiter.hh +++ b/utils/rate_limiter.hh @@ -24,6 +24,7 @@ #include "core/timer.hh" #include "core/semaphore.hh" #include "core/reactor.hh" +#include "seastarx.hh" namespace utils { diff --git a/utils/serialization.hh b/utils/serialization.hh index 382492ed10..d377f654d6 100644 --- a/utils/serialization.hh +++ b/utils/serialization.hh @@ -57,7 +57,7 @@ static constexpr size_t serialize_int16_size = 2; static constexpr size_t serialize_int32_size = 4; static constexpr size_t serialize_int64_size = 8; -namespace internal { +namespace internal_impl { template GCC6_CONCEPT(requires std::is_integral::value && std::is_integral::value && requires (CharOutputIterator it) { @@ -74,25 +74,25 @@ void serialize_int(CharOutputIterator& out, IntegerType val) { template inline void serialize_int8(CharOutputIterator& out, uint8_t val) { - internal::serialize_int(out, val); + internal_impl::serialize_int(out, val); } template inline void serialize_int16(CharOutputIterator& out, uint16_t val) { - internal::serialize_int(out, val); + internal_impl::serialize_int(out, val); } template inline void serialize_int32(CharOutputIterator& out, uint32_t val) { - internal::serialize_int(out, val); + internal_impl::serialize_int(out, val); } template inline void serialize_int64(CharOutputIterator& out, uint64_t val) { - internal::serialize_int(out, val); + internal_impl::serialize_int(out, val); } template diff --git a/version.hh b/version.hh index 68f0cd8390..ba3340a887 100644 --- a/version.hh +++ b/version.hh @@ -26,6 +26,8 @@ #include "core/print.hh" #include +#include "seastarx.hh" + namespace version { class version { std::tuple _version;