move static msgs out of Status class (#4144)

Summary:
The member msgs of class Status contains all types of status messages.
When users dump a Status object, msgs will confuse users. So move it out
of class Status by making it as file-local static variable.

Closes #3831 .
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4144

Differential Revision: D8941419

Pulled By: sagar0

fbshipit-source-id: 56b0510258465ff26db15aa6b04e01532e053e3d
This commit is contained in:
Chang Su 2018-07-23 15:42:15 -07:00 committed by Facebook Github Bot
parent c6d2a7f821
commit 374c37da5b
6 changed files with 12 additions and 27 deletions

View File

@ -596,7 +596,6 @@ set(SOURCES
util/slice.cc
util/sst_file_manager_impl.cc
util/status.cc
util/status_message.cc
util/string_util.cc
util/sync_point.cc
util/sync_point_impl.cc

View File

@ -218,7 +218,6 @@ cpp_library(
"util/slice.cc",
"util/sst_file_manager_impl.cc",
"util/status.cc",
"util/status_message.cc",
"util/string_util.cc",
"util/sync_point.cc",
"util/sync_point_impl.cc",

View File

@ -282,8 +282,6 @@ class Status {
Severity sev_;
const char* state_;
static const char* msgs[static_cast<int>(kMaxSubCode)];
explicit Status(Code _code, SubCode _subcode = kNone)
: code_(_code), subcode_(_subcode), sev_(kNoError), state_(nullptr) {}

1
src.mk
View File

@ -147,7 +147,6 @@ LIB_SOURCES = \
util/slice.cc \
util/sst_file_manager_impl.cc \
util/status.cc \
util/status_message.cc \
util/string_util.cc \
util/sync_point.cc \
util/sync_point_impl.cc \

View File

@ -32,6 +32,18 @@ const char* Status::CopyState(const char* state) {
#endif
}
static const char* msgs[static_cast<int>(Status::kMaxSubCode)] = {
"", // kNone
"Timeout Acquiring Mutex", // kMutexTimeout
"Timeout waiting to lock key", // kLockTimeout
"Failed to acquire lock due to max_num_locks limit", // kLockLimit
"No space left on device", // kNoSpace
"Deadlock", // kDeadlock
"Stale file handle", // kStaleFile
"Memory limit reached", // kMemoryLimit
"Space limit reached" // kSpaceLimit
};
Status::Status(Code _code, SubCode _subcode, const Slice& msg,
const Slice& msg2)
: code_(_code), subcode_(_subcode), sev_(kNoError) {

View File

@ -1,22 +0,0 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include "rocksdb/status.h"
namespace rocksdb {
const char* Status::msgs[] = {
"", // kNone
"Timeout Acquiring Mutex", // kMutexTimeout
"Timeout waiting to lock key", // kLockTimeout
"Failed to acquire lock due to max_num_locks limit", // kLockLimit
"No space left on device", // kNoSpace
"Deadlock", // kDeadlock
"Stale file handle", // kStaleFile
"Memory limit reached", // kMemoryLimit
"Space limit reached" // kSpaceLimit
};
} // namespace rocksdb