The directory utils/ is supposed to contain general-purpose utility
classes and functions, which are either already used across the project,
or are designed to be used across the project.
This patch moves 8 files out of utils/:
utils/advanced_rpc_compressor.hh
utils/advanced_rpc_compressor.cc
utils/advanced_rpc_compressor_protocol.hh
utils/stream_compressor.hh
utils/stream_compressor.cc
utils/dict_trainer.cc
utils/dict_trainer.hh
utils/shared_dict.hh
These 8 files together implement the compression feature of RPC.
None of them are used by any other Scylla component (e.g., sstables have
a different compression), or are ready to be used by another component,
so this patch moves all of them into message/, where RPC is implemented.
Theoretically, we may want in the future to use this cluster of classes
for some other component, but even then, we shouldn't just have these
files individually in utils/ - these are not useful stand-alone
utilities. One cannot use "shared_dict.hh" assuming it is some sort of
general-purpose shared hash table or something - it is completely
specific to compression and zstd, and specifically to its use in those
other classes.
Beyond moving these 8 files, this patch also contains changes to:
1. Fix includes to the 5 moved header files (.hh).
2. Fix configure.py, utils/CMakeLists.txt and message/CMakeLists.txt
for the three moved source files (.cc).
3. In the moved files, change from the "utils::" namespace, to the
"netw::" namespace used by RPC. Also needed to change a bunch
of callers for the new namespace. Also, had to add "utils::"
explicitly in several places which previously assumed the
current namespace is "utils::".
Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Closes scylladb/scylladb#25149
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2023-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "shared_dict.hh"
|
|
#include "advanced_rpc_compressor.hh"
|
|
|
|
namespace netw {
|
|
|
|
struct control_protocol_frame {
|
|
enum header_enum : uint8_t {
|
|
NONE, // This means that the field isn't filled.
|
|
UPDATE,
|
|
COMMIT,
|
|
};
|
|
|
|
struct one_side {
|
|
header_enum header = NONE;
|
|
uint64_t epoch = 0;
|
|
compression_algorithm_set algo = compression_algorithm_set::singleton(compression_algorithm::type::RAW);
|
|
shared_dict::dict_id dict;
|
|
constexpr static size_t serialized_size = 1+8+1+16+8+32;
|
|
void serialize(std::span<std::byte, serialized_size>);
|
|
static one_side deserialize(std::span<const std::byte, serialized_size>);
|
|
};
|
|
|
|
// The negotiation algorithm is run for each of the two directions of the connection separately.
|
|
// The `receiver` field below is a message for the algorithm instance in which we are the receiver.
|
|
// `sender` is for the instance in which we are the sender.
|
|
//
|
|
// Even though usually only one of these will be filled with something meaningful (not `NONE`),
|
|
// we always send both just to keep the layout of the frame fixed. It simplifies the serialization.
|
|
one_side receiver;
|
|
one_side sender;
|
|
|
|
constexpr static size_t serialized_size = 2 * one_side::serialized_size;
|
|
void serialize(std::span<std::byte, serialized_size>);
|
|
static control_protocol_frame deserialize(std::span<const std::byte, serialized_size>);
|
|
};
|
|
|
|
} // namespace netw
|