ewmscp  ..
followBeeGfsRequestProvider.cpp
Go to the documentation of this file.
2 #include <beegfs/beegfs_file_event_log.hpp>
3 
5 defineStatic(followBeeGfsRequestProvider::beegfsroot, '\0', "beegfsroot", "root dir (mount point) of beegfs");
6 
14 void followBeeGfsRequestProvider::processSources(const std::vector<std::string>& sources) {
15  for (auto& source : sources) {
16  BeeGFS::FileEventReceiver receiver(source);
17  while (true) {
18  const auto data = receiver.read();
19  if (data.first == BeeGFS::FileEventReceiver::ReadErrorCode::Success) {
20  auto& event = data.second;
21  if (event.type == BeeGFS::FileEventType::CLOSE_WRITE) {
22  std::string path(beegfsroot);
23  path += "/";
24  path += event.path;
25  std::string dstPath;
26  auto mapEntry = getDstPath(path, dstPath);
27  handleOther(path, dstPath, mapEntry, copyRequest::clock_type::now(), false);
28  } else if (event.type == BeeGFS::FileEventType::RENAME) {
29  std::string path(beegfsroot);
30  path += "/";
31  path += event.path;
32  std::string fromPath;
33  auto mapEntryF = getDstPath(path, fromPath);
34  std::string target(beegfsroot);
35  target += "/";
36  target += event.targetPath;
37  std::string dstPath;
38  auto mapEntryD = getDstPath(target, dstPath);
39  handleMove(target, dstPath, fromPath, path, mapEntryD, copyRequest::clock_type::now());
40  } else if (event.type == BeeGFS::FileEventType::UNLINK ||
41  event.type == BeeGFS::FileEventType::RMDIR) {
42  std::string path(beegfsroot);
43  path += "/";
44  path += event.path;
45  std::string dstPath;
46  auto mapEntry = getDstPath(path, dstPath);
47  handleOther(path, dstPath, mapEntry, copyRequest::clock_type::now(), true);
48  } else if (event.type == BeeGFS::FileEventType::SYMLINK) {
49  std::string path(beegfsroot);
50  path += "/";
51  path += event.targetPath;
52  std::string dstPath;
53  auto mapEntry = getDstPath(path, dstPath);
54  handleOther(path, dstPath, mapEntry, copyRequest::clock_type::now(), false);
55  }
56  } else {
57  }
58  }
59  }
60 }
followBeeGfsRequestProvider::processSources
void processSources(const std::vector< std::string > &sources) override
Definition: followBeeGfsRequestProvider.cpp:14
followBeeGfsRequestProvider.h
followRequestProvider::handleMove
virtual void handleMove(const std::string &srcPath, const std::string &dstPath, const std::string &fromPath, const std::string &origPath, const singleMap &mapEntry, copyRequest::clock_type::time_point timestamp)
Definition: followRequestProvider.cpp:31
followBeeGfsRequestProvider::factory
static factoryTemplate< followBeeGfsRequestProvider > factory
Definition: followBeeGfsRequestProvider.h:9
followBeeGfsRequestProvider::beegfsroot
static options::single< std::string > beegfsroot
Definition: followBeeGfsRequestProvider.h:10
requestProvider::getDstPath
virtual const singleMap & getDstPath(const std::string &source, std::string &destination, bool baseNameOnly=false)
get detstination papth for a given source path
Definition: requestProvider.cpp:30
followRequestProvider::handleOther
virtual void handleOther(const std::string &srcPath, const std::string &dstPath, const singleMap &mapEntry, copyRequest::clock_type::time_point timestamp, bool requestForRemoval)
Definition: followRequestProvider.cpp:41
defineStatic
#define defineStatic(var,...)
defines a static variable and instatitates the constructor with the variable number of arguments.
Definition: ewmscp.h:42