From 6bfb281281ac382c1abbbaeaac04d687b1c5c512 Mon Sep 17 00:00:00 2001 From: welin Date: Tue, 29 Oct 2024 21:25:07 -0700 Subject: [PATCH] clean up code --- .../trash/TimeBasedSnapshotCleanupPolicy.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) 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)); } }