@@ -209,6 +209,26 @@ inline std::string DescribeReadSliceResponse(
209209 return oss.str ();
210210}
211211
212+ // print OpenResponse
213+ inline std::string DescribeOpenResponse (pb::mds::OpenResponse& response) {
214+ std::ostringstream oss;
215+ oss << response.info ().ShortDebugString ()
216+ << " session_id:" << response.session_id () << " inode("
217+ << response.inode ().ShortDebugString () << " ) chunks[" ;
218+ for (const auto & chunk : response.chunks ()) {
219+ std::vector<uint64_t > slice_ids;
220+ slice_ids.reserve (chunk.slices ().size ());
221+ for (const auto & slice : chunk.slices ()) {
222+ slice_ids.push_back (slice.id ());
223+ }
224+ oss << fmt::format (" ({},{} slice_ids{})," , chunk.index (), chunk.version (),
225+ slice_ids);
226+ }
227+
228+ oss << " ]" ;
229+ return oss.str ();
230+ }
231+
212232template <typename Request, typename Response>
213233Status RPC::SendRequest (const EndPoint& endpoint,
214234 const std::string& service_name,
@@ -269,21 +289,31 @@ Status RPC::SendRequest(const EndPoint& endpoint,
269289 }
270290
271291 if (response.error ().errcode () == pb::error::OK) {
272- if constexpr (! std::is_same_v<Response, pb::mds::ReadSliceResponse>) {
292+ if constexpr (std::is_same_v<Response, pb::mds::ReadSliceResponse>) {
273293 LOG (INFO) << fmt::format (
274294 " [meta.rpc][{}][{}][{}us] success, retry({}) request({}) "
275295 " response({}) doing({})." ,
276296 EndPointToStr (endpoint), api_name, elapsed_us, retry,
277- request.ShortDebugString (), response. ShortDebugString ( ),
297+ request.ShortDebugString (), DescribeReadSliceResponse (response ),
278298 DoingReqCount ());
299+
300+ } else if constexpr (std::is_same_v<Response, pb::mds::OpenResponse>) {
301+ LOG (INFO) << fmt::format (
302+ " [meta.rpc][{}][{}][{}us] success, retry({}) request({}) "
303+ " response({}) doing({})." ,
304+ EndPointToStr (endpoint), api_name, elapsed_us, retry,
305+ request.ShortDebugString (), DescribeOpenResponse (response),
306+ DoingReqCount ());
307+
279308 } else {
280309 LOG (INFO) << fmt::format (
281310 " [meta.rpc][{}][{}][{}us] success, retry({}) request({}) "
282311 " response({}) doing({})." ,
283312 EndPointToStr (endpoint), api_name, elapsed_us, retry,
284- request.ShortDebugString (), DescribeReadSliceResponse ( response),
313+ request.ShortDebugString (), response. ShortDebugString ( ),
285314 DoingReqCount ());
286315 }
316+
287317 return Status::OK ();
288318 }
289319
0 commit comments