Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign stoppable objects #3741

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
0747c09
Remove Stoppable::onPrepare
thejohnfreeman Dec 29, 2020
73e6347
[fold] Move timer from RootStoppable to LoadManager
thejohnfreeman Dec 29, 2020
6b56845
[fold] Call stopped() in LedgerCleanerImp::onStop
thejohnfreeman Dec 30, 2020
2180d82
[fold] Remove Stoppable from base classes of OrderBookDB, LedgerMaster
thejohnfreeman Dec 30, 2020
e8f8d04
[fold] Call stopped() in SHAMapStoreImp::onStop
thejohnfreeman Dec 30, 2020
0282848
[fold] Call stopped() in NodeStore::Database::onStop
thejohnfreeman Dec 30, 2020
50a9967
[fold] NodeStoreScheduler is not a Stoppable
thejohnfreeman Dec 30, 2020
9af6acc
[fold] Call stopped() in ServerHandlerImp::onStop
thejohnfreeman Dec 30, 2020
1bb43f7
[fold] Stop NodeStore::TaskQueue from NodeStore::DatabaseShardImp::on…
thejohnfreeman Dec 30, 2020
94c830c
[fold] Move JobCounter from RootStoppable to JobQueue
thejohnfreeman Dec 31, 2020
ef7d968
[fold] Call stopped() in OverlayImpl::onStop
thejohnfreeman Dec 31, 2020
c27f440
[fold] Call stopped() in NodeStore::DatabaseShardImp::onStop
thejohnfreeman Dec 31, 2020
aad8a32
[fold] Call stopped() in PerfLogImp::onStop
thejohnfreeman Dec 31, 2020
59557fe
[fold] Remove Stoppable::{stopped,onChildrenStopped}
thejohnfreeman Dec 31, 2020
78050db
[fold] Remove Stoppable::{setParent,getRoot}
thejohnfreeman Dec 31, 2020
251bf3e
[fold] Remove RootStoppable::start and Stoppable::startRecursive
thejohnfreeman Jan 5, 2021
299e059
[fold] Inline Application::start
thejohnfreeman Jan 6, 2021
ad12f0e
[fold] LoadManager is not a Stoppable
thejohnfreeman Jan 6, 2021
ffa6c2c
[fold] PeerFinder::Manager is not a Stoppable
thejohnfreeman Jan 6, 2021
4d32cf6
[fold] Remove unused include
thejohnfreeman Jan 6, 2021
f331b3f
[fold] ServerHandlerImp is not a Stoppable
thejohnfreeman Jan 6, 2021
f8bd287
[fold] LedgerCleaner is not a Stoppable
thejohnfreeman Jan 6, 2021
15a9472
[fold] NetworkOPsImp is not a Stoppable
thejohnfreeman Jan 6, 2021
eb68656
[fold] Remove unused include
thejohnfreeman Jan 6, 2021
2d26155
[fold] GRPCServer is not a Stoppable
thejohnfreeman Jan 6, 2021
727b349
[fold] PerfLogImp is not a Stoppable
thejohnfreeman Jan 7, 2021
3e08270
[fold] Use a fixture for PerfLog tests
thejohnfreeman Jan 7, 2021
15b7da1
[fold] OverlayImpl is not a Stoppable
thejohnfreeman Jan 8, 2021
4a150d1
[fold] InboundTransactionsImp is not a Stoppable
thejohnfreeman Jan 8, 2021
2b35d46
[fold] InboundLedgersImp is not a Stoppable
thejohnfreeman Jan 8, 2021
833767e
[fold] ReportingETL is not a Stoppable
thejohnfreeman Jan 22, 2021
77a6ac7
[fold] PgPool is not a Stoppable
thejohnfreeman Jan 22, 2021
8c5deef
[fold] NodeStore::Database is not a Stoppable
thejohnfreeman Jan 18, 2021
023998b
[fold] SHAMapStoreImp is not a Stoppable
thejohnfreeman Jan 19, 2021
21db979
[fold] ShardArchiveHandler is not a Stoppable
thejohnfreeman Jan 19, 2021
0b14202
[fold] JobQueue is not a Stoppable
thejohnfreeman Jan 19, 2021
fe5d5db
[fold] Remove Stoppable
thejohnfreeman Jan 19, 2021
ddf177e
[fold] Document ClosureCounter and Workers
thejohnfreeman Jan 19, 2021
846b0c7
[fold] Remove mentions of Stoppable
thejohnfreeman Jan 19, 2021
6a45a85
[fold] Rename HTTPDownloader::{onStop -> stop}
thejohnfreeman Jan 19, 2021
5e892a7
[fold] review fixes
thejohnfreeman Jan 26, 2021
cd9cd6e
[fold] Merge 1.7.0-b12
thejohnfreeman Jan 27, 2021
e8a8d3e
[fold] LedgerReplayer is not a Stoppable
thejohnfreeman Jan 27, 2021
bd22635
[fold] Use CTAD
thejohnfreeman Jan 31, 2021
a40ddf2
[fold] Move start, stop to PerfLog interface and use it
thejohnfreeman Jan 31, 2021
6fe6f26
[fold] Prefer narrow capture list
thejohnfreeman Jan 31, 2021
905a274
[fold] Rename Timer::{start -> async_wait}
thejohnfreeman Jan 31, 2021
f556e07
[fold] Move start, stop to Overlay interface and use it
thejohnfreeman Jan 31, 2021
a4fbb6c
[fold] Stop at the beginning of every NodeStore::Database destructor
thejohnfreeman Feb 1, 2021
954c6fb
[fold] Rename Workers::{pauseAllThreadsAndWait -> stop}
thejohnfreeman Feb 1, 2021
3596ce5
[fold] Ignore overlay when it is missing
thejohnfreeman Feb 1, 2021
fcba4a6
[fold] Fix comment
thejohnfreeman Feb 2, 2021
92e9c6a
[fold] Stop ServerHandlerImp
thejohnfreeman Feb 3, 2021
01521e5
[fold] Rearrange stop sequence
thejohnfreeman Feb 7, 2021
5e05663
Merge 1.7.0-rc2
thejohnfreeman Feb 7, 2021
6a025ff
Fix declaration of CassandraBackend::counters_
thejohnfreeman Feb 5, 2021
51adc26
[fold] review fixes
thejohnfreeman Feb 8, 2021
e531354
[fold] Move LedgerCleaner from LedgerMaster to ApplicationImp
thejohnfreeman Feb 8, 2021
5bfc16f
[fold] Merge 1.8.0-b1
thejohnfreeman Mar 15, 2021
2a39b7c
[fold] Add missing include
thejohnfreeman Mar 23, 2021
d3c1c1f
Fix compilation of krb5 dependency with GCC 10
thejohnfreeman Mar 23, 2021
e74afc3
Merge 1.8.0-b2
thejohnfreeman Apr 2, 2021
f1beb4f
[fold] Put PgPool behind conditional compilation
thejohnfreeman Apr 2, 2021
145f5a1
[fold] More conditional compilation
thejohnfreeman Apr 2, 2021
220f440
[fold] Requested changes
thejohnfreeman Apr 30, 2021
7b459ca
[fold] Requested changes
thejohnfreeman May 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ target_sources (rippled PRIVATE
src/ripple/core/impl/LoadMonitor.cpp
src/ripple/core/impl/SNTPClock.cpp
src/ripple/core/impl/SociDB.cpp
src/ripple/core/impl/Stoppable.cpp
src/ripple/core/impl/TimeKeeper.cpp
src/ripple/core/impl/Workers.cpp
src/ripple/core/Pg.cpp
Expand Down Expand Up @@ -767,7 +766,6 @@ target_sources (rippled PRIVATE
src/test/core/CryptoPRNG_test.cpp
src/test/core/JobQueue_test.cpp
src/test/core/SociDB_test.cpp
src/test/core/Stoppable_test.cpp
src/test/core/Workers_test.cpp
#[===============================[
test sources:
Expand Down
4 changes: 1 addition & 3 deletions src/ripple/app/ledger/InboundLedgers.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define RIPPLE_APP_LEDGER_INBOUNDLEDGERS_H_INCLUDED

#include <ripple/app/ledger/InboundLedger.h>
#include <ripple/core/Stoppable.h>
#include <ripple/protocol/RippleLedgerHash.h>
#include <memory>

Expand Down Expand Up @@ -83,14 +82,13 @@ class InboundLedgers
sweep() = 0;

virtual void
onStop() = 0;
stop() = 0;
};

std::unique_ptr<InboundLedgers>
make_InboundLedgers(
Application& app,
InboundLedgers::clock_type& clock,
Stoppable& parent,
beast::insight::Collector::ptr const& collector);

} // namespace ripple
Expand Down
5 changes: 3 additions & 2 deletions src/ripple/app/ledger/InboundTransactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define RIPPLE_APP_LEDGER_INBOUNDTRANSACTIONS_H_INCLUDED

#include <ripple/beast/clock/abstract_clock.h>
#include <ripple/core/Stoppable.h>
#include <ripple/overlay/Peer.h>
#include <ripple/shamap/SHAMap.h>
#include <memory>
Expand Down Expand Up @@ -85,12 +84,14 @@ class InboundTransactions
*/
virtual void
newRound(std::uint32_t seq) = 0;

virtual void
stop() = 0;
};

std::unique_ptr<InboundTransactions>
make_InboundTransactions(
Application& app,
Stoppable& parent,
beast::insight::Collector::ptr const& collector,
std::function<void(std::shared_ptr<SHAMap> const&, bool)> gotSet);

Expand Down
24 changes: 14 additions & 10 deletions src/ripple/app/ledger/LedgerCleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,45 @@
#include <ripple/app/main/Application.h>
#include <ripple/beast/utility/Journal.h>
#include <ripple/beast/utility/PropertyStream.h>
#include <ripple/core/Stoppable.h>
#include <ripple/json/json_value.h>
#include <memory>

namespace ripple {
namespace detail {

/** Check the ledger/transaction databases to make sure they have continuity */
class LedgerCleaner : public Stoppable, public beast::PropertyStream::Source
class LedgerCleaner : public beast::PropertyStream::Source
{
protected:
explicit LedgerCleaner(Stoppable& parent);
LedgerCleaner() : beast::PropertyStream::Source("ledgercleaner")
{
}

public:
/** Destroy the object. */
virtual ~LedgerCleaner() = 0;
virtual ~LedgerCleaner() = default;

virtual void
start() = 0;

virtual void
stop() = 0;

/** Start a long running task to clean the ledger.
The ledger is cleaned asynchronously, on an implementation defined
thread. This function call does not block. The long running task
will be stopped if the Stoppable stops.
will be stopped by a call to stop().

Thread safety:
Safe to call from any thread at any time.

@param parameters A Json object with configurable parameters.
*/
virtual void
doClean(Json::Value const& parameters) = 0;
clean(Json::Value const& parameters) = 0;
};

std::unique_ptr<LedgerCleaner>
make_LedgerCleaner(Application& app, Stoppable& parent, beast::Journal journal);
make_LedgerCleaner(Application& app, beast::Journal journal);

} // namespace detail
} // namespace ripple

#endif
14 changes: 2 additions & 12 deletions src/ripple/app/ledger/LedgerMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@
#include <ripple/app/ledger/AbstractFetchPackContainer.h>
#include <ripple/app/ledger/InboundLedgers.h>
#include <ripple/app/ledger/Ledger.h>
#include <ripple/app/ledger/LedgerCleaner.h>
#include <ripple/app/ledger/LedgerHistory.h>
#include <ripple/app/ledger/LedgerHolder.h>
#include <ripple/app/ledger/LedgerReplay.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/CanonicalTXSet.h>
#include <ripple/basics/RangeSet.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/basics/UptimeClock.h>
ximinez marked this conversation as resolved.
Show resolved Hide resolved
#include <ripple/basics/chrono.h>
#include <ripple/beast/insight/Collector.h>
#include <ripple/beast/utility/PropertyStream.h>
#include <ripple/core/Stoppable.h>
#include <ripple/protocol/Protocol.h>
#include <ripple/protocol/RippleLedgerHash.h>
#include <ripple/protocol/STValidation.h>
Expand Down Expand Up @@ -69,7 +67,7 @@ class ReportingShouldProxy : public std::runtime_error
// Tracks the current ledger and any ledgers in the process of closing
// Tracks ledger history
// Tracks held transactions
class LedgerMaster : public Stoppable, public AbstractFetchPackContainer
class LedgerMaster : public AbstractFetchPackContainer
{
public:
// Age for last validated ledger if the process has yet to validate.
Expand All @@ -79,7 +77,6 @@ class LedgerMaster : public Stoppable, public AbstractFetchPackContainer
explicit LedgerMaster(
Application& app,
Stopwatch& stopwatch,
Stoppable& parent,
beast::insight::Collector::ptr const& collector,
beast::Journal journal);

Expand Down Expand Up @@ -259,11 +256,6 @@ class LedgerMaster : public Stoppable, public AbstractFetchPackContainer

bool
fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
void
doLedgerCleaner(Json::Value const& parameters);

beast::PropertyStream::Source&
getPropertySource();

void
clearPriorLedgers(LedgerIndex seq);
Expand Down Expand Up @@ -385,8 +377,6 @@ class LedgerMaster : public Stoppable, public AbstractFetchPackContainer
std::recursive_mutex mCompleteLock;
RangeSet<std::uint32_t> mCompleteLedgers;

std::unique_ptr<detail::LedgerCleaner> mLedgerCleaner;

// Publish thread is running.
bool mAdvanceThread{false};

Expand Down
8 changes: 3 additions & 5 deletions src/ripple/app/ledger/LedgerReplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <ripple/app/ledger/LedgerReplayTask.h>
#include <ripple/app/main/Application.h>
#include <ripple/beast/utility/Journal.h>
#include <ripple/core/Stoppable.h>

#include <memory>
#include <mutex>
Expand Down Expand Up @@ -70,14 +69,13 @@ std::uint32_t constexpr MAX_QUEUED_TASKS = 100;
/**
* Manages the lifetime of ledger replay tasks.
*/
class LedgerReplayer final : public Stoppable
class LedgerReplayer final
{
public:
LedgerReplayer(
Application& app,
InboundLedgers& inboundLedgers,
std::unique_ptr<PeerSetBuilder> peerSetBuilder,
Stoppable& parent);
std::unique_ptr<PeerSetBuilder> peerSetBuilder);

~LedgerReplayer();

Expand Down Expand Up @@ -125,7 +123,7 @@ class LedgerReplayer final : public Stoppable
sweep();

void
onStop() override;
stop();

private:
mutable std::mutex mtx_;
Expand Down
9 changes: 3 additions & 6 deletions src/ripple/app/ledger/OrderBookDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@

namespace ripple {

OrderBookDB::OrderBookDB(Application& app, Stoppable& parent)
: Stoppable("OrderBookDB", parent)
, app_(app)
, mSeq(0)
, j_(app.journal("OrderBookDB"))
OrderBookDB::OrderBookDB(Application& app)
: app_(app), mSeq(0), j_(app.journal("OrderBookDB"))
{
}

Expand Down Expand Up @@ -101,7 +98,7 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)
{
for (auto& sle : ledger->sles)
{
if (isStopping())
if (app_.isStopping())
{
JLOG(j_.info())
<< "OrderBookDB::update exiting due to isStopping";
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/ledger/OrderBookDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

namespace ripple {

class OrderBookDB : public Stoppable
class OrderBookDB
{
public:
OrderBookDB(Application& app, Stoppable& parent);
OrderBookDB(Application& app);

void
setup(std::shared_ptr<ReadView const> const& ledger);
Expand Down
22 changes: 10 additions & 12 deletions src/ripple/app/ledger/impl/InboundLedgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

namespace ripple {

class InboundLedgersImp : public InboundLedgers, public Stoppable
class InboundLedgersImp : public InboundLedgers
{
private:
Application& app_;
Expand All @@ -49,11 +49,9 @@ class InboundLedgersImp : public InboundLedgers, public Stoppable
InboundLedgersImp(
Application& app,
clock_type& clock,
Stoppable& parent,
beast::insight::Collector::ptr const& collector,
std::unique_ptr<PeerSetBuilder> peerSetBuilder)
: Stoppable("InboundLedgers", parent)
, app_(app)
: app_(app)
, fetchRate_(clock.now())
, j_(app.journal("InboundLedger"))
, m_clock(clock)
Expand All @@ -74,13 +72,15 @@ class InboundLedgersImp : public InboundLedgers, public Stoppable
assert(
reason != InboundLedger::Reason::SHARD ||
(seq != 0 && app_.getShardStore()));
if (isStopping())
return {};

bool isNew = true;
std::shared_ptr<InboundLedger> inbound;
{
ScopedLockType sl(mLock);
if (stopping_)
{
return {};
}
auto it = mLedgers.find(hash);
if (it != mLedgers.end())
{
Expand Down Expand Up @@ -389,14 +389,12 @@ class InboundLedgersImp : public InboundLedgers, public Stoppable
}

void
onStop() override
stop() override
{
ScopedLockType lock(mLock);

stopping_ = true;
mLedgers.clear();
mRecentFailures.clear();

stopped();
}

private:
Expand All @@ -405,6 +403,7 @@ class InboundLedgersImp : public InboundLedgers, public Stoppable
using ScopedLockType = std::unique_lock<std::recursive_mutex>;
std::recursive_mutex mLock;

bool stopping_ = false;
using MapType = hash_map<uint256, std::shared_ptr<InboundLedger>>;
MapType mLedgers;

Expand All @@ -421,11 +420,10 @@ std::unique_ptr<InboundLedgers>
make_InboundLedgers(
Application& app,
InboundLedgers::clock_type& clock,
Stoppable& parent,
beast::insight::Collector::ptr const& collector)
{
return std::make_unique<InboundLedgersImp>(
app, clock, parent, collector, make_PeerSetBuilder(app));
app, clock, collector, make_PeerSetBuilder(app));
}

} // namespace ripple
22 changes: 9 additions & 13 deletions src/ripple/app/ledger/impl/InboundTransactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,15 @@ class InboundTransactionSet
}
};

class InboundTransactionsImp : public InboundTransactions, public Stoppable
class InboundTransactionsImp : public InboundTransactions
{
public:
Application& app_;

InboundTransactionsImp(
Application& app,
Stoppable& parent,
beast::insight::Collector::ptr const& collector,
std::function<void(std::shared_ptr<SHAMap> const&, bool)> gotSet,
std::unique_ptr<PeerSetBuilder> peerSetBuilder)
: Stoppable("InboundTransactions", parent)
, app_(app)
: app_(app)
, m_seq(0)
, m_zeroSet(m_map[uint256()])
, m_gotSet(std::move(gotSet))
Expand Down Expand Up @@ -118,7 +114,7 @@ class InboundTransactionsImp : public InboundTransactions, public Stoppable
return it->second.mSet;
}

if (!acquire || isStopping())
if (!acquire || stopping_)
return std::shared_ptr<SHAMap>();

ta = std::make_shared<TransactionAcquire>(
Expand Down Expand Up @@ -242,20 +238,21 @@ class InboundTransactionsImp : public InboundTransactions, public Stoppable
}

void
onStop() override
stop() override
{
std::lock_guard lock(mLock);

stopping_ = true;
m_map.clear();

stopped();
}

private:
using MapType = hash_map<uint256, InboundTransactionSet>;

Application& app_;

std::recursive_mutex mLock;

bool stopping_{false};
MapType m_map;
std::uint32_t m_seq;

Expand All @@ -274,12 +271,11 @@ InboundTransactions::~InboundTransactions() = default;
std::unique_ptr<InboundTransactions>
make_InboundTransactions(
Application& app,
Stoppable& parent,
beast::insight::Collector::ptr const& collector,
std::function<void(std::shared_ptr<SHAMap> const&, bool)> gotSet)
{
return std::make_unique<InboundTransactionsImp>(
app, parent, collector, std::move(gotSet), make_PeerSetBuilder(app));
app, collector, std::move(gotSet), make_PeerSetBuilder(app));
}

} // namespace ripple
Loading