From 3232f63509add2b1347561a51e649c728a8b2113 Mon Sep 17 00:00:00 2001 From: proller Date: Fri, 27 Sep 2024 10:39:53 +0200 Subject: [PATCH] [Filestore] Implement a tool which replays filestore-vhost's profilelog - part0: prepare (#2095) * [Filestore] Implement a tool which replays filestore-vhost's profile log - part0: prepare --- .../libs/diagnostics/events/profile_events.ev | 1 + .../libs/diagnostics/profile_log_events.cpp | 14 ++++++++++++++ .../filestore/libs/diagnostics/profile_log_ut.cpp | 11 +++++++---- cloud/filestore/public/api/protos/node.proto | 1 + .../analytics/libs/event-log/request_printer.cpp | 10 ++++++++++ .../libs/event-log/request_printer_ut.cpp | 15 ++++++++------- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/cloud/filestore/libs/diagnostics/events/profile_events.ev b/cloud/filestore/libs/diagnostics/events/profile_events.ev index 5fdab47daf8..25f14cfd7f6 100644 --- a/cloud/filestore/libs/diagnostics/events/profile_events.ev +++ b/cloud/filestore/libs/diagnostics/events/profile_events.ev @@ -23,6 +23,7 @@ message TProfileLogNodeInfo { optional string NewNodeName = 4; optional uint32 Flags = 5; optional uint32 Mode = 6; + optional uint32 Type = 10; // from response optional uint64 NodeId = 7; diff --git a/cloud/filestore/libs/diagnostics/profile_log_events.cpp b/cloud/filestore/libs/diagnostics/profile_log_events.cpp index 00d8f3261bf..afac2a7ed38 100644 --- a/cloud/filestore/libs/diagnostics/profile_log_events.cpp +++ b/cloud/filestore/libs/diagnostics/profile_log_events.cpp @@ -282,6 +282,20 @@ void InitProfileLogRequestInfo( auto* nodeInfo = profileLogRequest.MutableNodeInfo(); nodeInfo->SetNewParentNodeId(request.GetNodeId()); nodeInfo->SetNewNodeName(request.GetName()); + + if (request.HasFile()) { + nodeInfo->SetType(NProto::E_REGULAR_NODE); + } else if (request.HasDirectory()) { + nodeInfo->SetType(NProto::E_DIRECTORY_NODE); + } else if (request.HasLink()) { + nodeInfo->SetType(NProto::E_LINK_NODE); + } else if (request.HasSocket()) { + nodeInfo->SetType(NProto::E_SOCK_NODE); + } else if (request.HasSymLink()) { + nodeInfo->SetType(NProto::E_SYMLINK_NODE); + } else { + nodeInfo->SetType(NProto::E_INVALID_NODE); + } } template <> diff --git a/cloud/filestore/libs/diagnostics/profile_log_ut.cpp b/cloud/filestore/libs/diagnostics/profile_log_ut.cpp index 5f06e5e9f8a..0c2528179ae 100644 --- a/cloud/filestore/libs/diagnostics/profile_log_ut.cpp +++ b/cloud/filestore/libs/diagnostics/profile_log_ut.cpp @@ -49,7 +49,8 @@ TString NodeInfoToString(const NProto::TProfileLogNodeInfo& nodeInfo) << "," << nodeInfo.GetMode() << "," << nodeInfo.GetNodeId() << "," << nodeInfo.GetHandle() - << "," << nodeInfo.GetSize(); + << "," << nodeInfo.GetSize() + << "," << nodeInfo.GetType(); } TString LockInfoToString(const NProto::TProfileLogLockInfo& lockInfo) @@ -196,7 +197,8 @@ struct TRequestInfoBuilder ui32 mode, ui64 nodeId, ui64 handle, - ui64 size) + ui64 size, + ui32 type) { auto nodeInfo = R.MutableNodeInfo(); nodeInfo->SetParentNodeId(parentNodeId); @@ -208,6 +210,7 @@ struct TRequestInfoBuilder nodeInfo->SetNodeId(nodeId); nodeInfo->SetHandle(handle); nodeInfo->SetSize(size); + nodeInfo->SetType(type); return *this; } @@ -308,7 +311,7 @@ Y_UNIT_TEST_SUITE(TProfileLogTest) .SetDuration(TDuration::MilliSeconds(800)) .SetRequestType(11) .SetError(1) - .AddNodeInfo(1, "node", 2, "new_node", 3, 7, 12, 123, 32) + .AddNodeInfo(1, "node", 2, "new_node", 3, 7, 12, 123, 32, 2) .Build() }); @@ -340,7 +343,7 @@ Y_UNIT_TEST_SUITE(TProfileLogTest) EventProcessor.FlatMessages[2] ); UNIT_ASSERT_VALUES_EQUAL( - "fs2\t4000000\t11\t800000\t1\t1,node,2,new_node,3,7,12,123,32", + "fs2\t4000000\t11\t800000\t1\t1,node,2,new_node,3,7,12,123,32,2", EventProcessor.FlatMessages[3] ); UNIT_ASSERT_VALUES_EQUAL( diff --git a/cloud/filestore/public/api/protos/node.proto b/cloud/filestore/public/api/protos/node.proto index b4ec4c58adf..9b6c01b0f1f 100644 --- a/cloud/filestore/public/api/protos/node.proto +++ b/cloud/filestore/public/api/protos/node.proto @@ -29,6 +29,7 @@ enum ENodeType E_DIRECTORY_NODE = 2; E_LINK_NODE = 3; E_SOCK_NODE = 4; + E_SYMLINK_NODE = 5; } //////////////////////////////////////////////////////////////////////////////// diff --git a/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp b/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp index 1a44e96b9da..bc562a2732a 100644 --- a/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp +++ b/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp @@ -111,6 +111,7 @@ TString PrintNodeInfo( TStringBuf nodeIdLabel, TStringBuf handleLabel, TStringBuf sizeLabel, + TStringBuf typeLabel, const NProto::TProfileLogNodeInfo& nodeInfo) { TStringBuilder out; @@ -144,6 +145,9 @@ TString PrintNodeInfo( if (nodeInfo.HasSize()) { out << PrintValue(sizeLabel, nodeInfo.GetSize()) << ", "; } + if (nodeInfo.HasType()) { + out << PrintValue(typeLabel, nodeInfo.GetType()) << ", "; + } if (out.empty()) { out << "no_node_info"; @@ -302,6 +306,7 @@ class TDefaultRequestPrinter "node_id", "handle", "size", + "type", request.GetNodeInfo()) << "\t"; } @@ -365,6 +370,7 @@ class TAccessNodeRequestPrinter "node_id", "", "", + "", request.GetNodeInfo()); } @@ -391,6 +397,7 @@ class TGetSetNodeXAttrRequestPrinter "node_id", "", "version", + "", request.GetNodeInfo()); } @@ -417,6 +424,7 @@ class TRemoveNodeXAttrRequestPrinter "", "", "", + "", request.GetNodeInfo()); } @@ -443,6 +451,7 @@ class TCreateDestroyCheckpointRequestPrinter "node_id", "", "", + "", request.GetNodeInfo()); } @@ -469,6 +478,7 @@ class TFlushFsyncRequestPrinter "node_id", "handle", "", + "", request.GetNodeInfo()); } diff --git a/cloud/filestore/tools/analytics/libs/event-log/request_printer_ut.cpp b/cloud/filestore/tools/analytics/libs/event-log/request_printer_ut.cpp index 4cf80251862..93e28f3e16e 100644 --- a/cloud/filestore/tools/analytics/libs/event-log/request_printer_ut.cpp +++ b/cloud/filestore/tools/analytics/libs/event-log/request_printer_ut.cpp @@ -55,10 +55,11 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) nodeInfo->SetNodeId(30); nodeInfo->SetHandle(40); nodeInfo->SetSize(50); + nodeInfo->SetType(2); UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, new_parent_node_id=20, " - "new_node_name=name_2, flags=5, mode=7, node_id=30, handle=40, size=50}", + "new_node_name=name_2, flags=5, mode=7, node_id=30, handle=40, size=50, type=2}", printer->DumpInfo(Request)); nodeInfo->ClearNewParentNodeId(); @@ -66,7 +67,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}", + "handle=40, size=50, type=2}", printer->DumpInfo(Request)); auto* lockInfo = Request.MutableLockInfo(); @@ -82,7 +83,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}\t{node_id=100, handle=110, owner=120, offset=130, " + "handle=40, size=50, type=2}\t{node_id=100, handle=110, owner=120, offset=130, " "length=140, type=E_SHARED, conflicted_owner=220, conflicted_offset=230, " "conflicted_length=240}", printer->DumpInfo(Request)); @@ -95,7 +96,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, " + "handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, " "type=E_EXCLUSIVE}", printer->DumpInfo(Request)); @@ -110,7 +111,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, " + "handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, " "type=Unknown}\t[{node_id=300, handle=305, offset=310, bytes=315}, " "{node_id=301, handle=306, offset=311, bytes=316}]", printer->DumpInfo(Request)); @@ -119,7 +120,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, " + "handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, " "type=Unknown}\t[{node_id=300, handle=305, offset=310, bytes=315}]", printer->DumpInfo(Request)); @@ -127,7 +128,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest) UNIT_ASSERT_VALUES_EQUAL( "{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, " - "handle=40, size=50}\t[{node_id=300, handle=305, offset=310, bytes=315}]", + "handle=40, size=50, type=2}\t[{node_id=300, handle=305, offset=310, bytes=315}]", printer->DumpInfo(Request)); Request.ClearNodeInfo();