1
0

hdfs-delete-snapshot.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef LIBHDFSPP_TOOLS_HDFS_DELETE_SNAPSHOT
  19. #define LIBHDFSPP_TOOLS_HDFS_DELETE_SNAPSHOT
  20. #include <string>
  21. #include <boost/program_options.hpp>
  22. #include "hdfs-tool.h"
  23. namespace hdfs::tools {
  24. /**
  25. * {@class DeleteSnapshot} is an {@class HdfsTool} that facilitates the
  26. * snapshots of a directory at PATH to be created, causing the directory to be
  27. * snapshot-able.
  28. */
  29. class DeleteSnapshot : public HdfsTool {
  30. public:
  31. /**
  32. * {@inheritdoc}
  33. */
  34. DeleteSnapshot(int argc, char **argv);
  35. // Abiding to the Rule of 5
  36. DeleteSnapshot(const DeleteSnapshot &) = default;
  37. DeleteSnapshot(DeleteSnapshot &&) = default;
  38. DeleteSnapshot &operator=(const DeleteSnapshot &) = delete;
  39. DeleteSnapshot &operator=(DeleteSnapshot &&) = delete;
  40. ~DeleteSnapshot() override = default;
  41. /**
  42. * {@inheritdoc}
  43. */
  44. [[nodiscard]] std::string GetDescription() const override;
  45. /**
  46. * {@inheritdoc}
  47. */
  48. [[nodiscard]] bool Do() override;
  49. protected:
  50. /**
  51. * {@inheritdoc}
  52. */
  53. [[nodiscard]] bool Initialize() override;
  54. /**
  55. * {@inheritdoc}
  56. */
  57. [[nodiscard]] bool ValidateConstraints() const override;
  58. /**
  59. * {@inheritdoc}
  60. */
  61. [[nodiscard]] bool HandleHelp() const override;
  62. /**
  63. * Handle the arguments that are passed to this tool.
  64. *
  65. * @param path The path to the directory that is snapshot-able.
  66. * @param name The name of the snapshot.
  67. *
  68. * @return A boolean indicating the result of this operation.
  69. */
  70. [[nodiscard]] virtual bool HandleSnapshot(const std::string &path,
  71. const std::string &name) const;
  72. private:
  73. /**
  74. * A boost data-structure containing the description of positional arguments
  75. * passed to the command-line.
  76. */
  77. po::positional_options_description pos_opt_desc_;
  78. };
  79. } // namespace hdfs::tools
  80. #endif