This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 440bc82761 Revert "HDDS-12596. OM fs snapshot max limit is not
enforced (#8157)"
440bc82761 is described below
commit 440bc82761c7e0658fd29f935621c4557a44192f
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri May 2 09:22:14 2025 +0200
Revert "HDDS-12596. OM fs snapshot max limit is not enforced (#8157)"
This reverts commit f345492db0d96d5d3df77fe0581c24203fe8c414.
---
.../hadoop/ozone/om/exceptions/OMException.java | 4 +-
.../om/snapshot/TestOzoneManagerHASnapshot.java | 23 ------
.../src/main/proto/OmClientProtocol.proto | 1 -
.../apache/hadoop/ozone/om/OmSnapshotManager.java | 46 ------------
.../ozone/om/ratis/OzoneManagerStateMachine.java | 5 --
.../request/snapshot/OMSnapshotCreateRequest.java | 7 +-
.../hadoop/ozone/om/TestOmSnapshotManager.java | 85 ++++------------------
.../snapshot/TestOMSnapshotCreateRequest.java | 54 --------------
8 files changed, 15 insertions(+), 210 deletions(-)
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/exceptions/OMException.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/exceptions/OMException.java
index 596eb12765..660b21c45b 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/exceptions/OMException.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/exceptions/OMException.java
@@ -272,8 +272,6 @@ public enum ResultCodes {
TOO_MANY_BUCKETS,
KEY_UNDER_LEASE_RECOVERY,
KEY_ALREADY_CLOSED,
- KEY_UNDER_LEASE_SOFT_LIMIT_PERIOD,
-
- TOO_MANY_SNAPSHOTS,
+ KEY_UNDER_LEASE_SOFT_LIMIT_PERIOD
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
index 11de3873c4..874044c75d 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java
@@ -342,29 +342,6 @@ public void testKeyAndSnapshotDeletionService() throws
IOException, InterruptedE
checkSnapshotIsPurgedFromDB(omFollower, tableKey);
}
- @Test
- public void testSnapshotInFlightCount() throws Exception {
- // snapshot inflight count should be reset to 0 when leader changes
-
- // first do some snapshot creations
- String snapshotName1 = UUID.randomUUID().toString();
- store.createSnapshot(volumeName, bucketName, snapshotName1);
-
- // then shutdown the leader
- OzoneManager omLeader = cluster.getOMLeader();
- cluster.shutdownOzoneManager(omLeader);
-
- // wait for the new leader to be elected
- cluster.waitForLeaderOM();
-
- // check the inflight count on the new leader is 0
- OzoneManager newLeader = cluster.getOMLeader();
- assertEquals(0,
newLeader.getOmSnapshotManager().getInFlightSnapshotCount());
-
- // restart the previous shutdowned node
- cluster.restartOzoneManager(omLeader, true);
- }
-
private void createSnapshot(String volName, String buckName, String
snapName) throws IOException {
store.createSnapshot(volName, buckName, snapName);
diff --git
a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
index 92edafa942..4108af198b 100644
--- a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
+++ b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
@@ -564,7 +564,6 @@ enum Status {
KEY_ALREADY_CLOSED = 96;
KEY_UNDER_LEASE_SOFT_LIMIT_PERIOD = 97;
- TOO_MANY_SNAPSHOTS = 98;
}
/**
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
index 7882710422..6629e911af 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java
@@ -24,8 +24,6 @@
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_CHECKPOINT_DIR;
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_DIFF_DB_NAME;
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_INDICATOR;
-import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_FS_SNAPSHOT_MAX_LIMIT;
-import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_FS_SNAPSHOT_MAX_LIMIT_DEFAULT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE;
@@ -65,8 +63,6 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.StringUtils;
@@ -177,9 +173,6 @@ public final class OmSnapshotManager implements
AutoCloseable {
// Soft limit of the snapshot cache size.
private final int softCacheSize;
- private int fsSnapshotMaxLimit;
- private final AtomicInteger inFlightSnapshotCount = new AtomicInteger(0);
-
public OmSnapshotManager(OzoneManager ozoneManager) {
boolean isFilesystemSnapshotEnabled =
@@ -254,9 +247,6 @@ public OmSnapshotManager(OzoneManager ozoneManager) {
this.softCacheSize = ozoneManager.getConfiguration().getInt(
OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE,
OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE_DEFAULT);
-
- fsSnapshotMaxLimit =
ozoneManager.getConfiguration().getInt(OZONE_OM_FS_SNAPSHOT_MAX_LIMIT,
- OZONE_OM_FS_SNAPSHOT_MAX_LIMIT_DEFAULT);
CacheLoader<UUID, OmSnapshot> loader = createCacheLoader();
@@ -869,42 +859,6 @@ private void validateSnapshotsExistAndActive(final String
volumeName,
checkSnapshotActive(toSnapInfo, false);
}
- public void snapshotLimitCheck() throws IOException, OMException {
- OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl)
ozoneManager.getMetadataManager();
- SnapshotChainManager snapshotChainManager =
omMetadataManager.getSnapshotChainManager();
- int currentSnapshotNum =
snapshotChainManager.getGlobalSnapshotChain().size();
-
- AtomicReference<OMException> exceptionRef = new AtomicReference<>(null);
- inFlightSnapshotCount.updateAndGet(count -> {
- if (currentSnapshotNum + count >= fsSnapshotMaxLimit) {
- exceptionRef.set(new OMException(
- String.format("Snapshot limit of %d reached. Cannot create more
snapshots. " +
- "Current snapshots: %d, In-flight creations: %d",
- fsSnapshotMaxLimit, currentSnapshotNum, count) +
- " If you already deleted some snapshots, " +
- "please wait for the background service to complete the
cleanup.",
- OMException.ResultCodes.TOO_MANY_SNAPSHOTS));
- return count;
- }
- return count + 1;
- });
- if (exceptionRef.get() != null) {
- throw exceptionRef.get();
- }
- }
-
- public void decrementInFlightSnapshotCount() {
- inFlightSnapshotCount.decrementAndGet();
- }
-
- public void resetInFlightSnapshotCount() {
- inFlightSnapshotCount.set(0);
- }
-
- public int getInFlightSnapshotCount() {
- return inFlightSnapshotCount.get();
- }
-
private int getIndexFromToken(final String token) throws IOException {
if (isBlank(token)) {
return 0;
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
index 0ad3844716..8eadd5bff0 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
@@ -156,11 +156,6 @@ public SnapshotInfo getLatestSnapshot() {
return snapshotInfo;
}
- @Override
- public void notifyLeaderReady() {
- ozoneManager.getOmSnapshotManager().resetInFlightSnapshotCount();
- }
-
@Override
public void notifyLeaderChanged(RaftGroupMemberId groupMemberId,
RaftPeerId newLeaderId) {
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java
index 8efa517a75..900419ad42 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java
@@ -120,8 +120,6 @@ public OMRequest preExecute(OzoneManager ozoneManager)
throws IOException {
"Only bucket owners and Ozone admins can create snapshots",
OMException.ResultCodes.PERMISSION_DENIED);
}
- // verify snapshot limit
- ozoneManager.getOmSnapshotManager().snapshotLimitCheck();
CreateSnapshotRequest.Builder createSnapshotRequest =
omRequest.getCreateSnapshotRequest().toBuilder()
.setSnapshotId(toProtobuf(UUID.randomUUID()))
.setVolumeName(volumeName)
@@ -190,7 +188,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager
ozoneManager, Execut
// pre-replicated key size counter in OmBucketInfo.
snapshotInfo.setReferencedSize(estimateBucketDataSize(omBucketInfo));
- addSnapshotInfoToSnapshotChainAndCache(ozoneManager, omMetadataManager,
context.getIndex());
+ addSnapshotInfoToSnapshotChainAndCache(omMetadataManager,
context.getIndex());
omResponse.setCreateSnapshotResponse(
CreateSnapshotResponse.newBuilder()
@@ -252,7 +250,6 @@ public OMClientResponse validateAndUpdateCache(OzoneManager
ozoneManager, Execut
* it was removed at T-5.
*/
private void addSnapshotInfoToSnapshotChainAndCache(
- OzoneManager ozoneManager,
OmMetadataManagerImpl omMetadataManager,
long transactionLogIndex
) throws IOException {
@@ -291,8 +288,6 @@ private void addSnapshotInfoToSnapshotChainAndCache(
removeSnapshotInfoFromSnapshotChainManager(snapshotChainManager,
snapshotInfo);
throw new IOException(exception.getMessage(), exception);
- } finally {
- ozoneManager.getOmSnapshotManager().decrementInFlightSnapshotCount();
}
}
}
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
index abe7ec7c82..ef5ae4ab59 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
@@ -32,7 +32,6 @@
import static org.apache.hadoop.ozone.om.snapshot.OmSnapshotUtils.getINode;
import static
org.apache.hadoop.ozone.om.snapshot.OmSnapshotUtils.truncateFileName;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -55,7 +54,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -78,7 +76,6 @@
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.GenericTestUtils.LogCapturer;
import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -93,9 +90,6 @@
class TestOmSnapshotManager {
private OzoneManager om;
- private SnapshotChainManager snapshotChainManager;
- private OmMetadataManagerImpl omMetadataManager;
- private OmSnapshotManager omSnapshotManager;
private static final String CANDIDATE_DIR_NAME = OM_DB_NAME +
SNAPSHOT_CANDIDATE_DIR;
private File leaderDir;
@@ -120,15 +114,9 @@ void init(@TempDir File tempDir) throws Exception {
OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE, 1);
configuration.setBoolean(
OMConfigKeys.OZONE_OM_SNAPSHOT_ROCKSDB_METRICS_ENABLED, false);
- // Allow 2 fs snapshots
- configuration.setInt(
- OMConfigKeys.OZONE_OM_FS_SNAPSHOT_MAX_LIMIT, 2);
OmTestManagers omTestManagers = new OmTestManagers(configuration);
om = omTestManagers.getOzoneManager();
- omMetadataManager = (OmMetadataManagerImpl) om.getMetadataManager();
- omSnapshotManager = om.getOmSnapshotManager();
- snapshotChainManager = omMetadataManager.getSnapshotChainManager();
}
@AfterAll
@@ -136,21 +124,6 @@ void stop() {
om.stop();
}
- @AfterEach
- void cleanup() throws IOException {
- Table<String, SnapshotInfo> snapshotInfoTable =
omMetadataManager.getSnapshotInfoTable();
-
- Iterator<UUID> iter = snapshotChainManager.iterator(true);
- while (iter.hasNext()) {
- UUID snapshotId = iter.next();
- String snapshotInfoKey = snapshotChainManager.getTableKey(snapshotId);
- SnapshotInfo snapshotInfo = snapshotInfoTable.get(snapshotInfoKey);
- snapshotChainManager.deleteSnapshot(snapshotInfo);
- snapshotInfoTable.delete(snapshotInfoKey);
- }
- omSnapshotManager.invalidateCache();
- }
-
@Test
public void testSnapshotFeatureFlagSafetyCheck() throws IOException {
// Verify that the snapshot feature config safety check method
@@ -177,11 +150,11 @@ public void testCloseOnEviction() throws IOException,
final TypedTable<String, OmBucketInfo> bucketTable =
mock(TypedTable.class);
final TypedTable<String, SnapshotInfo> snapshotInfoTable =
mock(TypedTable.class);
HddsWhiteboxTestUtils.setInternalState(
- omMetadataManager, VOLUME_TABLE, volumeTable);
+ om.getMetadataManager(), VOLUME_TABLE, volumeTable);
HddsWhiteboxTestUtils.setInternalState(
- omMetadataManager, BUCKET_TABLE, bucketTable);
+ om.getMetadataManager(), BUCKET_TABLE, bucketTable);
HddsWhiteboxTestUtils.setInternalState(
- omMetadataManager, SNAPSHOT_INFO_TABLE, snapshotInfoTable);
+ om.getMetadataManager(), SNAPSHOT_INFO_TABLE, snapshotInfoTable);
final String volumeName = UUID.randomUUID().toString();
final String dbVolumeKey =
om.getMetadataManager().getVolumeKey(volumeName);
@@ -211,8 +184,8 @@ public void testCloseOnEviction() throws IOException,
when(snapshotInfoTable.get(first.getTableKey())).thenReturn(first);
when(snapshotInfoTable.get(second.getTableKey())).thenReturn(second);
- snapshotChainManager.addSnapshot(first);
- snapshotChainManager.addSnapshot(second);
+ ((OmMetadataManagerImpl)
om.getMetadataManager()).getSnapshotChainManager().addSnapshot(first);
+ ((OmMetadataManagerImpl)
om.getMetadataManager()).getSnapshotChainManager().addSnapshot(second);
RDBBatchOperation rdbBatchOperation = new RDBBatchOperation();
// create the first snapshot checkpoint
OmSnapshotManager.createOmSnapshotCheckpoint(om.getMetadataManager(),
@@ -220,6 +193,7 @@ public void testCloseOnEviction() throws IOException,
om.getMetadataManager().getStore().commitBatchOperation(rdbBatchOperation);
// retrieve it and setup store mock
+ OmSnapshotManager omSnapshotManager = om.getOmSnapshotManager();
OmSnapshot firstSnapshot = omSnapshotManager
.getActiveSnapshot(first.getVolumeName(), first.getBucketName(),
first.getName())
.get();
@@ -255,37 +229,6 @@ public void testCloseOnEviction() throws IOException,
}, 100, 30_000);
}
- @Test
- public void testValidateSnapshotLimit() throws IOException {
- Table<String, SnapshotInfo> snapshotInfoTable = mock(Table.class);
- HddsWhiteboxTestUtils.setInternalState(
- omMetadataManager, SNAPSHOT_INFO_TABLE, snapshotInfoTable);
-
- SnapshotInfo first = createSnapshotInfo("vol1", "buck1");
- SnapshotInfo second = createSnapshotInfo("vol1", "buck1");
-
- first.setGlobalPreviousSnapshotId(null);
- first.setPathPreviousSnapshotId(null);
- second.setGlobalPreviousSnapshotId(first.getSnapshotId());
- second.setPathPreviousSnapshotId(first.getSnapshotId());
-
- when(snapshotInfoTable.get(first.getTableKey())).thenReturn(first);
- when(snapshotInfoTable.get(second.getTableKey())).thenReturn(second);
-
- snapshotChainManager.addSnapshot(first);
- assertDoesNotThrow(() -> omSnapshotManager.snapshotLimitCheck());
- omSnapshotManager.decrementInFlightSnapshotCount();
-
- snapshotChainManager.addSnapshot(second);
-
- OMException exception = assertThrows(OMException.class, () ->
omSnapshotManager.snapshotLimitCheck());
- assertEquals(OMException.ResultCodes.TOO_MANY_SNAPSHOTS,
exception.getResult());
-
- snapshotChainManager.deleteSnapshot(second);
-
- assertDoesNotThrow(() -> omSnapshotManager.snapshotLimitCheck());
- }
-
@BeforeEach
void setupData(@TempDir File testDir) throws IOException {
// Set up the leader with the following files:
@@ -389,12 +332,16 @@ public void testHardLinkCreation() throws IOException {
@Test
public void testGetSnapshotInfo() throws IOException {
SnapshotInfo s1 = createSnapshotInfo("vol", "buck");
- UUID latestGlobalSnapId = snapshotChainManager.getLatestGlobalSnapshotId();
+ UUID latestGlobalSnapId =
+ ((OmMetadataManagerImpl)
om.getMetadataManager()).getSnapshotChainManager()
+ .getLatestGlobalSnapshotId();
UUID latestPathSnapId =
- snapshotChainManager.getLatestPathSnapshotId(String.join("/", "vol",
"buck"));
+ ((OmMetadataManagerImpl)
om.getMetadataManager()).getSnapshotChainManager()
+ .getLatestPathSnapshotId(String.join("/", "vol", "buck"));
s1.setPathPreviousSnapshotId(latestPathSnapId);
s1.setGlobalPreviousSnapshotId(latestGlobalSnapId);
- snapshotChainManager.addSnapshot(s1);
+ ((OmMetadataManagerImpl) om.getMetadataManager()).getSnapshotChainManager()
+ .addSnapshot(s1);
OMException ome = assertThrows(OMException.class,
() -> om.getOmSnapshotManager().getSnapshot(s1.getSnapshotId()));
assertEquals(OMException.ResultCodes.FILE_NOT_FOUND, ome.getResult());
@@ -403,12 +350,6 @@ public void testGetSnapshotInfo() throws IOException {
ome = assertThrows(OMException.class,
() -> om.getOmSnapshotManager().getSnapshot(s2.getSnapshotId()));
assertEquals(OMException.ResultCodes.FILE_NOT_FOUND, ome.getResult());
-
- // add to make cleanup work
- Table<String, SnapshotInfo> snapshotInfoTable = mock(Table.class);
- HddsWhiteboxTestUtils.setInternalState(
- omMetadataManager, SNAPSHOT_INFO_TABLE, snapshotInfoTable);
- when(snapshotInfoTable.get(s1.getTableKey())).thenReturn(s1);
}
/*
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
index a45991816b..7842bc1cab 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/snapshot/TestOMSnapshotCreateRequest.java
@@ -18,7 +18,6 @@
package org.apache.hadoop.ozone.om.request.snapshot;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
-import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_FS_SNAPSHOT_MAX_LIMIT;
import static org.apache.hadoop.ozone.om.helpers.SnapshotInfo.getFromProtobuf;
import static org.apache.hadoop.ozone.om.helpers.SnapshotInfo.getTableKey;
import static
org.apache.hadoop.ozone.om.request.OMRequestTestUtils.createSnapshotRequest;
@@ -38,7 +37,6 @@
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.utils.TransactionInfo;
import org.apache.hadoop.hdds.utils.db.Table;
-import org.apache.hadoop.ozone.om.OmSnapshotManager;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.ResolvedBucket;
import org.apache.hadoop.ozone.om.exceptions.OMException;
@@ -66,17 +64,11 @@
public class TestOMSnapshotCreateRequest extends
TestSnapshotRequestAndResponse {
private String snapshotName1;
private String snapshotName2;
- private String snapshotName3;
- private String snapshotName4;
- private String snapshotName5;
@BeforeEach
public void setup() throws Exception {
snapshotName1 = UUID.randomUUID().toString();
snapshotName2 = UUID.randomUUID().toString();
- snapshotName3 = UUID.randomUUID().toString();
- snapshotName4 = UUID.randomUUID().toString();
- snapshotName5 = UUID.randomUUID().toString();
}
@ValueSource(strings = {
@@ -272,52 +264,6 @@ public void testEntryExists() throws Exception {
assertEquals(2, getOmMetrics().getNumSnapshotCreates());
}
- @Test
- public void testSnapshotLimit() throws Exception {
- when(getOzoneManager().isAdmin(any())).thenReturn(true);
- getOzoneManager().getOmSnapshotManager().close();
-
getOzoneManager().getConfiguration().setInt(OZONE_OM_FS_SNAPSHOT_MAX_LIMIT, 3);
- OmSnapshotManager omSnapshotManager = new
OmSnapshotManager(getOzoneManager());
-
when(getOzoneManager().getOmSnapshotManager()).thenReturn(omSnapshotManager);
-
- // Test Case 1: No snapshots in chain, no in-flight
- String key1 = getTableKey(getVolumeName(), getBucketName(), snapshotName1);
- OMRequest omRequest = createSnapshotRequest(getVolumeName(),
getBucketName(), snapshotName1);
- OMSnapshotCreateRequest omSnapshotCreateRequest = doPreExecute(omRequest);
- assertNull(getOmMetadataManager().getSnapshotInfoTable().get(key1));
- omSnapshotCreateRequest.validateAndUpdateCache(getOzoneManager(), 1);
- assertNotNull(getOmMetadataManager().getSnapshotInfoTable().get(key1));
-
- // Test Case 2: One snapshot in chain, no in-flight
- String key2 = getTableKey(getVolumeName(), getBucketName(), snapshotName2);
- OMRequest snapshotRequest2 = createSnapshotRequest(getVolumeName(),
getBucketName(), snapshotName2);
- OMSnapshotCreateRequest omSnapshotCreateRequest2 =
doPreExecute(snapshotRequest2);
- omSnapshotCreateRequest2.validateAndUpdateCache(getOzoneManager(), 2);
- assertNotNull(getOmMetadataManager().getSnapshotInfoTable().get(key2));
-
- // Test Case 3: Two snapshots in chain, one in-flight
- // First create an in-flight snapshot
- String key3 = getTableKey(getVolumeName(), getBucketName(), snapshotName3);
- OMRequest snapshotRequest3 = createSnapshotRequest(getVolumeName(),
getBucketName(), snapshotName3);
- OMSnapshotCreateRequest omSnapshotCreateRequest3 =
doPreExecute(snapshotRequest3);
- // Don't call validateAndUpdateCache to keep it in-flight
-
- // Try to create another snapshot - should fail as total would be 4 (2 in
chain + 1 in-flight + 1 new)
- OMRequest snapshotRequest4 = createSnapshotRequest(getVolumeName(),
getBucketName(), snapshotName4);
- OMException omException = assertThrows(OMException.class, () ->
doPreExecute(snapshotRequest4));
- assertEquals(OMException.ResultCodes.TOO_MANY_SNAPSHOTS,
omException.getResult());
-
- // Complete the in-flight snapshot
- omSnapshotCreateRequest3.validateAndUpdateCache(getOzoneManager(), 3);
- assertNotNull(getOmMetadataManager().getSnapshotInfoTable().get(key3));
-
- // Test Case 4: Three snapshots in chain, no in-flight
- // Try to create another snapshot - should fail as we've reached the limit
- OMRequest snapshotRequest5 = createSnapshotRequest(getVolumeName(),
getBucketName(), snapshotName5);
- omException = assertThrows(OMException.class, () ->
doPreExecute(snapshotRequest5));
- assertEquals(OMException.ResultCodes.TOO_MANY_SNAPSHOTS,
omException.getResult());
- }
-
private void renameKey(String fromKey, String toKey, long offset)
throws IOException {
OmKeyInfo toKeyInfo = addKey(toKey, offset + 1L);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]