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);
}
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()));
}
}
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) {
}
}
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) {
}
}
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);
}
Aggregations