YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tools/fs_tool.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
// Shared fields and methods for querying local files and directories
33
#ifndef YB_TOOLS_FS_TOOL_H
34
#define YB_TOOLS_FS_TOOL_H
35
36
#include <memory>
37
#include <string>
38
39
#include "yb/util/status_fwd.h"
40
41
namespace yb {
42
43
class FsManager;
44
class Schema;
45
class RandomAccessFile;
46
47
namespace tablet {
48
class RaftGroupMetadata;
49
}
50
51
namespace tools {
52
53
struct DumpOptions {
54
  std::string start_key;
55
  std::string end_key;
56
  size_t nrows;
57
  bool metadata_only;
58
59
  DumpOptions()
60
      : start_key(""),
61
        end_key(""),
62
        nrows(0),
63
0
        metadata_only(false) {
64
0
  }
65
};
66
67
class FsTool {
68
 public:
69
70
  enum DetailLevel {
71
    MINIMUM = 0, // Minimum amount of information
72
    HEADERS_ONLY = 1, // Tablet/segment headers only
73
    MAXIMUM = 2,
74
  };
75
76
  explicit FsTool(DetailLevel detail_level);
77
  ~FsTool();
78
79
  CHECKED_STATUS Init();
80
81
  // Prints out the file system tree.
82
  CHECKED_STATUS FsTree();
83
84
  // Lists all log segments in the root WALs directory.
85
  CHECKED_STATUS ListAllLogSegments();
86
87
  // Lists all log segments for tablet 'tablet_id'.
88
  CHECKED_STATUS ListLogSegmentsForTablet(const std::string& tablet_id);
89
90
  // Lists all tablets in a tablet server's local file system.
91
  CHECKED_STATUS ListAllTablets();
92
93
  // Prints the header for a log segment residing in 'path'.
94
  CHECKED_STATUS PrintLogSegmentHeader(const std::string& path, int indent);
95
96
  // Prints the tablet metadata for a tablet 'tablet_id'.
97
  CHECKED_STATUS PrintTabletMeta(const std::string& tablet_id, int indent);
98
99
  // Dump the data stored in a tablet. The output here is much more readable
100
  // than DumpTabletBlocks, since it reconstructs docdb values.
101
  CHECKED_STATUS DumpTabletData(const std::string& tablet_id);
102
103
  // Prints the server's UUID to whom the data belongs and nothing else.
104
  CHECKED_STATUS PrintUUID(int indent);
105
 private:
106
  CHECKED_STATUS ListSegmentsInDir(const std::string& segments_dir);
107
108
  bool initialized_;
109
  const DetailLevel detail_level_;
110
  std::unique_ptr<FsManager> fs_manager_;
111
};
112
113
} // namespace tools
114
} // namespace yb
115
116
#endif // YB_TOOLS_FS_TOOL_H