Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_DB_DIR;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE_DEFAULT;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FILE_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_KEY_NAME;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_SNAPSHOT_ERROR;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotDiffManager.getSnapshotRootPath;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.checkSnapshotActive;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.dropColumnFamilyHandle;
Expand Down Expand Up @@ -351,7 +351,8 @@ public OmSnapshot load(@Nonnull UUID snapshotId) throws IOException {
// If it happens, then either snapshot has been purged in between or SnapshotChain is corrupted
// and missing some entries which needs investigation.
if (snapshotTableKey == null) {
throw new IOException("No snapshot exist with snapshotId: " + snapshotId);
throw new OMException("Snapshot " + snapshotId +
" is not found in the snapshot chain.", FILE_NOT_FOUND);
}

final SnapshotInfo snapshotInfo = getSnapshotInfo(snapshotTableKey);
Expand Down Expand Up @@ -740,7 +741,7 @@ private SnapshotInfo getSnapshotInfo(String snapshotKey) throws IOException {
snapshotInfo = ozoneManager.getMetadataManager().getSnapshotInfoTable().getSkipCache(snapshotKey);
}
if (snapshotInfo == null) {
throw new OMException("Snapshot '" + snapshotKey + "' is not found.", INVALID_SNAPSHOT_ERROR);
throw new OMException("Snapshot '" + snapshotKey + "' is not found.", FILE_NOT_FOUND);
}
return snapshotInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.RDBBatchOperation;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
Expand Down Expand Up @@ -72,6 +73,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -314,6 +316,29 @@ public void testHardLinkCreation() throws IOException {
getINode(f1FileLink.toPath()), "link matches original file");
}


@Test
public void testGetSnapshotInfo() throws IOException {
SnapshotInfo s1 = createSnapshotInfo("vol", "buck");
UUID latestGlobalSnapId =
((OmMetadataManagerImpl) om.getMetadataManager()).getSnapshotChainManager()
.getLatestGlobalSnapshotId();
UUID latestPathSnapId =
((OmMetadataManagerImpl) om.getMetadataManager()).getSnapshotChainManager()
.getLatestPathSnapshotId(String.join("/", "vol", "buck"));
s1.setPathPreviousSnapshotId(latestPathSnapId);
s1.setGlobalPreviousSnapshotId(latestGlobalSnapId);
((OmMetadataManagerImpl) om.getMetadataManager()).getSnapshotChainManager()
.addSnapshot(s1);
OMException ome = assertThrows(OMException.class,
() -> om.getOmSnapshotManager().getSnapshot(s1.getSnapshotId()));
assertEquals(OMException.ResultCodes.FILE_NOT_FOUND, ome.getResult());
// not present in snapshot chain too
SnapshotInfo s2 = createSnapshotInfo("vol", "buck");
ome = assertThrows(OMException.class,
() -> om.getOmSnapshotManager().getSnapshot(s2.getSnapshotId()));
assertEquals(OMException.ResultCodes.FILE_NOT_FOUND, ome.getResult());
}
/*
* Test that exclude list is generated correctly.
*/
Expand Down
Loading