rippled
DatabaseCon.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/contract.h>
22 #include <ripple/core/DatabaseCon.h>
23 #include <ripple/core/SociDB.h>
24 #include <memory>
25 
26 namespace ripple {
27 
28 DatabaseCon::Setup
30 {
31  DatabaseCon::Setup setup;
32 
33  setup.startUp = c.START_UP;
34  setup.standAlone = c.standalone();
35  setup.dataDir = c.legacy("database_path");
36  if (!setup.standAlone && setup.dataDir.empty())
37  {
38  Throw<std::runtime_error>("database_path must be set.");
39  }
40 
41  return setup;
42 }
43 
44 void
46 {
47  if (!q)
48  Throw<std::logic_error>("No JobQueue");
50 }
51 
52 } // namespace ripple
ripple::Logs
Manages partitions for logging.
Definition: Log.h:48
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:85
ripple::DatabaseCon::Setup::startUp
Config::StartUpType startUp
Definition: DatabaseCon.h:89
ripple::DatabaseCon::Setup::dataDir
boost::filesystem::path dataDir
Definition: DatabaseCon.h:91
ripple::DatabaseCon::setupCheckpointing
void setupCheckpointing(JobQueue *, Logs &)
Definition: DatabaseCon.cpp:45
ripple::setup_DatabaseCon
DatabaseCon::Setup setup_DatabaseCon(Config const &c)
Definition: DatabaseCon.cpp:29
ripple::DatabaseCon::Setup::standAlone
bool standAlone
Definition: DatabaseCon.h:90
ripple::Config
Definition: Config.h:66
ripple::makeCheckpointer
std::unique_ptr< Checkpointer > makeCheckpointer(soci::session &session, JobQueue &queue, Logs &logs)
Returns a new checkpointer which makes checkpoints of a soci database every checkpointPageCount pages...
Definition: SociDB.cpp:280
ripple::DatabaseCon::session_
soci::session session_
Definition: DatabaseCon.h:161
ripple::Config::standalone
bool standalone() const
Definition: Config.h:216
ripple::BasicConfig::legacy
void legacy(std::string const &section, std::string value)
Set a value that is not a key/value pair.
Definition: BasicConfig.cpp:175
ripple::Config::START_UP
StartUpType START_UP
Definition: Config.h:123
memory
ripple::JobQueue
A pool of threads to perform work.
Definition: JobQueue.h:55
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::DatabaseCon::checkpointer_
std::unique_ptr< Checkpointer > checkpointer_
Definition: DatabaseCon.h:162