提交 01ff5e2a 编写于 作者: K KernelMaker

1) add config resetstat to reset 'total_connections_received' &...

1) add config resetstat to reset 'total_connections_received' & 'total_commands_processed'; 2) add binlog_offset for info cmd
上级 6c30bf26
......@@ -202,6 +202,7 @@ private:
void ConfigGet(std::string &ret);
void ConfigSet(std::string &ret);
void ConfigRewrite(std::string &ret);
void ConfigResetstat(std::string &ret);
};
class MonitorCmd : public Cmd {
......
......@@ -24,6 +24,12 @@ public:
return thread_querynum_;
}
void ResetThreadQuerynum() {
slash::RWLock(&rwlock_, true);
thread_querynum_ = 0;
last_thread_querynum_ = 0;
}
uint64_t last_sec_thread_querynum() {
slash::RWLock(&rwlock_, false);
return last_sec_thread_querynum_;
......
......@@ -269,6 +269,7 @@ void SignalNextBinlogBGSerial();
void incr_accumulative_connections() {
++accumulative_connections_;
}
void ResetStat();
slash::RecordMutex mutex_record_;
private:
......
......@@ -26,6 +26,12 @@ public:
return thread_querynum_;
}
void ResetThreadQuerynum() {
slash::RWLock(&rwlock_, true);
thread_querynum_ = 0;
last_thread_querynum_ = 0;
}
uint64_t last_sec_thread_querynum() {
slash::RWLock(&rwlock_, false);
return last_sec_thread_querynum_;
......
......@@ -3,7 +3,7 @@
# Used for Release only.
TAG="2.1.0"
make clean && make RPATH=./lib
make clean && make RPATH=./lib __REL=1
#TAG="2.0.4"
#make clean && make RPATH=./lib __REL=1
......
......@@ -614,7 +614,7 @@ void InfoCmd::InfoLog(std::string &info) {
uint32_t filenum;
uint64_t offset;
g_pika_server->logger_->GetProducerStatus(&filenum, &offset);
tmp_stream << "write2file:" << filenum << "\r\n";
tmp_stream << "binlog_offset:" << filenum << " " << offset << "\r\n";
info.append(tmp_stream.str());
return;
......@@ -665,6 +665,11 @@ void ConfigCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info)
res_.SetRes(CmdRes::kErrOther, "Wrong number of arguments for CONFIG rewrite");
return;
}
} else if (argv[1] == "resetstat") {
if (argc != 2) {
res_.SetRes(CmdRes::kErrOther, "Wrong number of arguments for CONFIG resetstat");
return;
}
} else {
res_.SetRes(CmdRes::kErrOther, "CONFIG subcommand must be one of GET, SET, RESETSTAT, REWRITE");
return;
......@@ -681,6 +686,8 @@ void ConfigCmd::Do() {
ConfigSet(config_ret);
} else if (config_args_v_[0] == "rewrite") {
ConfigRewrite(config_ret);
} else if (config_args_v_[0] == "resetstat") {
ConfigResetstat(config_ret);
}
res_.AppendStringRaw(config_ret);
return;
......@@ -1023,6 +1030,11 @@ void ConfigCmd::ConfigRewrite(std::string &ret) {
ret = "+OK\r\n";
}
void ConfigCmd::ConfigResetstat(std::string &ret) {
g_pika_server->ResetStat();
ret = "+OK\r\n";
}
void MonitorCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
(void)ptr_info;
if (argv.size() != 2) { //append a arg in DoCmd for monitor cmd
......
......@@ -1069,6 +1069,14 @@ uint64_t PikaServer::ServerQueryNum() {
return server_query_num;
}
void PikaServer::ResetStat() {
for (int idx = 0; idx != worker_num_; ++idx) {
pika_worker_thread_[idx]->ResetThreadQuerynum();
}
pika_binlog_receiver_thread_->ResetThreadQuerynum();
accumulative_connections_ = 0;
}
uint64_t PikaServer::ServerCurrentQps() {
uint64_t server_current_qps = 0;
for (int idx = 0; idx != worker_num_; ++idx) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册