use of org.apache.geode.cache.DiskAccessException in project geode by apache.
the class Oplog method copyForwardModifyForCompact.
private void copyForwardModifyForCompact(DiskRegionView dr, DiskEntry entry, BytesAndBitsForCompactor wrapper) {
if (getOplogSet().getChild() != this) {
getOplogSet().getChild().copyForwardModifyForCompact(dr, entry, wrapper);
} else {
DiskId did = entry.getDiskId();
boolean exceptionOccurred = false;
int len = did.getValueLength();
try {
// TODO: compaction needs to get version?
byte userBits = wrapper.getBits();
ValueWrapper vw;
if (wrapper.getOffHeapData() != null) {
vw = new DiskEntry.Helper.OffHeapValueWrapper(wrapper.getOffHeapData());
} else {
vw = new DiskEntry.Helper.CompactorValueWrapper(wrapper.getBytes(), wrapper.getValidLength());
}
// Compactor always says to do an async basicModify so that its writes
// will be grouped. This is not a true async write; just a grouped one.
basicModify(dr, entry, vw, userBits, true, true);
} catch (IOException ex) {
exceptionOccurred = true;
getParent().getCancelCriterion().checkCancelInProgress(ex);
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, getParent());
} catch (InterruptedException ie) {
exceptionOccurred = true;
Thread.currentThread().interrupt();
getParent().getCancelCriterion().checkCancelInProgress(ie);
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, getParent());
} finally {
if (wrapper.getOffHeapData() != null) {
wrapper.setOffHeapData(null, (byte) 0);
}
if (exceptionOccurred) {
did.setValueLength(len);
}
}
}
}
use of org.apache.geode.cache.DiskAccessException in project geode by apache.
the class Oplog method remove.
/**
* Removes the key/value pair with the given id on disk.
*
* @param entry DiskEntry object on which remove operation is called
*/
public void remove(LocalRegion region, DiskEntry entry, boolean async, boolean isClear) {
DiskRegion dr = region.getDiskRegion();
if (getOplogSet().getChild() != this) {
getOplogSet().getChild().remove(region, entry, async, isClear);
} else {
DiskId did = entry.getDiskId();
boolean exceptionOccurred = false;
byte prevUsrBit = did.getUserBits();
int len = did.getValueLength();
try {
basicRemove(dr, entry, async, isClear);
} catch (IOException ex) {
exceptionOccurred = true;
getParent().getCancelCriterion().checkCancelInProgress(ex);
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, dr.getName());
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
region.getCancelCriterion().checkCancelInProgress(ie);
exceptionOccurred = true;
throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, dr.getName());
} finally {
if (exceptionOccurred) {
did.setValueLength(len);
did.setUserBits(prevUsrBit);
}
}
}
}
use of org.apache.geode.cache.DiskAccessException in project geode by apache.
the class DiskRegOplogSwtchingAndRollerJUnitTest method testDiskFullExcep.
// end of testGetEvictedEntry
/**
* DiskRegNoDiskAccessExceptionTest: tests that while rolling is set to true DiskAccessException
* doesn't occur even when amount of put data exceeds the max dir sizes.
*/
@Test
public void testDiskFullExcep() {
boolean exceptionOccurred = false;
int[] diskDirSize1 = new int[4];
diskDirSize1[0] = 1048576;
diskDirSize1[1] = 1048576;
diskDirSize1[2] = 1048576;
diskDirSize1[3] = 1048576;
diskProps.setDiskDirsAndSizes(dirs, diskDirSize1);
diskProps.setPersistBackup(true);
diskProps.setRolling(true);
diskProps.setMaxOplogSize(1000000000);
diskProps.setBytesThreshold(1000000);
diskProps.setTimeInterval(1500000);
region = DiskRegionHelperFactory.getAsyncPersistOnlyRegion(cache, diskProps);
DiskStore ds = cache.findDiskStore(((LocalRegion) region).getDiskStoreName());
// int[] diskSizes1 = ((LocalRegion)region).getDiskDirSizes();
assertTrue(ds != null);
int[] diskSizes1 = null;
diskSizes1 = ds.getDiskDirSizes();
assertTrue("diskSizes != 1048576 ", diskSizes1[0] == 1048576);
assertTrue("diskSizes != 1048576 ", diskSizes1[1] == 1048576);
assertTrue("diskSizes != 1048576 ", diskSizes1[2] == 1048576);
assertTrue("diskSizes != 1048576 ", diskSizes1[3] == 1048576);
final byte[] value = new byte[1024];
Arrays.fill(value, (byte) 77);
try {
for (int i = 0; i < 7000; i++) {
region.put("" + i, value);
}
} catch (DiskAccessException e) {
logWriter.error("exception not expected", e);
exceptionOccurred = true;
}
if (exceptionOccurred) {
fail("FAILED::DiskAccessException is Not expected here !!");
}
// region.close(); // closes disk file which will flush all buffers
}
use of org.apache.geode.cache.DiskAccessException 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;
}
use of org.apache.geode.cache.DiskAccessException in project geode by apache.
the class DiskRegionJUnitTest method entryCreateInSynchPersistTypeForIOExceptionCase.
/**
*
* If IOException occurs while creating an entry in a persist only synch mode, DiskAccessException
* should occur & region should be destroyed
*
* @throws Exception
*/
private void entryCreateInSynchPersistTypeForIOExceptionCase(Region region) throws Exception {
// Get the oplog handle & hence the underlying file & close it
UninterruptibleFileChannel oplogFileChannel = ((LocalRegion) region).getDiskRegion().testHook_getChild().getFileChannel();
oplogFileChannel.close();
try {
region.create("key1", "value1");
fail("Should have encountered DiskAccessException");
} catch (DiskAccessException dae) {
// OK
}
((LocalRegion) region).getDiskStore().waitForClose();
assertTrue(cache.isClosed());
region = null;
}
Aggregations