smengcl commented on code in PR #4438: URL: https://github.com/apache/ozone/pull/4438#discussion_r1148147501
########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java: ########## @@ -0,0 +1,79 @@ +/* + * 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.snapshot; + +import java.io.IOException; +import org.apache.hadoop.ozone.om.OzoneManager; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.SnapshotInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND; + +/** + * Util class for snapshot diff APIs. + */ +public final class SnapshotUtils { + private static final Logger LOG = + LoggerFactory.getLogger(SnapshotUtils.class); + + private SnapshotUtils() { + throw new IllegalStateException("SnapshotUtils should not be initialized."); + } + + public static SnapshotInfo getSnapshotInfo(final OzoneManager ozoneManager, + final String volumeName, + final String bucketName, + final String snapshotName) + throws IOException { + return getSnapshotInfo(ozoneManager, + SnapshotInfo.getTableKey(volumeName, bucketName, snapshotName)); + } + + public static SnapshotInfo getSnapshotInfo(final OzoneManager ozoneManager, + final String key) + throws IOException { + SnapshotInfo snapshotInfo; + try { + snapshotInfo = ozoneManager.getMetadataManager() + .getSnapshotInfoTable() + .get(key); + } catch (IOException e) { + LOG.error("Snapshot {}: not found: {}", key, e); + throw e; + } Review Comment: Sounds good. Thx -- 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]
