use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class DiskRegionJUnitTest method testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase.
/**
* If IOException occurs while updating an entry in an already initialized DiskRegion ,then the
* bridge servers should not be stopped , if any running as they are no clients connected to it.
*/
@Test
public void testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase() throws Exception {
DiskRegionProperties props = new DiskRegionProperties();
props.setRegionName("IGNORE_EXCEPTION_testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase");
props.setOverflow(true);
props.setRolling(true);
props.setDiskDirs(dirs);
props.setPersistBackup(true);
region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, props, Scope.LOCAL);
CacheServer bs1 = cache.addCacheServer();
bs1.setPort(0);
bs1.start();
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();
oplogFileChannel.close();
try {
region.put("key2", new byte[16]);
} catch (DiskAccessException dae) {
// OK expected
}
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(cache.isClosed());
region = null;
List bsRunning = cache.getCacheServers();
// [anil & bruce] the following assertion was changed to true because
// a disk access exception in a server should always stop the server
assertTrue(bsRunning.isEmpty());
}
use of org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel in project geode by apache.
the class DiskRegionJUnitTest method testBridgeServerRunningInSynchPersistOnlyForIOExceptionCase.
/**
* If IOException occurs while initializing a region ,then the bridge servers should not be
* stopped
*/
@Test
public void testBridgeServerRunningInSynchPersistOnlyForIOExceptionCase() throws Exception {
DiskRegionProperties props = new DiskRegionProperties();
props.setRegionName("IGNORE_EXCEPTION_testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase");
props.setOverflow(true);
props.setRolling(true);
props.setDiskDirs(dirs);
props.setPersistBackup(true);
// just needs to be bigger than 65550
props.setMaxOplogSize(100000);
region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, props, Scope.LOCAL);
CacheServer bs1 = cache.addCacheServer();
bs1.setPort(0);
bs1.start();
region.create("key1", new byte[16]);
region.create("key2", new byte[16]);
// Get the oplog file path
UninterruptibleFileChannel oplogFileChnl = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
// corrupt the opfile
oplogFileChnl.position(2);
ByteBuffer bf = ByteBuffer.allocate(416);
for (int i = 0; i < 5; ++i) {
bf.putInt(i);
}
bf.flip();
// Corrupt the oplogFile
oplogFileChnl.write(bf);
// Close the region
region.close();
assertTrue(region.isDestroyed());
try {
region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, props, Scope.LOCAL);
fail("expected DiskAccessException");
} catch (DiskAccessException dae) {
// OK expected
}
assertTrue(region.isDestroyed());
region = null;
List bsRunning = cache.getCacheServers();
assertTrue(!bsRunning.isEmpty());
}
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();
}
}
}
Aggregations