mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 02:25:53 +00:00
Refactor NodeStore:
Manager is changed to be a Meyer's singleton, with factories automatically registering upon construction.
This commit is contained in:
@@ -2403,33 +2403,21 @@
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\MemoryFactory.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\NullFactory.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\Database.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\DatabaseRotating.h">
|
||||
@@ -2472,9 +2460,11 @@
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\Manager.cpp">
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\impl\ManagerImp.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
||||
@@ -3405,39 +3405,21 @@
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\MemoryFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\NullFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.h">
|
||||
<Filter>ripple\nodestore\backend</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\Database.h">
|
||||
<Filter>ripple\nodestore</Filter>
|
||||
</ClInclude>
|
||||
@@ -3489,9 +3471,12 @@
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
|
||||
<Filter>ripple\nodestore\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\Manager.cpp">
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
|
||||
<Filter>ripple\nodestore\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\nodestore\impl\ManagerImp.h">
|
||||
<Filter>ripple\nodestore\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
|
||||
<Filter>ripple\nodestore\impl</Filter>
|
||||
</ClCompile>
|
||||
|
||||
23
SConstruct
23
SConstruct
@@ -580,11 +580,25 @@ for tu_style in ['classic', 'unity']:
|
||||
*list_sources('src/ripple/basics', '.cpp'))
|
||||
object_builder.add_source_files(
|
||||
*list_sources('src/ripple/protocol', '.cpp'))
|
||||
object_builder.add_source_files(
|
||||
*list_sources('src/ripple/nodestore', '.cpp'),
|
||||
CPPPATH=[
|
||||
'src/leveldb/include',
|
||||
#'src/hyperleveldb/include', # hyper
|
||||
'src/rocksdb2/include',
|
||||
])
|
||||
else:
|
||||
object_builder.add_source_files(
|
||||
'src/ripple/unity/basics.cpp',
|
||||
'src/ripple/unity/protocol.cpp',
|
||||
)
|
||||
object_builder.add_source_files(
|
||||
'src/ripple/unity/nodestore.cpp',
|
||||
CPPPATH=[
|
||||
'src/leveldb/include',
|
||||
#'src/hyperleveldb/include', # hyper
|
||||
'src/rocksdb2/include',
|
||||
])
|
||||
|
||||
object_builder.add_source_files(
|
||||
'src/ripple/unity/app.cpp',
|
||||
@@ -617,15 +631,6 @@ for tu_style in ['classic', 'unity']:
|
||||
'src/ripple/unity/beastc.c',
|
||||
CCFLAGS = ([] if toolchain == 'msvc' else ['-Wno-array-bounds']))
|
||||
|
||||
object_builder.add_source_files(
|
||||
'src/ripple/unity/nodestore.cpp',
|
||||
CPPPATH=[
|
||||
'src/leveldb/include',
|
||||
#'src/hyperleveldb/include', # hyper
|
||||
'src/rocksdb2/include',
|
||||
]
|
||||
)
|
||||
|
||||
if 'gcc' in toolchain:
|
||||
no_uninitialized_warning = {'CCFLAGS': ['-Wno-maybe-uninitialized']}
|
||||
else:
|
||||
|
||||
@@ -153,7 +153,6 @@ public:
|
||||
beast::Journal m_journal;
|
||||
Application::LockType m_masterMutex;
|
||||
|
||||
std::unique_ptr <NodeStore::Manager> m_nodeStoreManager;
|
||||
NodeStoreScheduler m_nodeStoreScheduler;
|
||||
std::unique_ptr <SHAMapStore> m_shaMapStore;
|
||||
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
||||
@@ -205,20 +204,6 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static
|
||||
std::vector <std::unique_ptr <NodeStore::Factory>>
|
||||
make_Factories (int hashnode_cache_size)
|
||||
{
|
||||
std::vector <std::unique_ptr <NodeStore::Factory>> list;
|
||||
|
||||
// VFALCO NOTE SqliteFactory is here because it has
|
||||
// dependencies like SqliteDatabase and DatabaseCon
|
||||
//
|
||||
list.emplace_back (make_SqliteFactory (hashnode_cache_size));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static
|
||||
std::size_t numberOfThreads()
|
||||
{
|
||||
@@ -238,16 +223,12 @@ public:
|
||||
|
||||
, m_journal (m_logs.journal("Application"))
|
||||
|
||||
, m_nodeStoreManager (NodeStore::make_Manager (
|
||||
std::move (make_Factories (
|
||||
getConfig ().getSize(siHashNodeDBCache) * 1024))))
|
||||
|
||||
, m_nodeStoreScheduler (*this)
|
||||
|
||||
, m_shaMapStore (make_SHAMapStore (setup_SHAMapStore (
|
||||
getConfig()), *this, *m_nodeStoreManager.get(),
|
||||
m_nodeStoreScheduler, m_logs.journal ("SHAMapStore"),
|
||||
m_logs.journal ("NodeObject"), m_txMaster))
|
||||
getConfig()), *this, m_nodeStoreScheduler,
|
||||
m_logs.journal ("SHAMapStore"), m_logs.journal ("NodeObject"),
|
||||
m_txMaster))
|
||||
|
||||
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
|
||||
|
||||
@@ -1392,10 +1373,10 @@ void ApplicationImp::updateTables ()
|
||||
if (getConfig ().doImport)
|
||||
{
|
||||
NodeStore::DummyScheduler scheduler;
|
||||
std::unique_ptr <NodeStore::Database> source (
|
||||
m_nodeStoreManager->make_Database ("NodeStore.import", scheduler,
|
||||
std::unique_ptr <NodeStore::Database> source =
|
||||
NodeStore::Manager::instance().make_Database ("NodeStore.import", scheduler,
|
||||
deprecatedLogs().journal("NodeObject"), 0,
|
||||
getConfig ().importNodeDatabase));
|
||||
getConfig ().importNodeDatabase);
|
||||
|
||||
WriteLog (lsWARNING, NodeObject) <<
|
||||
"Node import from '" << source->getName () << "' to '"
|
||||
|
||||
@@ -79,7 +79,6 @@ setup_SHAMapStore(Config const& c);
|
||||
std::unique_ptr<SHAMapStore>
|
||||
make_SHAMapStore(SHAMapStore::Setup const& s,
|
||||
beast::Stoppable& parent,
|
||||
NodeStore::Manager& manager,
|
||||
NodeStore::Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
beast::Journal nodeStoreJournal,
|
||||
|
||||
@@ -191,14 +191,12 @@ SHAMapStoreImp::SavedStateDB::checkError (beast::Error const& error)
|
||||
|
||||
SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
|
||||
Stoppable& parent,
|
||||
NodeStore::Manager& manager,
|
||||
NodeStore::Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
beast::Journal nodeStoreJournal,
|
||||
TransactionMaster& transactionMaster)
|
||||
: SHAMapStore (parent)
|
||||
, setup_ (setup)
|
||||
, manager_ (manager)
|
||||
, scheduler_ (scheduler)
|
||||
, journal_ (journal)
|
||||
, nodeStoreJournal_ (nodeStoreJournal)
|
||||
@@ -254,7 +252,7 @@ SHAMapStoreImp::makeDatabase (std::string const& name,
|
||||
}
|
||||
else
|
||||
{
|
||||
db = manager_.make_Database (name, scheduler_, nodeStoreJournal_,
|
||||
db = NodeStore::Manager::instance().make_Database (name, scheduler_, nodeStoreJournal_,
|
||||
readThreads, setup_.nodeDatabase,
|
||||
setup_.ephemeralNodeDatabase);
|
||||
}
|
||||
@@ -510,7 +508,7 @@ SHAMapStoreImp::makeBackendRotating (std::string path)
|
||||
}
|
||||
parameters.set("path", newPath.string());
|
||||
|
||||
return manager_.make_Backend (parameters, scheduler_,
|
||||
return NodeStore::Manager::instance().make_Backend (parameters, scheduler_,
|
||||
nodeStoreJournal_);
|
||||
}
|
||||
|
||||
@@ -522,10 +520,10 @@ SHAMapStoreImp::makeDatabaseRotating (std::string const& name,
|
||||
{
|
||||
std::unique_ptr <NodeStore::Backend> fastBackend (
|
||||
(setup_.ephemeralNodeDatabase.size() > 0)
|
||||
? manager_.make_Backend (setup_.ephemeralNodeDatabase,
|
||||
? NodeStore::Manager::instance().make_Backend (setup_.ephemeralNodeDatabase,
|
||||
scheduler_, journal_) : nullptr);
|
||||
|
||||
return manager_.make_DatabaseRotating ("NodeStore.main", scheduler_,
|
||||
return NodeStore::Manager::instance().make_DatabaseRotating ("NodeStore.main", scheduler_,
|
||||
readThreads, writableBackend, archiveBackend,
|
||||
std::move (fastBackend), nodeStoreJournal_);
|
||||
}
|
||||
@@ -710,13 +708,12 @@ setup_SHAMapStore (Config const& c)
|
||||
std::unique_ptr<SHAMapStore>
|
||||
make_SHAMapStore (SHAMapStore::Setup const& s,
|
||||
beast::Stoppable& parent,
|
||||
NodeStore::Manager& manager,
|
||||
NodeStore::Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
beast::Journal nodeStoreJournal,
|
||||
TransactionMaster& transactionMaster)
|
||||
{
|
||||
return std::make_unique<SHAMapStoreImp> (s, parent, manager, scheduler,
|
||||
return std::make_unique<SHAMapStoreImp> (s, parent, scheduler,
|
||||
journal, nodeStoreJournal, transactionMaster);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ private:
|
||||
std::uint32_t minimumDeletionInterval_ = 256;
|
||||
|
||||
Setup setup_;
|
||||
NodeStore::Manager& manager_;
|
||||
NodeStore::Scheduler& scheduler_;
|
||||
beast::Journal journal_;
|
||||
beast::Journal nodeStoreJournal_;
|
||||
@@ -107,7 +106,6 @@ private:
|
||||
public:
|
||||
SHAMapStoreImp (Setup const& setup,
|
||||
Stoppable& parent,
|
||||
NodeStore::Manager& manager,
|
||||
NodeStore::Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
beast::Journal nodeStoreJournal,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/node/SqliteFactory.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
@@ -225,13 +226,8 @@ private:
|
||||
|
||||
class SqliteFactory : public NodeStore::Factory
|
||||
{
|
||||
int hashnode_cache_size_;
|
||||
|
||||
public:
|
||||
SqliteFactory (int hashnode_cache_size)
|
||||
: hashnode_cache_size_ (hashnode_cache_size)
|
||||
{
|
||||
}
|
||||
SqliteFactory() = default;
|
||||
|
||||
std::string
|
||||
getName () const
|
||||
@@ -244,15 +240,11 @@ public:
|
||||
NodeStore::Scheduler&, beast::Journal)
|
||||
{
|
||||
return std::make_unique <SqliteBackend> (
|
||||
keyValues ["path"].toStdString (), hashnode_cache_size_);
|
||||
keyValues ["path"].toStdString (),
|
||||
getConfig ().getSize(siHashNodeDBCache) * 1024);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <NodeStore::Factory> make_SqliteFactory (int hashnode_cache_size)
|
||||
{
|
||||
return std::make_unique <SqliteFactory> (hashnode_cache_size);
|
||||
}
|
||||
static SqliteFactory sqliteFactory;
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
or other tasks scheduled, they will be completed before this call
|
||||
returns.
|
||||
*/
|
||||
virtual ~Backend () = 0;
|
||||
virtual ~Backend() = default;
|
||||
|
||||
/** Get the human-readable name of this backend.
|
||||
This is used for diagnostic output.
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
All pending operations are completed, pending writes flushed,
|
||||
and files closed before this returns.
|
||||
*/
|
||||
virtual ~Database () = 0 ;
|
||||
virtual ~Database() = default;
|
||||
|
||||
/** Retrieve the name associated with this backend.
|
||||
This is used for diagnostics and may not reflect the actual path
|
||||
|
||||
@@ -22,28 +22,34 @@
|
||||
|
||||
#include <ripple/nodestore/Backend.h>
|
||||
#include <ripple/nodestore/Scheduler.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce backends. */
|
||||
/** Base class for backend factories. */
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
virtual ~Factory () = 0;
|
||||
virtual
|
||||
~Factory() = default;
|
||||
|
||||
/** Retrieve the name of this factory. */
|
||||
virtual std::string getName () const = 0;
|
||||
virtual
|
||||
std::string
|
||||
getName() const = 0;
|
||||
|
||||
/** Create an instance of this factory's backend.
|
||||
|
||||
@param keyBytes The fixed number of bytes per key.
|
||||
@param keyValues A set of key/value configuration pairs.
|
||||
@param scheduler The scheduler to use for running tasks.
|
||||
@return A pointer to the Backend object.
|
||||
*/
|
||||
virtual std::unique_ptr <Backend> createInstance (size_t keyBytes,
|
||||
Parameters const& parameters, Scheduler& scheduler,
|
||||
beast::Journal journal) = 0;
|
||||
virtual
|
||||
std::unique_ptr <Backend>
|
||||
createInstance (size_t keyBytes, Parameters const& parameters,
|
||||
Scheduler& scheduler, beast::Journal journal) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -30,22 +30,31 @@ namespace NodeStore {
|
||||
class Manager
|
||||
{
|
||||
public:
|
||||
virtual ~Manager () = 0;
|
||||
/** Returns the instance of the manager singleton. */
|
||||
static
|
||||
Manager&
|
||||
instance();
|
||||
|
||||
/** Add the specified factory to the manager.
|
||||
Thread safety:
|
||||
Not thread-safe.
|
||||
*/
|
||||
virtual void add_factory (std::unique_ptr <Factory> factory) = 0;
|
||||
/** Add a factory. */
|
||||
virtual
|
||||
void
|
||||
insert (Factory& factory) = 0;
|
||||
|
||||
/** Remove a factory. */
|
||||
virtual
|
||||
void
|
||||
erase (Factory& factory) = 0;
|
||||
|
||||
/** Return a pointer to the matching factory if it exists.
|
||||
@param name The name to match, performed case-insensitive.
|
||||
@return `nullptr` if a match was not found.
|
||||
*/
|
||||
virtual Factory* find (std::string const& name) const = 0;
|
||||
//virtual Factory* find (std::string const& name) const = 0;
|
||||
|
||||
/** Create a backend. */
|
||||
virtual std::unique_ptr <Backend> make_Backend (Parameters const& parameters,
|
||||
virtual
|
||||
std::unique_ptr <Backend>
|
||||
make_Backend (Parameters const& parameters,
|
||||
Scheduler& scheduler, beast::Journal journal) = 0;
|
||||
|
||||
/** Construct a NodeStore database.
|
||||
@@ -72,30 +81,23 @@ public:
|
||||
|
||||
@return The opened database.
|
||||
*/
|
||||
virtual std::unique_ptr <Database> make_Database (std::string const& name,
|
||||
Scheduler& scheduler, beast::Journal journal, int readThreads,
|
||||
virtual
|
||||
std::unique_ptr <Database>
|
||||
make_Database (std::string const& name, Scheduler& scheduler,
|
||||
beast::Journal journal, int readThreads,
|
||||
Parameters const& backendParameters,
|
||||
Parameters fastBackendParameters = Parameters ()) = 0;
|
||||
Parameters fastBackendParameters = Parameters()) = 0;
|
||||
|
||||
virtual std::unique_ptr <DatabaseRotating> make_DatabaseRotating (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
std::int32_t readThreads,
|
||||
virtual
|
||||
std::unique_ptr <DatabaseRotating>
|
||||
make_DatabaseRotating (std::string const& name,
|
||||
Scheduler& scheduler, std::int32_t readThreads,
|
||||
std::shared_ptr <Backend> writableBackend,
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
std::unique_ptr <Backend> fastBackend,
|
||||
beast::Journal journal) = 0;
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
std::unique_ptr <Backend> fastBackend,
|
||||
beast::Journal journal) = 0;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Create a Manager.
|
||||
@param factories An optional array of additional factories to add.
|
||||
*/
|
||||
std::unique_ptr <Manager> make_Manager (
|
||||
std::vector <std::unique_ptr <Factory>> factories =
|
||||
std::vector <std::unique_ptr <Factory>>() );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_NODESTORE_SCHEDULER_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/Task.h>
|
||||
#include <chrono>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -52,7 +53,7 @@ struct BatchWriteReport
|
||||
class Scheduler
|
||||
{
|
||||
public:
|
||||
virtual ~Scheduler() = 0;
|
||||
virtual ~Scheduler() = default;
|
||||
|
||||
/** Schedules a task.
|
||||
Depending on the implementation, the task may be invoked either on
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace NodeStore {
|
||||
/** Derived classes perform scheduled tasks. */
|
||||
struct Task
|
||||
{
|
||||
virtual ~Task () = 0;
|
||||
virtual ~Task() = default;
|
||||
|
||||
/** Performs the task.
|
||||
The call may take place on a foreign thread.
|
||||
*/
|
||||
virtual void performScheduledTask () = 0;
|
||||
virtual void performScheduledTask() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,13 @@
|
||||
|
||||
#if RIPPLE_HYPERLEVELDB_AVAILABLE
|
||||
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/Config.h> // VFALCO Bad dependency
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -27,7 +33,6 @@ namespace NodeStore {
|
||||
class HyperDBBackend
|
||||
: public Backend
|
||||
, public BatchWriter::Callback
|
||||
, public beast::LeakChecked <HyperDBBackend>
|
||||
{
|
||||
private:
|
||||
std::atomic <bool> m_deletePath;
|
||||
@@ -249,6 +254,16 @@ public:
|
||||
class HyperDBFactory : public NodeStore::Factory
|
||||
{
|
||||
public:
|
||||
HyperDBFactory()
|
||||
{
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~HyperDBFactory()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
getName () const
|
||||
{
|
||||
@@ -267,13 +282,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory>
|
||||
make_HyperDBFactory ()
|
||||
{
|
||||
return std::make_unique <HyperDBFactory> ();
|
||||
}
|
||||
static HyperDBFactory hyperDBFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_HYPERDBFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_HYPERDBFACTORY_H_INCLUDED
|
||||
|
||||
#if RIPPLE_HYPERLEVELDB_AVAILABLE
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce HyperLevelDB backends for the NodeStore.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_HyperDBFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,13 @@
|
||||
|
||||
#if RIPPLE_LEVELDB_AVAILABLE
|
||||
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/Config.h> // VFALCO Bad dependency
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -27,7 +33,6 @@ namespace NodeStore {
|
||||
class LevelDBBackend
|
||||
: public Backend
|
||||
, public BatchWriter::Callback
|
||||
, public beast::LeakChecked <LevelDBBackend>
|
||||
{
|
||||
private:
|
||||
std::atomic <bool> m_deletePath;
|
||||
@@ -268,10 +273,13 @@ public:
|
||||
options.block_cache = leveldb::NewLRUCache (
|
||||
getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
|
||||
m_lruCache.reset (options.block_cache);
|
||||
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~LevelDBFactory()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -294,11 +302,7 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory>
|
||||
make_LevelDBFactory ()
|
||||
{
|
||||
return std::make_unique <LevelDBFactory> ();
|
||||
}
|
||||
static LevelDBFactory levelDBFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_LEVELDBFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_LEVELDBFACTORY_H_INCLUDED
|
||||
|
||||
#if RIPPLE_LEVELDB_AVAILABLE
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce LevelDBFactory backends for the NodeStore.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_LevelDBFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
@@ -108,6 +112,16 @@ public:
|
||||
class MemoryFactory : public Factory
|
||||
{
|
||||
public:
|
||||
MemoryFactory()
|
||||
{
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~MemoryFactory()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
getName () const
|
||||
{
|
||||
@@ -128,11 +142,7 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory>
|
||||
make_MemoryFactory ()
|
||||
{
|
||||
return std::make_unique <MemoryFactory> ();
|
||||
}
|
||||
static MemoryFactory memoryFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_MEMORYFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_MEMORYFACTORY_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce a RAM based backend for the NodeStore.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_MemoryFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
@@ -75,6 +79,16 @@ private:
|
||||
class NullFactory : public Factory
|
||||
{
|
||||
public:
|
||||
NullFactory()
|
||||
{
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~NullFactory()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
getName () const
|
||||
{
|
||||
@@ -91,12 +105,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory> make_NullFactory ()
|
||||
{
|
||||
return std::make_unique <NullFactory> ();
|
||||
}
|
||||
static NullFactory nullFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_NULLFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_NULLFACTORY_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce a null backend.
|
||||
This is for standalone / testing mode.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_NullFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,9 +19,15 @@
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/Config.h> // VFALCO Bad dependency
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <atomic>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -77,7 +83,6 @@ public:
|
||||
class RocksDBBackend
|
||||
: public Backend
|
||||
, public BatchWriter::Callback
|
||||
, public beast::LeakChecked <RocksDBBackend>
|
||||
{
|
||||
private:
|
||||
std::atomic <bool> m_deletePath;
|
||||
@@ -367,10 +372,13 @@ public:
|
||||
getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
|
||||
|
||||
m_lruCache = table_options.block_cache;
|
||||
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~RocksDBFactory ()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -391,13 +399,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory>
|
||||
make_RocksDBFactory ()
|
||||
{
|
||||
return std::make_unique <RocksDBFactory> ();
|
||||
}
|
||||
static RocksDBFactory rocksDBFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_ROCKSDBFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_ROCKSDBFACTORY_H_INCLUDED
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce RocksDB backends for the NodeStore.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_RocksDBFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,9 +19,14 @@
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/Config.h> // VFALCO Bad dependency
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <atomic>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -76,7 +81,6 @@ public:
|
||||
|
||||
class RocksDBQuickBackend
|
||||
: public Backend
|
||||
, public beast::LeakChecked <RocksDBQuickBackend>
|
||||
{
|
||||
private:
|
||||
std::atomic <bool> m_deletePath;
|
||||
@@ -328,15 +332,16 @@ public:
|
||||
class RocksDBQuickFactory : public Factory
|
||||
{
|
||||
public:
|
||||
std::shared_ptr <rocksdb::Cache> m_lruCache;
|
||||
RockDBQuickEnv m_env;
|
||||
|
||||
RocksDBQuickFactory ()
|
||||
RocksDBQuickFactory()
|
||||
{
|
||||
Manager::instance().insert(*this);
|
||||
}
|
||||
|
||||
~RocksDBQuickFactory ()
|
||||
~RocksDBQuickFactory()
|
||||
{
|
||||
Manager::instance().erase(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -357,13 +362,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr <Factory>
|
||||
make_RocksDBQuickFactory ()
|
||||
{
|
||||
return std::make_unique <RocksDBQuickFactory> ();
|
||||
}
|
||||
static RocksDBQuickFactory rocksDBQuickFactory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_ROCKSDBQUICKFACTORY_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_ROCKSDBQUICKFACTORY_H_INCLUDED
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
/** Factory to produce experimental RocksDB backends for the NodeStore.
|
||||
@see Database
|
||||
*/
|
||||
std::unique_ptr <Factory> make_RocksDBQuickFactory ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
Backend::~Backend ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
Database::~Database ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,14 @@
|
||||
#ifndef RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED
|
||||
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <ripple/nodestore/Scheduler.h>
|
||||
#include <ripple/nodestore/impl/Tuning.h>
|
||||
#include <ripple/basics/TaggedCache.h>
|
||||
#include <ripple/basics/KeyCache.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/seconds_clock.h>
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <set>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <beast/ByteOrder.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <beast/ByteOrder.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
#ifndef RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/NodeObject.h>
|
||||
#include <beast/module/core/memory/MemoryBlock.h>
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -34,13 +37,13 @@ struct EncodedBlob
|
||||
public:
|
||||
void prepare (NodeObject::Ptr const& object);
|
||||
void const* getKey () const noexcept { return m_key; }
|
||||
size_t getSize () const noexcept { return m_size; }
|
||||
std::size_t getSize () const noexcept { return m_size; }
|
||||
void const* getData () const noexcept { return m_data.getData (); }
|
||||
|
||||
private:
|
||||
void const* m_key;
|
||||
beast::MemoryBlock m_data;
|
||||
size_t m_size;
|
||||
std::size_t m_size;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
Factory::~Factory ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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 <ripple/nodestore/Manager.h>
|
||||
|
||||
#include <beast/utility/ci_char_traits.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
class ManagerImp : public Manager
|
||||
{
|
||||
public:
|
||||
typedef std::vector <std::unique_ptr <Factory>> List;
|
||||
List m_list;
|
||||
|
||||
explicit ManagerImp (std::vector <std::unique_ptr <Factory>>&& factories)
|
||||
: m_list (std::move (factories))
|
||||
{
|
||||
add_known_factories ();
|
||||
}
|
||||
|
||||
~ManagerImp ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
add_factory (std::unique_ptr <Factory> factory)
|
||||
{
|
||||
m_list.emplace_back (std::move (factory));
|
||||
}
|
||||
|
||||
void
|
||||
add_known_factories ()
|
||||
{
|
||||
// This is part of the ripple_app module since it has dependencies
|
||||
//addFactory (make_SqliteFactory ());
|
||||
|
||||
add_factory (make_LevelDBFactory ());
|
||||
|
||||
add_factory (make_MemoryFactory ());
|
||||
add_factory (make_NullFactory ());
|
||||
|
||||
#if RIPPLE_HYPERLEVELDB_AVAILABLE
|
||||
add_factory (make_HyperDBFactory ());
|
||||
#endif
|
||||
|
||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||
add_factory (make_RocksDBFactory ());
|
||||
add_factory (make_RocksDBQuickFactory ());
|
||||
#endif
|
||||
}
|
||||
|
||||
Factory*
|
||||
find (std::string const& name) const
|
||||
{
|
||||
for (List::const_iterator iter (m_list.begin ());
|
||||
iter != m_list.end (); ++iter)
|
||||
{
|
||||
if (beast::ci_equal ((*iter)->getName(), name))
|
||||
return iter->get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void
|
||||
missing_backend ()
|
||||
{
|
||||
throw std::runtime_error (
|
||||
"Your rippled.cfg is missing a [node_db] entry, "
|
||||
"please see the rippled-example.cfg file!"
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr <Backend>
|
||||
make_Backend (
|
||||
Parameters const& parameters,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal)
|
||||
{
|
||||
std::unique_ptr <Backend> backend;
|
||||
|
||||
std::string const type (parameters ["type"].toStdString ());
|
||||
|
||||
if (! type.empty ())
|
||||
{
|
||||
Factory* const factory (find (type));
|
||||
|
||||
if (factory != nullptr)
|
||||
{
|
||||
backend = factory->createInstance (
|
||||
NodeObject::keyBytes, parameters, scheduler, journal);
|
||||
}
|
||||
else
|
||||
{
|
||||
missing_backend ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
missing_backend ();
|
||||
}
|
||||
|
||||
return backend;
|
||||
}
|
||||
|
||||
std::unique_ptr <Database>
|
||||
make_Database (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
int readThreads,
|
||||
Parameters const& backendParameters,
|
||||
Parameters fastBackendParameters)
|
||||
{
|
||||
std::unique_ptr <Backend> backend (make_Backend (
|
||||
backendParameters, scheduler, journal));
|
||||
|
||||
std::unique_ptr <Backend> fastBackend (
|
||||
(fastBackendParameters.size () > 0)
|
||||
? make_Backend (fastBackendParameters, scheduler, journal)
|
||||
: nullptr);
|
||||
|
||||
return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
|
||||
std::move (backend), std::move (fastBackend), journal);
|
||||
}
|
||||
|
||||
std::unique_ptr <DatabaseRotating>
|
||||
make_DatabaseRotating (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
std::int32_t readThreads,
|
||||
std::shared_ptr <Backend> writableBackend,
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
std::unique_ptr <Backend> fastBackend,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
|
||||
readThreads, writableBackend, archiveBackend,
|
||||
std::move (fastBackend), journal);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Manager::~Manager ()
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr <Manager>
|
||||
make_Manager (std::vector <std::unique_ptr <Factory>> factories)
|
||||
{
|
||||
return std::make_unique <ManagerImp> (std::move (factories));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
163
src/ripple/nodestore/impl/ManagerImp.cpp
Normal file
163
src/ripple/nodestore/impl/ManagerImp.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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 <ripple/nodestore/impl/ManagerImp.h>
|
||||
#include <ripple/nodestore/impl/DatabaseImp.h>
|
||||
#include <ripple/nodestore/impl/DatabaseRotatingImp.h>
|
||||
#include <beast/utility/ci_char_traits.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
ManagerImp&
|
||||
ManagerImp::instance()
|
||||
{
|
||||
static beast::static_initializer<ManagerImp> _;
|
||||
return _.get();
|
||||
}
|
||||
|
||||
void
|
||||
ManagerImp::missing_backend()
|
||||
{
|
||||
throw std::runtime_error (
|
||||
"Your rippled.cfg is missing a [node_db] entry, "
|
||||
"please see the rippled-example.cfg file!"
|
||||
);
|
||||
}
|
||||
|
||||
ManagerImp::ManagerImp()
|
||||
{
|
||||
}
|
||||
|
||||
ManagerImp::~ManagerImp()
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr <Backend>
|
||||
ManagerImp::make_Backend (
|
||||
Parameters const& parameters,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal)
|
||||
{
|
||||
std::unique_ptr <Backend> backend;
|
||||
|
||||
std::string const type (parameters ["type"].toStdString ());
|
||||
|
||||
if (! type.empty ())
|
||||
{
|
||||
Factory* const factory (find (type));
|
||||
|
||||
if (factory != nullptr)
|
||||
{
|
||||
backend = factory->createInstance (
|
||||
NodeObject::keyBytes, parameters, scheduler, journal);
|
||||
}
|
||||
else
|
||||
{
|
||||
missing_backend ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
missing_backend ();
|
||||
}
|
||||
|
||||
return backend;
|
||||
}
|
||||
|
||||
std::unique_ptr <Database>
|
||||
ManagerImp::make_Database (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
int readThreads,
|
||||
Parameters const& backendParameters,
|
||||
Parameters fastBackendParameters)
|
||||
{
|
||||
std::unique_ptr <Backend> backend (make_Backend (
|
||||
backendParameters, scheduler, journal));
|
||||
|
||||
std::unique_ptr <Backend> fastBackend (
|
||||
(fastBackendParameters.size () > 0)
|
||||
? make_Backend (fastBackendParameters, scheduler, journal)
|
||||
: nullptr);
|
||||
|
||||
return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
|
||||
std::move (backend), std::move (fastBackend), journal);
|
||||
}
|
||||
|
||||
std::unique_ptr <DatabaseRotating>
|
||||
ManagerImp::make_DatabaseRotating (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
std::int32_t readThreads,
|
||||
std::shared_ptr <Backend> writableBackend,
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
std::unique_ptr <Backend> fastBackend,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
|
||||
readThreads, writableBackend, archiveBackend,
|
||||
std::move (fastBackend), journal);
|
||||
}
|
||||
|
||||
Factory*
|
||||
ManagerImp::find (std::string const& name)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(mutex_);
|
||||
auto const iter = std::find_if(list_.begin(), list_.end(),
|
||||
[&name](Factory* other)
|
||||
{
|
||||
return beast::ci_equal(name, other->getName());
|
||||
} );
|
||||
if (iter == list_.end())
|
||||
return nullptr;
|
||||
return *iter;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ManagerImp::insert (Factory& factory)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(mutex_);
|
||||
list_.push_back(&factory);
|
||||
}
|
||||
|
||||
void
|
||||
ManagerImp::erase (Factory& factory)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(mutex_);
|
||||
auto const iter = std::find_if(list_.begin(), list_.end(),
|
||||
[&factory](Factory* other) { return other == &factory; });
|
||||
assert(iter != list_.end());
|
||||
list_.erase(iter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Manager&
|
||||
Manager::instance()
|
||||
{
|
||||
return ManagerImp::instance();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
87
src/ripple/nodestore/impl/ManagerImp.h
Normal file
87
src/ripple/nodestore/impl/ManagerImp.h
Normal file
@@ -0,0 +1,87 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NODESTORE_MANAGERIMP_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_MANAGERIMP_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
class ManagerImp : public Manager
|
||||
{
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::vector<Factory*> list_;
|
||||
|
||||
public:
|
||||
static
|
||||
ManagerImp&
|
||||
instance();
|
||||
|
||||
static
|
||||
void
|
||||
missing_backend();
|
||||
|
||||
ManagerImp();
|
||||
|
||||
~ManagerImp();
|
||||
|
||||
Factory*
|
||||
find (std::string const& name);
|
||||
|
||||
void
|
||||
insert (Factory& factory) override;
|
||||
|
||||
void
|
||||
erase (Factory& factory) override;
|
||||
|
||||
std::unique_ptr <Backend>
|
||||
make_Backend (
|
||||
Parameters const& parameters,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal) override;
|
||||
|
||||
std::unique_ptr <Database>
|
||||
make_Database (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal,
|
||||
int readThreads,
|
||||
Parameters const& backendParameters,
|
||||
Parameters fastBackendParameters) override;
|
||||
|
||||
std::unique_ptr <DatabaseRotating>
|
||||
make_DatabaseRotating (
|
||||
std::string const& name,
|
||||
Scheduler& scheduler,
|
||||
std::int32_t readThreads,
|
||||
std::shared_ptr <Backend> writableBackend,
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
std::unique_ptr <Backend> fastBackend,
|
||||
beast::Journal journal) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/NodeObject.h>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
Scheduler::~Scheduler ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
Task::~Task ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/tests/Base.test.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -31,8 +33,6 @@ public:
|
||||
void testBackend (std::string const& type, std::int64_t const seedValue,
|
||||
int numObjectsToTest = 2000)
|
||||
{
|
||||
std::unique_ptr <Manager> manager (make_Manager ());
|
||||
|
||||
DummyScheduler scheduler;
|
||||
|
||||
testcase ("Backend type=" + type);
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
|
||||
{
|
||||
// Open the backend
|
||||
std::unique_ptr <Backend> backend (manager->make_Backend (
|
||||
params, scheduler, j));
|
||||
std::unique_ptr <Backend> backend =
|
||||
Manager::instance().make_Backend (params, scheduler, j);
|
||||
|
||||
// Write the batch
|
||||
storeBatch (*backend, batch);
|
||||
@@ -74,8 +74,8 @@ public:
|
||||
|
||||
{
|
||||
// Re-open the backend
|
||||
std::unique_ptr <Backend> backend (manager->make_Backend (
|
||||
params, scheduler, j));
|
||||
std::unique_ptr <Backend> backend = Manager::instance().make_Backend (
|
||||
params, scheduler, j);
|
||||
|
||||
// Read it back in
|
||||
Batch copy;
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#ifndef RIPPLE_NODESTORE_TESTBASE_H_INCLUDED
|
||||
#define RIPPLE_NODESTORE_TESTBASE_H_INCLUDED
|
||||
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <beast/module/core/maths/Random.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/tests/Base.test.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/tests/Base.test.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace NodeStore {
|
||||
@@ -28,8 +31,6 @@ public:
|
||||
void testImport (std::string const& destBackendType,
|
||||
std::string const& srcBackendType, std::int64_t seedValue)
|
||||
{
|
||||
std::unique_ptr <Manager> manager (make_Manager ());
|
||||
|
||||
DummyScheduler scheduler;
|
||||
|
||||
beast::UnitTestUtilities::TempDirectory node_db ("node_db");
|
||||
@@ -45,8 +46,8 @@ public:
|
||||
|
||||
// Write to source db
|
||||
{
|
||||
std::unique_ptr <Database> src (manager->make_Database (
|
||||
"test", scheduler, j, 2, srcParams));
|
||||
std::unique_ptr <Database> src = Manager::instance().make_Database (
|
||||
"test", scheduler, j, 2, srcParams);
|
||||
storeBatch (*src, batch);
|
||||
}
|
||||
|
||||
@@ -54,8 +55,8 @@ public:
|
||||
|
||||
{
|
||||
// Re-open the db
|
||||
std::unique_ptr <Database> src (manager->make_Database (
|
||||
"test", scheduler, j, 2, srcParams));
|
||||
std::unique_ptr <Database> src = Manager::instance().make_Database (
|
||||
"test", scheduler, j, 2, srcParams);
|
||||
|
||||
// Set up the destination database
|
||||
beast::UnitTestUtilities::TempDirectory dest_db ("dest_db");
|
||||
@@ -63,8 +64,8 @@ public:
|
||||
destParams.set ("type", destBackendType);
|
||||
destParams.set ("path", dest_db.getFullPathName ());
|
||||
|
||||
std::unique_ptr <Database> dest (manager->make_Database (
|
||||
"test", scheduler, j, 2, destParams));
|
||||
std::unique_ptr <Database> dest = Manager::instance().make_Database (
|
||||
"test", scheduler, j, 2, destParams);
|
||||
|
||||
testcase ("import into '" + destBackendType +
|
||||
"' from '" + srcBackendType + "'");
|
||||
@@ -90,8 +91,6 @@ public:
|
||||
std::int64_t const seedValue,
|
||||
int numObjectsToTest = 2000)
|
||||
{
|
||||
std::unique_ptr <Manager> manager (make_Manager ());
|
||||
|
||||
DummyScheduler scheduler;
|
||||
|
||||
std::string s = "NodeStore backend '" + type + "'";
|
||||
@@ -121,8 +120,8 @@ public:
|
||||
|
||||
{
|
||||
// Open the database
|
||||
std::unique_ptr <Database> db (manager->make_Database ("test", scheduler,
|
||||
j, 2, nodeParams, tempParams));
|
||||
std::unique_ptr <Database> db = Manager::instance().make_Database (
|
||||
"test", scheduler, j, 2, nodeParams, tempParams);
|
||||
|
||||
// Write the batch
|
||||
storeBatch (*db, batch);
|
||||
@@ -147,8 +146,8 @@ public:
|
||||
{
|
||||
{
|
||||
// Re-open the database without the ephemeral DB
|
||||
std::unique_ptr <Database> db (manager->make_Database (
|
||||
"test", scheduler, j, 2, nodeParams));
|
||||
std::unique_ptr <Database> db = Manager::instance().make_Database (
|
||||
"test", scheduler, j, 2, nodeParams);
|
||||
|
||||
// Read it back in
|
||||
Batch copy;
|
||||
@@ -163,8 +162,8 @@ public:
|
||||
if (useEphemeralDatabase)
|
||||
{
|
||||
// Verify the ephemeral db
|
||||
std::unique_ptr <Database> db (manager->make_Database ("test",
|
||||
scheduler, j, 2, tempParams, beast::StringPairArray ()));
|
||||
std::unique_ptr <Database> db = Manager::instance().make_Database ("test",
|
||||
scheduler, j, 2, tempParams, beast::StringPairArray ());
|
||||
|
||||
// Read it back in
|
||||
Batch copy;
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/nodestore/tests/Base.test.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||
#include <limits>
|
||||
|
||||
namespace ripple {
|
||||
@@ -210,7 +213,6 @@ public:
|
||||
|
||||
using check_func = std::function<bool(Status const)>;
|
||||
using backend_ptr = std::unique_ptr<Backend>;
|
||||
using manager_ptr = std::unique_ptr<Manager>;
|
||||
using result_type = std::vector<std::pair<std::string, double>>;
|
||||
|
||||
static bool checkNotFound(Status const status)
|
||||
@@ -265,11 +267,10 @@ public:
|
||||
Stopwatch t;
|
||||
result_type results;
|
||||
|
||||
auto manager = make_Manager();
|
||||
DummyScheduler scheduler;
|
||||
beast::Journal j;
|
||||
|
||||
auto backend = manager->make_Backend(params, scheduler, j);
|
||||
auto backend = Manager::instance().make_Backend(params, scheduler, j);
|
||||
|
||||
NodeFactory insertFactory(seedValue, numObjects, 0, numObjects);
|
||||
NodeFactory batchFactory(seedValue, numObjects, numObjects * 10,
|
||||
|
||||
@@ -17,52 +17,29 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
//#include <memory>
|
||||
//#include <vector>
|
||||
|
||||
// backend support
|
||||
#include <ripple/unity/leveldb.h>
|
||||
#include <ripple/unity/hyperleveldb.h>
|
||||
#include <ripple/unity/rocksdb.h>
|
||||
|
||||
#include <beast/cxx14/memory.h>
|
||||
|
||||
#include <ripple/basics/seconds_clock.h>
|
||||
#include <ripple/basics/TaggedCache.h>
|
||||
#include <ripple/basics/KeyCache.h>
|
||||
|
||||
#include <ripple/nodestore/impl/Tuning.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
|
||||
#include <ripple/nodestore/backend/HyperDBFactory.h>
|
||||
#include <ripple/nodestore/backend/HyperDBFactory.cpp>
|
||||
#include <ripple/nodestore/backend/LevelDBFactory.h>
|
||||
#include <ripple/nodestore/backend/LevelDBFactory.cpp>
|
||||
#include <ripple/nodestore/backend/MemoryFactory.h>
|
||||
#include <ripple/nodestore/backend/MemoryFactory.cpp>
|
||||
#include <ripple/nodestore/backend/NullFactory.h>
|
||||
#include <ripple/nodestore/backend/NullFactory.cpp>
|
||||
#include <ripple/nodestore/backend/RocksDBFactory.h>
|
||||
#include <ripple/nodestore/backend/RocksDBFactory.cpp>
|
||||
#include <ripple/nodestore/backend/RocksDBQuickFactory.h>
|
||||
#include <ripple/nodestore/backend/RocksDBQuickFactory.cpp>
|
||||
|
||||
#include <ripple/nodestore/impl/Backend.cpp>
|
||||
#include <ripple/nodestore/impl/BatchWriter.cpp>
|
||||
#include <ripple/nodestore/impl/DatabaseImp.h>
|
||||
#include <ripple/nodestore/impl/DatabaseRotatingImp.h>
|
||||
#include <ripple/nodestore/impl/Database.cpp>
|
||||
#include <ripple/nodestore/impl/DatabaseRotatingImp.cpp>
|
||||
#include <ripple/nodestore/impl/DummyScheduler.cpp>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.cpp>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.cpp>
|
||||
#include <ripple/nodestore/impl/Factory.cpp>
|
||||
#include <ripple/nodestore/impl/Manager.cpp>
|
||||
#include <ripple/nodestore/impl/ManagerImp.cpp>
|
||||
#include <ripple/nodestore/impl/NodeObject.cpp>
|
||||
#include <ripple/nodestore/impl/Scheduler.cpp>
|
||||
#include <ripple/nodestore/impl/Task.cpp>
|
||||
|
||||
#include <ripple/nodestore/tests/Backend.test.cpp>
|
||||
#include <ripple/nodestore/tests/Basics.test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user