hdfs-df.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_DF
  19. #define LIBHDFSPP_TOOLS_HDFS_DF
  20. #include <string>
  21. #include <boost/program_options.hpp>
  22. #include "hdfs-tool.h"
  23. namespace hdfs::tools {
  24. /**
  25. * {@class Df} is an {@class HdfsTool} that displays size, used space, and
  26. * available space of the entire filesystem where the given path is located.
  27. */
  28. class Df : public HdfsTool {
  29. public:
  30. /**
  31. * {@inheritdoc}
  32. */
  33. Df(int argc, char **argv);
  34. // Abiding to the Rule of 5
  35. Df(const Df &) = default;
  36. Df(Df &&) = default;
  37. Df &operator=(const Df &) = delete;
  38. Df &operator=(Df &&) = delete;
  39. ~Df() override = default;
  40. /**
  41. * {@inheritdoc}
  42. */
  43. [[nodiscard]] std::string GetDescription() const override;
  44. /**
  45. * {@inheritdoc}
  46. */
  47. [[nodiscard]] bool Do() override;
  48. protected:
  49. /**
  50. * {@inheritdoc}
  51. */
  52. [[nodiscard]] bool Initialize() override;
  53. /**
  54. * {@inheritdoc}
  55. */
  56. [[nodiscard]] bool ValidateConstraints() const override { return argc_ > 1; }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. [[nodiscard]] bool HandleHelp() const override;
  61. /**
  62. * Handle the path argument that's passed to this tool.
  63. *
  64. * @param path The path to the directory for which we need df info.
  65. *
  66. * @return A boolean indicating the result of this operation.
  67. */
  68. [[nodiscard]] virtual bool HandlePath(const std::string &path) const;
  69. private:
  70. /**
  71. * A boost data-structure containing the description of positional arguments
  72. * passed to the command-line.
  73. */
  74. po::positional_options_description pos_opt_desc_;
  75. };
  76. } // namespace hdfs::tools
  77. #endif