diff --git a/RocksDBFactory_8cpp_source.html b/RocksDBFactory_8cpp_source.html index 5a4113f955..c3dda01304 100644 --- a/RocksDBFactory_8cpp_source.html +++ b/RocksDBFactory_8cpp_source.html @@ -269,307 +269,311 @@ $(function() {
191
192 if (keyValues.exists("bbt_options"))
193 {
-
194 auto const s = rocksdb::GetBlockBasedTableOptionsFromString(
-
195 table_options, get(keyValues, "bbt_options"), &table_options);
-
196 if (!s.ok())
-
197 Throw<std::runtime_error>(
-
198 std::string("Unable to set RocksDB bbt_options: ") +
-
199 s.ToString());
-
200 }
-
201
-
202 m_options.table_factory.reset(NewBlockBasedTableFactory(table_options));
-
203
-
204 if (keyValues.exists("options"))
-
205 {
-
206 auto const s = rocksdb::GetOptionsFromString(
-
207 m_options, get(keyValues, "options"), &m_options);
-
208 if (!s.ok())
-
209 Throw<std::runtime_error>(
-
210 std::string("Unable to set RocksDB options: ") +
-
211 s.ToString());
-
212 }
-
213
-
214 std::string s1, s2;
-
215 rocksdb::GetStringFromDBOptions(&s1, m_options, "; ");
-
216 rocksdb::GetStringFromColumnFamilyOptions(&s2, m_options, "; ");
-
217 JLOG(m_journal.debug()) << "RocksDB DBOptions: " << s1;
-
218 JLOG(m_journal.debug()) << "RocksDB CFOptions: " << s2;
-
219 }
-
220
-
221 ~RocksDBBackend() override
-
222 {
-
223 close();
-
224 }
-
225
-
226 void
-
227 open(bool createIfMissing) override
-
228 {
-
229 if (m_db)
-
230 {
-
231 UNREACHABLE(
-
232 "ripple::NodeStore::RocksDBBackend::open : database is already "
-
233 "open");
-
234 JLOG(m_journal.error()) << "database is already open";
-
235 return;
-
236 }
-
237 rocksdb::DB* db = nullptr;
-
238 m_options.create_if_missing = createIfMissing;
-
239 rocksdb::Status status = rocksdb::DB::Open(m_options, m_name, &db);
-
240 if (!status.ok() || !db)
-
241 Throw<std::runtime_error>(
-
242 std::string("Unable to open/create RocksDB: ") +
-
243 status.ToString());
-
244 m_db.reset(db);
-
245 }
-
246
-
247 bool
-
248 isOpen() override
-
249 {
-
250 return static_cast<bool>(m_db);
-
251 }
-
252
-
253 void
-
254 close() override
-
255 {
-
256 if (m_db)
-
257 {
-
258 m_db.reset();
-
259 if (m_deletePath)
-
260 {
-
261 boost::filesystem::path dir = m_name;
-
262 boost::filesystem::remove_all(dir);
-
263 }
-
264 }
-
265 }
-
266
-
267 std::string
-
268 getName() override
-
269 {
-
270 return m_name;
-
271 }
-
272
-
273 //--------------------------------------------------------------------------
-
274
-
275 Status
-
276 fetch(void const* key, std::shared_ptr<NodeObject>* pObject) override
-
277 {
-
278 XRPL_ASSERT(
-
279 m_db,
-
280 "ripple::NodeStore::RocksDBBackend::fetch : non-null database");
-
281 pObject->reset();
-
282
-
283 Status status(ok);
-
284
-
285 rocksdb::ReadOptions const options;
-
286 rocksdb::Slice const slice(static_cast<char const*>(key), m_keyBytes);
-
287
-
288 std::string string;
-
289
-
290 rocksdb::Status getStatus = m_db->Get(options, slice, &string);
+
194 rocksdb::ConfigOptions config_options;
+
195 auto const s = rocksdb::GetBlockBasedTableOptionsFromString(
+
196 config_options,
+
197 table_options,
+
198 get(keyValues, "bbt_options"),
+
199 &table_options);
+
200 if (!s.ok())
+
201 Throw<std::runtime_error>(
+
202 std::string("Unable to set RocksDB bbt_options: ") +
+
203 s.ToString());
+
204 }
+
205
+
206 m_options.table_factory.reset(NewBlockBasedTableFactory(table_options));
+
207
+
208 if (keyValues.exists("options"))
+
209 {
+
210 auto const s = rocksdb::GetOptionsFromString(
+
211 m_options, get(keyValues, "options"), &m_options);
+
212 if (!s.ok())
+
213 Throw<std::runtime_error>(
+
214 std::string("Unable to set RocksDB options: ") +
+
215 s.ToString());
+
216 }
+
217
+
218 std::string s1, s2;
+
219 rocksdb::GetStringFromDBOptions(&s1, m_options, "; ");
+
220 rocksdb::GetStringFromColumnFamilyOptions(&s2, m_options, "; ");
+
221 JLOG(m_journal.debug()) << "RocksDB DBOptions: " << s1;
+
222 JLOG(m_journal.debug()) << "RocksDB CFOptions: " << s2;
+
223 }
+
224
+
225 ~RocksDBBackend() override
+
226 {
+
227 close();
+
228 }
+
229
+
230 void
+
231 open(bool createIfMissing) override
+
232 {
+
233 if (m_db)
+
234 {
+
235 UNREACHABLE(
+
236 "ripple::NodeStore::RocksDBBackend::open : database is already "
+
237 "open");
+
238 JLOG(m_journal.error()) << "database is already open";
+
239 return;
+
240 }
+
241 rocksdb::DB* db = nullptr;
+
242 m_options.create_if_missing = createIfMissing;
+
243 rocksdb::Status status = rocksdb::DB::Open(m_options, m_name, &db);
+
244 if (!status.ok() || !db)
+
245 Throw<std::runtime_error>(
+
246 std::string("Unable to open/create RocksDB: ") +
+
247 status.ToString());
+
248 m_db.reset(db);
+
249 }
+
250
+
251 bool
+
252 isOpen() override
+
253 {
+
254 return static_cast<bool>(m_db);
+
255 }
+
256
+
257 void
+
258 close() override
+
259 {
+
260 if (m_db)
+
261 {
+
262 m_db.reset();
+
263 if (m_deletePath)
+
264 {
+
265 boost::filesystem::path dir = m_name;
+
266 boost::filesystem::remove_all(dir);
+
267 }
+
268 }
+
269 }
+
270
+
271 std::string
+
272 getName() override
+
273 {
+
274 return m_name;
+
275 }
+
276
+
277 //--------------------------------------------------------------------------
+
278
+
279 Status
+
280 fetch(void const* key, std::shared_ptr<NodeObject>* pObject) override
+
281 {
+
282 XRPL_ASSERT(
+
283 m_db,
+
284 "ripple::NodeStore::RocksDBBackend::fetch : non-null database");
+
285 pObject->reset();
+
286
+
287 Status status(ok);
+
288
+
289 rocksdb::ReadOptions const options;
+
290 rocksdb::Slice const slice(static_cast<char const*>(key), m_keyBytes);
291
-
292 if (getStatus.ok())
-
293 {
-
294 DecodedBlob decoded(key, string.data(), string.size());
+
292 std::string string;
+
293
+
294 rocksdb::Status getStatus = m_db->Get(options, slice, &string);
295
-
296 if (decoded.wasOk())
-
297 {
-
298 *pObject = decoded.createObject();
-
299 }
-
300 else
+
296 if (getStatus.ok())
+
297 {
+
298 DecodedBlob decoded(key, string.data(), string.size());
+
299
+
300 if (decoded.wasOk())
301 {
-
302 // Decoding failed, probably corrupted!
-
303 //
-
304 status = dataCorrupt;
-
305 }
-
306 }
-
307 else
-
308 {
-
309 if (getStatus.IsCorruption())
-
310 {
-
311 status = dataCorrupt;
-
312 }
-
313 else if (getStatus.IsNotFound())
+
302 *pObject = decoded.createObject();
+
303 }
+
304 else
+
305 {
+
306 // Decoding failed, probably corrupted!
+
307 //
+
308 status = dataCorrupt;
+
309 }
+
310 }
+
311 else
+
312 {
+
313 if (getStatus.IsCorruption())
314 {
-
315 status = notFound;
+
315 status = dataCorrupt;
316 }
-
317 else
+
317 else if (getStatus.IsNotFound())
318 {
-
319 status =
-
320 Status(customCode + unsafe_cast<int>(getStatus.code()));
-
321
-
322 JLOG(m_journal.error()) << getStatus.ToString();
-
323 }
-
324 }
+
319 status = notFound;
+
320 }
+
321 else
+
322 {
+
323 status =
+
324 Status(customCode + unsafe_cast<int>(getStatus.code()));
325
-
326 return status;
-
327 }
-
328
-
329 std::pair<std::vector<std::shared_ptr<NodeObject>>, Status>
-
330 fetchBatch(std::vector<uint256 const*> const& hashes) override
-
331 {
-
332 std::vector<std::shared_ptr<NodeObject>> results;
-
333 results.reserve(hashes.size());
-
334 for (auto const& h : hashes)
-
335 {
-
336 std::shared_ptr<NodeObject> nObj;
-
337 Status status = fetch(h->begin(), &nObj);
-
338 if (status != ok)
-
339 results.push_back({});
-
340 else
-
341 results.push_back(nObj);
-
342 }
-
343
-
344 return {results, ok};
-
345 }
-
346
-
347 void
-
348 store(std::shared_ptr<NodeObject> const& object) override
-
349 {
-
350 m_batch.store(object);
-
351 }
-
352
-
353 void
-
354 storeBatch(Batch const& batch) override
-
355 {
-
356 XRPL_ASSERT(
-
357 m_db,
-
358 "ripple::NodeStore::RocksDBBackend::storeBatch : non-null "
-
359 "database");
-
360 rocksdb::WriteBatch wb;
-
361
-
362 for (auto const& e : batch)
-
363 {
-
364 EncodedBlob encoded(e);
+
326 JLOG(m_journal.error()) << getStatus.ToString();
+
327 }
+
328 }
+
329
+
330 return status;
+
331 }
+
332
+
333 std::pair<std::vector<std::shared_ptr<NodeObject>>, Status>
+
334 fetchBatch(std::vector<uint256 const*> const& hashes) override
+
335 {
+
336 std::vector<std::shared_ptr<NodeObject>> results;
+
337 results.reserve(hashes.size());
+
338 for (auto const& h : hashes)
+
339 {
+
340 std::shared_ptr<NodeObject> nObj;
+
341 Status status = fetch(h->begin(), &nObj);
+
342 if (status != ok)
+
343 results.push_back({});
+
344 else
+
345 results.push_back(nObj);
+
346 }
+
347
+
348 return {results, ok};
+
349 }
+
350
+
351 void
+
352 store(std::shared_ptr<NodeObject> const& object) override
+
353 {
+
354 m_batch.store(object);
+
355 }
+
356
+
357 void
+
358 storeBatch(Batch const& batch) override
+
359 {
+
360 XRPL_ASSERT(
+
361 m_db,
+
362 "ripple::NodeStore::RocksDBBackend::storeBatch : non-null "
+
363 "database");
+
364 rocksdb::WriteBatch wb;
365
-
366 wb.Put(
-
367 rocksdb::Slice(
-
368 reinterpret_cast<char const*>(encoded.getKey()),
-
369 m_keyBytes),
-
370 rocksdb::Slice(
-
371 reinterpret_cast<char const*>(encoded.getData()),
-
372 encoded.getSize()));
-
373 }
-
374
-
375 rocksdb::WriteOptions const options;
-
376
-
377 auto ret = m_db->Write(options, &wb);
+
366 for (auto const& e : batch)
+
367 {
+
368 EncodedBlob encoded(e);
+
369
+
370 wb.Put(
+
371 rocksdb::Slice(
+
372 reinterpret_cast<char const*>(encoded.getKey()),
+
373 m_keyBytes),
+
374 rocksdb::Slice(
+
375 reinterpret_cast<char const*>(encoded.getData()),
+
376 encoded.getSize()));
+
377 }
378
-
379 if (!ret.ok())
-
380 Throw<std::runtime_error>("storeBatch failed: " + ret.ToString());
-
381 }
+
379 rocksdb::WriteOptions const options;
+
380
+
381 auto ret = m_db->Write(options, &wb);
382
-
383 void
-
384 sync() override
-
385 {
-
386 }
-
387
-
388 void
-
389 for_each(std::function<void(std::shared_ptr<NodeObject>)> f) override
-
390 {
-
391 XRPL_ASSERT(
-
392 m_db,
-
393 "ripple::NodeStore::RocksDBBackend::for_each : non-null database");
-
394 rocksdb::ReadOptions const options;
-
395
-
396 std::unique_ptr<rocksdb::Iterator> it(m_db->NewIterator(options));
-
397
-
398 for (it->SeekToFirst(); it->Valid(); it->Next())
-
399 {
-
400 if (it->key().size() == m_keyBytes)
-
401 {
-
402 DecodedBlob decoded(
-
403 it->key().data(), it->value().data(), it->value().size());
-
404
-
405 if (decoded.wasOk())
-
406 {
-
407 f(decoded.createObject());
-
408 }
-
409 else
+
383 if (!ret.ok())
+
384 Throw<std::runtime_error>("storeBatch failed: " + ret.ToString());
+
385 }
+
386
+
387 void
+
388 sync() override
+
389 {
+
390 }
+
391
+
392 void
+
393 for_each(std::function<void(std::shared_ptr<NodeObject>)> f) override
+
394 {
+
395 XRPL_ASSERT(
+
396 m_db,
+
397 "ripple::NodeStore::RocksDBBackend::for_each : non-null database");
+
398 rocksdb::ReadOptions const options;
+
399
+
400 std::unique_ptr<rocksdb::Iterator> it(m_db->NewIterator(options));
+
401
+
402 for (it->SeekToFirst(); it->Valid(); it->Next())
+
403 {
+
404 if (it->key().size() == m_keyBytes)
+
405 {
+
406 DecodedBlob decoded(
+
407 it->key().data(), it->value().data(), it->value().size());
+
408
+
409 if (decoded.wasOk())
410 {
-
411 // Uh oh, corrupted data!
-
412 JLOG(m_journal.fatal())
-
413 << "Corrupt NodeObject #" << it->key().ToString(true);
-
414 }
-
415 }
-
416 else
-
417 {
-
418 // VFALCO NOTE What does it mean to find an
-
419 // incorrectly sized key? Corruption?
-
420 JLOG(m_journal.fatal())
-
421 << "Bad key size = " << it->key().size();
-
422 }
-
423 }
-
424 }
-
425
-
426 int
-
427 getWriteLoad() override
-
428 {
-
429 return m_batch.getWriteLoad();
-
430 }
-
431
-
432 void
-
433 setDeletePath() override
-
434 {
-
435 m_deletePath = true;
-
436 }
-
437
-
438 //--------------------------------------------------------------------------
-
439
-
440 void
-
441 writeBatch(Batch const& batch) override
-
442 {
-
443 storeBatch(batch);
-
444 }
-
445
-
447 int
-
448 fdRequired() const override
-
449 {
-
450 return fdRequired_;
-
451 }
-
452};
-
453
-
454//------------------------------------------------------------------------------
-
455
-
456class RocksDBFactory : public Factory
-
457{
-
458public:
-
459 RocksDBEnv m_env;
-
460
-
461 RocksDBFactory()
-
462 {
-
463 Manager::instance().insert(*this);
-
464 }
-
465
-
466 ~RocksDBFactory() override
-
467 {
-
468 Manager::instance().erase(*this);
-
469 }
-
470
-
471 std::string
-
472 getName() const override
-
473 {
-
474 return "RocksDB";
-
475 }
-
476
-
477 std::unique_ptr<Backend>
-
478 createInstance(
-
479 size_t keyBytes,
-
480 Section const& keyValues,
-
481 std::size_t,
-
482 Scheduler& scheduler,
-
483 beast::Journal journal) override
-
484 {
-
485 return std::make_unique<RocksDBBackend>(
-
486 keyBytes, keyValues, scheduler, journal, &m_env);
-
487 }
-
488};
-
489
-
490static RocksDBFactory rocksDBFactory;
-
491
-
492} // namespace NodeStore
-
493} // namespace ripple
-
494
-
495#endif
+
411 f(decoded.createObject());
+
412 }
+
413 else
+
414 {
+
415 // Uh oh, corrupted data!
+
416 JLOG(m_journal.fatal())
+
417 << "Corrupt NodeObject #" << it->key().ToString(true);
+
418 }
+
419 }
+
420 else
+
421 {
+
422 // VFALCO NOTE What does it mean to find an
+
423 // incorrectly sized key? Corruption?
+
424 JLOG(m_journal.fatal())
+
425 << "Bad key size = " << it->key().size();
+
426 }
+
427 }
+
428 }
+
429
+
430 int
+
431 getWriteLoad() override
+
432 {
+
433 return m_batch.getWriteLoad();
+
434 }
+
435
+
436 void
+
437 setDeletePath() override
+
438 {
+
439 m_deletePath = true;
+
440 }
+
441
+
442 //--------------------------------------------------------------------------
+
443
+
444 void
+
445 writeBatch(Batch const& batch) override
+
446 {
+
447 storeBatch(batch);
+
448 }
+
449
+
451 int
+
452 fdRequired() const override
+
453 {
+
454 return fdRequired_;
+
455 }
+
456};
+
457
+
458//------------------------------------------------------------------------------
+
459
+
460class RocksDBFactory : public Factory
+
461{
+
462public:
+
463 RocksDBEnv m_env;
+
464
+
465 RocksDBFactory()
+
466 {
+
467 Manager::instance().insert(*this);
+
468 }
+
469
+
470 ~RocksDBFactory() override
+
471 {
+
472 Manager::instance().erase(*this);
+
473 }
+
474
+
475 std::string
+
476 getName() const override
+
477 {
+
478 return "RocksDB";
+
479 }
+
480
+
481 std::unique_ptr<Backend>
+
482 createInstance(
+
483 size_t keyBytes,
+
484 Section const& keyValues,
+
485 std::size_t,
+
486 Scheduler& scheduler,
+
487 beast::Journal journal) override
+
488 {
+
489 return std::make_unique<RocksDBBackend>(
+
490 keyBytes, keyValues, scheduler, journal, &m_env);
+
491 }
+
492};
+
493
+
494static RocksDBFactory rocksDBFactory;
+
495
+
496} // namespace NodeStore
+
497} // namespace ripple
+
498
+
499#endif
atomic
std::string
std::stringstream
diff --git a/md____w_rippled_rippled_BUILD.html b/md____w_rippled_rippled_BUILD.html index 680b5955ec..c062328ccc 100644 --- a/md____w_rippled_rippled_BUILD.html +++ b/md____w_rippled_rippled_BUILD.html @@ -161,9 +161,9 @@ Multiple compilers
conan export --version 1.1.10 external/snappy

Export our Conan recipe for RocksDB. It does not override paths to dependencies when building with Visual Studio.

# Conan 1.x
-
conan export external/rocksdb rocksdb/6.29.5@
+
conan export external/rocksdb rocksdb/9.7.3@
# Conan 2.x
-
conan export --version 6.29.5 external/rocksdb
+
conan export --version 9.7.3 external/rocksdb

Export our Conan recipe for SOCI. It patches their CMake to correctly import its dependencies.

# Conan 1.x
conan export external/soci soci/4.0.3@