From 3ffa4bdf96b32b060f45657223717062ab7783bc Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 25 Sep 2017 19:32:39 -0700 Subject: [PATCH] tools/ceph-kvstore-tool: add destination store type to store-copy This allows e.g. copying from leveldb into rocksdb Signed-off-by: Josh Durgin (cherry picked from commit a65a7f0430a32a7748b54f4babecba0f58a5e42f) --- src/tools/ceph_kvstore_tool.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 751bf106c7041..1a9af24108b40 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -142,7 +142,7 @@ class StoreTool } int copy_store_to(string type, const string &other_path, - const int num_keys_per_tx) { + const int num_keys_per_tx, const string &other_type) { if (num_keys_per_tx <= 0) { std::cerr << "must specify a number of keys/tx > 0" << std::endl; @@ -150,7 +150,7 @@ class StoreTool } // open or create a leveldb store at @p other_path - KeyValueDB *other = KeyValueDB::create(g_ceph_context, type, other_path); + KeyValueDB *other = KeyValueDB::create(g_ceph_context, other_type, other_path); int err = other->create_and_open(std::cerr); if (err < 0) return err; @@ -219,7 +219,7 @@ void usage(const char *pname) << " crc \n" << " get-size [ ]\n" << " set [ver |in ]\n" - << " store-copy [num-keys-per-tx]\n" + << " store-copy [num-keys-per-tx] [leveldb|rocksdb|...] \n" << " store-crc \n" << std::endl; } @@ -408,8 +408,12 @@ int main(int argc, const char *argv[]) return 1; } } + string other_store_type = argv[1]; + if (argc > 6) { + other_store_type = argv[6]; + } - int ret = st.copy_store_to(argv[1], argv[4], num_keys_per_tx); + int ret = st.copy_store_to(argv[1], argv[4], num_keys_per_tx, other_store_type); if (ret < 0) { std::cerr << "error copying store to path '" << argv[4] << "': " << cpp_strerror(ret) << std::endl; -- 2.39.5