]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/monitoring/thread_status_impl.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / monitoring / thread_status_impl.cc
index 6c5d9cc3e79db82c69ba8f6bbe032fc62a2de38f..f4531ce75cc07246a649982e6e1fff364434b49f 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
-// This source code is licensed under the BSD-style license found in the
-// LICENSE file in the root directory of this source tree. An additional grant
-// of patent rights can be found in the PATENTS file in the same directory.
+//  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 <sstream>
 namespace rocksdb {
 
 #ifdef ROCKSDB_USING_THREAD_STATUS
-const std::string& ThreadStatus::GetThreadTypeName(
+std::string ThreadStatus::GetThreadTypeName(
     ThreadStatus::ThreadType thread_type) {
-  static std::string thread_type_names[NUM_THREAD_TYPES + 1] = {
-      "High Pri", "Low Pri", "User", "Unknown"};
-  if (thread_type < 0 || thread_type >= NUM_THREAD_TYPES) {
-    return thread_type_names[NUM_THREAD_TYPES];  // "Unknown"
+  switch (thread_type) {
+    case ThreadStatus::ThreadType::HIGH_PRIORITY:
+      return "High Pri";
+    case ThreadStatus::ThreadType::LOW_PRIORITY:
+      return "Low Pri";
+    case ThreadStatus::ThreadType::USER:
+      return "User";
+    case ThreadStatus::ThreadType::BOTTOM_PRIORITY:
+      return "Bottom Pri";
+    case ThreadStatus::ThreadType::NUM_THREAD_TYPES:
+      assert(false);
   }
-  return thread_type_names[thread_type];
+  return "Unknown";
 }
 
 const std::string& ThreadStatus::GetOperationName(
@@ -77,10 +84,8 @@ const std::string& ThreadStatus::GetOperationPropertyName(
   }
 }
 
-std::map<std::string, uint64_t>
-    ThreadStatus::InterpretOperationProperties(
-    ThreadStatus::OperationType op_type,
-    const uint64_t* op_properties) {
+std::map<std::string, uint64_t> ThreadStatus::InterpretOperationProperties(
+    ThreadStatus::OperationType op_type, const uint64_t* op_properties) {
   int num_properties;
   switch (op_type) {
     case OP_COMPACTION:
@@ -95,20 +100,14 @@ std::map<std::string, uint64_t>
 
   std::map<std::string, uint64_t> property_map;
   for (int i = 0; i < num_properties; ++i) {
-    if (op_type == OP_COMPACTION &&
-        i == COMPACTION_INPUT_OUTPUT_LEVEL) {
-      property_map.insert(
-          {"BaseInputLevel", op_properties[i] >> 32});
+    if (op_type == OP_COMPACTION && i == COMPACTION_INPUT_OUTPUT_LEVEL) {
+      property_map.insert({"BaseInputLevel", op_properties[i] >> 32});
       property_map.insert(
           {"OutputLevel", op_properties[i] % (uint64_t(1) << 32U)});
-    } else if (op_type == OP_COMPACTION &&
-               i == COMPACTION_PROP_FLAGS) {
-      property_map.insert(
-          {"IsManual", ((op_properties[i] & 2) >> 1)});
-      property_map.insert(
-          {"IsDeletion", ((op_properties[i] & 4) >> 2)});
-      property_map.insert(
-          {"IsTrivialMove", ((op_properties[i] & 8) >> 3)});
+    } else if (op_type == OP_COMPACTION && i == COMPACTION_PROP_FLAGS) {
+      property_map.insert({"IsManual", ((op_properties[i] & 2) >> 1)});
+      property_map.insert({"IsDeletion", ((op_properties[i] & 4) >> 2)});
+      property_map.insert({"IsTrivialMove", ((op_properties[i] & 8) >> 3)});
     } else {
       property_map.insert(
           {GetOperationPropertyName(op_type, i), op_properties[i]});
@@ -117,49 +116,46 @@ std::map<std::string, uint64_t>
   return property_map;
 }
 
-
 #else
 
-const std::string& ThreadStatus::GetThreadTypeName(
-    ThreadStatus::ThreadType thread_type) {
+std::string ThreadStatus::GetThreadTypeName(
+    ThreadStatus::ThreadType /*thread_type*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
 const std::string& ThreadStatus::GetOperationName(
-    ThreadStatus::OperationType op_type) {
+    ThreadStatus::OperationType /*op_type*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
 const std::string& ThreadStatus::GetOperationStageName(
-    ThreadStatus::OperationStage stage) {
+    ThreadStatus::OperationStage /*stage*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
 const std::string& ThreadStatus::GetStateName(
-    ThreadStatus::StateType state_type) {
+    ThreadStatus::StateType /*state_type*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
-const std::string ThreadStatus::MicrosToString(
-    uint64_t op_elapsed_time) {
+const std::string ThreadStatus::MicrosToString(uint64_t /*op_elapsed_time*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
 const std::string& ThreadStatus::GetOperationPropertyName(
-    ThreadStatus::OperationType op_type, int i) {
+    ThreadStatus::OperationType /*op_type*/, int /*i*/) {
   static std::string dummy_str = "";
   return dummy_str;
 }
 
-std::map<std::string, uint64_t>
-    ThreadStatus::InterpretOperationProperties(
-    ThreadStatus::OperationType op_type,
-    const uint64_t* op_properties) {
+std::map<std::string, uint64_t> ThreadStatus::InterpretOperationProperties(
+    ThreadStatus::OperationType /*op_type*/,
+    const uint64_t* /*op_properties*/) {
   return std::map<std::string, uint64_t>();
 }