use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskManagementDUnitTest method createPersistentRegionAsync.
private AsyncInvocation createPersistentRegionAsync(final VM memberVM) {
return memberVM.invokeAsync("createPersistentRegionAsync", () -> {
File dir = new File(diskDir, String.valueOf(ProcessUtils.identifyPid()));
Cache cache = this.managementTestRule.getCache();
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] { dir });
diskStoreFactory.setMaxOplogSize(1);
diskStoreFactory.setAllowForceCompaction(true);
diskStoreFactory.setAutoCompact(false);
DiskStore diskStore = diskStoreFactory.create(REGION_NAME);
RegionFactory regionFactory = cache.createRegionFactory();
regionFactory.setDiskStoreName(diskStore.getName());
regionFactory.setDiskSynchronous(true);
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
regionFactory.create(REGION_NAME);
});
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskManagementDUnitTest method invokeForceCompaction.
/**
* Invokes force compaction on disk store by MBean interface
*/
private void invokeForceCompaction(final VM memberVM) {
memberVM.invoke("invokeForceCompaction", () -> {
Cache cache = this.managementTestRule.getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAllowForceCompaction(true);
String name = "testForceCompaction_" + ProcessUtils.identifyPid();
DiskStore diskStore = dsf.create(name);
ManagementService service = this.managementTestRule.getManagementService();
DiskStoreMXBean diskStoreMXBean = service.getLocalDiskStoreMBean(name);
assertThat(diskStoreMXBean).isNotNull();
assertThat(diskStoreMXBean.getName()).isEqualTo(diskStore.getName());
assertThat(diskStoreMXBean.forceCompaction()).isFalse();
});
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class DiskManagementDUnitTest method invokeForceRoll.
/**
* Invokes force roll on disk store by MBean interface
*/
private void invokeForceRoll(final VM memberVM) {
memberVM.invoke("invokeForceRoll", () -> {
Cache cache = this.managementTestRule.getCache();
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
String name = "testForceRoll_" + ProcessUtils.identifyPid();
DiskStore diskStore = diskStoreFactory.create(name);
ManagementService service = this.managementTestRule.getManagementService();
DiskStoreMXBean diskStoreMXBean = service.getLocalDiskStoreMBean(name);
assertThat(diskStoreMXBean).isNotNull();
assertThat(diskStoreMXBean.getName()).isEqualTo(diskStore.getName());
diskStoreMXBean.forceRoll();
});
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class IndexCommandsDUnitTest method createRepRegWithPersistence.
private Region<?, ?> createRepRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
Cache cache = getCache();
File diskStoreDirFile = new File(diskDirName);
diskStoreDirFile.deleteOnExit();
if (!diskStoreDirFile.exists()) {
diskStoreDirFile.mkdirs();
}
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile });
diskStoreFactory.setMaxOplogSize(1);
diskStoreFactory.setAllowForceCompaction(true);
diskStoreFactory.setAutoCompact(false);
diskStoreFactory.create(diskStoreName);
/****
* Eviction Attributes
*/
EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
RegionFactory regionFactory = cache.createRegionFactory();
regionFactory.setDiskStoreName(diskStoreName);
regionFactory.setDiskSynchronous(true);
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
regionFactory.setEvictionAttributes(ea);
return regionFactory.create(regionName);
}
use of org.apache.geode.cache.DiskStoreFactory in project geode by apache.
the class PdxSerializableJUnitTest method testPdxPersistentKeys.
// for bugs 44271 and 44914
@Test
public void testPdxPersistentKeys() throws Exception {
this.c.close();
this.c = (GemFireCacheImpl) new CacheFactory().set(MCAST_PORT, "0").setPdxPersistent(true).setPdxDiskStore("pdxDS").create();
try {
DiskStoreFactory dsf = this.c.createDiskStoreFactory();
dsf.create("pdxDS");
this.c.createDiskStoreFactory().create("r2DS");
Region r1 = this.c.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).create("r1");
r1.put(new SimpleClass(1, (byte) 1), "1");
r1.put(new SimpleClass(2, (byte) 2), "2");
// so we have something to compact offline
r1.put(new SimpleClass(1, (byte) 1), "1.2");
Region r2 = this.c.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("r2DS").create("r2");
r2.put(new SimpleClass(1, (byte) 1), new SimpleClass(1, (byte) 1));
r2.put(new SimpleClass(2, (byte) 2), new SimpleClass(2, (byte) 2));
this.c.close();
this.c = (GemFireCacheImpl) new CacheFactory().set(MCAST_PORT, "0").setPdxPersistent(true).setPdxDiskStore("pdxDS").create();
dsf = this.c.createDiskStoreFactory();
dsf.create("pdxDS");
this.c.createDiskStoreFactory().create("r2DS");
r1 = this.c.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).create("r1");
r2 = this.c.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("r2DS").create("r2");
assertEquals(true, r1.containsKey(new SimpleClass(1, (byte) 1)));
assertEquals(true, r1.containsKey(new SimpleClass(2, (byte) 2)));
assertEquals(true, r2.containsKey(new SimpleClass(1, (byte) 1)));
assertEquals(true, r2.containsKey(new SimpleClass(2, (byte) 2)));
assertEquals(new SimpleClass(1, (byte) 1), r2.get(new SimpleClass(1, (byte) 1)));
assertEquals(new SimpleClass(2, (byte) 2), r2.get(new SimpleClass(2, (byte) 2)));
this.c.close();
// use a cache.xml to recover
this.c = (GemFireCacheImpl) new CacheFactory().set(MCAST_PORT, "0").create();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos), true);
pw.println("<?xml version=\"1.0\"?>");
pw.println("<!DOCTYPE cache PUBLIC");
pw.println(" \"-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN\"");
pw.println(" \"http://www.gemstone.com/dtd/cache7_0.dtd\">");
pw.println("<cache>");
pw.println(" <disk-store name=\"r2DS\"/>");
pw.println(" <disk-store name=\"pdxDS\"/>");
pw.println(" <pdx persistent=\"true\" disk-store-name=\"pdxDS\"/>");
pw.println(" <region name=\"r1\" refid=\"LOCAL_PERSISTENT\"/>");
pw.println(" <region name=\"r2\" refid=\"LOCAL_PERSISTENT\">");
pw.println(" <region-attributes disk-store-name=\"r2DS\"/>");
pw.println(" </region>");
pw.println("</cache>");
pw.close();
byte[] bytes = baos.toByteArray();
this.c.loadCacheXml(new ByteArrayInputStream(bytes));
r1 = this.c.getRegion("/r1");
r2 = this.c.getRegion("/r2");
assertEquals(true, r1.containsKey(new SimpleClass(1, (byte) 1)));
assertEquals(true, r1.containsKey(new SimpleClass(2, (byte) 2)));
assertEquals(true, r2.containsKey(new SimpleClass(1, (byte) 1)));
assertEquals(true, r2.containsKey(new SimpleClass(2, (byte) 2)));
assertEquals(new SimpleClass(1, (byte) 1), r2.get(new SimpleClass(1, (byte) 1)));
assertEquals(new SimpleClass(2, (byte) 2), r2.get(new SimpleClass(2, (byte) 2)));
this.c.close();
// make sure offlines tools work with disk store that has pdx keys
SystemAdmin.validateDiskStore("DEFAULT", ".");
SystemAdmin.compactDiskStore("DEFAULT", ".");
SystemAdmin.modifyDiskStore("DEFAULT", ".");
SystemAdmin.validateDiskStore("r2DS", ".");
SystemAdmin.compactDiskStore("r2DS", ".");
SystemAdmin.modifyDiskStore("r2DS", ".");
SystemAdmin.validateDiskStore("pdxDS", ".");
SystemAdmin.compactDiskStore("pdxDS", ".");
SystemAdmin.modifyDiskStore("pdxDS", ".");
} finally {
try {
this.c.close();
} finally {
Pattern pattern = Pattern.compile("BACKUP(DEFAULT|pdxDS|r2DS).*");
File[] files = new File(".").listFiles((dir1, name) -> pattern.matcher(name).matches());
if (files != null) {
for (File file : files) {
Files.delete(file.toPath());
}
}
}
}
}
Aggregations