public void replaceIncompatibleEntry(DiskEntry old, DiskEntry repl) { acquireReadLock(); try { getOplogSet().getChild().replaceIncompatibleEntry(this, old, repl); } finally { releaseReadLock(); } }
@Test public void whenHelperUpdateCalledAndDiskRegionAcquireReadLockThrowsRegionDestroyedExceptionThenStoredObjectShouldBeReleased() throws Exception { LocalRegion lr = mock(LocalRegion.class); DiskEntry diskEntry = mock(DiskEntry.class); when(diskEntry.getDiskId()).thenReturn(mock(DiskId.class)); EntryEventImpl entryEvent = mock(EntryEventImpl.class); DiskRegion diskRegion = mock(DiskRegion.class); when(lr.getDiskRegion()).thenReturn(diskRegion); Mockito.doThrow(new RegionDestroyedException("Region Destroyed", "mocked region")) .when(diskRegion).acquireReadLock(); StoredObject storedObject = mock(StoredObject.class); try { DiskEntry.Helper.update(diskEntry, lr, storedObject, entryEvent); fail(); } catch (RegionDestroyedException rde) { verify(storedObject, times(1)).release(); } }
public static void doAsyncFlush(VersionTag tag, InternalRegion region) { if (region.isThisRegionBeingClosedOrDestroyed()) return; DiskRegion dr = region.getDiskRegion(); if (!dr.isBackup()) { return; } assert !dr.isSync(); dr.acquireReadLock(); try { dr.getDiskStore().putVersionTagOnly(region, tag, true); } finally { dr.releaseReadLock(); } }
/** * Testing purpose only Get the value of an entry that is on disk without faulting it in and * without looking in the io buffer. * * @since GemFire 3.2.1 */ public static Object getValueOnDisk(DiskEntry entry, DiskRegion dr) { DiskId id = entry.getDiskId(); if (id == null) { return null; } dr.acquireReadLock(); try { synchronized (id) { if (dr.isBackup() && id.getKeyId() == DiskRegion.INVALID_ID || !entry.isValueNull() && id .needsToBeWritten() && !EntryBits .isRecoveredFromDisk(id.getUserBits())/* fix for bug 41942 */) { return null; } return dr.getNoBuffer(id); } } finally { dr.releaseReadLock(); } }
/** * Get the serialized value directly from disk. Returned object may be a * {@link CachedDeserializable}. Goes straight to disk without faulting into memory. Only looks * at the disk storage, not at heap storage. * * @param entry the entry used to identify the value to fetch * @param dr the persistent storage from which to fetch the value * @return either null, byte array, or CacheDeserializable * @since GemFire 57_hotfix */ public static Object getSerializedValueOnDisk(DiskEntry entry, DiskRegion dr) { DiskId did = entry.getDiskId(); if (did == null) { return null; } dr.acquireReadLock(); try { synchronized (did) { if (dr.isBackup() && did.getKeyId() == DiskRegion.INVALID_ID) { return null; } else if (!entry.isValueNull() && did.needsToBeWritten() && !EntryBits.isRecoveredFromDisk(did.getUserBits())/* fix for bug 41942 */) { return null; } return dr.getSerializedData(did); } } finally { dr.releaseReadLock(); } }
dr.acquireReadLock(); try { synchronized (did) {
dr.acquireReadLock(); try { DiskId did = entry.getDiskId();