linyiqun commented on a change in pull request #1997: URL: https://github.com/apache/ozone/pull/1997#discussion_r589197166
########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/s3/multipart/S3MultipartUploadAbortResponseV1.java ########## @@ -0,0 +1,100 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.response.s3.multipart; + +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.OmUtils; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; +import org.apache.hadoop.ozone.om.helpers.OmKeyInfo; +import org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo; +import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; +import org.apache.hadoop.ozone.om.response.CleanupTableInfo; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo; + +import javax.annotation.Nonnull; +import java.io.IOException; +import java.util.Map; +import java.util.TreeMap; + +import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.DELETED_TABLE; +import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.MULTIPARTFILEINFO_TABLE; +import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.OPEN_FILE_TABLE; + +/** + * Response for Multipart Abort Request layout version V1. + */ +@CleanupTableInfo(cleanupTables = {OPEN_FILE_TABLE, DELETED_TABLE, + MULTIPARTFILEINFO_TABLE}) +public class S3MultipartUploadAbortResponseV1 + extends S3MultipartUploadAbortResponse { + + public S3MultipartUploadAbortResponseV1(@Nonnull OMResponse omResponse, + String multipartKey, @Nonnull OmMultipartKeyInfo omMultipartKeyInfo, + boolean isRatisEnabled, @Nonnull OmBucketInfo omBucketInfo) { + + super(omResponse, multipartKey, omMultipartKeyInfo, isRatisEnabled, + omBucketInfo); + } + + /** + * For when the request is not successful. + * For a successful request, the other constructor should be used. + */ + public S3MultipartUploadAbortResponseV1(@Nonnull OMResponse omResponse) { + super(omResponse); + } + + @Override + public void addToDBBatch(OMMetadataManager omMetadataManager, + BatchOperation batchOperation) throws IOException { + + // Delete from openKey table and multipart info table. + omMetadataManager.getOpenKeyTable().deleteWithBatch(batchOperation, + getMultipartKey()); + omMetadataManager.getMultipartInfoTable().deleteWithBatch(batchOperation, + getMultipartKey()); + + // Move all the parts to delete table + TreeMap<Integer, PartKeyInfo > partKeyInfoMap = + getOmMultipartKeyInfo().getPartKeyInfoMap(); + for (Map.Entry<Integer, PartKeyInfo > partKeyInfoEntry : + partKeyInfoMap.entrySet()) { + PartKeyInfo partKeyInfo = partKeyInfoEntry.getValue(); + OmKeyInfo currentKeyPartInfo = + OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo()); + + RepeatedOmKeyInfo repeatedOmKeyInfo = + omMetadataManager.getDeletedTable().get(partKeyInfo.getPartName()); Review comment: Thanks for addressing the comment, @rakeshadr . The reference UT verified that the part key entries are correctly put into the delete table. But the key name here might be a full part key name I think, as delete table format is like below: ```java |----------------------------------------------------------------------| | deletedTable | /volumeName/bucketName/keyName->RepeatedKeyInfo | |----------------------------------------------------------------------| ``` Now part name stored in omMultipartKeyInfo is filename+clientID, use this part name as a key name in delete table doesn't match above format. So below line needed to be update: ```java omMetadataManager.getDeletedTable().putWithBatch(batchOperation, partKeyInfo.getPartName(), repeatedOmKeyInfo); ``` Correct me If I am wrong. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
