[ 
https://issues.apache.org/jira/browse/GOBBLIN-2141?focusedWorklogId=931539&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-931539
 ]

ASF GitHub Bot logged work on GOBBLIN-2141:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Aug/24 17:35
            Start Date: 23/Aug/24 17:35
    Worklog Time Spent: 10m 
      Work Description: arjun4084346 commented on code in PR #4036:
URL: https://github.com/apache/gobblin/pull/4036#discussion_r1729309787


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/Trash.java:
##########
@@ -189,11 +197,18 @@ public boolean moveToTrash(Path path) throws IOException {
     Path targetPathInTrash = PathUtils.mergePaths(this.trashLocation, 
fullyResolvedPath);
 
     if (!this.fs.exists(targetPathInTrash.getParent())) {
-      this.fs.mkdirs(targetPathInTrash.getParent());
+      if (this.simulate) {
+        LOG.info("Making a parent directory at " + 
targetPathInTrash.getParent() + " in trash.");
+      } else {
+        this.fs.mkdirs(targetPathInTrash.getParent());
+      }
     } else if (this.fs.exists(targetPathInTrash)) {
       targetPathInTrash = targetPathInTrash.suffix("_" + 
System.currentTimeMillis());
     }
-
+    if (this.simulate) {
+      LOG.info("Simulating moving " + fullyResolvedPath + " to " + 
targetPathInTrash + " in trash.");
+      return true;
+    }

Review Comment:
   * nit , i prefer doing it like `else { return ...}` to emphasize on the need 
that only one blocks should run. in case we needed to add a line before L212, 
it may not by mistake be added to only one branch





Issue Time Tracking
-------------------

    Worklog Id:     (was: 931539)
    Time Spent: 20m  (was: 10m)

> Enable simulate retention jobs using the actual trash class instead of 
> mocktrash
> --------------------------------------------------------------------------------
>
>                 Key: GOBBLIN-2141
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-2141
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: William Lo
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Simulation mode in retention relies on the usage of MockTrash, which doesn't 
> always reflect the details of moving trash to certain spaces that the actual 
> Trash class implements, and some of the details of which folders it creates.
> The mock trash class also makes it difficult to simulate behaviors on any 
> classes that extend a part of Trash class since they would have to create a 
> corresponding mock class, which makes the purpose of the simulate mode moot 
> since it's not actually simulating the live behavior.
> We want to have an opt-in configuration (to not break existing simulation 
> jobs of retention) to have the Trash class log out which files it is moving 
> to its trash location.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to