Ejemplo n.º 1
0
 /**
  * Link event triggered by FUSE.
  *
  * @param pid PID of the triggering process.
  * @param originalFilePath The original file path.
  * @param linkPath Path to link to.
  */
 public void link(int pid, String originalFilePath, String linkPath) {
   checkProgramTree(Integer.toString(pid));
   originalFilePath = sanitizePath(originalFilePath);
   linkPath = sanitizePath(linkPath);
   long now = System.currentTimeMillis();
   File link = createLinkVertex(linkPath);
   putVertex(link);
   File original = createFileVertex(originalFilePath);
   putVertex(original);
   WasDerivedFrom linkEdge = new WasDerivedFrom(original, link);
   linkEdge.addAnnotation("operation", "link");
   linkEdge.addAnnotation("endtime", Long.toString(now));
   putEdge(linkEdge);
   // Add the link to the links map.
   links.put(linkPath, originalFilePath);
 }
Ejemplo n.º 2
0
 /**
  * Rename event triggered by FUSE.
  *
  * @param pid PID of the triggering process.
  * @param iotime IO time of the operation.
  * @param pathfrom The source path.
  * @param pathto The destination path.
  * @param link An integer used to indicate whether the target was a link or not.
  * @param done An intiger used to indicate whether this event was triggered before or after the
  *     rename operation.
  */
 public void rename(int pid, int iotime, String pathfrom, String pathto, int link, int done) {
   checkProgramTree(Integer.toString(pid));
   pathfrom = sanitizePath(pathfrom);
   pathto = sanitizePath(pathto);
   long now = System.currentTimeMillis();
   // 'done' is used to indicate whether this is a pre-rename or a post-rename
   // call. In pre-rename, a Used edge is created from the process to the old
   // file. In post-rename, a WasGeneratedBy edge is created from the process
   // to the new file and a WasDerivedEdge created between the two file
   // artifacts.
   if (done == 0) {
     // Create file artifact depending on whether this is a link or not.
     // Link artifacts are created differently to avoid recursion that may
     // cause FUSE to crash.
     File fileVertex = (link == 1) ? createLinkVertex(pathfrom) : createFileVertex(pathfrom);
     putVertex(fileVertex);
     // Put the file artifact in the localCache to be removed on post-rename.
     localCache.put(pathfrom, fileVertex);
     Used edge = new Used((Program) localCache.get(Integer.toString(pid)), fileVertex);
     edge.addAnnotation("endtime", Long.toString(now));
     putEdge(edge);
   } else {
     // Create file artifact depending on whether this is a link or not.
     // Link artifacts are created differently to avoid recursion that may
     // cause FUSE to crash.
     File fileVertex = (link == 1 ? createLinkVertex(pathto) : createFileVertex(pathto));
     putVertex(fileVertex);
     WasGeneratedBy writeEdge =
         new WasGeneratedBy(fileVertex, (Program) localCache.get(Integer.toString(pid)));
     writeEdge.addAnnotation("endtime", Long.toString(now));
     putEdge(writeEdge);
     WasDerivedFrom renameEdge =
         new WasDerivedFrom(fileVertex, (File) localCache.remove(pathfrom));
     renameEdge.addAnnotation("iotime", Integer.toString(iotime));
     renameEdge.addAnnotation("endtime", Long.toString(now));
     renameEdge.addAnnotation("operation", "rename");
     putEdge(renameEdge);
     if (links.containsKey(pathfrom)) {
       // If the rename is on a link then update the link name.
       String linkedLocation = links.get(pathfrom);
       links.remove(pathfrom);
       links.put(pathto, linkedLocation);
     }
   }
 }