Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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;
Expand Down Expand Up @@ -541,7 +541,7 @@ public void clearSnapshottableDirs() {
*
* @return maximum allowable snapshot ID.
*/
public int getMaxSnapshotID() {
public int getMaxSnapshotID() {
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,18 @@ public void testSnapshotLimits() throws Exception {
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);
}

}