use of org.apache.geode.internal.cache.DiskEntry in project geode by apache.
the class OffHeapRegionEntryHelperJUnitTest method releaseEntryShouldSetValueToRemovePhase2AndSetsAsyncToFalseForDiskEntry.
@Test
public void releaseEntryShouldSetValueToRemovePhase2AndSetsAsyncToFalseForDiskEntry() {
// mock region entry
OffHeapRegionEntry re = mock(VersionedStatsDiskRegionEntryOffHeap.class);
when(re.getAddress()).thenReturn(1L);
when(re.setAddress(1L, OffHeapRegionEntryHelper.REMOVED_PHASE2_ADDRESS)).thenReturn(Boolean.TRUE);
DiskId spy = Mockito.spy(DiskId.class);
when(((DiskEntry) re).getDiskId()).thenReturn(spy);
when(spy.isPendingAsync()).thenReturn(Boolean.TRUE);
// mock required methods
PowerMockito.spy(OffHeapRegionEntryHelper.class);
PowerMockito.doNothing().when(OffHeapRegionEntryHelper.class);
OffHeapRegionEntryHelper.setValue(re, Token.REMOVED_PHASE2);
OffHeapRegionEntryHelper.releaseEntry(re);
verify(spy, times(1)).setPendingAsync(Boolean.FALSE);
PowerMockito.verifyStatic();
OffHeapRegionEntryHelper.setValue(re, Token.REMOVED_PHASE2);
}
use of org.apache.geode.internal.cache.DiskEntry in project geode by apache.
the class OffHeapRegionEntryHelper method releaseEntry.
/**
* The address in 're' will be @Released.
*/
public static void releaseEntry(@Released OffHeapRegionEntry re) {
if (re instanceof DiskEntry) {
DiskId did = ((DiskEntry) re).getDiskId();
if (did != null && did.isPendingAsync()) {
synchronized (did) {
// This may not be needed so remove this call if it causes problems.
// We no longer need this entry to be written to disk so unschedule it
// before we change its value to REMOVED_PHASE2.
did.setPendingAsync(false);
setValue(re, Token.REMOVED_PHASE2);
return;
}
}
}
setValue(re, Token.REMOVED_PHASE2);
}
Aggregations