Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 = 31;

private boolean allowNestedSnapshots = false;
private int snapshotCounter = 0;
Expand Down Expand Up @@ -541,8 +541,8 @@ public void clearSnapshottableDirs() {
*
* @return maximum allowable snapshot ID.
*/
public int getMaxSnapshotID() {
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 1);
public int getMaxSnapshotID() {
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 3);
}

private ObjectName mxBeanName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,15 @@ public void testSnapshotLimits() throws Exception {
StringUtils.toLowerCase(se.getMessage()).contains("rollover"));
}
}


@Test
public void testValidateSnapshotIDWidth() {
FSDirectory fsdir = mock(FSDirectory.class);
SnapshotManager snapshotManager = new SnapshotManager(new Configuration(),
fsdir);
Assert.assertTrue(snapshotManager.
getMaxSnapshotID() < Snapshot.CURRENT_STATE_ID);
}

}