db_stress_env_wrapper.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. #ifdef GFLAGS
  10. #pragma once
  11. #include "db_stress_tool/db_stress_common.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. class DbStressEnvWrapper : public EnvWrapper {
  14. public:
  15. explicit DbStressEnvWrapper(Env* t) : EnvWrapper(t) {}
  16. Status DeleteFile(const std::string& f) override {
  17. // We determine whether it is a manifest file by searching a strong,
  18. // so that there will be false positive if the directory path contains the
  19. // keyword but it is unlikely.
  20. // Checkpoint directory needs to be exempted.
  21. if (!if_preserve_all_manifests ||
  22. f.find("MANIFEST-") == std::string::npos ||
  23. f.find("checkpoint") != std::string::npos) {
  24. return target()->DeleteFile(f);
  25. }
  26. return Status::OK();
  27. }
  28. // If true, all manifest files will not be delted in DeleteFile().
  29. bool if_preserve_all_manifests = true;
  30. };
  31. } // namespace ROCKSDB_NAMESPACE
  32. #endif // GFLAGS