rakeshadr commented on code in PR #9886: URL: https://github.com/apache/ozone/pull/9886#discussion_r3050573456
########## 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: Can you perform below empty file MPU upload operation to know the behavior. I've tried this in my local cluster with old schema version and able to store empty file. If it works, then ignore my comment. Please check whether partInfo is getting stored with empty or its getting skipped? Step-1) ``` aws s3api create-multipart-upload \ --endpoint-url http://localhost:9878 \ --bucket ec-obs-demo \ --key empty-mpu-file-001.txt ``` Step-2) ``` aws s3api upload-part \ --endpoint-url http://localhost:9878 \ --bucket ec-obs-demo \ --key empty-mpu-file-001.txt \ --part-number 1 \ --body empty.txt \ --upload-id <YOUR_UPLOAD_ID_FROM_STEP_1> ``` step-3) create file:///parts.json ``` { "Parts": [ { "PartNumber": 1, "ETag": "<YOUR_ETAG_FROM_STEP_2>" } ] } ``` Step-4) ``` aws s3api complete-multipart-upload \ --endpoint-url http://localhost:9878 \ --bucket ec-obs-demo \ --key empty-mpu-file-001.txt \ --upload-id 019d6c78-ed57-70bd-9b59-2e82948dfc65-116368432015278088 \ --multipart-upload file:///parts.json ``` -- 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]
