diff --git a/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicy.java b/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicy.java index a0c38494ea..e3a999beed 100644 --- a/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicy.java +++ b/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicy.java @@ -22,7 +22,6 @@ import org.apache.hadoop.fs.FileStatus; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.joda.time.Duration; /** @@ -43,20 +42,7 @@ public TimeBasedSnapshotCleanupPolicy(Properties props) { @Override public boolean shouldDeleteSnapshot(FileStatus snapshot, Trash trash) { DateTime snapshotTime = Trash.TRASH_SNAPSHOT_NAME_FORMATTER.parseDateTime(snapshot.getPath().getName()); - System.out.println("Parsed time is " + snapshotTime + " and the timezone is " + snapshotTime.getZone()); - System.out.println("Target clean up time is " + snapshotTime.plusMinutes(this.retentionMinutes)); - System.out.println("Current time is " + new DateTime() + " and the timezone is " + new DateTime().getZone()); - - DateTime now = new DateTime().withZone(DateTimeZone.UTC).minusHours(7); // mimic the time in azkaban - DateTime targetCleanupTime = snapshotTime.plusMinutes(this.retentionMinutes); - DateTime delta = targetCleanupTime.minus(now.getMillis()); - - Duration duration = new Duration(now, targetCleanupTime); - duration.toStandardHours(); - duration.toStandardMinutes(); - System.out.println("Time delta is " + duration.toStandardHours() + " hours and " + duration.toStandardMinutes() + " minutes"); - - - return snapshotTime.plusMinutes(this.retentionMinutes).isBeforeNow(); + // To ensure that the comparison between snapshotTime and the current time is done in the same time zone + return snapshotTime.plusMinutes(this.retentionMinutes).isBefore(DateTime.now(DateTimeZone.UTC)); } }