<commit_before>/*
 * Copyright (C) 2020-present ScyllaDB
 */

/*
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
#include "service/raft/raft_group_registry.hh"
#include "service/raft/raft_rpc.hh"
#include "service/raft/raft_gossip_failure_detector.hh"
#include "message/messaging_service.hh"
#include "serializer_impl.hh"
#include "idl/raft.dist.hh"
#include "gms/feature_service.hh"
#include "gms/gossiper.hh"

#include <seastar/core/coroutine.hh>

namespace service {

logging::logger rslog("raft_group_registry");

raft_group_registry::raft_group_registry(bool is_enabled, netw::messaging_service& ms, gms::gossiper& gossiper, gms::feature_service& feat)
    : _is_enabled(is_enabled)
    , _ms(ms)
    , _fd(make_shared<raft_gossip_failure_detector>(gossiper, _srv_address_mappings))
    , _raft_support_listener(feat.cluster_supports_raft_cluster_mgmt().when_enabled([this, &feat, &gossiper] {
        // If the `USES_RAFT_CLUSTER_MANAGEMENT` feature was already enabled, do nothing.
        //
        // This can happen if the current node is either a fresh node in an empty cluster
        // or a restarting node, which is already part of an existing group0.
        if (!_is_enabled || feat.cluster_uses_raft_cluster_mgmt()) {
            return;
        }
        // When the cluster fully supports raft-based cluster management,
        // we can re-enable support for the second gossip feature to trigger
        // actual use of raft-based cluster management procedures.
        feat.support(gms::features::USES_RAFT_CLUSTER_MANAGEMENT).get();
        // When the supported feature set is dynamically extended, re-advertise it through the gossip.
        gossiper.add_local_application_state(gms::application_state::SUPPORTED_FEATURES,
            gms::versioned_value::supported_features(feat.supported_feature_set())).get();
    }))
{
}

void raft_group_registry::init_rpc_verbs() {
    auto handle_raft_rpc = [this] (
            const rpc::client_info& cinfo,<commit_msg>raft_group_registry: update gossiper state only on shard 0<commit_after>/*
 * Copyright (C) 2020-present ScyllaDB
 */

/*
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
#include "service/raft/raft_group_registry.hh"
#include "service/raft/raft_rpc.hh"
#include "service/raft/raft_gossip_failure_detector.hh"
#include "message/messaging_service.hh"
#include "serializer_impl.hh"
#include "idl/raft.dist.hh"
#include "gms/feature_service.hh"
#include "gms/gossiper.hh"

#include <seastar/core/coroutine.hh>

namespace service {

logging::logger rslog("raft_group_registry");

raft_group_registry::raft_group_registry(bool is_enabled, netw::messaging_service& ms, gms::gossiper& gossiper, gms::feature_service& feat)
    : _is_enabled(is_enabled)
    , _ms(ms)
    , _fd(make_shared<raft_gossip_failure_detector>(gossiper, _srv_address_mappings))
    , _raft_support_listener(feat.cluster_supports_raft_cluster_mgmt().when_enabled([this, &feat, &gossiper] {
        // If the `USES_RAFT_CLUSTER_MANAGEMENT` feature was already enabled, do nothing.
        //
        // This can happen if the current node is either a fresh node in an empty cluster
        // or a restarting node, which is already part of an existing group0.
        if (!_is_enabled || feat.cluster_uses_raft_cluster_mgmt()) {
            return;
        }
        // When the cluster fully supports raft-based cluster management,
        // we can re-enable support for the second gossip feature to trigger
        // actual use of raft-based cluster management procedures.
        feat.support(gms::features::USES_RAFT_CLUSTER_MANAGEMENT).get();
        if (this_shard_id() == 0) {
            // When the supported feature set is dynamically extended, re-advertise it through the gossip.
            gossiper.add_local_application_state(gms::application_state::SUPPORTED_FEATURES,
                gms::versioned_value::supported_features(feat.supported_feature_set())).get();
        }
    }))
{
}

void raft_group_registry::init_rpc_verbs() {
    auto handle_raft_rpc = [this] (
            const rpc::client_info& cinfo,
{'fraction_non_alphanumeric': 0.10746634026927784, 'fraction_numerical': 0.003916768665850673, 'mean_word_length': 3.9347826086956523, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '110733', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1301, 'n_words': 279}