]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/kvstore_tool.h
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / tools / kvstore_tool.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#pragma once
5
6#include <memory>
7#include <ostream>
8#include <string>
9
10#include "acconfig.h"
11#include "include/buffer_fwd.h"
12#ifdef WITH_BLUESTORE
13#include "os/bluestore/BlueStore.h"
14#endif
15
16class KeyValueDB;
17
18class StoreTool
19{
20#ifdef WITH_BLUESTORE
21 struct Deleter {
22 BlueStore *bluestore;
23 Deleter()
24 : bluestore(nullptr) {}
25 Deleter(BlueStore *store)
26 : bluestore(store) {}
27 void operator()(KeyValueDB *db) {
28 if (bluestore) {
29 bluestore->umount();
30 delete bluestore;
31 } else {
32 delete db;
33 }
34 }
35 };
36 std::unique_ptr<KeyValueDB, Deleter> db;
37#else
38 std::unique_ptr<KeyValueDB> db;
39#endif
40
41 const std::string store_path;
42
43public:
44 StoreTool(const std::string& type,
45 const std::string& path,
494da23a
TL
46 bool need_open_db = true,
47 bool need_stats = false);
11fdf7f2
TL
48 int load_bluestore(const std::string& path, bool need_open_db);
49 uint32_t traverse(const std::string& prefix,
50 const bool do_crc,
51 const bool do_value_dump,
52 ostream *out);
53 void list(const std::string& prefix,
54 const bool do_crc,
55 const bool do_value_dump);
56 bool exists(const std::string& prefix);
57 bool exists(const std::string& prefix, const std::string& key);
58 ceph::bufferlist get(const std::string& prefix,
59 const std::string& key,
60 bool& exists);
61 uint64_t get_size();
62 bool set(const std::string& prefix,
63 const std::string& key,
64 ceph::bufferlist& val);
65 bool rm(const std::string& prefix, const std::string& key);
66 bool rm_prefix(const std::string& prefix);
67 void print_summary(const uint64_t total_keys, const uint64_t total_size,
68 const uint64_t total_txs, const std::string& store_path,
69 const std::string& other_path, const int duration) const;
70 int copy_store_to(const std::string& type, const std::string& other_path,
71 const int num_keys_per_tx, const std::string& other_type);
72 void compact();
73 void compact_prefix(const std::string& prefix);
74 void compact_range(const std::string& prefix,
75 const std::string& start,
76 const std::string& end);
77 int destructive_repair();
494da23a
TL
78
79 int print_stats() const;
11fdf7f2 80};