Search in sources :

Example 46 with DiskStore

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

the class DiskStoreFactoryJUnitTest method testMaxOplogSize.

@Test
public void testMaxOplogSize() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testMaxOplogSize";
    DiskStore ds = dsf.setMaxOplogSize(0).create(name);
    assertEquals(0, ds.getMaxOplogSize());
    name = "testMaxOplogSize2";
    long max = Long.MAX_VALUE / (1024 * 1024);
    ds = dsf.setMaxOplogSize(max).create(name);
    assertEquals(max, ds.getMaxOplogSize());
    // check illegal stuff
    try {
        dsf.setMaxOplogSize(-1);
        fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
    }
    try {
        dsf.setMaxOplogSize(max + 1);
        fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
    }
}
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 47 with DiskStore

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

the class DiskStoreFactoryJUnitTest method testQueueSize.

@Test
public void testQueueSize() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testQueueSize";
    DiskStore ds = dsf.setQueueSize(0).create(name);
    assertEquals(0, ds.getQueueSize());
    name = "testQueueSize2";
    ds = dsf.setQueueSize(Integer.MAX_VALUE).create(name);
    assertEquals(Integer.MAX_VALUE, ds.getQueueSize());
    // check illegal stuff
    try {
        dsf.setQueueSize(-1);
        fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
    }
}
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 48 with DiskStore

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

the class DiskStoreFactoryJUnitTest method testMissingCrfFile.

@Test
public void testMissingCrfFile() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testMissingCrfFile";
    DiskStore diskStore = dsf.create(name);
    File crfFile = new File(diskStore.getDiskDirs()[0], "BACKUP" + name + "_1.crf");
    AttributesFactory af = new AttributesFactory();
    af.setDiskStoreName(name);
    af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
    Region r = cache.createRegion("r", af.create());
    r.put("key", "value");
    assertTrue(crfFile.exists());
    cache.close();
    assertTrue(crfFile.exists());
    assertTrue(crfFile.delete());
    assertFalse(crfFile.exists());
    cache = createCache();
    dsf = cache.createDiskStoreFactory();
    assertEquals(null, ((GemFireCacheImpl) cache).findDiskStore(name));
    try {
        dsf.create(name);
        fail("expected IllegalStateException");
    } catch (IllegalStateException expected) {
    }
    // if test passed clean up files
    removeFiles(diskStore);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) Region(org.apache.geode.cache.Region) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 49 with DiskStore

use of org.apache.geode.cache.DiskStore 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 50 with DiskStore

use of org.apache.geode.cache.DiskStore 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)

Aggregations

DiskStore (org.apache.geode.cache.DiskStore)190 Test (org.junit.Test)120 AttributesFactory (org.apache.geode.cache.AttributesFactory)91 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)91 File (java.io.File)79 Region (org.apache.geode.cache.Region)71 Cache (org.apache.geode.cache.Cache)61 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)54 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)46 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)44 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)39 LocalRegion (org.apache.geode.internal.cache.LocalRegion)32 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)31 VM (org.apache.geode.test.dunit.VM)28 DiskRegion (org.apache.geode.internal.cache.DiskRegion)24 Host (org.apache.geode.test.dunit.Host)23 Expectations (org.jmock.Expectations)23 InternalCache (org.apache.geode.internal.cache.InternalCache)21 UnitTest (org.apache.geode.test.junit.categories.UnitTest)21 IOException (java.io.IOException)20