Search in sources :

Example 1 with UninterruptibleFileChannel

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;
}
Also used : UninterruptibleFileChannel(org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel)

Example 2 with UninterruptibleFileChannel

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;
}
Also used : UninterruptibleFileChannel(org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 3 with UninterruptibleFileChannel

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;
}
Also used : UninterruptibleFileChannel(org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel) DiskAccessException(org.apache.geode.cache.DiskAccessException)

Example 4 with UninterruptibleFileChannel

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();
        }
    }
}
Also used : UninterruptibleFileChannel(org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel) DiskAccessException(org.apache.geode.cache.DiskAccessException) Region(org.apache.geode.cache.Region) List(java.util.List)

Example 5 with UninterruptibleFileChannel

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;
}
Also used : UninterruptibleFileChannel(org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel) DiskAccessException(org.apache.geode.cache.DiskAccessException)

Aggregations

UninterruptibleFileChannel (org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel)8 DiskAccessException (org.apache.geode.cache.DiskAccessException)6 List (java.util.List)3 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CacheServer (org.apache.geode.cache.server.CacheServer)2 ByteBuffer (java.nio.ByteBuffer)1 Region (org.apache.geode.cache.Region)1 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)1