]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/tools/ldb_cmd_impl.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / tools / ldb_cmd_impl.h
index 475cc44c92b878319ae968a8e2e46d321e9418cc..97de981b1a47ccf018272cdee30c867316b156ef 100644 (file)
@@ -5,13 +5,13 @@
 
 #pragma once
 
-#include "rocksdb/utilities/ldb_cmd.h"
-
 #include <map>
 #include <string>
 #include <utility>
 #include <vector>
 
+#include "rocksdb/utilities/ldb_cmd.h"
+
 namespace ROCKSDB_NAMESPACE {
 
 class CompactorCommand : public LDBCommand {
@@ -24,7 +24,7 @@ class CompactorCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
  private:
   bool null_from_;
@@ -43,7 +43,30 @@ class DBFileDumperCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
+
+ private:
+  bool decode_blob_index_;
+  bool dump_uncompressed_blobs_;
+};
+
+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);
+
+  void DoCommand() override;
+
+ private:
+  bool sort_by_filename_;
+
+  static const std::string ARG_SORT_BY_FILENAME;
 };
 
 class DBDumperCommand : public LDBCommand {
@@ -56,13 +79,13 @@ class DBDumperCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  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("/\\");
 
@@ -85,6 +108,8 @@ class DBDumperCommand : public LDBCommand {
   bool count_delim_;
   bool print_stats_;
   std::string path_;
+  bool decode_blob_index_;
+  bool dump_uncompressed_blobs_;
 
   static const std::string ARG_COUNT_ONLY;
   static const std::string ARG_COUNT_DELIM;
@@ -102,7 +127,7 @@ class InternalDumpCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
  private:
   bool has_from_;
@@ -115,6 +140,7 @@ class InternalDumpCommand : public LDBCommand {
   bool count_delim_;
   bool print_stats_;
   bool is_input_key_hex_;
+  bool decode_blob_index_;
 
   static const std::string ARG_DELIM;
   static const std::string ARG_COUNT_ONLY;
@@ -134,9 +160,10 @@ class DBLoaderCommand : public LDBCommand {
                   const std::vector<std::string>& flags);
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
 
-  virtual void OverrideBaseOptions() override;
+  void DoCommand() override;
+
+  void OverrideBaseOptions() override;
 
  private:
   bool disable_wal_;
@@ -157,9 +184,10 @@ class ManifestDumpCommand : public LDBCommand {
                       const std::vector<std::string>& flags);
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  void DoCommand() override;
+
+  bool NoDBOpen() override { return true; }
 
  private:
   bool verbose_;
@@ -171,6 +199,28 @@ class ManifestDumpCommand : public LDBCommand {
   static const std::string ARG_PATH;
 };
 
+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;
+};
+
 class FileChecksumDumpCommand : public LDBCommand {
  public:
   static std::string Name() { return "file_checksum_dump"; }
@@ -186,10 +236,26 @@ class FileChecksumDumpCommand : public LDBCommand {
 
  private:
   std::string path_;
+  bool is_checksum_hex_;
 
   static const std::string ARG_PATH;
 };
 
+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_;
+};
+
 class ListColumnFamiliesCommand : public LDBCommand {
  public:
   static std::string Name() { return "list_column_families"; }
@@ -199,9 +265,10 @@ class ListColumnFamiliesCommand : public LDBCommand {
                             const std::vector<std::string>& flags);
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  void DoCommand() override;
+
+  bool NoDBOpen() override { return true; }
 };
 
 class CreateColumnFamilyCommand : public LDBCommand {
@@ -213,9 +280,10 @@ class CreateColumnFamilyCommand : public LDBCommand {
                             const std::vector<std::string>& flags);
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return false; }
+  void DoCommand() override;
+
+  bool NoDBOpen() override { return false; }
 
  private:
   std::string new_cf_name_;
@@ -230,9 +298,10 @@ class DropColumnFamilyCommand : public LDBCommand {
                           const std::vector<std::string>& flags);
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return false; }
+  void DoCommand() override;
+
+  bool NoDBOpen() override { return false; }
 
  private:
   std::string cf_name_to_drop_;
@@ -246,11 +315,11 @@ class ReduceDBLevelsCommand : public LDBCommand {
                         const std::map<std::string, std::string>& options,
                         const std::vector<std::string>& flags);
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseCFOptions(ColumnFamilyOptions* cf_opts) override;
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  bool NoDBOpen() override { return true; }
 
   static void Help(std::string& msg);
 
@@ -278,9 +347,9 @@ class ChangeCompactionStyleCommand : public LDBCommand {
       const std::map<std::string, std::string>& options,
       const std::vector<std::string>& flags);
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseCFOptions(ColumnFamilyOptions* cf_opts) override;
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& msg);
 
@@ -300,10 +369,11 @@ class WALDumperCommand : public LDBCommand {
                    const std::map<std::string, std::string>& options,
                    const std::vector<std::string>& flags);
 
-  virtual bool NoDBOpen() override { return true; }
+  bool NoDBOpen() override { return true; }
 
   static void Help(std::string& ret);
-  virtual void DoCommand() override;
+
+  void DoCommand() override;
 
  private:
   bool print_header_;
@@ -325,7 +395,7 @@ class GetCommand : public LDBCommand {
              const std::map<std::string, std::string>& options,
              const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
@@ -341,7 +411,7 @@ class ApproxSizeCommand : public LDBCommand {
                     const std::map<std::string, std::string>& options,
                     const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
@@ -358,11 +428,11 @@ class BatchPutCommand : public LDBCommand {
                   const std::map<std::string, std::string>& options,
                   const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseOptions() override;
 
  private:
   /**
@@ -379,7 +449,7 @@ class ScanCommand : public LDBCommand {
               const std::map<std::string, std::string>& options,
               const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
@@ -400,7 +470,23 @@ class DeleteCommand : public LDBCommand {
                 const std::map<std::string, std::string>& options,
                 const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
+
+  static void Help(std::string& ret);
+
+ private:
+  std::string key_;
+};
+
+class SingleDeleteCommand : public LDBCommand {
+ public:
+  static std::string Name() { return "singledelete"; }
+
+  SingleDeleteCommand(const std::vector<std::string>& params,
+                      const std::map<std::string, std::string>& options,
+                      const std::vector<std::string>& flags);
+
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
@@ -416,7 +502,7 @@ class DeleteRangeCommand : public LDBCommand {
                      const std::map<std::string, std::string>& options,
                      const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
@@ -433,11 +519,11 @@ class PutCommand : public LDBCommand {
              const std::map<std::string, std::string>& options,
              const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseOptions() override;
 
  private:
   std::string key_;
@@ -458,7 +544,7 @@ class DBQuerierCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
  private:
   static const char* HELP_CMD;
@@ -475,9 +561,9 @@ class CheckConsistencyCommand : public LDBCommand {
                           const std::map<std::string, std::string>& options,
                           const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  bool NoDBOpen() override { return true; }
 
   static void Help(std::string& ret);
 };
@@ -487,14 +573,15 @@ class CheckPointCommand : public LDBCommand {
   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);
+                    const std::map<std::string, std::string>& options,
+                    const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
   static void Help(std::string& ret);
 
   std::string checkpoint_dir_;
+
  private:
   static const std::string ARG_CHECKPOINT_DIR;
 };
@@ -507,24 +594,31 @@ class RepairCommand : public LDBCommand {
                 const std::map<std::string, std::string>& options,
                 const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  bool NoDBOpen() override { return true; }
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseOptions() override;
 
   static void Help(std::string& ret);
+
+ protected:
+  bool verbose_;
+
+ private:
+  static const std::string ARG_VERBOSE;
 };
 
-class BackupableCommand : public LDBCommand {
+class BackupEngineCommand : public LDBCommand {
  public:
-  BackupableCommand(const std::vector<std::string>& params,
-                    const std::map<std::string, std::string>& options,
-                    const std::vector<std::string>& flags);
+  BackupEngineCommand(const std::vector<std::string>& params,
+                      const std::map<std::string, std::string>& options,
+                      const std::vector<std::string>& flags);
 
  protected:
   static void Help(const std::string& name, std::string& ret);
   std::string backup_env_uri_;
+  std::string backup_fs_uri_;
   std::string backup_dir_;
   int num_threads_;
   std::unique_ptr<Logger> logger_;
@@ -533,28 +627,29 @@ class BackupableCommand : public LDBCommand {
  private:
   static const std::string ARG_BACKUP_DIR;
   static const std::string ARG_BACKUP_ENV_URI;
+  static const std::string ARG_BACKUP_FS_URI;
   static const std::string ARG_NUM_THREADS;
   static const std::string ARG_STDERR_LOG_LEVEL;
 };
 
-class BackupCommand : public BackupableCommand {
+class BackupCommand : public BackupEngineCommand {
  public:
   static std::string Name() { return "backup"; }
   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;
+  void DoCommand() override;
   static void Help(std::string& ret);
 };
 
-class RestoreCommand : public BackupableCommand {
+class RestoreCommand : public BackupEngineCommand {
  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; }
+  void DoCommand() override;
+  bool NoDBOpen() override { return true; }
   static void Help(std::string& ret);
 };
 
@@ -566,11 +661,11 @@ class WriteExternalSstFilesCommand : public LDBCommand {
       const std::map<std::string, std::string>& options,
       const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return false; }
+  bool NoDBOpen() override { return false; }
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseOptions() override;
 
   static void Help(std::string& ret);
 
@@ -586,11 +681,11 @@ class IngestExternalSstFilesCommand : public LDBCommand {
       const std::map<std::string, std::string>& options,
       const std::vector<std::string>& flags);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return false; }
+  bool NoDBOpen() override { return false; }
 
-  virtual void OverrideBaseOptions() override;
+  void OverrideBaseOptions() override;
 
   static void Help(std::string& ret);
 
@@ -638,9 +733,9 @@ class UnsafeRemoveSstFileCommand : public LDBCommand {
 
   static void Help(std::string& ret);
 
-  virtual void DoCommand() override;
+  void DoCommand() override;
 
-  virtual bool NoDBOpen() override { return true; }
+  bool NoDBOpen() override { return true; }
 
  private:
   uint64_t sst_file_number_;