service: move topology coordinator to a separate file

The topology coordinator is a large class that sits in an even larger
storage_service.cc file. For the sake of code modularization and
reducing recompilation time, move the topology coordinator outside
storage_service.cc.

The topology_coordinator class is moved to the new
topology_coordinator.cc unchanged. Along with it, the following items
are moved:

- wait_for_ip function - it's used both by storage_service and
  topology_coordinator, so in order for the new topology_coordinator.cc
  not to depend on storage service, it is moved to the new file,
- raft_topology logger - for the same reason as wait_for_ip,
- run_topology_coordinator - serves as the main interface for the
  topology coordinator. The topology coordinator class is not exposed at
  all, it's only possible to start the coordinator and wait until it
  shuts down itself via that function.
This commit is contained in:
Piotr Dulikowski
2024-01-23 14:02:09 +01:00
parent 4ad6b6563b
commit c3c3f5c1c8
5 changed files with 2313 additions and 2194 deletions

View File

@@ -1193,6 +1193,7 @@ scylla_core = (['message/messaging_service.cc',
'utils/to_string.cc',
'service/topology_state_machine.cc',
'service/topology_mutation.cc',
'service/topology_coordinator.cc',
'node_ops/node_ops_ctl.cc'
] + [Antlr3Grammar('cql3/Cql.g')] + [Thrift('interface/cassandra.thrift', 'Cassandra')] \
+ scylla_raft_core

View File

@@ -27,6 +27,7 @@ target_sources(service
storage_proxy.cc
storage_service.cc
tablet_allocator.cc
topology_coordinator.cc
topology_mutation.cc
topology_state_machine.cc)
target_include_directories(service

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2024-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include <chrono>
#include <seastar/core/future.hh>
#include <seastar/core/sharded.hh>
#include "log.hh"
#include "raft/raft.hh"
#include "gms/inet_address.hh"
#include "service/endpoint_lifecycle_subscriber.hh"
#include "service/topology_state_machine.hh"
namespace db {
class system_keyspace;
class system_distributed_keyspace;
}
namespace gms {
class gossiper;
}
namespace netw {
class messaging_service;
}
namespace locator {
class shared_token_metadata;
}
namespace replica {
class database;
}
namespace raft {
class server;
}
namespace service {
template <typename Clock>
class raft_address_map_t;
using raft_address_map = raft_address_map_t<seastar::lowres_clock>;
class raft_group0;
class tablet_allocator;
extern logging::logger rtlogger;
future<gms::inet_address> wait_for_ip(raft::server_id id, const raft_address_map& am, seastar::abort_source& as);
using raft_topology_cmd_handler_type = noncopyable_function<future<raft_topology_cmd_result>(
raft::term_t, uint64_t, const raft_topology_cmd&)>;
future<> run_topology_coordinator(
seastar::sharded<db::system_distributed_keyspace>& sys_dist_ks, gms::gossiper& gossiper,
netw::messaging_service& messaging, locator::shared_token_metadata& shared_tm,
db::system_keyspace& sys_ks, replica::database& db, service::raft_group0& group0,
service::topology_state_machine& topo_sm, seastar::abort_source& as, raft::server& raft,
raft_topology_cmd_handler_type raft_topology_cmd_handler,
tablet_allocator& tablet_allocator,
std::chrono::milliseconds ring_delay,
endpoint_lifecycle_notifier& lifecycle_notifier);
}