]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/db_info_dumper.cc
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).
6 #include "db/db_info_dumper.h"
15 #include "file/filename.h"
16 #include "rocksdb/env.h"
18 namespace ROCKSDB_NAMESPACE
{
20 void DumpDBFileSummary(const ImmutableDBOptions
& options
,
21 const std::string
& dbname
,
22 const std::string
& session_id
) {
23 if (options
.info_log
== nullptr) {
27 auto* env
= options
.env
;
29 FileType type
= kInfoLogFile
;
31 std::vector
<std::string
> files
;
32 uint64_t file_num
= 0;
34 std::string file_info
, wal_info
;
36 Header(options
.info_log
, "DB SUMMARY\n");
37 Header(options
.info_log
, "DB Session ID: %s\n", session_id
.c_str());
40 // Get files in dbname dir
41 s
= env
->GetChildren(dbname
, &files
);
43 Error(options
.info_log
, "Error when reading %s dir %s\n", dbname
.c_str(),
44 s
.ToString().c_str());
46 std::sort(files
.begin(), files
.end());
47 for (const std::string
& file
: files
) {
48 if (!ParseFileName(file
, &number
, &type
)) {
53 Header(options
.info_log
, "CURRENT file: %s\n", file
.c_str());
56 Header(options
.info_log
, "IDENTITY file: %s\n", file
.c_str());
59 s
= env
->GetFileSize(dbname
+ "/" + file
, &file_size
);
61 Header(options
.info_log
,
62 "MANIFEST file: %s size: %" PRIu64
" Bytes\n", file
.c_str(),
65 Error(options
.info_log
,
66 "Error when reading MANIFEST file: %s/%s %s\n", dbname
.c_str(),
67 file
.c_str(), s
.ToString().c_str());
71 s
= env
->GetFileSize(dbname
+ "/" + file
, &file_size
);
75 .append(std::to_string(file_size
))
78 Error(options
.info_log
, "Error when reading LOG file: %s/%s %s\n",
79 dbname
.c_str(), file
.c_str(), s
.ToString().c_str());
83 if (++file_num
< 10) {
84 file_info
.append(file
).append(" ");
92 // Get sst files in db_path dir
93 for (auto& db_path
: options
.db_paths
) {
94 if (dbname
.compare(db_path
.path
) != 0) {
95 s
= env
->GetChildren(db_path
.path
, &files
);
97 Error(options
.info_log
, "Error when reading %s dir %s\n",
98 db_path
.path
.c_str(), s
.ToString().c_str());
101 std::sort(files
.begin(), files
.end());
102 for (const std::string
& file
: files
) {
103 if (ParseFileName(file
, &number
, &type
)) {
104 if (type
== kTableFile
&& ++file_num
< 10) {
105 file_info
.append(file
).append(" ");
110 Header(options
.info_log
,
111 "SST files in %s dir, Total Num: %" PRIu64
", files: %s\n",
112 db_path
.path
.c_str(), file_num
, file_info
.c_str());
117 // Get wal file in wal_dir
118 const auto& wal_dir
= options
.GetWalDir(dbname
);
119 if (!options
.IsWalDirSameAsDBPath(dbname
)) {
120 s
= env
->GetChildren(wal_dir
, &files
);
122 Error(options
.info_log
, "Error when reading %s dir %s\n", wal_dir
.c_str(),
123 s
.ToString().c_str());
127 for (const std::string
& file
: files
) {
128 if (ParseFileName(file
, &number
, &type
)) {
129 if (type
== kWalFile
) {
130 s
= env
->GetFileSize(wal_dir
+ "/" + file
, &file_size
);
132 wal_info
.append(file
)
134 .append(std::to_string(file_size
))
137 Error(options
.info_log
, "Error when reading LOG file %s/%s %s\n",
138 wal_dir
.c_str(), file
.c_str(), s
.ToString().c_str());
144 Header(options
.info_log
, "Write Ahead Log file in %s: %s\n", wal_dir
.c_str(),
147 } // namespace ROCKSDB_NAMESPACE