Refactor NodeStore:

Manager is changed to be a Meyer's singleton, with factories automatically
registering upon construction.
This commit is contained in:
Vinnie Falco
2014-12-28 08:24:48 -08:00
parent 6283801981
commit 96fbcc9a5a
46 changed files with 471 additions and 780 deletions

View File

@@ -2403,33 +2403,21 @@
<ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\MemoryFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\NullFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\nodestore\Database.h"> <ClInclude Include="..\..\src\ripple\nodestore\Database.h">
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\ripple\nodestore\DatabaseRotating.h"> <ClInclude Include="..\..\src\ripple\nodestore\DatabaseRotating.h">
@@ -2472,9 +2460,11 @@
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Manager.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\ManagerImp.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>

View File

@@ -3405,39 +3405,21 @@
<ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\HyperDBFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\LevelDBFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\MemoryFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\MemoryFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\NullFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\NullFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.cpp">
<Filter>ripple\nodestore\backend</Filter> <Filter>ripple\nodestore\backend</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\backend\RocksDBQuickFactory.h">
<Filter>ripple\nodestore\backend</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\nodestore\Database.h"> <ClInclude Include="..\..\src\ripple\nodestore\Database.h">
<Filter>ripple\nodestore</Filter> <Filter>ripple\nodestore</Filter>
</ClInclude> </ClInclude>
@@ -3489,9 +3471,12 @@
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
<Filter>ripple\nodestore\impl</Filter> <Filter>ripple\nodestore\impl</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Manager.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
<Filter>ripple\nodestore\impl</Filter> <Filter>ripple\nodestore\impl</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\ManagerImp.h">
<Filter>ripple\nodestore\impl</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp"> <ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
<Filter>ripple\nodestore\impl</Filter> <Filter>ripple\nodestore\impl</Filter>
</ClCompile> </ClCompile>

View File

@@ -580,11 +580,25 @@ for tu_style in ['classic', 'unity']:
*list_sources('src/ripple/basics', '.cpp')) *list_sources('src/ripple/basics', '.cpp'))
object_builder.add_source_files( object_builder.add_source_files(
*list_sources('src/ripple/protocol', '.cpp')) *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: else:
object_builder.add_source_files( object_builder.add_source_files(
'src/ripple/unity/basics.cpp', 'src/ripple/unity/basics.cpp',
'src/ripple/unity/protocol.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( object_builder.add_source_files(
'src/ripple/unity/app.cpp', 'src/ripple/unity/app.cpp',
@@ -617,15 +631,6 @@ for tu_style in ['classic', 'unity']:
'src/ripple/unity/beastc.c', 'src/ripple/unity/beastc.c',
CCFLAGS = ([] if toolchain == 'msvc' else ['-Wno-array-bounds'])) 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: if 'gcc' in toolchain:
no_uninitialized_warning = {'CCFLAGS': ['-Wno-maybe-uninitialized']} no_uninitialized_warning = {'CCFLAGS': ['-Wno-maybe-uninitialized']}
else: else:

View File

@@ -153,7 +153,6 @@ public:
beast::Journal m_journal; beast::Journal m_journal;
Application::LockType m_masterMutex; Application::LockType m_masterMutex;
std::unique_ptr <NodeStore::Manager> m_nodeStoreManager;
NodeStoreScheduler m_nodeStoreScheduler; NodeStoreScheduler m_nodeStoreScheduler;
std::unique_ptr <SHAMapStore> m_shaMapStore; std::unique_ptr <SHAMapStore> m_shaMapStore;
std::unique_ptr <NodeStore::Database> m_nodeStore; 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 static
std::size_t numberOfThreads() std::size_t numberOfThreads()
{ {
@@ -238,16 +223,12 @@ public:
, m_journal (m_logs.journal("Application")) , m_journal (m_logs.journal("Application"))
, m_nodeStoreManager (NodeStore::make_Manager (
std::move (make_Factories (
getConfig ().getSize(siHashNodeDBCache) * 1024))))
, m_nodeStoreScheduler (*this) , m_nodeStoreScheduler (*this)
, m_shaMapStore (make_SHAMapStore (setup_SHAMapStore ( , m_shaMapStore (make_SHAMapStore (setup_SHAMapStore (
getConfig()), *this, *m_nodeStoreManager.get(), getConfig()), *this, m_nodeStoreScheduler,
m_nodeStoreScheduler, m_logs.journal ("SHAMapStore"), m_logs.journal ("SHAMapStore"), m_logs.journal ("NodeObject"),
m_logs.journal ("NodeObject"), m_txMaster)) m_txMaster))
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4)) , m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
@@ -1392,10 +1373,10 @@ void ApplicationImp::updateTables ()
if (getConfig ().doImport) if (getConfig ().doImport)
{ {
NodeStore::DummyScheduler scheduler; NodeStore::DummyScheduler scheduler;
std::unique_ptr <NodeStore::Database> source ( std::unique_ptr <NodeStore::Database> source =
m_nodeStoreManager->make_Database ("NodeStore.import", scheduler, NodeStore::Manager::instance().make_Database ("NodeStore.import", scheduler,
deprecatedLogs().journal("NodeObject"), 0, deprecatedLogs().journal("NodeObject"), 0,
getConfig ().importNodeDatabase)); getConfig ().importNodeDatabase);
WriteLog (lsWARNING, NodeObject) << WriteLog (lsWARNING, NodeObject) <<
"Node import from '" << source->getName () << "' to '" "Node import from '" << source->getName () << "' to '"

View File

@@ -79,7 +79,6 @@ setup_SHAMapStore(Config const& c);
std::unique_ptr<SHAMapStore> std::unique_ptr<SHAMapStore>
make_SHAMapStore(SHAMapStore::Setup const& s, make_SHAMapStore(SHAMapStore::Setup const& s,
beast::Stoppable& parent, beast::Stoppable& parent,
NodeStore::Manager& manager,
NodeStore::Scheduler& scheduler, NodeStore::Scheduler& scheduler,
beast::Journal journal, beast::Journal journal,
beast::Journal nodeStoreJournal, beast::Journal nodeStoreJournal,

View File

@@ -191,14 +191,12 @@ SHAMapStoreImp::SavedStateDB::checkError (beast::Error const& error)
SHAMapStoreImp::SHAMapStoreImp (Setup const& setup, SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
Stoppable& parent, Stoppable& parent,
NodeStore::Manager& manager,
NodeStore::Scheduler& scheduler, NodeStore::Scheduler& scheduler,
beast::Journal journal, beast::Journal journal,
beast::Journal nodeStoreJournal, beast::Journal nodeStoreJournal,
TransactionMaster& transactionMaster) TransactionMaster& transactionMaster)
: SHAMapStore (parent) : SHAMapStore (parent)
, setup_ (setup) , setup_ (setup)
, manager_ (manager)
, scheduler_ (scheduler) , scheduler_ (scheduler)
, journal_ (journal) , journal_ (journal)
, nodeStoreJournal_ (nodeStoreJournal) , nodeStoreJournal_ (nodeStoreJournal)
@@ -254,7 +252,7 @@ SHAMapStoreImp::makeDatabase (std::string const& name,
} }
else else
{ {
db = manager_.make_Database (name, scheduler_, nodeStoreJournal_, db = NodeStore::Manager::instance().make_Database (name, scheduler_, nodeStoreJournal_,
readThreads, setup_.nodeDatabase, readThreads, setup_.nodeDatabase,
setup_.ephemeralNodeDatabase); setup_.ephemeralNodeDatabase);
} }
@@ -510,7 +508,7 @@ SHAMapStoreImp::makeBackendRotating (std::string path)
} }
parameters.set("path", newPath.string()); parameters.set("path", newPath.string());
return manager_.make_Backend (parameters, scheduler_, return NodeStore::Manager::instance().make_Backend (parameters, scheduler_,
nodeStoreJournal_); nodeStoreJournal_);
} }
@@ -522,10 +520,10 @@ SHAMapStoreImp::makeDatabaseRotating (std::string const& name,
{ {
std::unique_ptr <NodeStore::Backend> fastBackend ( std::unique_ptr <NodeStore::Backend> fastBackend (
(setup_.ephemeralNodeDatabase.size() > 0) (setup_.ephemeralNodeDatabase.size() > 0)
? manager_.make_Backend (setup_.ephemeralNodeDatabase, ? NodeStore::Manager::instance().make_Backend (setup_.ephemeralNodeDatabase,
scheduler_, journal_) : nullptr); scheduler_, journal_) : nullptr);
return manager_.make_DatabaseRotating ("NodeStore.main", scheduler_, return NodeStore::Manager::instance().make_DatabaseRotating ("NodeStore.main", scheduler_,
readThreads, writableBackend, archiveBackend, readThreads, writableBackend, archiveBackend,
std::move (fastBackend), nodeStoreJournal_); std::move (fastBackend), nodeStoreJournal_);
} }
@@ -710,13 +708,12 @@ setup_SHAMapStore (Config const& c)
std::unique_ptr<SHAMapStore> std::unique_ptr<SHAMapStore>
make_SHAMapStore (SHAMapStore::Setup const& s, make_SHAMapStore (SHAMapStore::Setup const& s,
beast::Stoppable& parent, beast::Stoppable& parent,
NodeStore::Manager& manager,
NodeStore::Scheduler& scheduler, NodeStore::Scheduler& scheduler,
beast::Journal journal, beast::Journal journal,
beast::Journal nodeStoreJournal, beast::Journal nodeStoreJournal,
TransactionMaster& transactionMaster) TransactionMaster& transactionMaster)
{ {
return std::make_unique<SHAMapStoreImp> (s, parent, manager, scheduler, return std::make_unique<SHAMapStoreImp> (s, parent, scheduler,
journal, nodeStoreJournal, transactionMaster); journal, nodeStoreJournal, transactionMaster);
} }

View File

@@ -81,7 +81,6 @@ private:
std::uint32_t minimumDeletionInterval_ = 256; std::uint32_t minimumDeletionInterval_ = 256;
Setup setup_; Setup setup_;
NodeStore::Manager& manager_;
NodeStore::Scheduler& scheduler_; NodeStore::Scheduler& scheduler_;
beast::Journal journal_; beast::Journal journal_;
beast::Journal nodeStoreJournal_; beast::Journal nodeStoreJournal_;
@@ -107,7 +106,6 @@ private:
public: public:
SHAMapStoreImp (Setup const& setup, SHAMapStoreImp (Setup const& setup,
Stoppable& parent, Stoppable& parent,
NodeStore::Manager& manager,
NodeStore::Scheduler& scheduler, NodeStore::Scheduler& scheduler,
beast::Journal journal, beast::Journal journal,
beast::Journal nodeStoreJournal, beast::Journal nodeStoreJournal,

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include <ripple/app/node/SqliteFactory.h> #include <ripple/app/node/SqliteFactory.h>
#include <ripple/core/Config.h>
#include <type_traits> #include <type_traits>
namespace ripple { namespace ripple {
@@ -225,13 +226,8 @@ private:
class SqliteFactory : public NodeStore::Factory class SqliteFactory : public NodeStore::Factory
{ {
int hashnode_cache_size_;
public: public:
SqliteFactory (int hashnode_cache_size) SqliteFactory() = default;
: hashnode_cache_size_ (hashnode_cache_size)
{
}
std::string std::string
getName () const getName () const
@@ -244,15 +240,11 @@ public:
NodeStore::Scheduler&, beast::Journal) NodeStore::Scheduler&, beast::Journal)
{ {
return std::make_unique <SqliteBackend> ( return std::make_unique <SqliteBackend> (
keyValues ["path"].toStdString (), hashnode_cache_size_); keyValues ["path"].toStdString (),
getConfig ().getSize(siHashNodeDBCache) * 1024);
} }
}; };
//------------------------------------------------------------------------------ static SqliteFactory sqliteFactory;
std::unique_ptr <NodeStore::Factory> make_SqliteFactory (int hashnode_cache_size)
{
return std::make_unique <SqliteFactory> (hashnode_cache_size);
}
} }

View File

@@ -43,7 +43,7 @@ public:
or other tasks scheduled, they will be completed before this call or other tasks scheduled, they will be completed before this call
returns. returns.
*/ */
virtual ~Backend () = 0; virtual ~Backend() = default;
/** Get the human-readable name of this backend. /** Get the human-readable name of this backend.
This is used for diagnostic output. This is used for diagnostic output.

View File

@@ -47,7 +47,7 @@ public:
All pending operations are completed, pending writes flushed, All pending operations are completed, pending writes flushed,
and files closed before this returns. and files closed before this returns.
*/ */
virtual ~Database () = 0 ; virtual ~Database() = default;
/** Retrieve the name associated with this backend. /** Retrieve the name associated with this backend.
This is used for diagnostics and may not reflect the actual path This is used for diagnostics and may not reflect the actual path

View File

@@ -22,28 +22,34 @@
#include <ripple/nodestore/Backend.h> #include <ripple/nodestore/Backend.h>
#include <ripple/nodestore/Scheduler.h> #include <ripple/nodestore/Scheduler.h>
#include <beast/utility/Journal.h>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
/** Factory to produce backends. */ /** Base class for backend factories. */
class Factory class Factory
{ {
public: public:
virtual ~Factory () = 0; virtual
~Factory() = default;
/** Retrieve the name of this factory. */ /** 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. /** Create an instance of this factory's backend.
@param keyBytes The fixed number of bytes per key. @param keyBytes The fixed number of bytes per key.
@param keyValues A set of key/value configuration pairs. @param keyValues A set of key/value configuration pairs.
@param scheduler The scheduler to use for running tasks. @param scheduler The scheduler to use for running tasks.
@return A pointer to the Backend object. @return A pointer to the Backend object.
*/ */
virtual std::unique_ptr <Backend> createInstance (size_t keyBytes, virtual
Parameters const& parameters, Scheduler& scheduler, std::unique_ptr <Backend>
beast::Journal journal) = 0; createInstance (size_t keyBytes, Parameters const& parameters,
Scheduler& scheduler, beast::Journal journal) = 0;
}; };
} }

View File

@@ -30,22 +30,31 @@ namespace NodeStore {
class Manager class Manager
{ {
public: public:
virtual ~Manager () = 0; /** Returns the instance of the manager singleton. */
static
Manager&
instance();
/** Add the specified factory to the manager. /** Add a factory. */
Thread safety: virtual
Not thread-safe. void
*/ insert (Factory& factory) = 0;
virtual void add_factory (std::unique_ptr <Factory> factory) = 0;
/** Remove a factory. */
virtual
void
erase (Factory& factory) = 0;
/** Return a pointer to the matching factory if it exists. /** Return a pointer to the matching factory if it exists.
@param name The name to match, performed case-insensitive. @param name The name to match, performed case-insensitive.
@return `nullptr` if a match was not found. @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. */ /** 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; Scheduler& scheduler, beast::Journal journal) = 0;
/** Construct a NodeStore database. /** Construct a NodeStore database.
@@ -72,30 +81,23 @@ public:
@return The opened database. @return The opened database.
*/ */
virtual std::unique_ptr <Database> make_Database (std::string const& name, virtual
Scheduler& scheduler, beast::Journal journal, int readThreads, std::unique_ptr <Database>
make_Database (std::string const& name, Scheduler& scheduler,
beast::Journal journal, int readThreads,
Parameters const& backendParameters, Parameters const& backendParameters,
Parameters fastBackendParameters = Parameters ()) = 0; Parameters fastBackendParameters = Parameters()) = 0;
virtual std::unique_ptr <DatabaseRotating> make_DatabaseRotating ( virtual
std::string const& name, std::unique_ptr <DatabaseRotating>
Scheduler& scheduler, make_DatabaseRotating (std::string const& name,
std::int32_t readThreads, Scheduler& scheduler, std::int32_t readThreads,
std::shared_ptr <Backend> writableBackend, std::shared_ptr <Backend> writableBackend,
std::shared_ptr <Backend> archiveBackend, std::shared_ptr <Backend> archiveBackend,
std::unique_ptr <Backend> fastBackend, std::unique_ptr <Backend> fastBackend,
beast::Journal journal) = 0; 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>>() );
} }
} }

View File

@@ -21,6 +21,7 @@
#define RIPPLE_NODESTORE_SCHEDULER_H_INCLUDED #define RIPPLE_NODESTORE_SCHEDULER_H_INCLUDED
#include <ripple/nodestore/Task.h> #include <ripple/nodestore/Task.h>
#include <chrono>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -52,7 +53,7 @@ struct BatchWriteReport
class Scheduler class Scheduler
{ {
public: public:
virtual ~Scheduler() = 0; virtual ~Scheduler() = default;
/** Schedules a task. /** Schedules a task.
Depending on the implementation, the task may be invoked either on Depending on the implementation, the task may be invoked either on

View File

@@ -26,12 +26,12 @@ namespace NodeStore {
/** Derived classes perform scheduled tasks. */ /** Derived classes perform scheduled tasks. */
struct Task struct Task
{ {
virtual ~Task () = 0; virtual ~Task() = default;
/** Performs the task. /** Performs the task.
The call may take place on a foreign thread. The call may take place on a foreign thread.
*/ */
virtual void performScheduledTask () = 0; virtual void performScheduledTask() = 0;
}; };
} }

View File

@@ -19,7 +19,13 @@
#if RIPPLE_HYPERLEVELDB_AVAILABLE #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 ripple {
namespace NodeStore { namespace NodeStore {
@@ -27,7 +33,6 @@ namespace NodeStore {
class HyperDBBackend class HyperDBBackend
: public Backend : public Backend
, public BatchWriter::Callback , public BatchWriter::Callback
, public beast::LeakChecked <HyperDBBackend>
{ {
private: private:
std::atomic <bool> m_deletePath; std::atomic <bool> m_deletePath;
@@ -249,6 +254,16 @@ public:
class HyperDBFactory : public NodeStore::Factory class HyperDBFactory : public NodeStore::Factory
{ {
public: public:
HyperDBFactory()
{
Manager::instance().insert(*this);
}
~HyperDBFactory()
{
Manager::instance().erase(*this);
}
std::string std::string
getName () const getName () const
{ {
@@ -267,13 +282,7 @@ public:
} }
}; };
//------------------------------------------------------------------------------ static HyperDBFactory hyperDBFactory;
std::unique_ptr <Factory>
make_HyperDBFactory ()
{
return std::make_unique <HyperDBFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -19,7 +19,13 @@
#if RIPPLE_LEVELDB_AVAILABLE #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 ripple {
namespace NodeStore { namespace NodeStore {
@@ -27,7 +33,6 @@ namespace NodeStore {
class LevelDBBackend class LevelDBBackend
: public Backend : public Backend
, public BatchWriter::Callback , public BatchWriter::Callback
, public beast::LeakChecked <LevelDBBackend>
{ {
private: private:
std::atomic <bool> m_deletePath; std::atomic <bool> m_deletePath;
@@ -268,10 +273,13 @@ public:
options.block_cache = leveldb::NewLRUCache ( options.block_cache = leveldb::NewLRUCache (
getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024); getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
m_lruCache.reset (options.block_cache); m_lruCache.reset (options.block_cache);
Manager::instance().insert(*this);
} }
~LevelDBFactory() ~LevelDBFactory()
{ {
Manager::instance().erase(*this);
} }
std::string std::string
@@ -294,11 +302,7 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::unique_ptr <Factory> static LevelDBFactory levelDBFactory;
make_LevelDBFactory ()
{
return std::make_unique <LevelDBFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -17,6 +17,10 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/Factory.h>
#include <ripple/nodestore/Manager.h>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -108,6 +112,16 @@ public:
class MemoryFactory : public Factory class MemoryFactory : public Factory
{ {
public: public:
MemoryFactory()
{
Manager::instance().insert(*this);
}
~MemoryFactory()
{
Manager::instance().erase(*this);
}
std::string std::string
getName () const getName () const
{ {
@@ -128,11 +142,7 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::unique_ptr <Factory> static MemoryFactory memoryFactory;
make_MemoryFactory ()
{
return std::make_unique <MemoryFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -17,6 +17,10 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/Factory.h>
#include <ripple/nodestore/Manager.h>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -75,6 +79,16 @@ private:
class NullFactory : public Factory class NullFactory : public Factory
{ {
public: public:
NullFactory()
{
Manager::instance().insert(*this);
}
~NullFactory()
{
Manager::instance().erase(*this);
}
std::string std::string
getName () const getName () const
{ {
@@ -91,12 +105,7 @@ public:
} }
}; };
//------------------------------------------------------------------------------ static NullFactory nullFactory;
std::unique_ptr <Factory> make_NullFactory ()
{
return std::make_unique <NullFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -19,9 +19,15 @@
#if RIPPLE_ROCKSDB_AVAILABLE #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 <beast/threads/Thread.h>
#include <atomic> #include <atomic>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -77,7 +83,6 @@ public:
class RocksDBBackend class RocksDBBackend
: public Backend : public Backend
, public BatchWriter::Callback , public BatchWriter::Callback
, public beast::LeakChecked <RocksDBBackend>
{ {
private: private:
std::atomic <bool> m_deletePath; std::atomic <bool> m_deletePath;
@@ -367,10 +372,13 @@ public:
getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024); getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
m_lruCache = table_options.block_cache; m_lruCache = table_options.block_cache;
Manager::instance().insert(*this);
} }
~RocksDBFactory () ~RocksDBFactory ()
{ {
Manager::instance().erase(*this);
} }
std::string std::string
@@ -391,13 +399,7 @@ public:
} }
}; };
//------------------------------------------------------------------------------ static RocksDBFactory rocksDBFactory;
std::unique_ptr <Factory>
make_RocksDBFactory ()
{
return std::make_unique <RocksDBFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -19,9 +19,14 @@
#if RIPPLE_ROCKSDB_AVAILABLE #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 <beast/threads/Thread.h>
#include <atomic> #include <atomic>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -76,7 +81,6 @@ public:
class RocksDBQuickBackend class RocksDBQuickBackend
: public Backend : public Backend
, public beast::LeakChecked <RocksDBQuickBackend>
{ {
private: private:
std::atomic <bool> m_deletePath; std::atomic <bool> m_deletePath;
@@ -328,15 +332,16 @@ public:
class RocksDBQuickFactory : public Factory class RocksDBQuickFactory : public Factory
{ {
public: public:
std::shared_ptr <rocksdb::Cache> m_lruCache;
RockDBQuickEnv m_env; RockDBQuickEnv m_env;
RocksDBQuickFactory () RocksDBQuickFactory()
{ {
Manager::instance().insert(*this);
} }
~RocksDBQuickFactory () ~RocksDBQuickFactory()
{ {
Manager::instance().erase(*this);
} }
std::string std::string
@@ -357,13 +362,7 @@ public:
} }
}; };
//------------------------------------------------------------------------------ static RocksDBQuickFactory rocksDBQuickFactory;
std::unique_ptr <Factory>
make_RocksDBQuickFactory ()
{
return std::make_unique <RocksDBQuickFactory> ();
}
} }
} }

View File

@@ -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

View File

@@ -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 ()
{
}
}
}

View File

@@ -17,6 +17,8 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/impl/BatchWriter.h>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {

View File

@@ -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 ()
{
}
}
}

View File

@@ -20,9 +20,14 @@
#ifndef RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED #ifndef RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED
#define 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/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 <chrono>
#include <condition_variable> #include <condition_variable>
#include <set> #include <set>

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/impl/DecodedBlob.h>
#include <beast/ByteOrder.h> #include <beast/ByteOrder.h>
#include <algorithm> #include <algorithm>

View File

@@ -17,6 +17,9 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/impl/EncodedBlob.h>
#include <beast/ByteOrder.h>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {

View File

@@ -20,7 +20,10 @@
#ifndef RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED #ifndef RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
#define 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/module/core/memory/MemoryBlock.h>
#include <beast/utility/noexcept.h>
#include <cstddef>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -34,13 +37,13 @@ struct EncodedBlob
public: public:
void prepare (NodeObject::Ptr const& object); void prepare (NodeObject::Ptr const& object);
void const* getKey () const noexcept { return m_key; } 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 (); } void const* getData () const noexcept { return m_data.getData (); }
private: private:
void const* m_key; void const* m_key;
beast::MemoryBlock m_data; beast::MemoryBlock m_data;
size_t m_size; std::size_t m_size;
}; };
} }

View File

@@ -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 ()
{
}
}
}

View File

@@ -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));
}
}
}

View 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();
}
}
}

View 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

View File

@@ -17,6 +17,9 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/nodestore/NodeObject.h>
#include <memory>
namespace ripple { namespace ripple {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@@ -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 ()
{
}
}
}

View File

@@ -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 ()
{
}
}
}

View File

@@ -18,6 +18,8 @@
//============================================================================== //==============================================================================
#include <ripple/nodestore/tests/Base.test.h> #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 <beast/module/core/diagnostic/UnitTestUtilities.h>
namespace ripple { namespace ripple {
@@ -31,8 +33,6 @@ public:
void testBackend (std::string const& type, std::int64_t const seedValue, void testBackend (std::string const& type, std::int64_t const seedValue,
int numObjectsToTest = 2000) int numObjectsToTest = 2000)
{ {
std::unique_ptr <Manager> manager (make_Manager ());
DummyScheduler scheduler; DummyScheduler scheduler;
testcase ("Backend type=" + type); testcase ("Backend type=" + type);
@@ -50,8 +50,8 @@ public:
{ {
// Open the backend // Open the backend
std::unique_ptr <Backend> backend (manager->make_Backend ( std::unique_ptr <Backend> backend =
params, scheduler, j)); Manager::instance().make_Backend (params, scheduler, j);
// Write the batch // Write the batch
storeBatch (*backend, batch); storeBatch (*backend, batch);
@@ -74,8 +74,8 @@ public:
{ {
// Re-open the backend // Re-open the backend
std::unique_ptr <Backend> backend (manager->make_Backend ( std::unique_ptr <Backend> backend = Manager::instance().make_Backend (
params, scheduler, j)); params, scheduler, j);
// Read it back in // Read it back in
Batch copy; Batch copy;

View File

@@ -20,9 +20,10 @@
#ifndef RIPPLE_NODESTORE_TESTBASE_H_INCLUDED #ifndef RIPPLE_NODESTORE_TESTBASE_H_INCLUDED
#define 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/unit_test/suite.h>
#include <beast/module/core/maths/Random.h> #include <beast/module/core/maths/Random.h>
#include <ripple/basics/StringUtilities.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <iomanip> #include <iomanip>

View File

@@ -18,6 +18,10 @@
//============================================================================== //==============================================================================
#include <ripple/nodestore/tests/Base.test.h> #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 ripple {
namespace NodeStore { namespace NodeStore {

View File

@@ -18,6 +18,9 @@
//============================================================================== //==============================================================================
#include <ripple/nodestore/tests/Base.test.h> #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 ripple {
namespace NodeStore { namespace NodeStore {
@@ -28,8 +31,6 @@ public:
void testImport (std::string const& destBackendType, void testImport (std::string const& destBackendType,
std::string const& srcBackendType, std::int64_t seedValue) std::string const& srcBackendType, std::int64_t seedValue)
{ {
std::unique_ptr <Manager> manager (make_Manager ());
DummyScheduler scheduler; DummyScheduler scheduler;
beast::UnitTestUtilities::TempDirectory node_db ("node_db"); beast::UnitTestUtilities::TempDirectory node_db ("node_db");
@@ -45,8 +46,8 @@ public:
// Write to source db // Write to source db
{ {
std::unique_ptr <Database> src (manager->make_Database ( std::unique_ptr <Database> src = Manager::instance().make_Database (
"test", scheduler, j, 2, srcParams)); "test", scheduler, j, 2, srcParams);
storeBatch (*src, batch); storeBatch (*src, batch);
} }
@@ -54,8 +55,8 @@ public:
{ {
// Re-open the db // Re-open the db
std::unique_ptr <Database> src (manager->make_Database ( std::unique_ptr <Database> src = Manager::instance().make_Database (
"test", scheduler, j, 2, srcParams)); "test", scheduler, j, 2, srcParams);
// Set up the destination database // Set up the destination database
beast::UnitTestUtilities::TempDirectory dest_db ("dest_db"); beast::UnitTestUtilities::TempDirectory dest_db ("dest_db");
@@ -63,8 +64,8 @@ public:
destParams.set ("type", destBackendType); destParams.set ("type", destBackendType);
destParams.set ("path", dest_db.getFullPathName ()); destParams.set ("path", dest_db.getFullPathName ());
std::unique_ptr <Database> dest (manager->make_Database ( std::unique_ptr <Database> dest = Manager::instance().make_Database (
"test", scheduler, j, 2, destParams)); "test", scheduler, j, 2, destParams);
testcase ("import into '" + destBackendType + testcase ("import into '" + destBackendType +
"' from '" + srcBackendType + "'"); "' from '" + srcBackendType + "'");
@@ -90,8 +91,6 @@ public:
std::int64_t const seedValue, std::int64_t const seedValue,
int numObjectsToTest = 2000) int numObjectsToTest = 2000)
{ {
std::unique_ptr <Manager> manager (make_Manager ());
DummyScheduler scheduler; DummyScheduler scheduler;
std::string s = "NodeStore backend '" + type + "'"; std::string s = "NodeStore backend '" + type + "'";
@@ -121,8 +120,8 @@ public:
{ {
// Open the database // Open the database
std::unique_ptr <Database> db (manager->make_Database ("test", scheduler, std::unique_ptr <Database> db = Manager::instance().make_Database (
j, 2, nodeParams, tempParams)); "test", scheduler, j, 2, nodeParams, tempParams);
// Write the batch // Write the batch
storeBatch (*db, batch); storeBatch (*db, batch);
@@ -147,8 +146,8 @@ public:
{ {
{ {
// Re-open the database without the ephemeral DB // Re-open the database without the ephemeral DB
std::unique_ptr <Database> db (manager->make_Database ( std::unique_ptr <Database> db = Manager::instance().make_Database (
"test", scheduler, j, 2, nodeParams)); "test", scheduler, j, 2, nodeParams);
// Read it back in // Read it back in
Batch copy; Batch copy;
@@ -163,8 +162,8 @@ public:
if (useEphemeralDatabase) if (useEphemeralDatabase)
{ {
// Verify the ephemeral db // Verify the ephemeral db
std::unique_ptr <Database> db (manager->make_Database ("test", std::unique_ptr <Database> db = Manager::instance().make_Database ("test",
scheduler, j, 2, tempParams, beast::StringPairArray ())); scheduler, j, 2, tempParams, beast::StringPairArray ());
// Read it back in // Read it back in
Batch copy; Batch copy;

View File

@@ -18,6 +18,9 @@
//============================================================================== //==============================================================================
#include <ripple/nodestore/tests/Base.test.h> #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> #include <limits>
namespace ripple { namespace ripple {
@@ -210,7 +213,6 @@ public:
using check_func = std::function<bool(Status const)>; using check_func = std::function<bool(Status const)>;
using backend_ptr = std::unique_ptr<Backend>; using backend_ptr = std::unique_ptr<Backend>;
using manager_ptr = std::unique_ptr<Manager>;
using result_type = std::vector<std::pair<std::string, double>>; using result_type = std::vector<std::pair<std::string, double>>;
static bool checkNotFound(Status const status) static bool checkNotFound(Status const status)
@@ -265,11 +267,10 @@ public:
Stopwatch t; Stopwatch t;
result_type results; result_type results;
auto manager = make_Manager();
DummyScheduler scheduler; DummyScheduler scheduler;
beast::Journal j; 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 insertFactory(seedValue, numObjects, 0, numObjects);
NodeFactory batchFactory(seedValue, numObjects, numObjects * 10, NodeFactory batchFactory(seedValue, numObjects, numObjects * 10,

View File

@@ -17,52 +17,29 @@
*/ */
//============================================================================== //==============================================================================
#include <memory> //#include <memory>
#include <vector> //#include <vector>
// backend support // backend support
#include <ripple/unity/leveldb.h> #include <ripple/unity/leveldb.h>
#include <ripple/unity/hyperleveldb.h> #include <ripple/unity/hyperleveldb.h>
#include <ripple/unity/rocksdb.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/HyperDBFactory.cpp>
#include <ripple/nodestore/backend/LevelDBFactory.h>
#include <ripple/nodestore/backend/LevelDBFactory.cpp> #include <ripple/nodestore/backend/LevelDBFactory.cpp>
#include <ripple/nodestore/backend/MemoryFactory.h>
#include <ripple/nodestore/backend/MemoryFactory.cpp> #include <ripple/nodestore/backend/MemoryFactory.cpp>
#include <ripple/nodestore/backend/NullFactory.h>
#include <ripple/nodestore/backend/NullFactory.cpp> #include <ripple/nodestore/backend/NullFactory.cpp>
#include <ripple/nodestore/backend/RocksDBFactory.h>
#include <ripple/nodestore/backend/RocksDBFactory.cpp> #include <ripple/nodestore/backend/RocksDBFactory.cpp>
#include <ripple/nodestore/backend/RocksDBQuickFactory.h>
#include <ripple/nodestore/backend/RocksDBQuickFactory.cpp> #include <ripple/nodestore/backend/RocksDBQuickFactory.cpp>
#include <ripple/nodestore/impl/Backend.cpp>
#include <ripple/nodestore/impl/BatchWriter.cpp> #include <ripple/nodestore/impl/BatchWriter.cpp>
#include <ripple/nodestore/impl/DatabaseImp.h> #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/DatabaseRotatingImp.cpp>
#include <ripple/nodestore/impl/DummyScheduler.cpp> #include <ripple/nodestore/impl/DummyScheduler.cpp>
#include <ripple/nodestore/impl/DecodedBlob.cpp> #include <ripple/nodestore/impl/DecodedBlob.cpp>
#include <ripple/nodestore/impl/EncodedBlob.cpp> #include <ripple/nodestore/impl/EncodedBlob.cpp>
#include <ripple/nodestore/impl/Factory.cpp> #include <ripple/nodestore/impl/ManagerImp.cpp>
#include <ripple/nodestore/impl/Manager.cpp>
#include <ripple/nodestore/impl/NodeObject.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/Backend.test.cpp>
#include <ripple/nodestore/tests/Basics.test.cpp> #include <ripple/nodestore/tests/Basics.test.cpp>