public long nextGenerationStamp(boolean legacyBlock) throws IOException { return blockIdManager.nextGenerationStamp(legacyBlock); }
/** * Test that the generation stamp for legacy and new blocks is updated * as expected. * * @throws IOException */ @Test public void testGenerationStampUpdate() throws IOException { // Setup a mock object and stub out a few routines to // retrieve the generation stamp counters. BlockIdManager bid = mock(BlockIdManager.class); final long nextGenerationStampV1 = 5000; final long nextGenerationStampV2 = 20000; when(bid.getNextGenerationStampV1()) .thenReturn(nextGenerationStampV1); when(bid.getNextGenerationStampV2()) .thenReturn(nextGenerationStampV2); // Make sure that the generation stamp is set correctly for both // kinds of blocks. when(bid.nextGenerationStamp(anyBoolean())).thenCallRealMethod(); assertThat(bid.nextGenerationStamp(true), is(nextGenerationStampV1)); assertThat(bid.nextGenerationStamp(false), is(nextGenerationStampV2)); } }
/** * Increments, logs and then returns the stamp */ long nextGenerationStamp(boolean legacyBlock) throws IOException, SafeModeException { assert hasWriteLock(); checkNameNodeSafeMode("Cannot get next generation stamp"); long gs = blockIdManager.nextGenerationStamp(legacyBlock); if (legacyBlock) { getEditLog().logGenerationStampV1(gs); } else { getEditLog().logGenerationStampV2(gs); } // NB: callers sync the log return gs; }
/** * Increments, logs and then returns the stamp */ long nextGenerationStamp(boolean legacyBlock) throws IOException, SafeModeException { assert hasWriteLock(); checkNameNodeSafeMode("Cannot get next generation stamp"); long gs = blockIdManager.nextGenerationStamp(legacyBlock); if (legacyBlock) { getEditLog().logGenerationStampV1(gs); } else { getEditLog().logGenerationStampV2(gs); } // NB: callers sync the log return gs; }