use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class Oplog method testSetCrfChannel.
/**
* Method to be used only for testing
*
* @param ch Object to replace the channel in the Oplog.crf
* @return original channel object
*/
UninterruptibleFileChannel testSetCrfChannel(UninterruptibleFileChannel ch) {
UninterruptibleFileChannel chPrev = this.crf.channel;
this.crf.channel = ch;
return chPrev;
}
use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class DiskRegionJUnitTest method testEntryUpdateInASynchPersistOnlyForIOExceptionCase.
/**
* If IOException occurs while updating an entry in an Asynch mode, DiskAccessException should
* occur & region should be destroyed
*/
@Test
public void testEntryUpdateInASynchPersistOnlyForIOExceptionCase() throws Exception {
DiskRegionProperties props = new DiskRegionProperties();
props.setRegionName("IGNORE_EXCEPTION_testEntryUpdateInASynchPersistOnlyForIOExceptionCase");
props.setOverflow(true);
props.setRolling(false);
props.setBytesThreshold(48);
props.setDiskDirs(dirs);
props.setPersistBackup(true);
region = DiskRegionHelperFactory.getAsyncPersistOnlyRegion(cache, props);
// Get the oplog handle & hence the underlying file & close it
UninterruptibleFileChannel oplogFileChannel = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
oplogFileChannel.close();
region.create("key1", new byte[16]);
region.create("key2", new byte[16]);
DiskRegion dr = ((LocalRegion) region).getDiskRegion();
dr.flushForTesting();
// Join till the asynch writer terminates
if (!dr.testWaitForAsyncFlusherThread(2000)) {
fail("async flusher thread did not terminate");
}
Wait.waitForCriterion(new WaitCriterion() {
@Override
public boolean done() {
return cache.isClosed();
}
@Override
public String description() {
return "Waiting for region IGNORE_EXCEPTION_testEntryUpdateInASynchPersistOnlyForIOExceptionCase to be destroyed.";
}
}, 5000, 500, true);
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(cache.isClosed());
region = null;
}
use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class DiskRegionJUnitTest method entryUpdateInSynchPersistTypeForIOExceptionCase.
/**
* If IOException occurs while updating an entry in a persist only synch mode, DiskAccessException
* should occur & region should be destroyed
*
* @throws Exception
*/
private void entryUpdateInSynchPersistTypeForIOExceptionCase(Region region) throws Exception {
region.create("key1", "value1");
// Get the oplog handle & hence the underlying file & close it
UninterruptibleFileChannel oplogFileChannel = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
oplogFileChannel.close();
try {
region.put("key1", "value2");
fail("Should have encountered DiskAccessException");
} catch (DiskAccessException dae) {
// OK
}
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(cache.isClosed());
region = null;
}
use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class Bug39079DUnitTest method validateRunningBridgeServerList.
private void validateRunningBridgeServerList() throws IOException {
Region region = getCache().getRegion(REGION_NAME_testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase);
try {
region.create("key1", new byte[16]);
region.create("key2", new byte[16]);
// Get the oplog handle & hence the underlying file & close it
UninterruptibleFileChannel oplogFileChannel = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
try {
oplogFileChannel.close();
region.put("key2", new byte[16]);
fail("Expected DiskAccessException");
} catch (DiskAccessException expected) {
}
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(region.getRegionService().isClosed());
region = null;
List bsRunning = getCache().getCacheServers();
assertTrue(bsRunning.isEmpty());
} finally {
if (region != null) {
region.destroyRegion();
}
}
}
use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class DiskRegionJUnitTest method entryInvalidateInSynchPersistTypeForIOExceptionCase.
/**
* If IOException occurs while invalidating an entry in a persist only synch mode,
* DiskAccessException should occur & region should be destroyed
*
* @throws Exception
*/
private void entryInvalidateInSynchPersistTypeForIOExceptionCase(Region region) throws Exception {
region.create("key1", "value1");
// Get the oplog handle & hence the underlying file & close it
UninterruptibleFileChannel oplogFileChannel = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
oplogFileChannel.close();
try {
region.invalidate("key1");
fail("Should have encountered DiskAccessException");
} catch (DiskAccessException dae) {
// OK
}
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(cache.isClosed());
region = null;
}
Aggregations