Search in sources :

Example 36 with DiskStoreFactory

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

the class DiskRegionIllegalArguementsJUnitTest method testDiskDirs.

@Test
public void testDiskDirs() {
    File file1 = new File("file6");
    File file2 = new File("file7");
    File file3 = new File("file8");
    File file4 = new File("file9");
    File[] dirs = { file1, file2, file3, file4 };
    int[] ints = { 1, 2, 3, 4 };
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    try {
        dsf.setDiskDirsAndSizes(dirs, ints);
    // The disk store would create the disk store directories.
    // fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }
    int[] ints1 = { 1, 2, 3 };
    file1.mkdir();
    file2.mkdir();
    file3.mkdir();
    file4.mkdir();
    file1.deleteOnExit();
    file2.deleteOnExit();
    file3.deleteOnExit();
    file4.deleteOnExit();
    try {
        dsf.setDiskDirsAndSizes(dirs, ints1);
    // The disk store would create the disk store directories.
    // fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }
    dsf.setDiskDirsAndSizes(dirs, ints);
}
Also used : File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 37 with DiskStoreFactory

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

the class DiskStoreFactoryJUnitTest method testGetDefaultInstance.

/**
   * Test method for 'org.apache.geode.cache.DiskWriteAttributes.getDefaultInstance()'
   */
@Test
public void testGetDefaultInstance() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    String name = "testGetDefaultInstance";
    assertEquals(null, cache.findDiskStore(name));
    DiskStore ds = dsf.create(name);
    assertEquals(ds, cache.findDiskStore(name));
    assertEquals(name, ds.getName());
    assertEquals(DiskStoreFactory.DEFAULT_AUTO_COMPACT, ds.getAutoCompact());
    assertEquals(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD, ds.getCompactionThreshold());
    assertEquals(DiskStoreFactory.DEFAULT_ALLOW_FORCE_COMPACTION, ds.getAllowForceCompaction());
    assertEquals(DiskStoreFactory.DEFAULT_MAX_OPLOG_SIZE, ds.getMaxOplogSize());
    assertEquals(DiskStoreFactory.DEFAULT_TIME_INTERVAL, ds.getTimeInterval());
    assertEquals(DiskStoreFactory.DEFAULT_WRITE_BUFFER_SIZE, ds.getWriteBufferSize());
    assertEquals(DiskStoreFactory.DEFAULT_QUEUE_SIZE, ds.getQueueSize());
    if (!Arrays.equals(DiskStoreFactory.DEFAULT_DISK_DIRS, ds.getDiskDirs())) {
        fail("expected=" + Arrays.toString(DiskStoreFactory.DEFAULT_DISK_DIRS) + " had=" + Arrays.toString(ds.getDiskDirs()));
    }
    if (!Arrays.equals(DiskStoreFactory.DEFAULT_DISK_DIR_SIZES, ds.getDiskDirSizes())) {
        fail("expected=" + Arrays.toString(DiskStoreFactory.DEFAULT_DISK_DIR_SIZES) + " had=" + Arrays.toString(ds.getDiskDirSizes()));
    }
}
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 38 with DiskStoreFactory

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

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

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

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