From 9fcdde932416609c79ebe16a1b1ee66a1d647647 Mon Sep 17 00:00:00 2001 From: wuhanqing Date: Thu, 17 Sep 2020 10:49:48 +0800 Subject: [PATCH] change some log level --- src/client/chunk_closure.cpp | 2 +- src/client/lease_executor.cpp | 14 ++-- src/client/libcurve_file.cpp | 29 ++++++- src/client/libcurve_snapshot.cpp | 6 +- src/client/mds_client.cpp | 138 +++++++++++++++---------------- src/client/mds_client_base.cpp | 56 ++++++------- src/client/metacache.cpp | 2 +- src/client/service_helper.cpp | 2 - src/client/splitor.cpp | 2 +- 9 files changed, 138 insertions(+), 113 deletions(-) diff --git a/src/client/chunk_closure.cpp b/src/client/chunk_closure.cpp index 75bdeb953a..337ef3461c 100644 --- a/src/client/chunk_closure.cpp +++ b/src/client/chunk_closure.cpp @@ -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() diff --git a/src/client/lease_executor.cpp b/src/client/lease_executor.cpp index 7870453688..810931c3f5 100644 --- a/src/client/lease_executor.cpp +++ b/src/client/lease_executor.cpp @@ -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; } @@ -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; diff --git a/src/client/libcurve_file.cpp b/src/client/libcurve_file.cpp index 54e85c4e42..81ef70c8ca 100644 --- a/src/client/libcurve_file.cpp +++ b/src/client/libcurve_file.cpp @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -550,6 +576,7 @@ std::string FileClient::GetClusterId() { return clsctx.clusterId; } + LOG(ERROR) << "GetClusterId failed, ret: " << ret; return {}; } diff --git a/src/client/libcurve_snapshot.cpp b/src/client/libcurve_snapshot.cpp index 8eab79bd2b..fd7b3cd7ca 100644 --- a/src/client/libcurve_snapshot.cpp +++ b/src/client/libcurve_snapshot.cpp @@ -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; @@ -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); } diff --git a/src/client/mds_client.cpp b/src/client/mds_client.cpp index 305f912aae..5e1e03bc0b 100644 --- a/src/client/mds_client.cpp +++ b/src/client/mds_client.cpp @@ -232,7 +232,7 @@ int MDSClient::MDSRPCExcutor::ExcuteTask( brpc::Channel channel; int ret = channel.Init(mdsaddr.c_str(), nullptr); if (ret != 0) { - LOG(WARNING) << "Init channel failed! addr = " << mdsaddr.c_str(); + LOG(WARNING) << "Init channel failed! addr = " << mdsaddr; // 返回EHOSTDOWN给上层调用者,促使其切换mds return -EHOSTDOWN; } @@ -265,8 +265,8 @@ LIBCURVE_ERROR MDSClient::OpenFile(const std::string& filename, LIBCURVE_ERROR retcode = LIBCURVE_ERROR::FAILED; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "OpenFile: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "OpenFile: filename = " << filename << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -282,7 +282,7 @@ LIBCURVE_ERROR MDSClient::OpenFile(const std::string& filename, FileInfo finfo = response.fileinfo(); ServiceHelper::ProtoFileInfo2Local(&finfo, fi); } else { - LOG(ERROR) << "mds response has no file info or session info!"; + LOG(WARNING) << "mds response has no file info or session info!"; return LIBCURVE_ERROR::FAILED; } @@ -311,8 +311,8 @@ LIBCURVE_ERROR MDSClient::CreateFile(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "CreateFile: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "CreateFile: filename = " << filename << ", owner = " << userinfo.owner << ", is nomalfile: " << normalFile << ", errocde = " << retcode @@ -343,8 +343,8 @@ LIBCURVE_ERROR MDSClient::CloseFile(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "CloseFile: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "CloseFile: filename = " << filename << ", owner = " << userinfo.owner << ", sessionid = " << sessionid << ", errocde = " << retcode @@ -378,8 +378,8 @@ LIBCURVE_ERROR MDSClient::GetFileInfo(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "GetFileInfo: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "GetFileInfo: filename = " << filename << ", owner = " << uinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -432,8 +432,8 @@ LIBCURVE_ERROR MDSClient::CreateSnapShot(const std::string& filename, LIBCURVE_ERROR retcode; MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "CreateSnapShot: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "CreateSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -460,8 +460,8 @@ LIBCURVE_ERROR MDSClient::DeleteSnapShot(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "DeleteSnapShot: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "DeleteSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", seqnum = " << seq << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -489,8 +489,8 @@ LIBCURVE_ERROR MDSClient::ListSnapShot(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "ListSnapShot: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "ListSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode); @@ -522,7 +522,7 @@ LIBCURVE_ERROR MDSClient::GetSnapshotSegmentInfo(const std::string& filename, auto task = RPCTaskDefine { GetOrAllocateSegmentResponse response; mdsClientBase_.GetSnapshotSegmentInfo(filename, userinfo, seq, offset, - &response, cntl, channel); + &response, cntl, channel); if (cntl->Failed()) { LOG(WARNING) << "get snap file segment info failed, errcorde = " << cntl->ErrorCode() @@ -533,8 +533,8 @@ LIBCURVE_ERROR MDSClient::GetSnapshotSegmentInfo(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "GetSnapshotSegmentInfo: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "GetSnapshotSegmentInfo: filename = " << filename << ", owner = " << userinfo.owner << ", offset = " << offset << ", seqnum = " << seq @@ -542,7 +542,7 @@ LIBCURVE_ERROR MDSClient::GetSnapshotSegmentInfo(const std::string& filename, << ", error msg = " << StatusCode_Name(stcode); if (stcode != StatusCode::kOK) { - LOG(ERROR) << "GetSnapshotSegmentInfo return error, " + LOG(WARNING) << "GetSnapshotSegmentInfo return error, " << ", filename = " << filename << ", seq = " << seq; return retcode; @@ -561,7 +561,7 @@ LIBCURVE_ERROR MDSClient::GetSnapshotSegmentInfo(const std::string& filename, int chunksNum = pfs.chunks_size(); if (chunksNum == 0) { - LOG(ERROR) << "mds allocate segment, but no chunk!"; + LOG(WARNING) << "mds allocate segment, but no chunk!"; return LIBCURVE_ERROR::FAILED; } @@ -597,18 +597,19 @@ LIBCURVE_ERROR MDSClient::RefreshSession(const std::string& filename, } StatusCode stcode = response.statuscode(); - LOG_IF(WARNING, stcode != StatusCode::kOK) - << "RefreshSession NOT OK: filename = " - << filename.c_str() << ", owner = " - << userinfo.owner << ", sessionid = " - << sessionid << ", status code = " - << StatusCode_Name(stcode); - - LOG_EVERY_N(INFO, 10) << "RefreshSession returned: filename = " - << filename.c_str() << ", owner = " - << userinfo.owner << ", sessionid = " - << sessionid << ", status code = " - << StatusCode_Name(stcode); + if (stcode != StatusCode::kOK) { + LOG(WARNING) + << "RefreshSession NOT OK: filename = " << filename + << ", owner = " << userinfo.owner + << ", sessionid = " << sessionid + << ", status code = " << StatusCode_Name(stcode); + } else { + LOG_EVERY_SECOND(INFO) + << "RefreshSession returned: filename = " << filename + << ", owner = " << userinfo.owner + << ", sessionid = " << sessionid + << ", status code = " << StatusCode_Name(stcode); + } switch (stcode) { case StatusCode::kSessionNotExist: @@ -630,7 +631,7 @@ LIBCURVE_ERROR MDSClient::RefreshSession(const std::string& filename, } if (nullptr != lease) { if (!response.has_protosession()) { - LOG(ERROR) << "session response has no protosession"; + LOG(WARNING) << "session response has no protosession"; return LIBCURVE_ERROR::FAILED; } ProtoSession leasesession = response.protosession(); @@ -671,8 +672,8 @@ LIBCURVE_ERROR MDSClient::CheckSnapShotStatus(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "CheckSnapShotStatus: filename = " << filename.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "CheckSnapShotStatus: filename = " << filename << ", owner = " << userinfo.owner << ", seqnum = " << seq << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode); @@ -732,10 +733,10 @@ LIBCURVE_ERROR MDSClient::GetServerList(const LogicPoolID& logicalpooid, } cpinfoVec->push_back(copysetseverl); DVLOG(9) << "copyset id : " << copysetseverl.cpid_ - << ", peer info : " << copyset_peer.c_str(); + << ", peer info : " << copyset_peer; } - LOG_IF(ERROR, response.statuscode() != 0) + LOG_IF(WARNING, response.statuscode() != 0) << "GetServerList failed" << ", errocde = " << response.statuscode() << ", log id = " << cntl->log_id(); @@ -752,10 +753,9 @@ LIBCURVE_ERROR MDSClient::GetClusterInfo(ClusterContext* clsctx) { mdsClientBase_.GetClusterInfo(&response, cntl, channel); if (cntl->Failed()) { - LOG(ERROR) << "get cluster info from mds failed, status code = " - << cntl->ErrorCode() - << ", error content: " - << cntl->ErrorText(); + LOG(WARNING) << "get cluster info from mds failed, status code = " + << cntl->ErrorCode() + << ", error content: " << cntl->ErrorText(); return -cntl->ErrorCode(); } @@ -789,10 +789,10 @@ LIBCURVE_ERROR MDSClient::CreateCloneFile(const std::string& source, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) << "CreateCloneFile: source = " << source << ", destination = " << destination - << ", owner = " << userinfo.owner.c_str() << ", seqnum = " << sn + << ", owner = " << userinfo.owner << ", seqnum = " << sn << ", size = " << size << ", chunksize = " << chunksize << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -835,9 +835,9 @@ LIBCURVE_ERROR MDSClient::SetCloneFileStatus(const std::string &filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "SetCloneFileStatus failed, filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "SetCloneFileStatus failed, filename = " << filename + << ", owner = " << userinfo.owner << ", filestatus = " << static_cast(filestatus) << ", fileID = " << fileID << ", errocde = " << retcode @@ -869,7 +869,7 @@ LIBCURVE_ERROR MDSClient::GetOrAllocateSegment(bool allocate, uint64_t offset, auto statuscode = response.statuscode(); switch (statuscode) { case StatusCode::kOwnerAuthFail: - LOG(ERROR) << "GetOrAllocateSegment Auth failed!"; + LOG(WARNING) << "GetOrAllocateSegment Auth failed!"; return LIBCURVE_ERROR::AUTHFAIL; break; case StatusCode::kSegmentNotAllocated: @@ -888,7 +888,7 @@ LIBCURVE_ERROR MDSClient::GetOrAllocateSegment(bool allocate, uint64_t offset, int chunksNum = pfs.chunks_size(); if (allocate && chunksNum <= 0) { - LOG(ERROR) << "MDS allocate segment, but no chunkinfo!"; + LOG(WARNING) << "MDS allocate segment, but no chunkinfo!"; return LIBCURVE_ERROR::FAILED; } @@ -923,12 +923,12 @@ LIBCURVE_ERROR MDSClient::RenameFile(const UserInfo_t& userinfo, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "RenameFile: origin = " << origin.c_str() - << ", destination = " << destination.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "RenameFile: origin = " << origin + << ", destination = " << destination << ", originId = " << originId << ", destinationId = " << destinationId - << ", owner = " << userinfo.owner.c_str() + << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -959,9 +959,9 @@ LIBCURVE_ERROR MDSClient::Extend(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "Extend: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "Extend: filename = " << filename + << ", owner = " << userinfo.owner << ", newsize = " << newsize << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) @@ -990,9 +990,9 @@ LIBCURVE_ERROR MDSClient::DeleteFile(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "DeleteFile: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "DeleteFile: filename = " << filename + << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) << ", log id = " << cntl->log_id(); @@ -1020,10 +1020,10 @@ LIBCURVE_ERROR MDSClient::ChangeOwner(const std::string& filename, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "ChangeOwner: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() - << ", new owner = " << newOwner.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "ChangeOwner: filename = " << filename + << ", owner = " << userinfo.owner + << ", new owner = " << newOwner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) << ", log id = " << cntl->log_id(); @@ -1051,9 +1051,9 @@ LIBCURVE_ERROR MDSClient::Listdir(const std::string& dirpath, LIBCURVE_ERROR retcode; StatusCode stcode = response.statuscode(); MDSStatusCode2LibcurveError(stcode, &retcode); - LOG_IF(ERROR, retcode != LIBCURVE_ERROR::OK) - << "Listdir: filename = " << dirpath.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG_IF(WARNING, retcode != LIBCURVE_ERROR::OK) + << "Listdir: filename = " << dirpath + << ", owner = " << userinfo.owner << ", errocde = " << retcode << ", error msg = " << StatusCode_Name(stcode) << ", log id = " << cntl->log_id(); @@ -1072,7 +1072,7 @@ LIBCURVE_ERROR MDSClient::Listdir(const std::string& dirpath, memcpy(filestat.owner, finfo.owner().c_str(), NAME_MAX_SIZE); memset(filestat.filename, 0, NAME_MAX_SIZE); memcpy(filestat.filename, finfo.filename().c_str(), - NAME_MAX_SIZE); + NAME_MAX_SIZE); filestatVec->push_back(filestat); } } @@ -1116,7 +1116,7 @@ LIBCURVE_ERROR MDSClient::GetChunkServerInfo(const ChunkServerAddr& csAddr, } int statusCode = response.statuscode(); - LOG_IF(ERROR, statusCode != 0) + LOG_IF(WARNING, statusCode != 0) << "GetChunkServerInfo: errocde = " << statusCode << ", log id = " << cntl->log_id(); @@ -1163,7 +1163,7 @@ LIBCURVE_ERROR MDSClient::ListChunkServerInServer( } int statusCode = response.statuscode(); - LOG_IF(ERROR, statusCode != 0) + LOG_IF(WARNING, statusCode != 0) << "ListChunkServerInServer failed, " << "errorcode = " << response.statuscode() << ", chunkserver ip = " << serverIp diff --git a/src/client/mds_client_base.cpp b/src/client/mds_client_base.cpp index 2faf14b045..1371d7cfae 100644 --- a/src/client/mds_client_base.cpp +++ b/src/client/mds_client_base.cpp @@ -42,7 +42,7 @@ void MDSClientBase::OpenFile(const std::string& filename, request.set_clientversion(curve::common::CurveVersion()); FillUserInfo(&request, userinfo); - LOG(INFO) << "OpenFile: filename = " << filename.c_str() + LOG(INFO) << "OpenFile: filename = " << filename << ", owner = " << userinfo.owner << ", log id = " << cntl->log_id(); @@ -68,7 +68,7 @@ void MDSClientBase::CreateFile(const std::string& filename, FillUserInfo(&request, userinfo); - LOG(INFO) << "CreateFile: filename = " << filename.c_str() + LOG(INFO) << "CreateFile: filename = " << filename << ", owner = " << userinfo.owner << ", is nomalfile: " << normalFile << ", log id = " << cntl->log_id(); @@ -88,7 +88,7 @@ void MDSClientBase::CloseFile(const std::string& filename, request.set_sessionid(sessionid); FillUserInfo(&request, userinfo); - LOG(INFO) << "CloseFile: filename = " << filename.c_str() + LOG(INFO) << "CloseFile: filename = " << filename << ", owner = " << userinfo.owner << ", sessionid = " << sessionid << ", log id = " << cntl->log_id(); @@ -106,9 +106,9 @@ void MDSClientBase::GetFileInfo(const std::string& filename, request.set_filename(filename); FillUserInfo(&request, userinfo); - LOG(INFO) << "GetFileInfo: filename = " << filename.c_str() - << ", owner = " << userinfo.owner - << ", log id = " << cntl->log_id(); + LOG_EVERY_SECOND(INFO) << "GetFileInfo: filename = " << filename + << ", owner = " << userinfo.owner + << ", log id = " << cntl->log_id(); curve::mds::CurveFSService_Stub stub(channel); stub.GetFileInfo(cntl, &request, response, nullptr); @@ -123,7 +123,7 @@ void MDSClientBase::CreateSnapShot(const std::string& filename, request.set_filename(filename); FillUserInfo<::curve::mds::CreateSnapShotRequest>(&request, userinfo); - LOG(INFO) << "CreateSnapShot: filename = " << filename.c_str() + LOG(INFO) << "CreateSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", log id = " << cntl->log_id(); @@ -142,7 +142,7 @@ void MDSClientBase::DeleteSnapShot(const std::string& filename, request.set_filename(filename); FillUserInfo<::curve::mds::DeleteSnapShotRequest>(&request, userinfo); - LOG(INFO) << "DeleteSnapShot: filename = " << filename.c_str() + LOG(INFO) << "DeleteSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", seqnum = " << seq << ", log id = " << cntl->log_id(); @@ -164,7 +164,7 @@ void MDSClientBase::ListSnapShot(const std::string& filename, request.set_filename(filename); FillUserInfo(&request, userinfo); - LOG(INFO) << "ListSnapShot: filename = " << filename.c_str() + LOG(INFO) << "ListSnapShot: filename = " << filename << ", owner = " << userinfo.owner << ", seqnum = " << [seq] () { std::string data("[ "); @@ -195,7 +195,7 @@ void MDSClientBase::GetSnapshotSegmentInfo(const std::string& filename, request.set_seqnum(seq); FillUserInfo(&request, userinfo); - LOG(INFO) << "GetSnapshotSegmentInfo: filename = " << filename.c_str() + LOG(INFO) << "GetSnapshotSegmentInfo: filename = " << filename << ", owner = " << userinfo.owner << ", offset = " << offset << ", seqnum = " << seq @@ -226,7 +226,7 @@ void MDSClientBase::RefreshSession(const std::string& filename, FillUserInfo(&request, userinfo); - LOG_EVERY_N(INFO, 10) << "RefreshSession: filename = " << filename.c_str() + LOG_EVERY_N(INFO, 10) << "RefreshSession: filename = " << filename << ", owner = " << userinfo.owner << ", sessionid = " << sessionid << ", log id = " << cntl->log_id(); @@ -246,7 +246,7 @@ void MDSClientBase::CheckSnapShotStatus(const std::string& filename, request.set_filename(filename); FillUserInfo(&request, userinfo); - LOG(INFO) << "CheckSnapShotStatus: filename = " << filename.c_str() + LOG(INFO) << "CheckSnapShotStatus: filename = " << filename << ", owner = " << userinfo.owner << ", seqnum = " << seq << ", log id = " << cntl->log_id(); @@ -299,7 +299,7 @@ void MDSClientBase::CreateCloneFile(const std::string& source, LOG(INFO) << "CreateCloneFile: source = " << source << ", destination = " << destination - << ", owner = " << userinfo.owner.c_str() << ", seqnum = " << sn + << ", owner = " << userinfo.owner << ", seqnum = " << sn << ", size = " << size << ", chunksize = " << chunksize << ", log id = " << cntl->log_id(); @@ -322,8 +322,8 @@ void MDSClientBase::SetCloneFileStatus(const std::string &filename, } FillUserInfo(&request, userinfo); - LOG(INFO) << "SetCloneFileStatus: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG(INFO) << "SetCloneFileStatus: filename = " << filename + << ", owner = " << userinfo.owner << ", filestatus = " << static_cast(filestatus) << ", fileID = " << fileID << ", log id = " << cntl->log_id(); @@ -350,7 +350,7 @@ void MDSClientBase::GetOrAllocateSegment(bool allocate, FillUserInfo(&request, fi->userinfo); LOG(INFO) << "GetOrAllocateSegment: allocate = " << allocate - << ", owner = " << fi->owner.c_str() + << ", owner = " << fi->owner << ", offset = " << offset << ", segment offset = " << seg_offset << ", log id = " << cntl->log_id(); @@ -376,11 +376,11 @@ void MDSClientBase::RenameFile(const UserInfo_t& userinfo, } FillUserInfo(&request, userinfo); - LOG(INFO) << "RenameFile: origin = " << origin.c_str() - << ", destination = " << destination.c_str() + LOG(INFO) << "RenameFile: origin = " << origin + << ", destination = " << destination << ", originId = " << originId << ", destinationId = " << destinationId - << ", owner = " << userinfo.owner.c_str() + << ", owner = " << userinfo.owner << ", log id = " << cntl->log_id(); curve::mds::CurveFSService_Stub stub(channel); @@ -398,8 +398,8 @@ void MDSClientBase::Extend(const std::string& filename, request.set_newsize(newsize); FillUserInfo(&request, userinfo); - LOG(INFO) << "Extend: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG(INFO) << "Extend: filename = " << filename + << ", owner = " << userinfo.owner << ", newsize = " << newsize << ", log id = " << cntl->log_id(); @@ -422,8 +422,8 @@ void MDSClientBase::DeleteFile(const std::string& filename, } FillUserInfo(&request, userinfo); - LOG(INFO) << "DeleteFile: filename = " << filename.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG(INFO) << "DeleteFile: filename = " << filename + << ", owner = " << userinfo.owner << ", log id = " << cntl->log_id(); curve::mds::CurveFSService_Stub stub(channel); @@ -444,9 +444,9 @@ void MDSClientBase::ChangeOwner(const std::string& filename, request.set_rootowner(userinfo.owner); request.set_signature(CalcSignature(userinfo, date)); - LOG(INFO) << "ChangeOwner: filename = " << filename.c_str() - << ", operator owner = " << userinfo.owner.c_str() - << ", new owner = " << newOwner.c_str() + LOG(INFO) << "ChangeOwner: filename = " << filename + << ", operator owner = " << userinfo.owner + << ", new owner = " << newOwner << ", log id = " << cntl->log_id(); curve::mds::CurveFSService_Stub stub(channel); @@ -463,8 +463,8 @@ void MDSClientBase::Listdir(const std::string& dirpath, FillUserInfo<::curve::mds::ListDirRequest>(&request, userinfo); - LOG(INFO) << "Listdir: filename = " << dirpath.c_str() - << ", owner = " << userinfo.owner.c_str() + LOG(INFO) << "Listdir: filename = " << dirpath + << ", owner = " << userinfo.owner << ", log id = " << cntl->log_id(); curve::mds::CurveFSService_Stub stub(channel); diff --git a/src/client/metacache.cpp b/src/client/metacache.cpp index 7d782344b3..ada4acf621 100644 --- a/src/client/metacache.cpp +++ b/src/client/metacache.cpp @@ -304,7 +304,7 @@ int MetaCache::SetServerUnstable(const std::string& serverIp) { std::vector csIds; int ret = mdsclient_->ListChunkServerInServer(serverIp, &csIds); if (ret != LIBCURVE_ERROR::OK) { - LOG(WARNING) << "ListChunkServer failed"; + LOG(ERROR) << "ListChunkServer failed, server ip: " << serverIp; return -1; } diff --git a/src/client/service_helper.cpp b/src/client/service_helper.cpp index 517153fa09..a8e407c3a3 100644 --- a/src/client/service_helper.cpp +++ b/src/client/service_helper.cpp @@ -338,7 +338,6 @@ bool ServiceHelper::GetUserInfoFromFilename(const std::string& filename, *realfilename = filename.substr(0, user_begin); *user = filename.substr(user_begin + 1, user_end - user_begin - 1); - LOG(INFO) << "user info [" << *user << "]"; return true; } @@ -375,4 +374,3 @@ int ServiceHelper::CheckChunkServerHealth( } // namespace client } // namespace curve - diff --git a/src/client/splitor.cpp b/src/client/splitor.cpp index 710ce295bc..7e1d6c7e26 100644 --- a/src/client/splitor.cpp +++ b/src/client/splitor.cpp @@ -178,7 +178,7 @@ bool Splitor::AssignInternal(IOTracker* iotracker, (off_t)chunkidx * fileinfo->chunksize, fileinfo, &segInfo); - if (re == LIBCURVE_ERROR::FAILED || re == LIBCURVE_ERROR::AUTHFAIL) { + if (re != LIBCURVE_ERROR::OK) { LOG(ERROR) << "GetOrAllocateSegment failed! " << "offset = " << chunkidx * fileinfo->chunksize; return false;