chungen0126 commented on code in PR #11293:
URL: https://github.com/apache/ozone/pull/11293#discussion_r4674979735
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java:
##########
@@ -657,6 +688,10 @@ public BucketInfo getProtobuf() {
if (owner != null) {
bib.setOwner(owner);
}
+ bib.setObjectLockEnabled(objectLockEnabled);
Review Comment:
Only set `objectLockEnabled` when it is `true`. By design,
`objectLockEnabled` can only transition from `false` to `true`, and the proto
field already defaults to `false`.
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -532,6 +545,8 @@ public static class Builder extends
WithParentObjectId.Builder<OmKeyInfo> {
private boolean isFile;
private final MapBuilder<String, String> tags;
private Long expectedDataGeneration = null;
+ private ObjectRetention retention;
+ private Boolean legalHold;
Review Comment:
Why is `legalHold` a `Boolean` instead of a primitive `boolean`?
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/EventHold.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.util.Objects;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+
+/**
+ * Immutable event hold with an optional enabled flag that defaults to true.
+ */
+public final class EventHold {
+ private final Boolean enabled;
Review Comment:
Why is `enabled` a `Boolean` instead of a primitive `boolean`?
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ObjectRetention.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.util.Objects;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyRetention;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RetentionMode;
+
+/**
+ * Immutable retention state applied to a key, with an optional expiration
time in epoch milliseconds.
+ */
+public final class ObjectRetention {
+ private final RetentionMode retentionMode;
+ private final Long retentionDate;
+ private final EventHold eventHold;
+
+ public ObjectRetention(RetentionMode retentionMode, Long retentionDate,
EventHold eventHold) {
+ this.retentionMode = Objects.requireNonNull(retentionMode, "retention mode
is null");
+ this.retentionDate = retentionDate;
+ if (eventHold != null) {
+ RetentionUtil.validateEventHoldRule(eventHold.getDuration());
Review Comment:
Please separate `validateEventHoldRule` from the constructor. Keeping this
validation here tightly couples it with the key.
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/Retention.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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 com.google.protobuf.TextFormat;
+import java.util.Objects;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketRetention;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RetentionMode;
+
+/**
+ * Immutable default retention configuration for a bucket.
+ */
+public final class Retention {
+ private final RetentionMode retentionMode;
+ private final RetentionDuration duration;
+ private final RetentionDuration defaultEventHold;
+
+ public Retention(RetentionMode retentionMode, RetentionDuration duration,
RetentionDuration defaultEventHold) {
+ this.retentionMode = Objects.requireNonNull(retentionMode, "retention mode
is null");
+ this.duration = duration;
+ if (defaultEventHold != null) {
+ RetentionUtil.validateEventHoldRule(defaultEventHold);
Review Comment:
Please separate `validateEventHoldRule` from the constructor. Retention is
only set in `setRetentionConfig`, so keeping this validation here tightly
couples it with the bucket.
--
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]