rakeshadr commented on code in PR #9886:
URL: https://github.com/apache/ozone/pull/9886#discussion_r3045553688


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartKeyInfo.java:
##########
@@ -74,6 +84,11 @@ public final class OmMultipartKeyInfo extends WithObjectID 
implements CopyObject
    */
   private final long parentID;
 
+  // This stores the schema version of the multipart key.
+  // 0 - Legacy Schema -> Uses the same table to store the multipart part info
+  // 1 - New Schema -> Uses a separate table to store the multipart part info
+  private final byte schemaVersion;

Review Comment:
   Can we use int, so that it will be inline with `uint32 in proto -> int in 
Java`



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartPartInfo.java:
##########
@@ -0,0 +1,349 @@
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.fs.FileChecksum;
+import org.apache.hadoop.fs.FileEncryptionInfo;
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2Codec;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.OzoneConsts;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyLocationList;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.MultipartPartInfo;
+import org.apache.hadoop.ozone.protocolPB.OMPBHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class represents a part of a multipart upload key.
+ */
+public final class OmMultipartPartInfo {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OmMultipartPartInfo.class);
+  private static final Codec<OmMultipartPartInfo> CODEC = new DelegatedCodec<>(
+      Proto2Codec.get(MultipartPartInfo.getDefaultInstance()),
+      OmMultipartPartInfo::getFromProto,
+      OmMultipartPartInfo::getProto,
+      OmMultipartPartInfo.class);
+
+  private final String partName;
+  private final int partNumber;
+  private final long dataSize;
+  private final long modificationTime;
+  private final long objectID;
+  private final long updateID;
+  private final List<OmKeyLocationInfoGroup> keyLocationInfos;
+  private final String eTag;
+  private final FileEncryptionInfo encInfo;
+  private final FileChecksum fileChecksum;
+
+  public static Codec<OmMultipartPartInfo> getCodec() {
+    return CODEC;
+  }
+
+  private OmMultipartPartInfo(Builder b) {
+    if (StringUtils.isBlank(b.partName)) {
+      throw new IllegalArgumentException("partName is required");
+    }
+    if (b.partNumber <= 0) {
+      throw new IllegalArgumentException("partNumber is required and > 0");
+    }
+    if (StringUtils.isBlank(b.eTag)) {
+      throw new IllegalArgumentException("eTag is required");
+    }
+    if (b.keyLocationInfos == null || b.keyLocationInfos.isEmpty()) {

Review Comment:
   `keyLocationInfos.isEmpty()` throws for any zero-byte part (no blocks 
allocated). But S3 semantics allows 0-byte parts.
   
   I think, 5 places need changing in OmMultipartPartInfo.java. Please double 
check it,
   
   Fix 1 -> Builder constructor:
   ```
   if (b.keyLocationInfos == null) {
         throw new IllegalArgumentException("keyLocationList must not be null");
       }
   ```
   
   Fix 2 -> getProto() validation and serialization:
   ```
       if (keyLocationInfos == null) {
         throw new IllegalArgumentException("keyLocationList must not be null");
       }
   ```
   Fix 3 -> getFromProto():
   ```
           .setKeyLocationInfos(multipartPartInfo.hasKeyLocationList()
               ? getKeyLocationInfosFromProto(multipartPartInfo)
               : Collections.emptyList())
   ```
   
   Fix 4 -> getKeyLocationInfosAsProto()
   Remove below check:
      ```
    if (keyLocationInfos == null || keyLocationInfos.isEmpty()) {
         throw new IllegalArgumentException("keyLocationList is required");
       }
   ```
   
   Fix-5 -> validateRequiredProtoFields():
   
   Remove below check:
   ```
       if (!partInfo.hasKeyLocationList()) {
         throw new IllegalArgumentException("MultipartPartInfo missing 
keyLocationList");
       }
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -1521,6 +1530,25 @@ public List<ExpiredMultipartUploadsBucket> 
getExpiredMultipartUploads(
               .addMultipartUploads(builder.setName(dbMultipartInfoKey)
                   .build());
           numParts += omMultipartKeyInfo.getPartKeyInfoMap().size();
+          // TODO: Uncomment this when the complete flow for MPU split table 
is done

Review Comment:
   Can you check whether we can use OzoneManagerVersion or OMLayoutFeature 
flags and implement behind it? By default the feature will be disabled, anyone 
can enable it?



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