diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index 4b439dfbc..5429d4a68 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -2403,33 +2403,21 @@
True
-
-
True
-
-
True
-
-
True
-
-
True
-
-
True
-
-
@@ -2472,9 +2460,11 @@
True
-
+
True
+
+
True
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index 3b7d9f302..797ea3c8b 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -3405,39 +3405,21 @@
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore\backend
-
- ripple\nodestore\backend
-
ripple\nodestore
@@ -3489,9 +3471,12 @@
ripple\nodestore\impl
-
+
ripple\nodestore\impl
+
+ ripple\nodestore\impl
+
ripple\nodestore\impl
diff --git a/SConstruct b/SConstruct
index 16a396a90..9e710f619 100644
--- a/SConstruct
+++ b/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:
diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp
index 2fe0194c3..306ea1ba9 100644
--- a/src/ripple/app/main/Application.cpp
+++ b/src/ripple/app/main/Application.cpp
@@ -153,7 +153,6 @@ public:
beast::Journal m_journal;
Application::LockType m_masterMutex;
- std::unique_ptr m_nodeStoreManager;
NodeStoreScheduler m_nodeStoreScheduler;
std::unique_ptr m_shaMapStore;
std::unique_ptr m_nodeStore;
@@ -205,20 +204,6 @@ public:
//--------------------------------------------------------------------------
- static
- std::vector >
- make_Factories (int hashnode_cache_size)
- {
- std::vector > 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 source (
- m_nodeStoreManager->make_Database ("NodeStore.import", scheduler,
+ std::unique_ptr 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 '"
diff --git a/src/ripple/app/misc/SHAMapStore.h b/src/ripple/app/misc/SHAMapStore.h
index 03a2b6478..377f51159 100644
--- a/src/ripple/app/misc/SHAMapStore.h
+++ b/src/ripple/app/misc/SHAMapStore.h
@@ -79,7 +79,6 @@ setup_SHAMapStore(Config const& c);
std::unique_ptr
make_SHAMapStore(SHAMapStore::Setup const& s,
beast::Stoppable& parent,
- NodeStore::Manager& manager,
NodeStore::Scheduler& scheduler,
beast::Journal journal,
beast::Journal nodeStoreJournal,
diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp
index 2232103b1..d4d09efba 100644
--- a/src/ripple/app/misc/SHAMapStoreImp.cpp
+++ b/src/ripple/app/misc/SHAMapStoreImp.cpp
@@ -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 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
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 (s, parent, manager, scheduler,
+ return std::make_unique (s, parent, scheduler,
journal, nodeStoreJournal, transactionMaster);
}
diff --git a/src/ripple/app/misc/SHAMapStoreImp.h b/src/ripple/app/misc/SHAMapStoreImp.h
index ee704c1d2..e2a83381e 100644
--- a/src/ripple/app/misc/SHAMapStoreImp.h
+++ b/src/ripple/app/misc/SHAMapStoreImp.h
@@ -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,
diff --git a/src/ripple/app/node/SqliteFactory.cpp b/src/ripple/app/node/SqliteFactory.cpp
index 3568297f4..cd7d776ee 100644
--- a/src/ripple/app/node/SqliteFactory.cpp
+++ b/src/ripple/app/node/SqliteFactory.cpp
@@ -18,6 +18,7 @@
//==============================================================================
#include
+#include
#include
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 (
- keyValues ["path"].toStdString (), hashnode_cache_size_);
+ keyValues ["path"].toStdString (),
+ getConfig ().getSize(siHashNodeDBCache) * 1024);
}
};
-//------------------------------------------------------------------------------
-
-std::unique_ptr make_SqliteFactory (int hashnode_cache_size)
-{
- return std::make_unique (hashnode_cache_size);
-}
+static SqliteFactory sqliteFactory;
}
diff --git a/src/ripple/nodestore/Backend.h b/src/ripple/nodestore/Backend.h
index 2c5b471ba..3b9ab4b54 100644
--- a/src/ripple/nodestore/Backend.h
+++ b/src/ripple/nodestore/Backend.h
@@ -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.
diff --git a/src/ripple/nodestore/Database.h b/src/ripple/nodestore/Database.h
index 20e26e52a..51a3b2ff9 100644
--- a/src/ripple/nodestore/Database.h
+++ b/src/ripple/nodestore/Database.h
@@ -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
diff --git a/src/ripple/nodestore/Factory.h b/src/ripple/nodestore/Factory.h
index d08efe3ca..53e12ba9a 100644
--- a/src/ripple/nodestore/Factory.h
+++ b/src/ripple/nodestore/Factory.h
@@ -22,28 +22,34 @@
#include
#include
+#include
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 createInstance (size_t keyBytes,
- Parameters const& parameters, Scheduler& scheduler,
- beast::Journal journal) = 0;
+ virtual
+ std::unique_ptr
+ createInstance (size_t keyBytes, Parameters const& parameters,
+ Scheduler& scheduler, beast::Journal journal) = 0;
};
}
diff --git a/src/ripple/nodestore/Manager.h b/src/ripple/nodestore/Manager.h
index 3beb598c7..d7d4976c8 100644
--- a/src/ripple/nodestore/Manager.h
+++ b/src/ripple/nodestore/Manager.h
@@ -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) = 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 make_Backend (Parameters const& parameters,
+ virtual
+ std::unique_ptr
+ 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 make_Database (std::string const& name,
- Scheduler& scheduler, beast::Journal journal, int readThreads,
+ virtual
+ std::unique_ptr
+ 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 make_DatabaseRotating (
- std::string const& name,
- Scheduler& scheduler,
- std::int32_t readThreads,
+ virtual
+ std::unique_ptr
+ make_DatabaseRotating (std::string const& name,
+ Scheduler& scheduler, std::int32_t readThreads,
std::shared_ptr writableBackend,
- std::shared_ptr archiveBackend,
- std::unique_ptr fastBackend,
- beast::Journal journal) = 0;
+ std::shared_ptr archiveBackend,
+ std::unique_ptr fastBackend,
+ beast::Journal journal) = 0;
};
-//------------------------------------------------------------------------------
-
-/** Create a Manager.
- @param factories An optional array of additional factories to add.
-*/
-std::unique_ptr make_Manager (
- std::vector > factories =
- std::vector >() );
-
}
}
diff --git a/src/ripple/nodestore/Scheduler.h b/src/ripple/nodestore/Scheduler.h
index 9aab6a7da..be6175fcf 100644
--- a/src/ripple/nodestore/Scheduler.h
+++ b/src/ripple/nodestore/Scheduler.h
@@ -21,6 +21,7 @@
#define RIPPLE_NODESTORE_SCHEDULER_H_INCLUDED
#include
+#include
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
diff --git a/src/ripple/nodestore/Task.h b/src/ripple/nodestore/Task.h
index 42eb5d8af..6f9e85e8e 100644
--- a/src/ripple/nodestore/Task.h
+++ b/src/ripple/nodestore/Task.h
@@ -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;
};
}
diff --git a/src/ripple/nodestore/backend/HyperDBFactory.cpp b/src/ripple/nodestore/backend/HyperDBFactory.cpp
index 5cc194ad2..03dd800e1 100644
--- a/src/ripple/nodestore/backend/HyperDBFactory.cpp
+++ b/src/ripple/nodestore/backend/HyperDBFactory.cpp
@@ -19,15 +19,20 @@
#if RIPPLE_HYPERLEVELDB_AVAILABLE
-#include
-
+#include // VFALCO Bad dependency
+#include
+#include
+#include
+#include
+#include
+#include //
+
namespace ripple {
namespace NodeStore {
class HyperDBBackend
: public Backend
, public BatchWriter::Callback
- , public beast::LeakChecked
{
private:
std::atomic 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
-make_HyperDBFactory ()
-{
- return std::make_unique ();
-}
+static HyperDBFactory hyperDBFactory;
}
}
diff --git a/src/ripple/nodestore/backend/HyperDBFactory.h b/src/ripple/nodestore/backend/HyperDBFactory.h
deleted file mode 100644
index b81d9e876..000000000
--- a/src/ripple/nodestore/backend/HyperDBFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce HyperLevelDB backends for the NodeStore.
- @see Database
-*/
-std::unique_ptr make_HyperDBFactory ();
-
-}
-}
-
-#endif
-
-#endif
diff --git a/src/ripple/nodestore/backend/LevelDBFactory.cpp b/src/ripple/nodestore/backend/LevelDBFactory.cpp
index 8d06cc378..6716a74e9 100644
--- a/src/ripple/nodestore/backend/LevelDBFactory.cpp
+++ b/src/ripple/nodestore/backend/LevelDBFactory.cpp
@@ -19,7 +19,13 @@
#if RIPPLE_LEVELDB_AVAILABLE
-#include
+#include // VFALCO Bad dependency
+#include
+#include
+#include
+#include
+#include
+#include //
namespace ripple {
namespace NodeStore {
@@ -27,7 +33,6 @@ namespace NodeStore {
class LevelDBBackend
: public Backend
, public BatchWriter::Callback
- , public beast::LeakChecked
{
private:
std::atomic 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
-make_LevelDBFactory ()
-{
- return std::make_unique ();
-}
+static LevelDBFactory levelDBFactory;
}
}
diff --git a/src/ripple/nodestore/backend/LevelDBFactory.h b/src/ripple/nodestore/backend/LevelDBFactory.h
deleted file mode 100644
index af105a711..000000000
--- a/src/ripple/nodestore/backend/LevelDBFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce LevelDBFactory backends for the NodeStore.
- @see Database
-*/
-std::unique_ptr make_LevelDBFactory ();
-
-}
-}
-
-#endif
-
-#endif
diff --git a/src/ripple/nodestore/backend/MemoryFactory.cpp b/src/ripple/nodestore/backend/MemoryFactory.cpp
index a25e4f2ff..eab59e258 100644
--- a/src/ripple/nodestore/backend/MemoryFactory.cpp
+++ b/src/ripple/nodestore/backend/MemoryFactory.cpp
@@ -17,6 +17,10 @@
*/
//==============================================================================
+#include
+#include
+#include //
+
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
-make_MemoryFactory ()
-{
- return std::make_unique ();
-}
+static MemoryFactory memoryFactory;
}
}
diff --git a/src/ripple/nodestore/backend/MemoryFactory.h b/src/ripple/nodestore/backend/MemoryFactory.h
deleted file mode 100644
index 35882a4df..000000000
--- a/src/ripple/nodestore/backend/MemoryFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce a RAM based backend for the NodeStore.
- @see Database
-*/
-std::unique_ptr make_MemoryFactory ();
-
-}
-}
-
-#endif
diff --git a/src/ripple/nodestore/backend/NullFactory.cpp b/src/ripple/nodestore/backend/NullFactory.cpp
index 9a61aa568..a8fa0e93c 100644
--- a/src/ripple/nodestore/backend/NullFactory.cpp
+++ b/src/ripple/nodestore/backend/NullFactory.cpp
@@ -17,6 +17,10 @@
*/
//==============================================================================
+#include
+#include
+#include //
+
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 make_NullFactory ()
-{
- return std::make_unique ();
-}
+static NullFactory nullFactory;
}
}
diff --git a/src/ripple/nodestore/backend/NullFactory.h b/src/ripple/nodestore/backend/NullFactory.h
deleted file mode 100644
index a081a71c1..000000000
--- a/src/ripple/nodestore/backend/NullFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce a null backend.
- This is for standalone / testing mode.
- @see Database
-*/
-std::unique_ptr make_NullFactory ();
-
-}
-}
-
-#endif
-
diff --git a/src/ripple/nodestore/backend/RocksDBFactory.cpp b/src/ripple/nodestore/backend/RocksDBFactory.cpp
index 22a8e8a78..58d9d353c 100644
--- a/src/ripple/nodestore/backend/RocksDBFactory.cpp
+++ b/src/ripple/nodestore/backend/RocksDBFactory.cpp
@@ -19,9 +19,15 @@
#if RIPPLE_ROCKSDB_AVAILABLE
-#include
+#include // VFALCO Bad dependency
+#include
+#include
+#include
+#include
+#include
#include
#include
+#include //
namespace ripple {
namespace NodeStore {
@@ -77,7 +83,6 @@ public:
class RocksDBBackend
: public Backend
, public BatchWriter::Callback
- , public beast::LeakChecked
{
private:
std::atomic 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
-make_RocksDBFactory ()
-{
- return std::make_unique ();
-}
+static RocksDBFactory rocksDBFactory;
}
}
diff --git a/src/ripple/nodestore/backend/RocksDBFactory.h b/src/ripple/nodestore/backend/RocksDBFactory.h
deleted file mode 100644
index c4125838f..000000000
--- a/src/ripple/nodestore/backend/RocksDBFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce RocksDB backends for the NodeStore.
- @see Database
-*/
-std::unique_ptr make_RocksDBFactory ();
-
-}
-}
-
-#endif
-
-#endif
diff --git a/src/ripple/nodestore/backend/RocksDBQuickFactory.cpp b/src/ripple/nodestore/backend/RocksDBQuickFactory.cpp
index 86a2249aa..56183fec4 100644
--- a/src/ripple/nodestore/backend/RocksDBQuickFactory.cpp
+++ b/src/ripple/nodestore/backend/RocksDBQuickFactory.cpp
@@ -19,9 +19,14 @@
#if RIPPLE_ROCKSDB_AVAILABLE
-#include
+#include // VFALCO Bad dependency
+#include
+#include
+#include
+#include
#include
#include
+#include //
namespace ripple {
namespace NodeStore {
@@ -76,7 +81,6 @@ public:
class RocksDBQuickBackend
: public Backend
- , public beast::LeakChecked
{
private:
std::atomic m_deletePath;
@@ -328,15 +332,16 @@ public:
class RocksDBQuickFactory : public Factory
{
public:
- std::shared_ptr 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
-make_RocksDBQuickFactory ()
-{
- return std::make_unique ();
-}
+static RocksDBQuickFactory rocksDBQuickFactory;
}
}
diff --git a/src/ripple/nodestore/backend/RocksDBQuickFactory.h b/src/ripple/nodestore/backend/RocksDBQuickFactory.h
deleted file mode 100644
index 0d98f46b8..000000000
--- a/src/ripple/nodestore/backend/RocksDBQuickFactory.h
+++ /dev/null
@@ -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
-
-namespace ripple {
-namespace NodeStore {
-
-/** Factory to produce experimental RocksDB backends for the NodeStore.
- @see Database
-*/
-std::unique_ptr make_RocksDBQuickFactory ();
-
-}
-}
-
-#endif
-
-#endif
diff --git a/src/ripple/nodestore/impl/Backend.cpp b/src/ripple/nodestore/impl/Backend.cpp
deleted file mode 100644
index 4bf75171b..000000000
--- a/src/ripple/nodestore/impl/Backend.cpp
+++ /dev/null
@@ -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 ()
-{
-}
-
-}
-}
diff --git a/src/ripple/nodestore/impl/BatchWriter.cpp b/src/ripple/nodestore/impl/BatchWriter.cpp
index 4419331d7..9e67f1f6f 100644
--- a/src/ripple/nodestore/impl/BatchWriter.cpp
+++ b/src/ripple/nodestore/impl/BatchWriter.cpp
@@ -17,6 +17,8 @@
*/
//==============================================================================
+#include
+
namespace ripple {
namespace NodeStore {
diff --git a/src/ripple/nodestore/impl/Database.cpp b/src/ripple/nodestore/impl/Database.cpp
deleted file mode 100644
index 18bb407ea..000000000
--- a/src/ripple/nodestore/impl/Database.cpp
+++ /dev/null
@@ -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 ()
-{
-}
-
-}
-}
diff --git a/src/ripple/nodestore/impl/DatabaseImp.h b/src/ripple/nodestore/impl/DatabaseImp.h
index 0611edfd4..34a22237a 100644
--- a/src/ripple/nodestore/impl/DatabaseImp.h
+++ b/src/ripple/nodestore/impl/DatabaseImp.h
@@ -20,9 +20,14 @@
#ifndef RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED
#define RIPPLE_NODESTORE_DATABASEIMP_H_INCLUDED
-#include
-#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
#include
diff --git a/src/ripple/nodestore/impl/DecodedBlob.cpp b/src/ripple/nodestore/impl/DecodedBlob.cpp
index a2c691282..f947186a2 100644
--- a/src/ripple/nodestore/impl/DecodedBlob.cpp
+++ b/src/ripple/nodestore/impl/DecodedBlob.cpp
@@ -17,6 +17,7 @@
*/
//==============================================================================
+#include
#include
#include
diff --git a/src/ripple/nodestore/impl/EncodedBlob.cpp b/src/ripple/nodestore/impl/EncodedBlob.cpp
index e567baccf..7faf511ee 100644
--- a/src/ripple/nodestore/impl/EncodedBlob.cpp
+++ b/src/ripple/nodestore/impl/EncodedBlob.cpp
@@ -17,6 +17,9 @@
*/
//==============================================================================
+#include
+#include
+
namespace ripple {
namespace NodeStore {
diff --git a/src/ripple/nodestore/impl/EncodedBlob.h b/src/ripple/nodestore/impl/EncodedBlob.h
index b150a45e8..2a46fea3f 100644
--- a/src/ripple/nodestore/impl/EncodedBlob.h
+++ b/src/ripple/nodestore/impl/EncodedBlob.h
@@ -20,7 +20,10 @@
#ifndef RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
#define RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
+#include
#include
+#include
+#include
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;
};
}
diff --git a/src/ripple/nodestore/impl/Factory.cpp b/src/ripple/nodestore/impl/Factory.cpp
deleted file mode 100644
index 19e5262ea..000000000
--- a/src/ripple/nodestore/impl/Factory.cpp
+++ /dev/null
@@ -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 ()
-{
-}
-
-}
-}
diff --git a/src/ripple/nodestore/impl/Manager.cpp b/src/ripple/nodestore/impl/Manager.cpp
deleted file mode 100644
index 87b1a5b94..000000000
--- a/src/ripple/nodestore/impl/Manager.cpp
+++ /dev/null
@@ -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
-
-#include
-
-namespace ripple {
-namespace NodeStore {
-
-class ManagerImp : public Manager
-{
-public:
- typedef std::vector > List;
- List m_list;
-
- explicit ManagerImp (std::vector >&& factories)
- : m_list (std::move (factories))
- {
- add_known_factories ();
- }
-
- ~ManagerImp ()
- {
- }
-
- void
- add_factory (std::unique_ptr 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
- make_Backend (
- Parameters const& parameters,
- Scheduler& scheduler,
- beast::Journal journal)
- {
- std::unique_ptr 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
- make_Database (
- std::string const& name,
- Scheduler& scheduler,
- beast::Journal journal,
- int readThreads,
- Parameters const& backendParameters,
- Parameters fastBackendParameters)
- {
- std::unique_ptr backend (make_Backend (
- backendParameters, scheduler, journal));
-
- std::unique_ptr fastBackend (
- (fastBackendParameters.size () > 0)
- ? make_Backend (fastBackendParameters, scheduler, journal)
- : nullptr);
-
- return std::make_unique (name, scheduler, readThreads,
- std::move (backend), std::move (fastBackend), journal);
- }
-
- std::unique_ptr
- make_DatabaseRotating (
- std::string const& name,
- Scheduler& scheduler,
- std::int32_t readThreads,
- std::shared_ptr writableBackend,
- std::shared_ptr archiveBackend,
- std::unique_ptr fastBackend,
- beast::Journal journal)
- {
- return std::make_unique (name, scheduler,
- readThreads, writableBackend, archiveBackend,
- std::move (fastBackend), journal);
- }
-};
-
-//------------------------------------------------------------------------------
-
-Manager::~Manager ()
-{
-}
-
-std::unique_ptr
-make_Manager (std::vector > factories)
-{
- return std::make_unique (std::move (factories));
-}
-
-}
-}
diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp
new file mode 100644
index 000000000..e8a9a7a02
--- /dev/null
+++ b/src/ripple/nodestore/impl/ManagerImp.cpp
@@ -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
+#include
+#include
+#include
+#include //
+#include
+
+namespace ripple {
+namespace NodeStore {
+
+ManagerImp&
+ManagerImp::instance()
+{
+ static beast::static_initializer _;
+ 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
+ManagerImp::make_Backend (
+ Parameters const& parameters,
+ Scheduler& scheduler,
+ beast::Journal journal)
+{
+ std::unique_ptr 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
+ManagerImp::make_Database (
+ std::string const& name,
+ Scheduler& scheduler,
+ beast::Journal journal,
+ int readThreads,
+ Parameters const& backendParameters,
+ Parameters fastBackendParameters)
+{
+ std::unique_ptr backend (make_Backend (
+ backendParameters, scheduler, journal));
+
+ std::unique_ptr fastBackend (
+ (fastBackendParameters.size () > 0)
+ ? make_Backend (fastBackendParameters, scheduler, journal)
+ : nullptr);
+
+ return std::make_unique (name, scheduler, readThreads,
+ std::move (backend), std::move (fastBackend), journal);
+}
+
+std::unique_ptr
+ManagerImp::make_DatabaseRotating (
+ std::string const& name,
+ Scheduler& scheduler,
+ std::int32_t readThreads,
+ std::shared_ptr writableBackend,
+ std::shared_ptr archiveBackend,
+ std::unique_ptr fastBackend,
+ beast::Journal journal)
+{
+ return std::make_unique (name, scheduler,
+ readThreads, writableBackend, archiveBackend,
+ std::move (fastBackend), journal);
+}
+
+Factory*
+ManagerImp::find (std::string const& name)
+{
+ std::lock_guard _(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 _(mutex_);
+ list_.push_back(&factory);
+}
+
+void
+ManagerImp::erase (Factory& factory)
+{
+ std::lock_guard _(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();
+}
+
+}
+}
diff --git a/src/ripple/nodestore/impl/ManagerImp.h b/src/ripple/nodestore/impl/ManagerImp.h
new file mode 100644
index 000000000..9d802d428
--- /dev/null
+++ b/src/ripple/nodestore/impl/ManagerImp.h
@@ -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
+#include
+#include
+
+namespace ripple {
+namespace NodeStore {
+
+class ManagerImp : public Manager
+{
+private:
+ std::mutex mutex_;
+ std::vector 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
+ make_Backend (
+ Parameters const& parameters,
+ Scheduler& scheduler,
+ beast::Journal journal) override;
+
+ std::unique_ptr
+ make_Database (
+ std::string const& name,
+ Scheduler& scheduler,
+ beast::Journal journal,
+ int readThreads,
+ Parameters const& backendParameters,
+ Parameters fastBackendParameters) override;
+
+ std::unique_ptr
+ make_DatabaseRotating (
+ std::string const& name,
+ Scheduler& scheduler,
+ std::int32_t readThreads,
+ std::shared_ptr writableBackend,
+ std::shared_ptr archiveBackend,
+ std::unique_ptr fastBackend,
+ beast::Journal journal) override;
+};
+
+}
+}
+
+#endif
diff --git a/src/ripple/nodestore/impl/NodeObject.cpp b/src/ripple/nodestore/impl/NodeObject.cpp
index da088c90d..83df40900 100644
--- a/src/ripple/nodestore/impl/NodeObject.cpp
+++ b/src/ripple/nodestore/impl/NodeObject.cpp
@@ -17,6 +17,9 @@
*/
//==============================================================================
+#include
+#include
+
namespace ripple {
//------------------------------------------------------------------------------
diff --git a/src/ripple/nodestore/impl/Scheduler.cpp b/src/ripple/nodestore/impl/Scheduler.cpp
deleted file mode 100644
index d603c6bc0..000000000
--- a/src/ripple/nodestore/impl/Scheduler.cpp
+++ /dev/null
@@ -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 ()
-{
-}
-
-}
-}
diff --git a/src/ripple/nodestore/impl/Task.cpp b/src/ripple/nodestore/impl/Task.cpp
deleted file mode 100644
index 34bbc4ce6..000000000
--- a/src/ripple/nodestore/impl/Task.cpp
+++ /dev/null
@@ -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 ()
-{
-}
-
-}
-}
diff --git a/src/ripple/nodestore/tests/Backend.test.cpp b/src/ripple/nodestore/tests/Backend.test.cpp
index 47c7c56ee..9175eb48d 100644
--- a/src/ripple/nodestore/tests/Backend.test.cpp
+++ b/src/ripple/nodestore/tests/Backend.test.cpp
@@ -18,6 +18,8 @@
//==============================================================================
#include
+#include
+#include
#include
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 (make_Manager ());
-
DummyScheduler scheduler;
testcase ("Backend type=" + type);
@@ -50,8 +50,8 @@ public:
{
// Open the backend
- std::unique_ptr backend (manager->make_Backend (
- params, scheduler, j));
+ std::unique_ptr 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 (manager->make_Backend (
- params, scheduler, j));
+ std::unique_ptr backend = Manager::instance().make_Backend (
+ params, scheduler, j);
// Read it back in
Batch copy;
diff --git a/src/ripple/nodestore/tests/Base.test.h b/src/ripple/nodestore/tests/Base.test.h
index 18cb9425c..e74acac8a 100644
--- a/src/ripple/nodestore/tests/Base.test.h
+++ b/src/ripple/nodestore/tests/Base.test.h
@@ -20,9 +20,10 @@
#ifndef RIPPLE_NODESTORE_TESTBASE_H_INCLUDED
#define RIPPLE_NODESTORE_TESTBASE_H_INCLUDED
+#include
+#include
#include
#include
-#include
#include
#include
diff --git a/src/ripple/nodestore/tests/Basics.test.cpp b/src/ripple/nodestore/tests/Basics.test.cpp
index e047f74ef..a15c8183d 100644
--- a/src/ripple/nodestore/tests/Basics.test.cpp
+++ b/src/ripple/nodestore/tests/Basics.test.cpp
@@ -18,6 +18,10 @@
//==============================================================================
#include
+#include
+#include
+#include
+#include
namespace ripple {
namespace NodeStore {
diff --git a/src/ripple/nodestore/tests/Database.test.cpp b/src/ripple/nodestore/tests/Database.test.cpp
index 6990e331a..3bf516231 100644
--- a/src/ripple/nodestore/tests/Database.test.cpp
+++ b/src/ripple/nodestore/tests/Database.test.cpp
@@ -18,6 +18,9 @@
//==============================================================================
#include
+#include
+#include
+#include
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 (make_Manager ());
-
DummyScheduler scheduler;
beast::UnitTestUtilities::TempDirectory node_db ("node_db");
@@ -45,8 +46,8 @@ public:
// Write to source db
{
- std::unique_ptr src (manager->make_Database (
- "test", scheduler, j, 2, srcParams));
+ std::unique_ptr 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 src (manager->make_Database (
- "test", scheduler, j, 2, srcParams));
+ std::unique_ptr 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 dest (manager->make_Database (
- "test", scheduler, j, 2, destParams));
+ std::unique_ptr 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 (make_Manager ());
-
DummyScheduler scheduler;
std::string s = "NodeStore backend '" + type + "'";
@@ -121,8 +120,8 @@ public:
{
// Open the database
- std::unique_ptr db (manager->make_Database ("test", scheduler,
- j, 2, nodeParams, tempParams));
+ std::unique_ptr 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 db (manager->make_Database (
- "test", scheduler, j, 2, nodeParams));
+ std::unique_ptr 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 db (manager->make_Database ("test",
- scheduler, j, 2, tempParams, beast::StringPairArray ()));
+ std::unique_ptr db = Manager::instance().make_Database ("test",
+ scheduler, j, 2, tempParams, beast::StringPairArray ());
// Read it back in
Batch copy;
diff --git a/src/ripple/nodestore/tests/Timing.test.cpp b/src/ripple/nodestore/tests/Timing.test.cpp
index 51ae5366d..df0aa9a4a 100644
--- a/src/ripple/nodestore/tests/Timing.test.cpp
+++ b/src/ripple/nodestore/tests/Timing.test.cpp
@@ -18,6 +18,9 @@
//==============================================================================
#include
+#include
+#include
+#include
#include
namespace ripple {
@@ -210,7 +213,6 @@ public:
using check_func = std::function;
using backend_ptr = std::unique_ptr;
- using manager_ptr = std::unique_ptr;
using result_type = std::vector>;
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,
diff --git a/src/ripple/unity/nodestore.cpp b/src/ripple/unity/nodestore.cpp
index 1f4c63888..d8407468e 100644
--- a/src/ripple/unity/nodestore.cpp
+++ b/src/ripple/unity/nodestore.cpp
@@ -17,52 +17,29 @@
*/
//==============================================================================
-#include
-#include
+//#include
+//#include
// backend support
#include
#include
#include
-#include