Skip to content

Commit

Permalink
change some log level
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-hanqing committed Sep 21, 2020
1 parent 764001e commit 9fcdde9
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/client/chunk_closure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void ClientClosure::OnRpcFailed() {
MetricHelper::IncremTimeOutRPCCount(fileMetric_, reqCtx_->optype_);
}

LOG_EVERY_N(ERROR, 10) << OpTypeToString(reqCtx_->optype_)
LOG_EVERY_SECOND(WARNING) << OpTypeToString(reqCtx_->optype_)
<< " failed, error code: "
<< cntl_->ErrorCode()
<< ", error: " << cntl_->ErrorText()
Expand Down
14 changes: 7 additions & 7 deletions src/client/lease_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ bool LeaseExecutor::RefreshLease() {
return true;
} else if (LIBCURVE_ERROR::AUTHFAIL == ret) {
iomanager_->LeaseTimeoutBlockIO();
LOG(WARNING) << "Refresh session auth fail, block io. "
<< "session id = " << leasesession_.sessionID
<< ", filename = " << fullFileName_;
LOG(ERROR) << "Refresh session auth fail, block io. "
<< "session id = " << leasesession_.sessionID
<< ", filename = " << fullFileName_;
return true;
}

Expand All @@ -112,12 +112,12 @@ bool LeaseExecutor::RefreshLease() {
} else if (response.status == LeaseRefreshResult::Status::NOT_EXIST) {
iomanager_->LeaseTimeoutBlockIO();
isleaseAvaliable_.store(false);
LOG(WARNING) << "session or file not exists, no longer refresh!"
<< ", sessionid = " << leasesession_.sessionID
<< ", filename = " << fullFileName_;
LOG(ERROR) << "session or file not exists, no longer refresh!"
<< ", sessionid = " << leasesession_.sessionID
<< ", filename = " << fullFileName_;
return false;
} else {
LOG(WARNING) << "Refresh session failed, filename = " << fullFileName_;
LOG(ERROR) << "Refresh session failed, filename = " << fullFileName_;
return true;
}
return true;
Expand Down
29 changes: 28 additions & 1 deletion src/client/libcurve_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ int FileClient::Open(const std::string& filename,

int ret = fileserv->Open(filename, userinfo, sessionId);
if (ret != LIBCURVE_ERROR::OK) {
LOG(ERROR) << "Open file fail, retCode = " << ret;
LOG(ERROR) << "Open file failed, filename: " << filename
<< ", retCode: " << ret;
fileserv->UnInitialize();
delete fileserv;
return ret;
Expand Down Expand Up @@ -261,6 +262,8 @@ int FileClient::Create(const std::string& filename,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->CreateFile(filename, userinfo, size);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Create file failed, filename: " << filename << ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand Down Expand Up @@ -355,6 +358,10 @@ int FileClient::Rename(const UserInfo_t& userinfo,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->RenameFile(userinfo, oldpath, newpath);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Rename failed, OldPath: " << oldpath
<< ", NewPath: " << newpath
<< ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -367,6 +374,10 @@ int FileClient::Extend(const std::string& filename,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->Extend(filename, userinfo, newsize);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Extend failed, filename: " << filename
<< ", NewSize: " << newsize
<< ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -379,6 +390,10 @@ int FileClient::Unlink(const std::string& filename,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->DeleteFile(filename, userinfo, deleteforce);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Unlink failed, filename: " << filename
<< ", force: " << deleteforce
<< ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -392,6 +407,8 @@ int FileClient::StatFile(const std::string& filename,
int ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->GetFileInfo(filename, userinfo, &fi);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "StatFile failed, filename: " << filename << ", ret" << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand Down Expand Up @@ -420,6 +437,9 @@ int FileClient::Listdir(const std::string& dirpath,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->Listdir(dirpath, userinfo, filestatVec);
LOG_IF(ERROR,
ret != LIBCURVE_ERROR::OK && ret != LIBCURVE_ERROR::NOTEXIST)
<< "Listdir failed, Path: " << dirpath << ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -431,6 +451,8 @@ int FileClient::Mkdir(const std::string& dirpath, const UserInfo_t& userinfo) {
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->CreateFile(dirpath, userinfo, 0, false);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Create file failed, filename: " << dirpath << ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -442,6 +464,8 @@ int FileClient::Rmdir(const std::string& dirpath, const UserInfo_t& userinfo) {
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->DeleteFile(dirpath, userinfo);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Rmdir failed, Path: " << dirpath << ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand All @@ -454,6 +478,8 @@ int FileClient::ChangeOwner(const std::string& filename,
LIBCURVE_ERROR ret;
if (mdsClient_ != nullptr) {
ret = mdsClient_->ChangeOwner(filename, newOwner, userinfo);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "ChangeOwner failed, filename: " << filename << ", ret: " << ret;
} else {
LOG(ERROR) << "global mds client not inited!";
return -LIBCURVE_ERROR::FAILED;
Expand Down Expand Up @@ -550,6 +576,7 @@ std::string FileClient::GetClusterId() {
return clsctx.clusterId;
}

LOG(ERROR) << "GetClusterId failed, ret: " << ret;
return {};
}

Expand Down
6 changes: 3 additions & 3 deletions src/client/libcurve_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int SnapshotClient::GetSnapShot(const std::string& filename,
if (ret == LIBCURVE_ERROR::OK && !infomap.empty()) {
auto it = infomap.begin();
if (it->first != seq) {
LOG(ERROR) << "Snapshot info not found with seqnum = " << seq;
LOG(WARNING) << "Snapshot info not found with seqnum = " << seq;
return -LIBCURVE_ERROR::NOTEXIST;
}
*snapinfo = it->second;
Expand All @@ -138,11 +138,11 @@ int SnapshotClient::GetSnapshotSegmentInfo(const std::string& filename,
seq, offset, segInfo);

if (ret != LIBCURVE_ERROR::OK) {
LOG(ERROR) << "GetSnapshotSegmentInfo failed, ret = " << ret;
LOG(WARNING) << "GetSnapshotSegmentInfo failed, ret = " << ret;
return -ret;
}

for (auto iter : segInfo->chunkvec) {
for (const auto& iter : segInfo->chunkvec) {
iomanager4chunk_.GetMetaCache()->UpdateChunkInfoByID(iter.cid_, iter);
}

Expand Down
Loading

0 comments on commit 9fcdde9

Please sign in to comment.