priyeshkaratha commented on code in PR #12170:
URL: https://github.com/apache/ozone/pull/12170#discussion_r4779180834


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCExpiration.java:
##########
@@ -72,6 +73,31 @@ public boolean isExpired(long timestamp) {
     }
   }
 
+  /**
+   * Returns when an object last modified at the given time expires under this 
action, as AWS S3 reports it in the
+   * x-amz-expiration header: for Days, the modification time plus the days, 
rounded up to the next midnight UTC;
+   * for Date, the configured date.
+   *
+   * @param modificationTime modification time of the object in milliseconds 
since epoch
+   * @return the expiry time, or null if neither a positive Days nor a 
parsable Date is set
+   */
+  @Nullable
+  public Instant getExpiryTime(long modificationTime) {
+    if (days != null && days > 0) {
+      ZonedDateTime expiry = 
Instant.ofEpochMilli(modificationTime).atZone(ZoneOffset.UTC).plusDays(days);
+      ZonedDateTime midnight = expiry.truncatedTo(ChronoUnit.DAYS);
+      return (midnight.equals(expiry) ? midnight : 
midnight.plusDays(1)).toInstant();

Review Comment:
   Agreed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to