Skip to content

Commit 92f650a

Browse files
authored
Merge branch 'develop' into Add_age_metric
2 parents 9810f37 + 6ba58f4 commit 92f650a

File tree

575 files changed

+14317
-6554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

575 files changed

+14317
-6554
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ BreakBeforeBinaryOperators: false
2222
BreakBeforeBraces: WebKit
2323
BreakBeforeTernaryOperators: true
2424
BreakConstructorInitializersBeforeComma: true
25-
ColumnLimit: 120
25+
ColumnLimit: 100
2626
CommentPragmas: "^ IWYU pragma:"
2727
ConstructorInitializerAllOnOneLineOrOnePerLine: true
2828
ConstructorInitializerIndentWidth: 4

benchmarks/rpc/WorkQueueBenchmarks.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ auto const kCONFIG = ClioConfigDefinition{
5151
{"log.channels.[].channel", Array{ConfigValue{ConfigType::String}}},
5252
{"log.channels.[].level", Array{ConfigValue{ConfigType::String}}},
5353
{"log.level", ConfigValue{ConfigType::String}.defaultValue("info")},
54-
{"log.format", ConfigValue{ConfigType::String}.defaultValue(R"(%Y-%m-%d %H:%M:%S.%f %^%3!l:%n%$ - %v)")},
54+
{"log.format",
55+
ConfigValue{ConfigType::String}.defaultValue(R"(%Y-%m-%d %H:%M:%S.%f %^%3!l:%n%$ - %v)")},
5556
{"log.is_async", ConfigValue{ConfigType::Boolean}.defaultValue(false)},
5657
{"log.enable_console", ConfigValue{ConfigType::Boolean}.defaultValue(false)},
5758
{"log.directory", ConfigValue{ConfigType::String}.optional()},
58-
{"log.rotation_size", ConfigValue{ConfigType::Integer}.defaultValue(2048).withConstraint(gValidateUint32)},
59-
{"log.directory_max_files", ConfigValue{ConfigType::Integer}.defaultValue(25).withConstraint(gValidateUint32)},
59+
{"log.rotation_size",
60+
ConfigValue{ConfigType::Integer}.defaultValue(2048).withConstraint(gValidateUint32)},
61+
{"log.directory_max_files",
62+
ConfigValue{ConfigType::Integer}.defaultValue(25).withConstraint(gValidateUint32)},
6063
{"log.tag_style", ConfigValue{ConfigType::String}.defaultValue("none")},
6164
};
6265

@@ -124,9 +127,14 @@ benchmarkWorkQueue(benchmark::State& state)
124127
ASSERT(totalQueued <= itemsPerClient * clientThreads, "Queued more than requested");
125128

126129
if (maxQueueSize == 0) {
127-
ASSERT(totalQueued == itemsPerClient * clientThreads, "Queued exactly the expected amount");
130+
ASSERT(
131+
totalQueued == itemsPerClient * clientThreads, "Queued exactly the expected amount"
132+
);
128133
} else {
129-
ASSERT(totalQueued >= std::min(maxQueueSize, itemsPerClient * clientThreads), "Queued less than expected");
134+
ASSERT(
135+
totalQueued >= std::min(maxQueueSize, itemsPerClient * clientThreads),
136+
"Queued less than expected"
137+
);
130138
}
131139
}
132140
}

benchmarks/util/log/LoggerBenchmark.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ uniqueLogDir()
6262
{
6363
auto const epochTime = std::chrono::high_resolution_clock::now().time_since_epoch();
6464
auto const tmpDir = std::filesystem::temp_directory_path();
65-
std::string const dirName =
66-
fmt::format("logs_{}", std::chrono::duration_cast<std::chrono::microseconds>(epochTime).count());
65+
std::string const dirName = fmt::format(
66+
"logs_{}", std::chrono::duration_cast<std::chrono::microseconds>(epochTime).count()
67+
);
6768
return tmpDir / "clio_benchmark" / dirName;
6869
}
6970

@@ -108,7 +109,8 @@ benchmarkConcurrentFileLogging(benchmark::State& state)
108109
channel, fileSink, spdlog::thread_pool(), spdlog::async_overflow_policy::block
109110
);
110111
spdlog::register_logger(logger);
111-
Logger const threadLogger = BenchmarkLoggingInitializer::getLogger(std::move(logger));
112+
Logger const threadLogger =
113+
BenchmarkLoggingInitializer::getLogger(std::move(logger));
112114

113115
barrier.arrive_and_wait();
114116

@@ -124,13 +126,16 @@ benchmarkConcurrentFileLogging(benchmark::State& state)
124126
spdlog::shutdown();
125127

126128
auto const end = std::chrono::high_resolution_clock::now();
127-
state.SetIterationTime(std::chrono::duration_cast<std::chrono::duration<double>>(end - start).count());
129+
state.SetIterationTime(
130+
std::chrono::duration_cast<std::chrono::duration<double>>(end - start).count()
131+
);
128132

129133
std::filesystem::remove_all(logDir);
130134
}
131135

132136
auto const totalMessages = numThreads * messagesPerThread;
133-
state.counters["TotalMessagesRate"] = benchmark::Counter(totalMessages, benchmark::Counter::kIsRate);
137+
state.counters["TotalMessagesRate"] =
138+
benchmark::Counter(totalMessages, benchmark::Counter::kIsRate);
134139
state.counters["Threads"] = numThreads;
135140
state.counters["MessagesPerThread"] = messagesPerThread;
136141
}

src/app/CliArgs.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ CliArgs::parse(int argc, char const* argv[])
5858
positional.add("conf", 1);
5959

6060
auto const printHelp = [&description]() {
61-
std::cout << "Clio server " << util::build::getClioFullVersionString() << "\n\n" << description;
61+
std::cout << "Clio server " << util::build::getClioFullVersionString() << "\n\n"
62+
<< description;
6263
};
6364

6465
po::variables_map parsed;
6566
try {
66-
po::store(po::command_line_parser(argc, argv).options(description).positional(positional).run(), parsed);
67+
po::store(
68+
po::command_line_parser(argc, argv).options(description).positional(positional).run(),
69+
parsed
70+
);
6771
po::notify(parsed);
6872
} catch (po::error const& e) {
6973
std::cerr << "Error: " << e.what() << std::endl << std::endl;
@@ -87,7 +91,8 @@ CliArgs::parse(int argc, char const* argv[])
8791
if (parsed.contains("config-description")) {
8892
std::filesystem::path const filePath = parsed["config-description"].as<std::string>();
8993

90-
auto const res = util::config::ClioConfigDescription::generateConfigDescriptionToFile(filePath);
94+
auto const res =
95+
util::config::ClioConfigDescription::generateConfigDescriptionToFile(filePath);
9196
if (res.has_value())
9297
return Action{Action::Exit{EXIT_SUCCESS}};
9398

@@ -100,14 +105,20 @@ CliArgs::parse(int argc, char const* argv[])
100105
if (parsed.contains("migrate")) {
101106
auto const opt = parsed["migrate"].as<std::string>();
102107
if (opt == "status")
103-
return Action{Action::Migrate{.configPath = std::move(configPath), .subCmd = MigrateSubCmd::status()}};
104-
return Action{Action::Migrate{.configPath = std::move(configPath), .subCmd = MigrateSubCmd::migration(opt)}};
108+
return Action{Action::Migrate{
109+
.configPath = std::move(configPath), .subCmd = MigrateSubCmd::status()
110+
}};
111+
return Action{Action::Migrate{
112+
.configPath = std::move(configPath), .subCmd = MigrateSubCmd::migration(opt)
113+
}};
105114
}
106115

107116
if (parsed.contains("verify"))
108117
return Action{Action::VerifyConfig{.configPath = std::move(configPath)}};
109118

110-
return Action{Action::Run{.configPath = std::move(configPath), .useNgWebServer = parsed.contains("ng-web-server")}};
119+
return Action{Action::Run{
120+
.configPath = std::move(configPath), .useNgWebServer = parsed.contains("ng-web-server")
121+
}};
111122
}
112123

113124
} // namespace app

src/app/CliArgs.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class CliArgs {
7979
/**
8080
* @brief Apply a function to the action.
8181
*
82-
* @tparam Processors Action processors types. Must be callable with the action type and return int.
82+
* @tparam Processors Action processors types. Must be callable with the action type and
83+
* return int.
8384
* @param processors Action processors.
8485
* @return Exit code.
8586
*/

src/app/ClioApplication.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@ ClioApplication::run(bool const useNgWebServer)
136136
auto const migrationInspector = migration::makeMigrationInspector(config_, backend);
137137
// Check if any migration is blocking Clio server starting.
138138
if (migrationInspector->isBlockingClio() and backend->hardFetchLedgerRangeNoThrow()) {
139-
LOG(util::LogService::error())
140-
<< "Existing Migration is blocking Clio, Please complete the database migration first.";
139+
LOG(util::LogService::error()) << "Existing Migration is blocking Clio, Please "
140+
"complete the database migration first.";
141141
return EXIT_FAILURE;
142142
}
143143
}
144144

145145
// Manages clients subscribed to streams
146-
auto subscriptions = feed::SubscriptionManager::makeSubscriptionManager(config_, backend, amendmentCenter);
146+
auto subscriptions =
147+
feed::SubscriptionManager::makeSubscriptionManager(config_, backend, amendmentCenter);
147148

148149
// Tracks which ledgers have been validated by the network
149150
auto ledgers = etl::NetworkValidatedLedgers::makeValidatedLedgers();
@@ -156,7 +157,8 @@ ClioApplication::run(bool const useNgWebServer)
156157
config_, ioc, backend, subscriptions, std::make_unique<util::MTRandomGenerator>(), ledgers
157158
);
158159

159-
// ETL is responsible for writing and publishing to streams. In read-only mode, ETL only publishes
160+
// ETL is responsible for writing and publishing to streams. In read-only mode, ETL only
161+
// publishes
160162
auto etl = etl::ETLService::makeETLService(
161163
config_, std::move(systemState), ctx, backend, subscriptions, balancer, ledgers
162164
);
@@ -169,15 +171,19 @@ ClioApplication::run(bool const useNgWebServer)
169171
);
170172

171173
using RPCEngineType = rpc::RPCEngine<rpc::Counters>;
172-
auto const rpcEngine =
173-
RPCEngineType::makeRPCEngine(config_, backend, balancer, dosGuard, workQueue, counters, handlerProvider);
174+
auto const rpcEngine = RPCEngineType::makeRPCEngine(
175+
config_, backend, balancer, dosGuard, workQueue, counters, handlerProvider
176+
);
174177

175178
if (useNgWebServer or config_.get<bool>("server.__ng_web_server")) {
176-
web::ng::RPCServerHandler<RPCEngineType> handler{config_, backend, rpcEngine, etl, dosGuard};
179+
web::ng::RPCServerHandler<RPCEngineType> handler{
180+
config_, backend, rpcEngine, etl, dosGuard
181+
};
177182

178183
auto expectedAdminVerifier = web::makeAdminVerificationStrategy(config_);
179184
if (not expectedAdminVerifier.has_value()) {
180-
LOG(util::LogService::error()) << "Error creating admin verifier: " << expectedAdminVerifier.error();
185+
LOG(util::LogService::error())
186+
<< "Error creating admin verifier: " << expectedAdminVerifier.error();
181187
return EXIT_FAILURE;
182188
}
183189
auto const adminVerifier = std::move(expectedAdminVerifier).value();
@@ -226,12 +232,21 @@ ClioApplication::run(bool const useNgWebServer)
226232
}
227233

228234
// Init the web server
229-
auto handler = std::make_shared<web::RPCServerHandler<RPCEngineType>>(config_, backend, rpcEngine, etl, dosGuard);
235+
auto handler = std::make_shared<web::RPCServerHandler<RPCEngineType>>(
236+
config_, backend, rpcEngine, etl, dosGuard
237+
);
230238

231239
auto const httpServer = web::makeHttpServer(config_, ioc, dosGuard, handler, cache);
232240
appStopper_.setOnStop(
233241
Stopper::makeOnStopCallback(
234-
*httpServer, *balancer, *etl, *subscriptions, *backend, cacheSaver, clusterCommunicationService, ioc
242+
*httpServer,
243+
*balancer,
244+
*etl,
245+
*subscriptions,
246+
*backend,
247+
cacheSaver,
248+
clusterCommunicationService,
249+
ioc
235250
)
236251
);
237252

src/app/Stopper.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
namespace app {
4040

4141
/**
42-
* @brief Application stopper class. On stop it will create a new thread to run all the shutdown tasks.
42+
* @brief Application stopper class. On stop it will create a new thread to run all the shutdown
43+
* tasks.
4344
*/
4445
class Stopper {
4546
boost::asio::io_context ctx_;

src/app/VerifyConfig.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ parseConfig(std::string_view configPath)
4141

4242
auto const json = ConfigFileJson::makeConfigFileJson(configPath);
4343
if (!json.has_value()) {
44-
std::cerr << "Error parsing json from config: " << configPath << "\n" << json.error().error << std::endl;
44+
std::cerr << "Error parsing json from config: " << configPath << "\n"
45+
<< json.error().error << std::endl;
4546
return false;
4647
}
4748
auto const errors = getClioConfig().parse(json.value());

src/app/WebHandlers.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ OnConnectCheck::operator()(web::ng::Connection const& connection)
5151
{
5252
dosguard_.get().increment(connection.ip());
5353
if (not dosguard_.get().isOk(connection.ip())) {
54-
return std::unexpected{
55-
web::ng::Response{boost::beast::http::status::too_many_requests, "Too many requests", connection}
56-
};
54+
return std::unexpected{web::ng::Response{
55+
boost::beast::http::status::too_many_requests, "Too many requests", connection
56+
}};
5757
}
5858

5959
return {};
@@ -80,7 +80,10 @@ DisconnectHook::operator()(web::ng::Connection const& connection)
8080
dosguard_.get().decrement(connection.ip());
8181
}
8282

83-
MetricsHandler::MetricsHandler(std::shared_ptr<web::AdminVerificationStrategy> adminVerifier, rpc::WorkQueue& workQueue)
83+
MetricsHandler::MetricsHandler(
84+
std::shared_ptr<web::AdminVerificationStrategy> adminVerifier,
85+
rpc::WorkQueue& workQueue
86+
)
8487
: adminVerifier_{std::move(adminVerifier)}, workQueue_{std::ref(workQueue)}
8588
{
8689
}
@@ -120,7 +123,9 @@ MetricsHandler::operator()(
120123

121124
if (!postSuccessful) {
122125
return web::ng::Response{
123-
boost::beast::http::status::too_many_requests, rpc::makeError(rpc::RippledError::rpcTOO_BUSY), request
126+
boost::beast::http::status::too_many_requests,
127+
rpc::makeError(rpc::RippledError::rpcTOO_BUSY),
128+
request
124129
};
125130
}
126131

@@ -177,7 +182,9 @@ CacheStateHandler::operator()(
177182
if (cache_.get().isFull())
178183
return web::ng::Response{boost::beast::http::status::ok, kCACHE_CHECK_LOADED_HTML, request};
179184

180-
return web::ng::Response{boost::beast::http::status::service_unavailable, kCACHE_CHECK_NOT_LOADED_HTML, request};
185+
return web::ng::Response{
186+
boost::beast::http::status::service_unavailable, kCACHE_CHECK_NOT_LOADED_HTML, request
187+
};
181188
}
182189

183190
} // namespace app

src/app/WebHandlers.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class OnConnectCheck {
6868
};
6969

7070
/**
71-
* @brief A function object that is called when the IP of a connection changes (usually if proxy detected).
72-
* This is used to update the DOS guard.
71+
* @brief A function object that is called when the IP of a connection changes (usually if proxy
72+
* detected). This is used to update the DOS guard.
7373
*/
7474
class IpChangeHook {
7575
std::reference_wrapper<web::dosguard::DOSGuardInterface> dosguard_;
@@ -126,10 +126,14 @@ class MetricsHandler {
126126
/**
127127
* @brief Construct a new MetricsHandler object
128128
*
129-
* @param adminVerifier The AdminVerificationStrategy to use for verifying the connection for admin access.
129+
* @param adminVerifier The AdminVerificationStrategy to use for verifying the connection for
130+
* admin access.
130131
* @param workQueue The WorkQueue to use for handling the request.
131132
*/
132-
MetricsHandler(std::shared_ptr<web::AdminVerificationStrategy> adminVerifier, rpc::WorkQueue& workQueue);
133+
MetricsHandler(
134+
std::shared_ptr<web::AdminVerificationStrategy> adminVerifier,
135+
rpc::WorkQueue& workQueue
136+
);
133137

134138
/**
135139
* @brief The call of the function object.
@@ -214,10 +218,14 @@ class RequestHandler {
214218
/**
215219
* @brief Construct a new RequestHandler object
216220
*
217-
* @param adminVerifier The AdminVerificationStrategy to use for verifying the connection for admin access.
221+
* @param adminVerifier The AdminVerificationStrategy to use for verifying the connection for
222+
* admin access.
218223
* @param rpcHandler The RPC handler to use for handling the request.
219224
*/
220-
RequestHandler(std::shared_ptr<web::AdminVerificationStrategy> adminVerifier, RpcHandlerType& rpcHandler)
225+
RequestHandler(
226+
std::shared_ptr<web::AdminVerificationStrategy> adminVerifier,
227+
RpcHandlerType& rpcHandler
228+
)
221229
: adminVerifier_(std::move(adminVerifier)), rpcHandler_(rpcHandler)
222230
{
223231
}

0 commit comments

Comments
 (0)