Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Meta add slow log and update floyd
Browse files Browse the repository at this point in the history
  • Loading branch information
CatKang committed Jan 8, 2018
1 parent 90e684c commit b074ee4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/meta/zp_meta_client_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ int ZPMetaClientConn::DealMessage() {

g_meta_server->PlusQueryNum();

uint64_t start_us = slash::NowMicros();

cmd->Do(&request_, &response_);
res_ = &response_;

int64_t duration = slash::NowMicros() - start_us;
if (g_zp_conf->slowlog_slower_than() > 0
&& duration > g_zp_conf->slowlog_slower_than()) {
LOG(WARNING) << "slow client command:" << cmd->name()
<< ", duration(us): " << duration;
}
return 0;
}
6 changes: 3 additions & 3 deletions src/meta/zp_meta_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ Status ZPMetaServer::GetMetaStatus(ZPMeta::MetaCmdResponse_MetaStatus* ms) {
std::string* floyd_status = ms->mutable_consistency_stautus();
floyd_->GetServerStatus(floyd_status);
ZPMeta::MigrateStatus migrate_s;
Status s = migrate_register_->Check(&migrate_s);
if (s.ok()) {
if (IsLeader()
&& migrate_register_->Check(&migrate_s).ok()) {
ms->mutable_migrate_status()->CopyFrom(migrate_s);
}
return Status::OK();
Expand Down Expand Up @@ -1009,7 +1009,7 @@ void ZPMetaServer::InitClientCmdTable() {
listmetaptr));

// MetaStatus Command
Cmd* meta_status_ptr = new MetaStatusCmd(kCmdFlagsRead | kCmdFlagsRedirect);
Cmd* meta_status_ptr = new MetaStatusCmd(kCmdFlagsRead);
cmds_.insert(std::pair<int, Cmd*>(static_cast<int>(ZPMeta::Type::METASTATUS),
meta_status_ptr));

Expand Down
1 change: 0 additions & 1 deletion src/meta/zp_meta_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class ZPMetaServer {
return role_ != MetaRole::kNone;
}


private:
// Server related
std::atomic<bool> should_exit_;
Expand Down
6 changes: 4 additions & 2 deletions src/node/zp_data_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ void Partition::DoBinlogCommand(const PartitionSyncOption& option,
int64_t duration = slash::NowMicros() - start_us;
zp_data_server->PlusLatencyStat(
StatType::kSync, table_name_, cmd->type_, duration / 1000);
if (duration > g_zp_conf->slowlog_slower_than()) {
if (g_zp_conf->slowlog_slower_than() > 0
&& duration > g_zp_conf->slowlog_slower_than()) {
LOG(WARNING) << "slow sync command:" << cmd->name()
<< ", duration(us): " << duration
<< ", For " << table_name_ << "_" << partition_id_;
Expand Down Expand Up @@ -928,7 +929,8 @@ void Partition::DoCommand(const Cmd* cmd, const client::CmdRequest &req,
int64_t duration = slash::NowMicros() - start_us;
zp_data_server->PlusLatencyStat(
StatType::kClient, table_name_, cmd->type_, duration / 1000);
if (duration > g_zp_conf->slowlog_slower_than()) {
if (g_zp_conf->slowlog_slower_than() > 0
&& duration > g_zp_conf->slowlog_slower_than()) {
LOG(WARNING) << "slow client command:" << cmd->name()
<< ", duration(us): " << duration
<< ", For " << table_name_ << "_" << partition_id_;
Expand Down
2 changes: 1 addition & 1 deletion third/floyd

0 comments on commit b074ee4

Please sign in to comment.