diff --git a/src/v/archival/ntp_archiver_service.cc b/src/v/archival/ntp_archiver_service.cc index 7f83c93060e6e..8c9ff012b53c9 100644 --- a/src/v/archival/ntp_archiver_service.cc +++ b/src/v/archival/ntp_archiver_service.cc @@ -36,7 +36,7 @@ #include "model/fundamental.h" #include "model/metadata.h" #include "model/record.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "storage/disk_log_impl.h" #include "storage/fs_utils.h" #include "storage/ntp_config.h" diff --git a/src/v/archival/tests/archival_metadata_stm_test.cc b/src/v/archival/tests/archival_metadata_stm_test.cc index eae88e143d419..490e2307f7809 100644 --- a/src/v/archival/tests/archival_metadata_stm_test.cc +++ b/src/v/archival/tests/archival_metadata_stm_test.cc @@ -18,11 +18,11 @@ #include "model/metadata.h" #include "model/record.h" #include "model/timestamp.h" +#include "raft/fundamental.h" #include "raft/persisted_stm.h" #include "raft/state_machine_manager.h" #include "raft/tests/raft_group_fixture.h" #include "raft/tests/simple_raft_fixture.h" -#include "raft/types.h" #include "storage/tests/utils/disk_log_builder.h" #include "test_utils/async.h" diff --git a/src/v/cluster/cloud_metadata/uploader.cc b/src/v/cluster/cloud_metadata/uploader.cc index 64f9f49ac685b..1d0a64c806ad9 100644 --- a/src/v/cluster/cloud_metadata/uploader.cc +++ b/src/v/cluster/cloud_metadata/uploader.cc @@ -22,8 +22,8 @@ #include "model/fundamental.h" #include "model/namespace.h" #include "raft/consensus.h" +#include "raft/fundamental.h" #include "raft/group_manager.h" -#include "raft/types.h" #include "ssx/future-util.h" #include "ssx/sleep_abortable.h" #include "storage/api.h" diff --git a/src/v/cluster/controller_backend.cc b/src/v/cluster/controller_backend.cc index c7ed3d4652f39..9f43cead820e3 100644 --- a/src/v/cluster/controller_backend.cc +++ b/src/v/cluster/controller_backend.cc @@ -31,8 +31,8 @@ #include "model/fundamental.h" #include "model/metadata.h" #include "prometheus/prometheus_sanitize.h" +#include "raft/fundamental.h" #include "raft/group_configuration.h" -#include "raft/types.h" #include "ssx/event.h" #include "ssx/future-util.h" #include "storage/offset_translator.h" diff --git a/src/v/cluster/id_allocator_stm.cc b/src/v/cluster/id_allocator_stm.cc index 4a656f360ab7c..19a86a9a7561a 100644 --- a/src/v/cluster/id_allocator_stm.cc +++ b/src/v/cluster/id_allocator_stm.cc @@ -16,7 +16,7 @@ #include "model/namespace.h" #include "raft/consensus.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "storage/ntp_config.h" #include "storage/record_batch_builder.h" diff --git a/src/v/cluster/log_eviction_stm.cc b/src/v/cluster/log_eviction_stm.cc index e30a0eb12c7db..7f08c59552a35 100644 --- a/src/v/cluster/log_eviction_stm.cc +++ b/src/v/cluster/log_eviction_stm.cc @@ -15,7 +15,7 @@ #include "cluster/prefix_truncate_record.h" #include "model/fundamental.h" #include "raft/consensus.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "serde/serde.h" #include diff --git a/src/v/cluster/members_manager.cc b/src/v/cluster/members_manager.cc index 3fefc4eba5d45..f98b098887787 100644 --- a/src/v/cluster/members_manager.cc +++ b/src/v/cluster/members_manager.cc @@ -29,7 +29,6 @@ #include "raft/consensus_utils.h" #include "raft/errc.h" #include "raft/group_configuration.h" -#include "raft/types.h" #include "random/generators.h" #include "reflection/adl.h" #include "storage/api.h" diff --git a/src/v/cluster/migrations/tx_manager_migrator.cc b/src/v/cluster/migrations/tx_manager_migrator.cc index adcd027f2f616..01eecbb54ea0c 100644 --- a/src/v/cluster/migrations/tx_manager_migrator.cc +++ b/src/v/cluster/migrations/tx_manager_migrator.cc @@ -26,7 +26,6 @@ #include "model/record_batch_reader.h" #include "model/record_batch_types.h" #include "model/timeout_clock.h" -#include "raft/types.h" #include "ssx/future-util.h" #include "storage/types.h" diff --git a/src/v/cluster/partition.cc b/src/v/cluster/partition.cc index a62ed0ac60d61..dede3485dd9bd 100644 --- a/src/v/cluster/partition.cc +++ b/src/v/cluster/partition.cc @@ -26,9 +26,9 @@ #include "model/fundamental.h" #include "model/metadata.h" #include "model/namespace.h" +#include "raft/fundamental.h" #include "raft/fwd.h" #include "raft/state_machine_manager.h" -#include "raft/types.h" #include #include diff --git a/src/v/cluster/partition.h b/src/v/cluster/partition.h index dee93644711ae..5b95254746a1c 100644 --- a/src/v/cluster/partition.h +++ b/src/v/cluster/partition.h @@ -21,7 +21,6 @@ #include "model/record_batch_reader.h" #include "model/timeout_clock.h" #include "raft/replicate.h" -#include "raft/types.h" #include "storage/translating_reader.h" #include "storage/types.h" diff --git a/src/v/cluster/partition_manager.cc b/src/v/cluster/partition_manager.cc index 2721f710cd217..d94fe6748103b 100644 --- a/src/v/cluster/partition_manager.cc +++ b/src/v/cluster/partition_manager.cc @@ -26,9 +26,9 @@ #include "model/metadata.h" #include "raft/consensus.h" #include "raft/consensus_utils.h" +#include "raft/fundamental.h" #include "raft/group_configuration.h" #include "raft/rpc_client_protocol.h" -#include "raft/types.h" #include "resource_mgmt/io_priority.h" #include "ssx/async-clear.h" #include "storage/segment_utils.h" diff --git a/src/v/cluster/rm_stm.cc b/src/v/cluster/rm_stm.cc index d7f3df48872cd..3cdc6debdda9e 100644 --- a/src/v/cluster/rm_stm.cc +++ b/src/v/cluster/rm_stm.cc @@ -23,9 +23,9 @@ #include "prometheus/prometheus_sanitize.h" #include "raft/consensus_utils.h" #include "raft/errc.h" +#include "raft/fundamental.h" #include "raft/persisted_stm.h" #include "raft/state_machine_base.h" -#include "raft/types.h" #include "ssx/future-util.h" #include "storage/parser_utils.h" #include "storage/record_batch_builder.h" diff --git a/src/v/cluster/security_frontend.cc b/src/v/cluster/security_frontend.cc index a1f8820b94af3..3cb83fa2a1bd4 100644 --- a/src/v/cluster/security_frontend.cc +++ b/src/v/cluster/security_frontend.cc @@ -26,7 +26,7 @@ #include "model/namespace.h" #include "model/validation.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/generators.h" #include "rpc/errc.h" #include "rpc/types.h" diff --git a/src/v/cluster/security_manager.cc b/src/v/cluster/security_manager.cc index 4aa006f971891..4080cbcb09cf1 100644 --- a/src/v/cluster/security_manager.cc +++ b/src/v/cluster/security_manager.cc @@ -14,7 +14,7 @@ #include "cluster/commands.h" #include "cluster/controller_snapshot.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "security/authorizer.h" #include "security/credential_store.h" #include "security/role_store.h" diff --git a/src/v/cluster/tests/allocation_bench.cc b/src/v/cluster/tests/allocation_bench.cc index aea1a46a5cd74..b85af443c262b 100644 --- a/src/v/cluster/tests/allocation_bench.cc +++ b/src/v/cluster/tests/allocation_bench.cc @@ -10,7 +10,7 @@ #include "base/outcome.h" #include "cluster/tests/partition_allocator_fixture.h" #include "cluster/types.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include #include diff --git a/src/v/cluster/tests/commands_serialization_test.cc b/src/v/cluster/tests/commands_serialization_test.cc index a6bdb46043e97..616445e52447f 100644 --- a/src/v/cluster/tests/commands_serialization_test.cc +++ b/src/v/cluster/tests/commands_serialization_test.cc @@ -15,7 +15,7 @@ #include "model/compression.h" #include "model/fundamental.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "test_utils/fixture.h" #include "topic_table_fixture.h" diff --git a/src/v/cluster/tests/id_allocator_stm_test.cc b/src/v/cluster/tests/id_allocator_stm_test.cc index 4faf91c1b0c68..782420216dfbc 100644 --- a/src/v/cluster/tests/id_allocator_stm_test.cc +++ b/src/v/cluster/tests/id_allocator_stm_test.cc @@ -13,8 +13,8 @@ #include "model/fundamental.h" #include "model/record.h" #include "model/timeout_clock.h" +#include "raft/fundamental.h" #include "raft/tests/simple_raft_fixture.h" -#include "raft/types.h" #include "random/generators.h" #include "reflection/adl.h" #include "storage/record_batch_builder.h" diff --git a/src/v/cluster/tests/idempotency_tests.cc b/src/v/cluster/tests/idempotency_tests.cc index d089366bc3791..a032b43210f3a 100644 --- a/src/v/cluster/tests/idempotency_tests.cc +++ b/src/v/cluster/tests/idempotency_tests.cc @@ -17,8 +17,8 @@ #include "model/tests/random_batch.h" #include "model/timestamp.h" #include "raft/consensus_utils.h" +#include "raft/fundamental.h" #include "raft/tests/raft_group_fixture.h" -#include "raft/types.h" #include "random/generators.h" #include "storage/record_batch_builder.h" #include "storage/tests/utils/disk_log_builder.h" diff --git a/src/v/cluster/tests/leader_balancer_constraints_test.cc b/src/v/cluster/tests/leader_balancer_constraints_test.cc index 8639289165d41..f65ad48a9b04f 100644 --- a/src/v/cluster/tests/leader_balancer_constraints_test.cc +++ b/src/v/cluster/tests/leader_balancer_constraints_test.cc @@ -17,7 +17,7 @@ #include "leader_balancer_test_utils.h" #include "model/fundamental.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include #include diff --git a/src/v/cluster/tests/manual_log_deletion_test.cc b/src/v/cluster/tests/manual_log_deletion_test.cc index d50a2a89c9b3f..6de06350793e7 100644 --- a/src/v/cluster/tests/manual_log_deletion_test.cc +++ b/src/v/cluster/tests/manual_log_deletion_test.cc @@ -15,8 +15,8 @@ #include "model/record.h" #include "model/timestamp.h" #include "raft/consensus_utils.h" +#include "raft/fundamental.h" #include "raft/tests/raft_group_fixture.h" -#include "raft/types.h" #include "random/generators.h" #include "storage/record_batch_builder.h" #include "storage/tests/utils/disk_log_builder.h" diff --git a/src/v/cluster/tests/partition_allocator_tests.cc b/src/v/cluster/tests/partition_allocator_tests.cc index cca4ca6076993..e7f96980bd7f3 100644 --- a/src/v/cluster/tests/partition_allocator_tests.cc +++ b/src/v/cluster/tests/partition_allocator_tests.cc @@ -13,7 +13,7 @@ #include "cluster/scheduling/types.h" #include "cluster/tests/partition_allocator_fixture.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/fast_prng.h" #include "random/generators.h" #include "test_utils/fixture.h" diff --git a/src/v/cluster/tests/partition_leaders_table_test.cc b/src/v/cluster/tests/partition_leaders_table_test.cc index 8803d94f2f73e..1688e7ee02b99 100644 --- a/src/v/cluster/tests/partition_leaders_table_test.cc +++ b/src/v/cluster/tests/partition_leaders_table_test.cc @@ -20,7 +20,7 @@ #include "model/metadata.h" #include "model/namespace.h" #include "model/timeout_clock.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/generators.h" #include "test_utils/randoms.h" #include "test_utils/test.h" diff --git a/src/v/cluster/tests/plugin_frontend_validation_test.cc b/src/v/cluster/tests/plugin_frontend_validation_test.cc index 12b738354c15a..07d1d4a7afda4 100644 --- a/src/v/cluster/tests/plugin_frontend_validation_test.cc +++ b/src/v/cluster/tests/plugin_frontend_validation_test.cc @@ -18,7 +18,7 @@ #include "model/metadata.h" #include "model/namespace.h" #include "model/transform.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "utils/uuid.h" #include diff --git a/src/v/cluster/tests/rm_stm_tests.cc b/src/v/cluster/tests/rm_stm_tests.cc index fb4b21144b8be..f775ad58879ff 100644 --- a/src/v/cluster/tests/rm_stm_tests.cc +++ b/src/v/cluster/tests/rm_stm_tests.cc @@ -20,7 +20,6 @@ #include "model/timestamp.h" #include "raft/consensus_utils.h" #include "raft/tests/raft_group_fixture.h" -#include "raft/types.h" #include "random/generators.h" #include "storage/record_batch_builder.h" #include "storage/tests/utils/disk_log_builder.h" diff --git a/src/v/cluster/tests/serialization_rt_test.cc b/src/v/cluster/tests/serialization_rt_test.cc index 82f8f6428a839..f0b8c0cee32ec 100644 --- a/src/v/cluster/tests/serialization_rt_test.cc +++ b/src/v/cluster/tests/serialization_rt_test.cc @@ -24,7 +24,7 @@ #include "model/tests/random_batch.h" #include "model/tests/randoms.h" #include "model/timestamp.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/generators.h" #include "reflection/adl.h" #include "reflection/async_adl.h" diff --git a/src/v/cluster/tests/tm_stm_tests.cc b/src/v/cluster/tests/tm_stm_tests.cc index 0b60f42bdbb03..80263f50d76e5 100644 --- a/src/v/cluster/tests/tm_stm_tests.cc +++ b/src/v/cluster/tests/tm_stm_tests.cc @@ -20,7 +20,6 @@ #include "raft/consensus_utils.h" #include "raft/tests/raft_group_fixture.h" #include "raft/tests/simple_raft_fixture.h" -#include "raft/types.h" #include "random/generators.h" #include "storage/record_batch_builder.h" #include "storage/tests/utils/disk_log_builder.h" diff --git a/src/v/cluster/tests/topic_table_test.cc b/src/v/cluster/tests/topic_table_test.cc index 768055a3be8c4..5cd1a613226d3 100644 --- a/src/v/cluster/tests/topic_table_test.cc +++ b/src/v/cluster/tests/topic_table_test.cc @@ -11,7 +11,7 @@ #include "cluster/types.h" #include "model/fundamental.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include #include diff --git a/src/v/cluster/tm_stm.cc b/src/v/cluster/tm_stm.cc index a3f6ba4e360b3..011bed4325088 100644 --- a/src/v/cluster/tm_stm.cc +++ b/src/v/cluster/tm_stm.cc @@ -14,7 +14,7 @@ #include "cluster/types.h" #include "model/record.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "storage/record_batch_builder.h" #include diff --git a/src/v/cluster/tm_stm_cache.cc b/src/v/cluster/tm_stm_cache.cc index fb1fffadcb7fa..467738b1ce8b9 100644 --- a/src/v/cluster/tm_stm_cache.cc +++ b/src/v/cluster/tm_stm_cache.cc @@ -14,7 +14,7 @@ #include "cluster/types.h" #include "model/record.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "storage/record_batch_builder.h" #include diff --git a/src/v/cluster/topic_updates_dispatcher.cc b/src/v/cluster/topic_updates_dispatcher.cc index 8925c32b9fcd2..3e6fa56cdbf96 100644 --- a/src/v/cluster/topic_updates_dispatcher.cc +++ b/src/v/cluster/topic_updates_dispatcher.cc @@ -19,7 +19,7 @@ #include "cluster/topic_table.h" #include "model/fundamental.h" #include "model/metadata.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "ssx/future-util.h" #include diff --git a/src/v/cluster/topics_frontend.cc b/src/v/cluster/topics_frontend.cc index 8d492010fdf82..a100e95c9eb17 100644 --- a/src/v/cluster/topics_frontend.cc +++ b/src/v/cluster/topics_frontend.cc @@ -38,7 +38,7 @@ #include "model/validation.h" #include "raft/consensus_client_protocol.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/generators.h" #include "rpc/errc.h" #include "rpc/types.h" diff --git a/src/v/cluster/types.h b/src/v/cluster/types.h index e8deafea4d1e0..fbe1ea9d099be 100644 --- a/src/v/cluster/types.h +++ b/src/v/cluster/types.h @@ -24,8 +24,8 @@ #include "model/transform.h" #include "pandaproxy/schema_registry/subject_name_strategy.h" #include "raft/errc.h" -#include "raft/fundamental.h" #include "raft/fwd.h" +#include "raft/transfer_leadership.h" #include "security/acl.h" #include "security/license.h" #include "security/role.h" @@ -2663,6 +2663,9 @@ struct delete_acls_reply auto serde_fields() { return std::tie(results); } }; +using transfer_leadership_request = raft::transfer_leadership_request; +using transfer_leadership_reply = raft::transfer_leadership_reply; + struct backend_operation : serde:: envelope, serde::compat_version<0>> { diff --git a/src/v/kafka/protocol/kafka_batch_adapter.cc b/src/v/kafka/protocol/kafka_batch_adapter.cc index 20ab1665bef48..60fc170bee345 100644 --- a/src/v/kafka/protocol/kafka_batch_adapter.cc +++ b/src/v/kafka/protocol/kafka_batch_adapter.cc @@ -18,7 +18,6 @@ #include "kafka/protocol/wire.h" #include "model/fundamental.h" #include "model/record.h" -#include "raft/types.h" #include "storage/parser_utils.h" #include diff --git a/src/v/kafka/server/group_manager.cc b/src/v/kafka/server/group_manager.cc index 8d116e686f045..97e9b141e559e 100644 --- a/src/v/kafka/server/group_manager.cc +++ b/src/v/kafka/server/group_manager.cc @@ -33,7 +33,7 @@ #include "model/namespace.h" #include "model/record.h" #include "raft/errc.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "resource_mgmt/io_priority.h" #include "ssx/future-util.h" diff --git a/src/v/kafka/server/handlers/produce.cc b/src/v/kafka/server/handlers/produce.cc index 34ff95917448c..23ba8edd0788d 100644 --- a/src/v/kafka/server/handlers/produce.cc +++ b/src/v/kafka/server/handlers/produce.cc @@ -27,7 +27,6 @@ #include "model/timestamp.h" #include "pandaproxy/schema_registry/validation.h" #include "raft/errc.h" -#include "raft/types.h" #include "ssx/future-util.h" #include "utils/remote.h" #include "utils/to_string.h" diff --git a/src/v/kafka/server/replicated_partition.cc b/src/v/kafka/server/replicated_partition.cc index 56b4535625bca..094fd4eddfa15 100644 --- a/src/v/kafka/server/replicated_partition.cc +++ b/src/v/kafka/server/replicated_partition.cc @@ -21,7 +21,6 @@ #include "model/timeout_clock.h" #include "raft/consensus_utils.h" #include "raft/errc.h" -#include "raft/types.h" #include "storage/log_reader.h" #include "storage/types.h" diff --git a/src/v/model/fundamental.h b/src/v/model/fundamental.h index 73d1488161d58..186458e5a21ce 100644 --- a/src/v/model/fundamental.h +++ b/src/v/model/fundamental.h @@ -68,6 +68,33 @@ namespace model { using node_uuid = named_type; using cluster_uuid = named_type; +using node_id = named_type; + +/** + * Reserved to represent the node_id value yet to be assigned + * when node is configured for automatic assignment of node_ids. + * Never used in node configuration. + */ +constexpr node_id unassigned_node_id(-1); + +/** + * We use revision_id to identify entities evolution in time. f.e. NTP that was + * first created and then removed, raft configuration + */ +using revision_id = named_type; + +/** + * Revision id that the partition had when the topic was just created. + * The revision_id of the partition might change when the partition is moved + * between the nodes. + */ +using initial_revision_id + = named_type; + +// tracking evolution of the shard table +using shard_revision_id + = named_type; + // Named after Kafka cleanup.policy topic property enum class cleanup_policy_bitflags : uint8_t { none = 0, diff --git a/src/v/model/metadata.h b/src/v/model/metadata.h index bcd83b9b172ad..3e8235d6bef98 100644 --- a/src/v/model/metadata.h +++ b/src/v/model/metadata.h @@ -34,32 +34,6 @@ #include namespace model { -using node_id = named_type; - -/** - * Reserved to represent the node_id value yet to be assigned - * when node is configured for automatic assignment of node_ids. - * Never used in node configuration. - */ -constexpr node_id unassigned_node_id(-1); - -/** - * We use revision_id to identify entities evolution in time. f.e. NTP that was - * first created and then removed, raft configuration - */ -using revision_id = named_type; - -/** - * Revision id that the partition had when the topic was just created. - * The revision_id of the partition might change when the partition is moved - * between the nodes. - */ -using initial_revision_id - = named_type; - -// tracking evolution of the shard table -using shard_revision_id - = named_type; /// Rack id type using rack_id = named_type; diff --git a/src/v/raft/consensus.h b/src/v/raft/consensus.h index 70879d7383ef6..39c525dd80393 100644 --- a/src/v/raft/consensus.h +++ b/src/v/raft/consensus.h @@ -36,6 +36,7 @@ #include "raft/replication_monitor.h" #include "raft/state_machine_manager.h" #include "raft/timeout_jitter.h" +#include "raft/transfer_leadership.h" #include "raft/types.h" #include "ssx/semaphore.h" #include "storage/log.h" diff --git a/src/v/raft/consensus_client_protocol.h b/src/v/raft/consensus_client_protocol.h index 23fe2697f601d..c96def642edf5 100644 --- a/src/v/raft/consensus_client_protocol.h +++ b/src/v/raft/consensus_client_protocol.h @@ -13,6 +13,7 @@ #include "base/outcome.h" #include "model/metadata.h" #include "raft/heartbeats.h" +#include "raft/transfer_leadership.h" #include "raft/types.h" #include "rpc/types.h" diff --git a/src/v/raft/transfer_leadership.h b/src/v/raft/transfer_leadership.h new file mode 100644 index 0000000000000..364ee4c2cd3a1 --- /dev/null +++ b/src/v/raft/transfer_leadership.h @@ -0,0 +1,66 @@ +/* + * Copyright 2024 Redpanda Data, Inc. + * + * Use of this software is governed by the Business Source License + * included in the file licenses/BSL.md + * + * As of the Change Date specified in that file, in accordance with + * the Business Source License, use of this software will be governed + * by the Apache License, Version 2.0 + */ + +#pragma once + +#include "model/fundamental.h" +#include "raft/errc.h" +#include "raft/fundamental.h" +#include "serde/envelope.h" + +namespace raft { + +// if not target is specified then the most up-to-date node will be selected +struct transfer_leadership_request + : serde::envelope< + transfer_leadership_request, + serde::version<1>, + serde::compat_version<0>> { + using rpc_adl_exempt = std::true_type; + group_id group; + std::optional target; + std::optional timeout; + + raft::group_id target_group() const { return group; } + + friend bool operator==( + const transfer_leadership_request&, const transfer_leadership_request&) + = default; + + auto serde_fields() { return std::tie(group, target, timeout); } + + friend std::ostream& + operator<<(std::ostream& o, const transfer_leadership_request& r); +}; + +struct transfer_leadership_reply + : serde::envelope< + transfer_leadership_reply, + serde::version<0>, + serde::compat_version<0>> { + using rpc_adl_exempt = std::true_type; + bool success{false}; + raft::errc result; + + friend bool operator==( + const transfer_leadership_reply&, const transfer_leadership_reply&) + = default; + + auto serde_fields() { return std::tie(success, result); } + + friend std::ostream& + operator<<(std::ostream& o, const transfer_leadership_reply& r) { + fmt::print(o, "success {} result {}", r.success, r.result); + return o; + } +}; + +} // namespace raft diff --git a/src/v/raft/types.cc b/src/v/raft/types.cc index 9dd4e1bdeb93d..cdc440d8c687d 100644 --- a/src/v/raft/types.cc +++ b/src/v/raft/types.cc @@ -10,21 +10,17 @@ #include "raft/types.h" #include "base/vassert.h" -#include "base/vlog.h" #include "model/async_adl_serde.h" #include "model/fundamental.h" -#include "model/metadata.h" #include "model/record.h" #include "model/record_batch_reader.h" #include "model/timeout_clock.h" #include "raft/consensus_utils.h" #include "raft/errc.h" #include "raft/group_configuration.h" -#include "raft/logger.h" +#include "raft/transfer_leadership.h" #include "reflection/adl.h" #include "reflection/async_adl.h" -#include "serde/serde.h" -#include "utils/to_string.h" #include @@ -32,8 +28,6 @@ #include #include -#include - namespace { template T decode_signed(T value) { diff --git a/src/v/raft/types.h b/src/v/raft/types.h index acf7ec139e638..98ec3c0d2ab9e 100644 --- a/src/v/raft/types.h +++ b/src/v/raft/types.h @@ -11,13 +11,9 @@ #pragma once -#include "base/outcome.h" #include "model/fundamental.h" -#include "model/metadata.h" #include "model/record_batch_reader.h" -#include "raft/errc.h" #include "raft/fundamental.h" -#include "raft/fwd.h" #include "raft/group_configuration.h" #include "raft/replicate.h" #include "reflection/adl.h" @@ -711,51 +707,6 @@ struct timeout_now_reply } }; -// if not target is specified then the most up-to-date node will be selected -struct transfer_leadership_request - : serde::envelope< - transfer_leadership_request, - serde::version<1>, - serde::compat_version<0>> { - using rpc_adl_exempt = std::true_type; - group_id group; - std::optional target; - std::optional timeout; - - raft::group_id target_group() const { return group; } - - friend bool operator==( - const transfer_leadership_request&, const transfer_leadership_request&) - = default; - - auto serde_fields() { return std::tie(group, target, timeout); } - - friend std::ostream& - operator<<(std::ostream& o, const transfer_leadership_request& r); -}; - -struct transfer_leadership_reply - : serde::envelope< - transfer_leadership_reply, - serde::version<0>, - serde::compat_version<0>> { - using rpc_adl_exempt = std::true_type; - bool success{false}; - raft::errc result; - - friend bool operator==( - const transfer_leadership_reply&, const transfer_leadership_reply&) - = default; - - auto serde_fields() { return std::tie(success, result); } - - friend std::ostream& - operator<<(std::ostream& o, const transfer_leadership_reply& r) { - fmt::print(o, "success {} result {}", r.success, r.result); - return o; - } -}; - // key types used to store data in key-value store enum class metadata_key : int8_t { voted_for = 0, diff --git a/src/v/raft/vote_stm.h b/src/v/raft/vote_stm.h index a3226432f3341..d67e0c2e1e86a 100644 --- a/src/v/raft/vote_stm.h +++ b/src/v/raft/vote_stm.h @@ -12,6 +12,7 @@ #pragma once #include "base/outcome.h" +#include "raft/fwd.h" #include "raft/group_configuration.h" #include "raft/logger.h" #include "raft/types.h" diff --git a/src/v/rpc/rpc_compiler.py b/src/v/rpc/rpc_compiler.py index 04008d5c80452..9183fb69ee806 100755 --- a/src/v/rpc/rpc_compiler.py +++ b/src/v/rpc/rpc_compiler.py @@ -26,7 +26,6 @@ #include "config/configuration.h" #include "metrics/metrics.h" -#include "raft/types.h" #include "reflection/adl.h" #include "rpc/types.h" #include "rpc/parse_utils.h" @@ -56,9 +55,6 @@ namespace {{namespace}} { -using transfer_leadership_request = raft::transfer_leadership_request; -using transfer_leadership_reply = raft::transfer_leadership_reply; - template class {{service_name}}_service_base : public ::rpc::service { public: diff --git a/src/v/storage/kvstore.cc b/src/v/storage/kvstore.cc index d3ecd98afcd90..8f003ac4b9c99 100644 --- a/src/v/storage/kvstore.cc +++ b/src/v/storage/kvstore.cc @@ -16,7 +16,6 @@ #include "model/async_adl_serde.h" #include "model/namespace.h" #include "prometheus/prometheus_sanitize.h" -#include "raft/types.h" #include "reflection/adl.h" #include "storage/parser.h" #include "storage/record_batch_builder.h" diff --git a/src/v/storage/tests/batch_cache_reclaim_test.cc b/src/v/storage/tests/batch_cache_reclaim_test.cc index eb676341fc95b..b1df4e7c98c8f 100644 --- a/src/v/storage/tests/batch_cache_reclaim_test.cc +++ b/src/v/storage/tests/batch_cache_reclaim_test.cc @@ -9,7 +9,6 @@ #include "cluster/simple_batch_builder.h" #include "model/record.h" -#include "raft/types.h" #include "storage/batch_cache.h" #include "test_utils/fixture.h" diff --git a/src/v/storage/tests/offset_translator_tests.cc b/src/v/storage/tests/offset_translator_tests.cc index f01d94236d752..87d20319e0281 100644 --- a/src/v/storage/tests/offset_translator_tests.cc +++ b/src/v/storage/tests/offset_translator_tests.cc @@ -9,7 +9,7 @@ #include "bytes/random.h" #include "model/fundamental.h" -#include "raft/types.h" +#include "raft/fundamental.h" #include "random/generators.h" #include "storage/api.h" #include "storage/fwd.h"