HDFS-15201 SnapshotCounter hits MaxSnapshotID limit (#1870)
This commit is contained in:
parent
5eddc82fb8
commit
5250cd6db3
|
@ -96,7 +96,7 @@ public class SnapshotManager implements SnapshotStatsMXBean {
|
|||
private final boolean snapshotDiffAllowSnapRootDescendant;
|
||||
|
||||
private final AtomicInteger numSnapshots = new AtomicInteger();
|
||||
private static final int SNAPSHOT_ID_BIT_WIDTH = 24;
|
||||
private static final int SNAPSHOT_ID_BIT_WIDTH = 28;
|
||||
|
||||
private boolean allowNestedSnapshots = false;
|
||||
private int snapshotCounter = 0;
|
||||
|
@ -541,7 +541,7 @@ public class SnapshotManager implements SnapshotStatsMXBean {
|
|||
*
|
||||
* @return maximum allowable snapshot ID.
|
||||
*/
|
||||
public int getMaxSnapshotID() {
|
||||
public int getMaxSnapshotID() {
|
||||
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,4 +92,18 @@ public class TestSnapshotManager {
|
|||
StringUtils.toLowerCase(se.getMessage()).contains("rollover"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot is identified by INODE CURRENT_STATE_ID.
|
||||
* So maximum allowable snapshotID should be less than CURRENT_STATE_ID
|
||||
*/
|
||||
@Test
|
||||
public void testValidateSnapshotIDWidth() {
|
||||
FSDirectory fsdir = mock(FSDirectory.class);
|
||||
SnapshotManager snapshotManager = new SnapshotManager(new Configuration(),
|
||||
fsdir);
|
||||
Assert.assertTrue(snapshotManager.
|
||||
getMaxSnapshotID() < Snapshot.CURRENT_STATE_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue