本文整理汇总了C++中Slave::stats方法的典型用法代码示例。如果您正苦于以下问题:C++ Slave::stats方法的具体用法?C++ Slave::stats怎么用?C++ Slave::stats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slave
的用法示例。
在下文中一共展示了Slave::stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_info
int proc_info(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
resp->push_back("ok");
resp->push_back("ssdb-server");
resp->push_back("version");
resp->push_back(SSDB_VERSION);
{
resp->push_back("links");
resp->add(net->link_count);
}
{
int64_t calls = 0;
proc_map_t::iterator it;
for(it=net->proc_map.begin(); it!=net->proc_map.end(); it++){
Command *cmd = it->second;
calls += cmd->calls;
}
resp->push_back("total_calls");
resp->add(calls);
}
{
uint64_t size = serv->ssdb->size();
resp->push_back("dbsize");
resp->push_back(str(size));
}
{
std::string s = serv->ssdb->binlogs->stats();
resp->push_back("binlogs");
resp->push_back(s);
}
{
std::vector<std::string> syncs = serv->backend_sync->stats();
std::vector<std::string>::iterator it;
for(it = syncs.begin(); it != syncs.end(); it++){
std::string s = *it;
resp->push_back("replication");
resp->push_back(s);
}
}
{
std::vector<Slave *>::iterator it;
for(it = serv->slaves.begin(); it != serv->slaves.end(); it++){
Slave *slave = *it;
std::string s = slave->stats();
resp->push_back("replication");
resp->push_back(s);
}
}
{
std::string val;
std::string s, e;
serv->get_kv_range(&s, &e);
char buf[512];
{
snprintf(buf, sizeof(buf), " kv : \"%s\" - \"%s\"",
str_escape(s).c_str(),
str_escape(e).c_str()
);
val.append(buf);
}
{
snprintf(buf, sizeof(buf), "\n hash: \"\" - \"\"");
val.append(buf);
}
{
snprintf(buf, sizeof(buf), "\n zset: \"\" - \"\"");
val.append(buf);
}
{
snprintf(buf, sizeof(buf), "\n list: \"\" - \"\"");
val.append(buf);
}
resp->push_back("serv_key_range");
resp->push_back(val);
}
if(req.size() == 1 || req[1] == "range"){
std::string val;
std::vector<std::string> tmp;
int ret = serv->ssdb->key_range(&tmp);
if(ret == 0){
char buf[512];
snprintf(buf, sizeof(buf), " kv : \"%s\" - \"%s\"",
hexmem(tmp[0].data(), tmp[0].size()).c_str(),
hexmem(tmp[1].data(), tmp[1].size()).c_str()
);
val.append(buf);
snprintf(buf, sizeof(buf), "\n hash: \"%s\" - \"%s\"",
hexmem(tmp[2].data(), tmp[2].size()).c_str(),
hexmem(tmp[3].data(), tmp[3].size()).c_str()
);
val.append(buf);
snprintf(buf, sizeof(buf), "\n zset: \"%s\" - \"%s\"",
hexmem(tmp[4].data(), tmp[4].size()).c_str(),
hexmem(tmp[5].data(), tmp[5].size()).c_str()
//.........这里部分代码省略.........