chihsuan commented on code in PR #11293:
URL: https://github.com/apache/ozone/pull/11293#discussion_r4348312939


##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -833,6 +833,41 @@ message BucketInfo {
     optional uint64 snapshotUsedBytes = 21;
     optional uint64 snapshotUsedNamespace = 22;
     repeated hadoop.hdds.KeyValue tags = 23;
+    optional bool objectLockEnabled = 24 [default = false];
+    optional RetentionConfig defaultRetention = 25;
+}
+
+message RetentionConfig {
+    required RetentionMode retentionMode = 1;
+    optional Rule rule = 2;
+    optional EventHold eventHold = 3;
+}
+
+message Retention {
+    required RetentionMode retentionMode = 1;
+    // UTC ISO-8601 timestamp.
+    optional string retentionDate = 2;

Review Comment:
   This follows an older revision of the design doc. Could we align it with the 
[latest 
one](https://github.com/apache/ozone/blob/c6aebcb118f296426f91da7d27eb6702538e3ff8/hadoop-hdds/docs/content/design/s3-object-lock.md#table-changes)?
 It renames these to `KeyRetention` / `BucketRetention` and stores 
`retentionDate` as `uint64` epoch millis.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/RetentionUtil.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.time.DateTimeException;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Rule;
+
+/**
+ * Validation and UTC date calculations for retention rules.
+ */
+public final class RetentionUtil {
+  private RetentionUtil() {
+  }
+
+  public static void validateRule(Rule rule) {
+    if (rule == null || !rule.isInitialized() || rule.getDuration() <= 0) {

Review Comment:
   Should `validateRule` also enforce the upper bound from the design doc? It 
caps the event hold duration at 36,500 days or 100 years, but this only checks 
for a positive value.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java:
##########
@@ -802,7 +839,9 @@ public boolean equals(Object o) {
         Objects.equals(bekInfo, that.bekInfo) &&
         Objects.equals(owner, that.owner) &&
         Objects.equals(defaultReplicationConfig, 
that.defaultReplicationConfig) &&
-        Objects.equals(tags, that.tags);
+        Objects.equals(tags, that.tags) &&
+        objectLockEnabled == that.objectLockEnabled &&
+        Objects.equals(defaultRetention, that.defaultRetention);

Review Comment:
   Could we add a test where two buckets differ only in `objectLockEnabled` or 
`defaultRetention`? I found that removing these lines, or `rule` from 
`Retention.equals`, still keeps all tests green.



-- 
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