2016-05-07 01:09:09 +02:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "rocksdb/utilities/ldb_cmd.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
class CompactorCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "compact"; }
|
|
|
|
|
|
|
|
CompactorCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool null_from_;
|
|
|
|
std::string from_;
|
|
|
|
bool null_to_;
|
|
|
|
std::string to_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DBFileDumperCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "dump_live_files"; }
|
|
|
|
|
|
|
|
DBFileDumperCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
2022-04-15 18:04:04 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool decode_blob_index_;
|
2016-05-07 01:09:09 +02:00
|
|
|
};
|
|
|
|
|
Add list live files metadata (#8446)
Summary:
Add an argument to ldb to dump live file names, column families, and levels, `list_live_files_metadata`. The output shows all active SST file names, sorted first by column family and then by level. For each level the SST files are sorted alphabetically.
Typically, the output looks like this:
```
./ldb --db=/tmp/test_db list_live_files_metadata
Live SST Files:
===== Column Family: default =====
---------- level 0 ----------
/tmp/test_db/000069.sst
---------- level 1 ----------
/tmp/test_db/000064.sst
/tmp/test_db/000065.sst
/tmp/test_db/000066.sst
/tmp/test_db/000071.sst
---------- level 2 ----------
/tmp/test_db/000038.sst
/tmp/test_db/000039.sst
/tmp/test_db/000052.sst
/tmp/test_db/000067.sst
/tmp/test_db/000070.sst
------------------------------
```
Second, a flag was added `--sort_by_filename`, to change the layout of the output. When this flag is added to the command, the output shows all active SST files sorted by name, in front of which the LSM level and the column family are mentioned. With the same example, the following command would return:
```
./ldb --db=/tmp/test_db list_live_files_metadata --sort_by_filename
Live SST Files:
/tmp/test_db/000038.sst : level 2, column family 'default'
/tmp/test_db/000039.sst : level 2, column family 'default'
/tmp/test_db/000052.sst : level 2, column family 'default'
/tmp/test_db/000064.sst : level 1, column family 'default'
/tmp/test_db/000065.sst : level 1, column family 'default'
/tmp/test_db/000066.sst : level 1, column family 'default'
/tmp/test_db/000067.sst : level 2, column family 'default'
/tmp/test_db/000069.sst : level 0, column family 'default'
/tmp/test_db/000070.sst : level 2, column family 'default'
/tmp/test_db/000071.sst : level 1, column family 'default'
------------------------------
```
Thus, the user can either request to show the files by levels, or sorted by filenames.
This PR includes a simple Python unit test that makes sure the file name and level printed out by this new feature matches the one found with an existing feature, `dump_live_file`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8446
Reviewed By: akankshamahajan15
Differential Revision: D29320080
Pulled By: bjlemaire
fbshipit-source-id: 01fb7b5637c59010d74c80730a28d815994e7009
2021-06-23 04:06:44 +02:00
|
|
|
class DBLiveFilesMetadataDumperCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "list_live_files_metadata"; }
|
|
|
|
|
|
|
|
DBLiveFilesMetadataDumperCommand(
|
|
|
|
const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool sort_by_filename_;
|
|
|
|
|
|
|
|
static const std::string ARG_SORT_BY_FILENAME;
|
|
|
|
};
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
class DBDumperCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "dump"; }
|
|
|
|
|
|
|
|
DBDumperCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Extract file name from the full path. We handle both the forward slash (/)
|
|
|
|
* and backslash (\) to make sure that different OS-s are supported.
|
|
|
|
*/
|
|
|
|
static std::string GetFileNameFromPath(const std::string& s) {
|
|
|
|
std::size_t n = s.find_last_of("/\\");
|
|
|
|
|
|
|
|
if (std::string::npos == n) {
|
|
|
|
return s;
|
|
|
|
} else {
|
|
|
|
return s.substr(n + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoDumpCommand();
|
|
|
|
|
|
|
|
bool null_from_;
|
|
|
|
std::string from_;
|
|
|
|
bool null_to_;
|
|
|
|
std::string to_;
|
|
|
|
int max_keys_;
|
|
|
|
std::string delim_;
|
|
|
|
bool count_only_;
|
|
|
|
bool count_delim_;
|
|
|
|
bool print_stats_;
|
|
|
|
std::string path_;
|
2022-04-20 20:10:20 +02:00
|
|
|
bool decode_blob_index_;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
static const std::string ARG_COUNT_ONLY;
|
|
|
|
static const std::string ARG_COUNT_DELIM;
|
|
|
|
static const std::string ARG_STATS;
|
|
|
|
static const std::string ARG_TTL_BUCKET;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InternalDumpCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "idump"; }
|
|
|
|
|
|
|
|
InternalDumpCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool has_from_;
|
|
|
|
std::string from_;
|
|
|
|
bool has_to_;
|
|
|
|
std::string to_;
|
|
|
|
int max_keys_;
|
|
|
|
std::string delim_;
|
|
|
|
bool count_only_;
|
|
|
|
bool count_delim_;
|
|
|
|
bool print_stats_;
|
|
|
|
bool is_input_key_hex_;
|
2022-04-20 20:10:20 +02:00
|
|
|
bool decode_blob_index_;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
static const std::string ARG_DELIM;
|
|
|
|
static const std::string ARG_COUNT_ONLY;
|
|
|
|
static const std::string ARG_COUNT_DELIM;
|
|
|
|
static const std::string ARG_STATS;
|
|
|
|
static const std::string ARG_INPUT_KEY_HEX;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DBLoaderCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "load"; }
|
|
|
|
|
|
|
|
DBLoaderCommand(std::string& db_name, std::vector<std::string>& args);
|
|
|
|
|
|
|
|
DBLoaderCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool disable_wal_;
|
|
|
|
bool bulk_load_;
|
|
|
|
bool compact_;
|
|
|
|
|
|
|
|
static const std::string ARG_DISABLE_WAL;
|
|
|
|
static const std::string ARG_BULK_LOAD;
|
|
|
|
static const std::string ARG_COMPACT;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ManifestDumpCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "manifest_dump"; }
|
|
|
|
|
|
|
|
ManifestDumpCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool verbose_;
|
|
|
|
bool json_;
|
|
|
|
std::string path_;
|
|
|
|
|
|
|
|
static const std::string ARG_VERBOSE;
|
|
|
|
static const std::string ARG_JSON;
|
|
|
|
static const std::string ARG_PATH;
|
|
|
|
};
|
|
|
|
|
2022-03-19 00:35:51 +01:00
|
|
|
class UpdateManifestCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "update_manifest"; }
|
|
|
|
|
|
|
|
UpdateManifestCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool verbose_;
|
|
|
|
bool update_temperatures_;
|
|
|
|
// TODO future: checksum_func for populating checksums
|
|
|
|
|
|
|
|
static const std::string ARG_VERBOSE;
|
|
|
|
static const std::string ARG_UPDATE_TEMPERATURES;
|
|
|
|
};
|
|
|
|
|
2020-02-11 00:42:46 +01:00
|
|
|
class FileChecksumDumpCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "file_checksum_dump"; }
|
|
|
|
|
|
|
|
FileChecksumDumpCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
void DoCommand() override;
|
|
|
|
|
|
|
|
bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string path_;
|
2021-01-04 20:12:08 +01:00
|
|
|
bool is_checksum_hex_;
|
2020-02-11 00:42:46 +01:00
|
|
|
|
|
|
|
static const std::string ARG_PATH;
|
|
|
|
};
|
|
|
|
|
2020-12-19 16:59:08 +01:00
|
|
|
class GetPropertyCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "get_property"; }
|
|
|
|
|
|
|
|
GetPropertyCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string property_;
|
|
|
|
};
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
class ListColumnFamiliesCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "list_column_families"; }
|
|
|
|
|
|
|
|
ListColumnFamiliesCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CreateColumnFamilyCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "create_column_family"; }
|
|
|
|
|
|
|
|
CreateColumnFamilyCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return false; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string new_cf_name_;
|
|
|
|
};
|
|
|
|
|
2019-06-27 20:08:45 +02:00
|
|
|
class DropColumnFamilyCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "drop_column_family"; }
|
|
|
|
|
|
|
|
DropColumnFamilyCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return false; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string cf_name_to_drop_;
|
|
|
|
};
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
class ReduceDBLevelsCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "reduce_levels"; }
|
|
|
|
|
|
|
|
ReduceDBLevelsCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
2021-01-12 05:54:58 +01:00
|
|
|
virtual void OverrideBaseCFOptions(ColumnFamilyOptions* cf_opts) override;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
static void Help(std::string& msg);
|
|
|
|
|
|
|
|
static std::vector<std::string> PrepareArgs(const std::string& db_path,
|
|
|
|
int new_levels,
|
|
|
|
bool print_old_level = false);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int old_levels_;
|
|
|
|
int new_levels_;
|
|
|
|
bool print_old_levels_;
|
|
|
|
|
|
|
|
static const std::string ARG_NEW_LEVELS;
|
|
|
|
static const std::string ARG_PRINT_OLD_LEVELS;
|
|
|
|
|
|
|
|
Status GetOldNumOfLevels(Options& opt, int* levels);
|
|
|
|
};
|
|
|
|
|
|
|
|
class ChangeCompactionStyleCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "change_compaction_style"; }
|
|
|
|
|
|
|
|
ChangeCompactionStyleCommand(
|
|
|
|
const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
2021-01-12 05:54:58 +01:00
|
|
|
virtual void OverrideBaseCFOptions(ColumnFamilyOptions* cf_opts) override;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& msg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int old_compaction_style_;
|
|
|
|
int new_compaction_style_;
|
|
|
|
|
|
|
|
static const std::string ARG_OLD_COMPACTION_STYLE;
|
|
|
|
static const std::string ARG_NEW_COMPACTION_STYLE;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WALDumperCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "dump_wal"; }
|
|
|
|
|
|
|
|
WALDumperCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool print_header_;
|
|
|
|
std::string wal_file_;
|
|
|
|
bool print_values_;
|
2018-04-08 06:46:53 +02:00
|
|
|
bool is_write_committed_; // default will be set to true
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
static const std::string ARG_WAL_FILE;
|
2018-04-08 06:46:53 +02:00
|
|
|
static const std::string ARG_WRITE_COMMITTED;
|
2016-05-07 01:09:09 +02:00
|
|
|
static const std::string ARG_PRINT_HEADER;
|
|
|
|
static const std::string ARG_PRINT_VALUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GetCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "get"; }
|
|
|
|
|
|
|
|
GetCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string key_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ApproxSizeCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "approxsize"; }
|
|
|
|
|
|
|
|
ApproxSizeCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string start_key_;
|
|
|
|
std::string end_key_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BatchPutCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "batchput"; }
|
|
|
|
|
|
|
|
BatchPutCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* The key-values to be inserted.
|
|
|
|
*/
|
|
|
|
std::vector<std::pair<std::string, std::string>> key_values_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScanCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "scan"; }
|
|
|
|
|
|
|
|
ScanCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string start_key_;
|
|
|
|
std::string end_key_;
|
|
|
|
bool start_key_specified_;
|
|
|
|
bool end_key_specified_;
|
|
|
|
int max_keys_scanned_;
|
|
|
|
bool no_value_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DeleteCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "delete"; }
|
|
|
|
|
|
|
|
DeleteCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string key_;
|
|
|
|
};
|
|
|
|
|
2016-11-16 00:49:15 +01:00
|
|
|
class DeleteRangeCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "deleterange"; }
|
|
|
|
|
|
|
|
DeleteRangeCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string begin_key_;
|
|
|
|
std::string end_key_;
|
|
|
|
};
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
class PutCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "put"; }
|
|
|
|
|
|
|
|
PutCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
2016-05-07 01:09:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string key_;
|
|
|
|
std::string value_;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command that starts up a REPL shell that allows
|
|
|
|
* get/put/delete.
|
|
|
|
*/
|
|
|
|
class DBQuerierCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "query"; }
|
|
|
|
|
|
|
|
DBQuerierCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const char* HELP_CMD;
|
|
|
|
static const char* GET_CMD;
|
|
|
|
static const char* PUT_CMD;
|
|
|
|
static const char* DELETE_CMD;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CheckConsistencyCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "checkconsistency"; }
|
|
|
|
|
|
|
|
CheckConsistencyCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
};
|
|
|
|
|
2017-03-21 19:49:08 +01:00
|
|
|
class CheckPointCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "checkpoint"; }
|
|
|
|
|
|
|
|
CheckPointCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
std::string checkpoint_dir_;
|
|
|
|
private:
|
|
|
|
static const std::string ARG_CHECKPOINT_DIR;
|
|
|
|
};
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
class RepairCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "repair"; }
|
|
|
|
|
|
|
|
RepairCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
|
|
|
|
2016-05-07 01:09:09 +02:00
|
|
|
static void Help(std::string& ret);
|
2021-07-29 01:43:16 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool verbose_;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const std::string ARG_VERBOSE;
|
2016-05-07 01:09:09 +02:00
|
|
|
};
|
|
|
|
|
2022-04-05 18:52:33 +02:00
|
|
|
class BackupEngineCommand : public LDBCommand {
|
2016-07-14 23:09:31 +02:00
|
|
|
public:
|
2022-04-05 18:52:33 +02:00
|
|
|
BackupEngineCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
2016-07-14 23:09:31 +02:00
|
|
|
|
2017-03-03 22:17:39 +01:00
|
|
|
protected:
|
|
|
|
static void Help(const std::string& name, std::string& ret);
|
|
|
|
std::string backup_env_uri_;
|
2021-03-10 05:47:26 +01:00
|
|
|
std::string backup_fs_uri_;
|
2017-03-03 22:17:39 +01:00
|
|
|
std::string backup_dir_;
|
|
|
|
int num_threads_;
|
|
|
|
std::unique_ptr<Logger> logger_;
|
2019-10-09 04:17:39 +02:00
|
|
|
std::shared_ptr<Env> backup_env_guard_;
|
2017-03-03 22:17:39 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const std::string ARG_BACKUP_DIR;
|
|
|
|
static const std::string ARG_BACKUP_ENV_URI;
|
2021-03-10 05:47:26 +01:00
|
|
|
static const std::string ARG_BACKUP_FS_URI;
|
2017-03-03 22:17:39 +01:00
|
|
|
static const std::string ARG_NUM_THREADS;
|
|
|
|
static const std::string ARG_STDERR_LOG_LEVEL;
|
|
|
|
};
|
|
|
|
|
2022-04-05 18:52:33 +02:00
|
|
|
class BackupCommand : public BackupEngineCommand {
|
2017-03-03 22:17:39 +01:00
|
|
|
public:
|
|
|
|
static std::string Name() { return "backup"; }
|
2016-07-14 23:09:31 +02:00
|
|
|
BackupCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
};
|
|
|
|
|
2022-04-05 18:52:33 +02:00
|
|
|
class RestoreCommand : public BackupEngineCommand {
|
2016-07-26 20:13:26 +02:00
|
|
|
public:
|
|
|
|
static std::string Name() { return "restore"; }
|
|
|
|
RestoreCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
};
|
2017-03-21 19:49:08 +01:00
|
|
|
|
2018-08-09 23:18:59 +02:00
|
|
|
class WriteExternalSstFilesCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "write_extern_sst"; }
|
|
|
|
WriteExternalSstFilesCommand(
|
|
|
|
const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return false; }
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
2018-08-09 23:18:59 +02:00
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string output_sst_path_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IngestExternalSstFilesCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "ingest_extern_sst"; }
|
|
|
|
IngestExternalSstFilesCommand(
|
|
|
|
const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return false; }
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
virtual void OverrideBaseOptions() override;
|
2018-08-09 23:18:59 +02:00
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string input_sst_path_;
|
|
|
|
bool move_files_;
|
|
|
|
bool snapshot_consistency_;
|
|
|
|
bool allow_global_seqno_;
|
|
|
|
bool allow_blocking_flush_;
|
|
|
|
bool ingest_behind_;
|
|
|
|
bool write_global_seqno_;
|
|
|
|
|
|
|
|
static const std::string ARG_MOVE_FILES;
|
|
|
|
static const std::string ARG_SNAPSHOT_CONSISTENCY;
|
|
|
|
static const std::string ARG_ALLOW_GLOBAL_SEQNO;
|
|
|
|
static const std::string ARG_ALLOW_BLOCKING_FLUSH;
|
|
|
|
static const std::string ARG_INGEST_BEHIND;
|
|
|
|
static const std::string ARG_WRITE_GLOBAL_SEQNO;
|
|
|
|
};
|
|
|
|
|
2019-08-16 01:59:42 +02:00
|
|
|
// Command that prints out range delete tombstones in SST files.
|
|
|
|
class ListFileRangeDeletesCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "list_file_range_deletes"; }
|
|
|
|
|
|
|
|
ListFileRangeDeletesCommand(const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
void DoCommand() override;
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int max_keys_ = 1000;
|
|
|
|
};
|
|
|
|
|
2020-09-04 01:53:14 +02:00
|
|
|
// Command that removes the SST file forcibly from the manifest.
|
|
|
|
class UnsafeRemoveSstFileCommand : public LDBCommand {
|
|
|
|
public:
|
|
|
|
static std::string Name() { return "unsafe_remove_sst_file"; }
|
|
|
|
|
|
|
|
UnsafeRemoveSstFileCommand(const std::vector<std::string>& params,
|
|
|
|
const std::map<std::string, std::string>& options,
|
|
|
|
const std::vector<std::string>& flags);
|
|
|
|
|
|
|
|
static void Help(std::string& ret);
|
|
|
|
|
|
|
|
virtual void DoCommand() override;
|
|
|
|
|
|
|
|
virtual bool NoDBOpen() override { return true; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t sst_file_number_;
|
|
|
|
};
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|