Skip to content

Commit

Permalink
[XrdCl] Additional adjustments to recorder plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jan 26, 2022
1 parent 0fad2f7 commit 88badb3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/XrdApps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ set_target_properties(
add_library(
${LIB_XRDCL_RECORDER_PLUGIN}
MODULE
XrdApps/RecordPlugin/XrdClRecorderPlugin.cc )
XrdApps/XrdClRecordPlugin/XrdClRecorderPlugin.cc )

target_link_libraries(${LIB_XRDCL_RECORDER_PLUGIN} XrdCl)

Expand All @@ -196,7 +196,7 @@ set_target_properties(

add_executable(
xrdreplay
XrdApps/RecordPlugin/XrdClReplay.cc )
XrdApps/XrdClRecordPlugin/XrdClReplay.cc )

target_link_libraries(
xrdreplay
Expand Down
14 changes: 14 additions & 0 deletions src/XrdApps/XrdClRecordPlugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# XrdClRecorder Plugin

This XRootD Client Plugin can be used to record all user's actions on XrdCl::File object and store them into a csv file. Afterwards, using the xrdreplay utily the actions can be replayed preserving the original timing.

Config file format:

**recorder.conf:**

```bash
url = *
lib = /home/simonm/git/xrootd-xrdreply/build/src/libXrdClRecorder-5.so
enable = true
output = /tmp/out.csv
```
4 changes: 2 additions & 2 deletions src/XrdApps/XrdClRecordPlugin/XrdClAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ namespace XrdCl {
std::stringstream ss;
ss << req[0].offset << ";" << req[0].length;
for( size_t i = 1; i < req.size(); ++i )
ss << req[i].offset << ";" << req[i].length;
ss << ";" << req[i].offset << ";" << req[i].length;
return ss.str();
}

Expand Down Expand Up @@ -456,7 +456,7 @@ namespace XrdCl {
std::stringstream ss;
ss << req[0].offset << ";" << req[0].length;
for( size_t i = 1; i < req.size(); ++i )
ss << req[i].offset << ";" << req[i].length;
ss << ";" << req[i].offset << ";" << req[i].length;
return ss.str();
}

Expand Down
9 changes: 6 additions & 3 deletions src/XrdApps/XrdClRecordPlugin/XrdClRecorder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ class Recorder: public FilePlugIn
//------------------------------------------------------------------------
~Output()
{
int rc = close( fd );
if( rc < 0 )
DefaultEnv::GetLog()->Warning( AppMsg, "[Recorder] failed to close the output file: %s", strerror( errno ) );
if( fd >= 0 )
{
int rc = close( fd );
if( rc < 0 )
DefaultEnv::GetLog()->Warning( AppMsg, "[Recorder] failed to close the output file: %s", strerror( errno ) );
}
}

std::mutex mtx; //< mutex guarding the writes
Expand Down
9 changes: 4 additions & 5 deletions src/XrdApps/XrdClRecordPlugin/XrdClReplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ class ActionExecutor
//--------------------------------------------------------------------------
uint16_t GetCloseArgs()
{
std::cout << "args = " << args << std::endl;
return static_cast<uint16_t>( std::stoul( args ) );
}

Expand Down Expand Up @@ -402,10 +401,10 @@ class ActionExecutor
std::vector<std::string> tokens;
Utils::splitString( tokens, args, ";" );
ChunkList chunks;
for( size_t i = 0; i < tokens.size(); i += 2 )
for( size_t i = 0; i < tokens.size() - 1; i += 2 )
{
uint64_t offset = std::stoull( tokens[1] );
uint32_t length = std::stoul( tokens[0] );
uint64_t offset = std::stoull( tokens[i] );
uint32_t length = std::stoul( tokens[i+1] );
char* buffer = new char[length];
memset( buffer, 'A', length );
chunks.emplace_back( offset, length, buffer );
Expand Down Expand Up @@ -492,7 +491,7 @@ std::thread ExecuteActions( std::unique_ptr<File> file, action_list &&actions )
for( auto &p : actions )
{
if( p.first > prevstop )
std::this_thread::sleep_for( std::chrono::duration<uint64_t, std::milli>( p.first - prevstop ) );
std::this_thread::sleep_for( std::chrono::seconds( p.first - prevstop ) );
prevstop = p.first;
auto &action = p.second;
mytimer_t timer;
Expand Down

0 comments on commit 88badb3

Please sign in to comment.