spacemonkd commented on code in PR #9886: URL: https://github.com/apache/ozone/pull/9886#discussion_r3052394157
########## 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: This test will pass. ``` ❯ aws s3api create-bucket --endpoint http://localhost:9878 --bucket ec-obs-demo ❯ touch empty.txt ❯ aws s3api create-multipart-upload --endpoint-url http://localhost:9878 --bucket ec-obs-demo --key empty-mpu-file-001.txt ❯ { "Bucket": "ec-obs-demo", "Key": "empty-mpu-file-001.txt", "UploadId": "019d6dab-282d-719e-9eac-81f3be90de5f-116369747262373889" } ❯ 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 019d6dab-282d-719e-9eac-81f3be90de5f-116369747262373889 { "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"" } ❯ touch parts.json ❯ aws s3api complete-multipart-upload --endpoint-url http://localhost:9878 --bucket ec-obs-demo --key empty-mpu-file-001.txt --upload-id 019d6dab-282d-719e-9eac-81f3be90de5f-116369747262373889 --multipart-upload file://parts.json ``` because the current code doesn't yet write into the split table. This change only introduces the new tables but we haven't changed the upload logic to handle the writes. -- 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]
