ivandika3 commented on code in PR #5753: URL: https://github.com/apache/ozone/pull/5753#discussion_r1429489159
########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/helpers/OmGetKey.java: ########## @@ -0,0 +1,175 @@ +/* + * 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 org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.request.file.OMFileRequest; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Iterator; + +/** + * This class help to get metadata keys. + */ +public final class OmGetKey { + + private String volumeName; + private String bucketName; + private String keyName; + private OMMetadataManager omMetadataManager; + private long clientID; + + private String fileName; + private Iterator<Path> pathComponents; + private long volumeId; + private long bucketId; + private long parentID; + + + @SuppressWarnings("checkstyle:parameternumber") + private OmGetKey(String volumeName, String bucketName, String keyName, + OMMetadataManager omMetadataManager, long clientID, + String fileName, Iterator<Path> pathComponents, long volumeId, + long bucketId, long parentID) { + this.volumeName = volumeName; + this.bucketName = bucketName; + this.keyName = keyName; + this.omMetadataManager = omMetadataManager; + this.clientID = clientID; + + this.fileName = fileName; + this.pathComponents = pathComponents; + this.volumeId = volumeId; + this.bucketId = bucketId; + this.parentID = parentID; + } + + /** + * Builder class for OmGetKey. + */ + public static class Builder { + private String volumeName; + private String bucketName; + private String keyName; + private OMMetadataManager omMetadataManager; + private long clientID; + private String errMsg; + + public Builder() { + this.errMsg = null; + } + + public Builder setVolumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + public Builder setBucketName(String bucketName) { + this.bucketName = bucketName; + return this; + } + + public Builder setKeyName(String keyName) { + this.keyName = keyName; + return this; + } + + public Builder setOmMetadataManager(OMMetadataManager omMetadataManager) { + this.omMetadataManager = omMetadataManager; + return this; + } + + public Builder setClientID(long clientID) { + this.clientID = clientID; + return this; + } + + public Builder setErrMsg(String errMsg) { + this.errMsg = errMsg; + return this; + } + + public OmGetKey build() throws IOException { + String fileName = OzoneFSUtils.getFileName(this.keyName); + Iterator<Path> pathComponents = Paths.get(this.keyName).iterator(); + final long volumeId = omMetadataManager.getVolumeId(this.volumeName); + final long bucketId = omMetadataManager.getBucketId(this.volumeName, + this.bucketName); + long parentID = OMFileRequest + .getParentID(volumeId, bucketId, pathComponents, this.keyName, + this.omMetadataManager, this.errMsg); Review Comment: @TaiJuWu I have created https://issues.apache.org/jira/browse/HDDS-9946 and assigned it to you. Please let me know if you have any questions. -- 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]
