private static void writeBytesToDisk(DiskEntry entry, InternalRegion region, boolean async, ValueWrapper vw) throws RegionClearedException { // @todo does the following unmark need to be called when an async // write is scheduled or is it ok for doAsyncFlush to do it? entry.getDiskId().unmarkForWriting(); region.getDiskRegion().put(entry, region, vw, async); }
@Test public void whenBasicUpdateWithDiskRegionBackupAndEntryNotSetThenReleaseOnStoredObjectShouldBeCalled() throws Exception { StoredObject storedObject = mock(StoredObject.class); 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(diskRegion.isBackup()).thenReturn(true); doThrow(new RegionDestroyedException("", "")).when(diskRegion).put(eq(diskEntry), eq(lr), ArgumentMatchers.any(DiskEntry.Helper.ValueWrapper.class), anyBoolean()); when(lr.getDiskRegion()).thenReturn(diskRegion); try { DiskEntry.Helper.basicUpdateForTesting(diskEntry, lr, storedObject, entryEvent); fail(); } catch (RegionDestroyedException rde) { verify(storedObject, times(1)).release(); } }
@Test public void whenBasicUpdateWithDiskRegionBackupAndAsyncWritesAndEntryNotSetThenReleaseOnStoredObjectShouldBeCalled() throws Exception { StoredObject storedObject = mock(StoredObject.class); 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(diskRegion.isBackup()).thenReturn(true); doThrow(new RegionDestroyedException("", "")).when(diskRegion).put(eq(diskEntry), eq(lr), ArgumentMatchers.any(DiskEntry.Helper.ValueWrapper.class), anyBoolean()); when(lr.getDiskRegion()).thenReturn(diskRegion); when(diskRegion.isSync()).thenReturn(false); when(lr.isInitialized()).thenReturn(true); when(lr.getConcurrencyChecksEnabled()).thenThrow(new RegionDestroyedException("", "")); try { DiskEntry.Helper.basicUpdateForTesting(diskEntry, lr, storedObject, entryEvent); fail(); } catch (RegionDestroyedException rde) { verify(storedObject, times(1)).release(); } }