Search in sources :

Example 41 with DiskStoreFactory

use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.

the class DiskStoreFactoryJUnitTest method testFlush.

@Test
public void testFlush() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testFlush";
    DiskStore ds = dsf.create(name);
    ds.flush();
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 42 with DiskStoreFactory

use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.

the class DiskStoreFactoryJUnitTest method testDestroyWithClosedRegion.

@Test
public void testDestroyWithClosedRegion() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testDestroy";
    DiskStore ds = dsf.create(name);
    Region region = cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("testDestroy").create("region");
    region.close();
    // This should now work
    ds.destroy();
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Region(org.apache.geode.cache.Region) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 43 with DiskStoreFactory

use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.

the class OplogJUnitTest method testPreblowErrorCondition.

/**
   * Tests if the preblowing of a file with size greater than the disk space available so that
   * preblowing results in IOException , is able to recover without problem
   *
   */
// Now we preallocate spaces for if files and also crfs and drfs. So the below test is not valid
// any more. See revision: r42359 and r42320. So disabling this test.
@Ignore("TODO: test is disabled")
@Test
public void testPreblowErrorCondition() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    ((DiskStoreFactoryImpl) dsf).setMaxOplogSizeInBytes(100000000L * 1024L * 1024L * 1024L);
    dsf.setAutoCompact(false);
    File dir = new File("testingDirectoryDefault");
    dir.mkdir();
    dir.deleteOnExit();
    File[] dirs = { dir };
    int[] size = new int[] { Integer.MAX_VALUE };
    dsf.setDiskDirsAndSizes(dirs, size);
    AttributesFactory factory = new AttributesFactory();
    logWriter.info("<ExpectedException action=add>" + "Could not pregrow" + "</ExpectedException>");
    try {
        DiskStore ds = dsf.create("test");
        factory.setDiskStoreName(ds.getName());
        factory.setDiskSynchronous(true);
        factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
        factory.setScope(Scope.LOCAL);
        try {
            region = cache.createVMRegion("test", factory.createRegionAttributes());
        } catch (Exception e1) {
            logWriter.error("Test failed due to exception", e1);
            fail("Test failed due to exception " + e1);
        }
        region.put("key1", new byte[900]);
        byte[] val = null;
        try {
            val = (byte[]) ((LocalRegion) region).getValueOnDisk("key1");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            fail(e.toString());
        }
        assertTrue(val.length == 900);
    } finally {
        logWriter.info("<ExpectedException action=remove>" + "Could not pregrow" + "</ExpectedException>");
    }
    closeDown();
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) IOException(java.io.IOException) CommitConflictException(org.apache.geode.cache.CommitConflictException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) Ignore(org.junit.Ignore) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 44 with DiskStoreFactory

use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.

the class PersistentReplicatedTestBase method createPersistentRegionWithoutCompaction.

protected SerializableRunnable createPersistentRegionWithoutCompaction(final VM vm0) {
    SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {

        public void run() {
            Cache cache = getCache();
            DiskStoreFactory dsf = cache.createDiskStoreFactory();
            File dir = getDiskDirForVM(vm0);
            dir.mkdirs();
            dsf.setDiskDirs(new File[] { dir });
            dsf.setMaxOplogSize(1);
            dsf.setAutoCompact(false);
            dsf.setAllowForceCompaction(true);
            dsf.setCompactionThreshold(20);
            DiskStore ds = dsf.create(REGION_NAME);
            RegionFactory rf = new RegionFactory();
            rf.setDiskStoreName(ds.getName());
            rf.setDiskSynchronous(true);
            rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
            rf.setScope(Scope.DISTRIBUTED_ACK);
            rf.create(REGION_NAME);
        }
    };
    vm0.invoke(createRegion);
    return createRegion;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) RegionFactory(org.apache.geode.cache.RegionFactory) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Cache(org.apache.geode.cache.Cache)

Example 45 with DiskStoreFactory

use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.

the class RollingUpgrade2DUnitTest method createPersistentReplicateRegion.

public static void createPersistentReplicateRegion(GemFireCache cache, String regionName, File diskStore) throws Exception {
    DiskStore store = cache.findDiskStore("store");
    if (store == null) {
        DiskStoreFactory factory = cache.createDiskStoreFactory();
        factory.setMaxOplogSize(1L);
        factory.setDiskDirs(new File[] { diskStore.getAbsoluteFile() });
        factory.create("store");
    }
    RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory();
    rf.setDiskStoreName("store");
    rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
    rf.create(regionName);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) RegionFactory(org.apache.geode.cache.RegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Aggregations

DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)132 File (java.io.File)95 DiskStore (org.apache.geode.cache.DiskStore)91 Test (org.junit.Test)86 AttributesFactory (org.apache.geode.cache.AttributesFactory)56 Region (org.apache.geode.cache.Region)46 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)46 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)35 Cache (org.apache.geode.cache.Cache)32 LocalRegion (org.apache.geode.internal.cache.LocalRegion)24 RegionFactory (org.apache.geode.cache.RegionFactory)22 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)21 DiskRegion (org.apache.geode.internal.cache.DiskRegion)19 Properties (java.util.Properties)18 VM (org.apache.geode.test.dunit.VM)18 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)16 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)12 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)11 IOException (java.io.IOException)10 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)10