ceph rgw md_config_t(SubsystemMap/subsystem)

ceph rgw md_config_t(SubsystemMap/subsystem)

md_config_t是一个结构体,代表这当前进程的配置,里面包含了进程运行过程中所用的配置:

/** This class represents the current Ceph configuration.
*
* For Ceph daemons, this is the daemon configuration. Log levels, caching
* settings, btrfs settings, and so forth can all be found here. For libcephfs
* and librados users, this is the configuration associated with their context.
*
* For information about how this class is loaded from a configuration file,
* see common/ConfUtils.
*
* ACCESS
*
* There are two ways to read the ceph context– the old way and the new way.
* In the old way, code would simply read the public variables of the
* configuration, without taking a lock. In the new way, code registers a
* configuration obserever which receives callbacks when a value changes. These
* callbacks take place under the md_config_t lock.
*
* To prevent serious problems resulting from thread-safety issues, we disallow
* changing std::string configuration values after
* md_config_t::internal_safe_to_start_threads becomes true. You can still
* change integer or floating point values, however.
*
* FIXME: really we shouldn’t allow changing integer or floating point values
* while another thread is reading them, either.
*/
他有一个与日志相关的非常重要的属性:

 ceph::log::SubsystemMap subsys;

下面是SubsystemMap的定义:

class SubsystemMap {
  std::vector<Subsystem> m_subsys;
  unsigned m_max_name_len;

  friend class Log; //友元类

public:
//构造函数
  SubsystemMap() : m_max_name_len(0) {}
//获取子系统数量
  int get_num() const {
    return m_subsys.size();
  }

//获取当前subsystem名字的最大长度
  int get_max_subsys_len() const {
    return m_max_name_len;

//添加新的日志子系统。
  void add(unsigned subsys, std::string name, int log, int gather);  

  //设置指定subsystem 的log level
  void set_log_level(unsigned subsys, int log);

  //设置指定subsystem的gather levels
  void set_gather_level(unsigned subsys, int gather);

//获取指定subsystem的log level
  int get_log_level(unsigned subsys) const {
    if (subsys >= m_subsys.size())
      subsys = 0;
    return m_subsys[subsys].log_level;
    }

//获取指定subsystem的gather level
  int get_gather_level(unsigned subsys) const {
    if (subsys >= m_subsys.size())
      subsys = 0;
    return m_subsys[subsys].gather_level;
  }

//获取指定subsystem的name
  const std::string& get_name(unsigned subsys) const {
    if (subsys >= m_subsys.size())
      subsys = 0;
    return m_subsys[subsys].name;
  }

//判断级别为level的日志,是否需要gather
  bool should_gather(unsigned sub, int level) {
    assert(sub < m_subsys.size());
    return level <= m_subsys[sub].gather_level ||
      level <= m_subsys[sub].log_level;
  }
};

Subsystem是一个结构体,代表subsystem实体。

struct Subsystem {
  int log_level, gather_level;//日志级别和gather级别
  std::string name;//subsystem实例的名字。

  Subsystem() : log_level(0), gather_level(0) {}     
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值