rippled
Loading...
Searching...
No Matches
DatabaseRotatingImp.h
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#ifndef RIPPLE_NODESTORE_DATABASEROTATINGIMP_H_INCLUDED
21#define RIPPLE_NODESTORE_DATABASEROTATINGIMP_H_INCLUDED
22
23#include <xrpld/nodestore/DatabaseRotating.h>
24
25#include <mutex>
26
27namespace ripple {
28namespace NodeStore {
29
31{
32public:
37
39 Scheduler& scheduler,
40 int readThreads,
41 std::shared_ptr<Backend> writableBackend,
42 std::shared_ptr<Backend> archiveBackend,
43 Section const& config,
45
47 {
48 stop();
49 }
50
51 void
52 rotate(
54 std::function<void(
55 std::string const& writableName,
56 std::string const& archiveName)> const& f) override;
57
59 getName() const override;
60
62 getWriteLoad() const override;
63
64 void
65 importDatabase(Database& source) override;
66
67 bool
69 {
70 // rotating store acts as one logical database
71 return true;
72 }
73
74 void
75 store(NodeObjectType type, Blob&& data, uint256 const& hash, std::uint32_t)
76 override;
77
78 void
79 sync() override;
80
81 void
82 sweep() override;
83
84private:
88
91 uint256 const& hash,
93 FetchReport& fetchReport,
94 bool duplicate) override;
95
96 void
98};
99
100} // namespace NodeStore
101} // namespace ripple
102
103#endif
A generic endpoint for log messages.
Definition: Journal.h:60
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
DatabaseRotatingImp(DatabaseRotatingImp const &)=delete
std::shared_ptr< Backend > archiveBackend_
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
void importDatabase(Database &source) override
Import objects from another database.
std::string getName() const override
Retrieve the name associated with this backend.
void sweep() override
Remove expired entries from the positive and negative caches.
bool isSameDB(std::uint32_t, std::uint32_t) override
std::shared_ptr< Backend > writableBackend_
void rotate(std::unique_ptr< NodeStore::Backend > &&newBackend, std::function< void(std::string const &writableName, std::string const &archiveName)> const &f) override
Rotates the backends.
DatabaseRotatingImp & operator=(DatabaseRotatingImp const &)=delete
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
Persistency layer for NodeObject.
Definition: Database.h:52
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
Definition: BasicConfig.h:45
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
NodeObjectType
The types of node objects.
Definition: NodeObject.h:32
Contains information about a fetch operation.