feat: Limit cache loading in cluster (#2985)

This PR adds an option to limit simultaneous cache loading in a cluster
to one node at a time.
Fixes #2707
This commit is contained in:
Sergey Kuznetsov
2026-03-09 17:11:20 +00:00
committed by GitHub
parent 53d9617b26
commit fbdd6d6105
34 changed files with 1283 additions and 79 deletions

View File

@@ -0,0 +1,61 @@
//------------------------------------------------------------------------------
/*
This file is part of clio: https://github.com/XRPLF/clio
Copyright (c) 2026, the clio developers.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include "data/LedgerCacheLoadingState.hpp"
#include <memory>
namespace data {
LedgerCacheLoadingState::LedgerCacheLoadingState(LedgerCacheInterface const& cache) : cache_(cache)
{
}
void
LedgerCacheLoadingState::allowLoading()
{
*isLoadingAllowed_ = true;
isLoadingAllowed_->notify_all();
}
bool
LedgerCacheLoadingState::isLoadingAllowed() const
{
return *isLoadingAllowed_;
}
void
LedgerCacheLoadingState::waitForLoadingAllowed() const
{
isLoadingAllowed_->wait(false);
}
bool
LedgerCacheLoadingState::isCurrentlyLoading() const
{
return cache_.get().isCurrentlyLoading();
}
std::unique_ptr<LedgerCacheLoadingStateInterface>
LedgerCacheLoadingState::clone() const
{
return std::make_unique<LedgerCacheLoadingState>(*this);
}
} // namespace data