Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
Copyright 2018-2022, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2022, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
This file is part of GekkoFS.
GekkoFS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GekkoFS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GekkoFS. If not, see <https://www.gnu.org/licenses/>.
SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef GEKKOFS_METADATA_PARALLAXBACKEND_HPP
#define GEKKOFS_METADATA_PARALLAXBACKEND_HPP
#include <memory>
#include <spdlog/spdlog.h>
#include <daemon/backend/exceptions.hpp>
#include <tuple>
extern "C" {
#include <parallax.h>
}
namespace rdb = rocksdb;
namespace gkfs::metadata {
class ParallaxBackend : public MetadataBackend<ParallaxBackend> {
private:
par_handle par_db_;
par_db_options par_options_;
std::string par_path_;
/**
* Convert a String to klc_key
* @param key
* @param klc_key struct
*/
inline void
str2par(const std::string& value, struct par_value& V) const;
/**
* Convert a String to klc_value
* @param value
* @param klc_value struct
*/
inline void
str2par(const std::string& key, struct par_key& K) const;
public:
/**
* Called when the daemon is started: Connects to the KV store
* @param path where KV store data is stored
*/
explicit ParallaxBackend(const std::string& path);
/**
* Exception wrapper on Status object. Throws NotFoundException if
* s == "Not Found", general DBException otherwise
* @param String with status
* @throws DBException
*/
static inline void
throw_status_excpt(const std::string& s);
/**
* @brief Destroy the Kreon Backend:: Kreon Backend object
* We remove the file, too large for the CI.
* TODO: Insert option
*/
virtual ~ParallaxBackend();
/**
* Gets a KV store value for a key
* @param key
* @return value
* @throws DBException on failure, NotFoundException if entry doesn't exist
*/
std::string
get_impl(const std::string& key) const;
/**
* Puts an entry into the KV store
* @param key
* @param val
* @throws DBException on failure
*/
void
put_impl(const std::string& key, const std::string& val);
/**
* Puts an entry into the KV store if it doesn't exist. This function does
* not use a mutex.
* @param key
* @param val
* @throws DBException on failure, ExistException if entry already exists
*/
void
put_no_exist_impl(const std::string& key, const std::string& val);
/**
* Removes an entry from the KV store
* @param key
* @throws DBException on failure, NotFoundException if entry doesn't exist
*/
void
remove_impl(const std::string& key);
/**
* checks for existence of an entry
* @param key
* @return true if exists
* @throws DBException on failure
*/
bool
exists_impl(const std::string& key);
/**
* Updates a metadentry atomically and also allows to change keys
* @param old_key
* @param new_key
* @param val
* @throws DBException on failure, NotFoundException if entry doesn't exist
*/
void
update_impl(const std::string& old_key, const std::string& new_key,
const std::string& val);
/**
* Updates the size on the metadata
* Operation. E.g., called before a write() call
* @param key
* @param size
* @param append
* @throws DBException on failure
*/
void
increase_size_impl(const std::string& key, size_t size, bool append);
/**
* Decreases the size on the metadata
* Operation E.g., called before a truncate() call
* @param key
* @param size
* @throws DBException on failure
*/
void
decrease_size_impl(const std::string& key, size_t size);
/**
* Return all the first-level entries of the directory @dir
*
* @return vector of pair <std::string name, bool is_dir>,
* where name is the name of the entries and is_dir
* is true in the case the entry is a directory.
*/
std::vector<std::pair<std::string, bool>>
get_dirents_impl(const std::string& dir) const;
/**
* Return all the first-level entries of the directory @dir
*
* @return vector of pair <std::string name, bool is_dir - size - ctime>,
* where name is the name of the entries and is_dir
* is true in the case the entry is a directory.
*/
std::vector<std::tuple<std::string, bool, size_t, time_t>>
get_dirents_extended_impl(const std::string& dir) const;
/**
* Code example for iterating all entries in KV store. This is for debug
* only as it is too expensive
*/
void
iterate_all_impl() const;
};
} // namespace gkfs::metadata
#endif // GEKKOFS_METADATA_KREONBACKEND_HPP