use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskStoreFactoryJUnitTest method testTimeInterval.
@Test
public void testTimeInterval() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
String name = "testTimeInterval";
DiskStore ds = dsf.setTimeInterval(0).create(name);
assertEquals(0, ds.getTimeInterval());
name = "testTimeInterval2";
ds = dsf.setTimeInterval(Long.MAX_VALUE).create(name);
assertEquals(Long.MAX_VALUE, ds.getTimeInterval());
// check illegal stuff
try {
dsf.setTimeInterval(-1);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskStoreFactoryJUnitTest method testRedefiningDefaultDiskStore.
@Test
public void testRedefiningDefaultDiskStore() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(!DiskStoreFactory.DEFAULT_AUTO_COMPACT);
String name = "testMissingDrfFile";
assertEquals(null, cache.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME));
DiskStore diskStore = dsf.create(DiskStoreFactory.DEFAULT_DISK_STORE_NAME);
AttributesFactory af = new AttributesFactory();
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
Region r = cache.createRegion("r", af.create());
r.put("key", "value");
DiskStore ds = ((LocalRegion) r).getDiskStore();
assertEquals(ds, cache.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME));
assertEquals(DiskStoreFactory.DEFAULT_DISK_STORE_NAME, ds.getName());
assertEquals(!DiskStoreFactory.DEFAULT_AUTO_COMPACT, ds.getAutoCompact());
cache.close();
// if test passed clean up files
removeFiles(diskStore);
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskStoreFactoryJUnitTest method testDestroyWithPersistentRegion.
@Test
public void testDestroyWithPersistentRegion() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
String name = "testDestroy";
DiskStore ds = dsf.create(name);
Region region = cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("testDestroy").create("region");
try {
ds.destroy();
fail("Should have thrown an exception");
} catch (IllegalStateException expected) {
// expected
}
region.destroyRegion();
// This should now work
ds.destroy();
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskStoreFactoryJUnitTest method testCompactionThreshold.
@Test
public void testCompactionThreshold() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
String name = "testCompactionThreshold1";
DiskStore ds = dsf.setCompactionThreshold(0).create(name);
assertEquals(0, ds.getCompactionThreshold());
name = "testCompactionThreshold2";
ds = dsf.setCompactionThreshold(100).create(name);
assertEquals(100, ds.getCompactionThreshold());
// check illegal stuff
try {
dsf.setCompactionThreshold(-1);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
try {
dsf.setCompactionThreshold(101);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskStoreFactoryJUnitTest method testMissingDrfFile.
@Test
public void testMissingDrfFile() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
String name = "testMissingDrfFile";
DiskStore diskStore = dsf.create(name);
File drfFile = new File(diskStore.getDiskDirs()[0], "BACKUP" + name + "_1.drf");
AttributesFactory af = new AttributesFactory();
af.setDiskStoreName(name);
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
Region r = cache.createRegion("r", af.create());
r.put("key", "value");
assertTrue(drfFile.exists());
cache.close();
assertTrue(drfFile.exists());
assertTrue(drfFile.delete());
assertFalse(drfFile.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);
}
Aggregations