use of org.apache.geode.internal.cache.DiskRegionStats in project geode by apache.
the class DiskRegionDUnitTest method testDestroy.
/**
* Tests destroying entries in an overflow region
*/
@Test
public void testDestroy() throws Exception {
final String name = this.getUniqueName();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK));
File d = new File("DiskRegions" + OSProcess.getId());
d.mkdirs();
DiskStoreFactory dsf = getCache().createDiskStoreFactory();
dsf.setDiskDirs(new File[] { d });
factory.setDiskSynchronous(true);
DiskStore ds = dsf.create(name);
factory.setDiskStoreName(ds.getName());
Region region = createRegion(name, factory.create());
DiskRegion dr = ((LocalRegion) region).getDiskRegion();
DiskRegionStats diskStats = dr.getStats();
LRUStatistics lruStats = getLRUStats(region);
int total;
for (total = 0; lruStats.getEvictions() < 40; total++) {
region.put(new Integer(total), new byte[1000]);
}
assertEquals(0, diskStats.getRemoves());
long evictions = lruStats.getEvictions();
LogWriterUtils.getLogWriter().info("Destroying memory resident entries");
// Destroying each of these guys should have no effect on the disk
for (int i = total - 1; i >= evictions; i--) {
region.destroy(new Integer(i));
flush(region);
assertEquals(0, diskStats.getRemoves());
assertEquals(evictions, lruStats.getEvictions());
}
// long startRemoves = diskStats.getRemoves();
LogWriterUtils.getLogWriter().info("Destroying disk-resident entries. evictions=" + evictions);
// Destroying each of these guys should cause a removal from disk
for (int i = ((int) evictions) - 1; i >= 0; i--) {
region.destroy(new Integer(i));
flush(region);
assertEquals((evictions - i), diskStats.getRemoves());
}
assertEquals(evictions, lruStats.getEvictions());
LogWriterUtils.getLogWriter().info("keys remaining in region: " + region.keySet().size());
assertEquals(0, region.keySet().size());
}
use of org.apache.geode.internal.cache.DiskRegionStats in project geode by apache.
the class ParallelGatewaySenderQueue method getNumEntriesInVMTestOnly.
public long getNumEntriesInVMTestOnly() {
long numEntriesInVM = 0;
for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) {
DiskRegionStats diskStats = prQ.getDiskRegionStats();
if (diskStats == null) {
if (logger.isDebugEnabled()) {
logger.debug("{}: DiskRegionStats for shadow PR is null. Returning the numEntriesInVM as 0", this);
}
return 0;
}
if (logger.isDebugEnabled()) {
logger.debug("{}: DiskRegionStats for shadow PR is NOT null. Returning the numEntriesInVM obtained from DiskRegionStats", this);
}
numEntriesInVM += diskStats.getNumEntriesInVM();
}
return numEntriesInVM;
}
use of org.apache.geode.internal.cache.DiskRegionStats in project geode by apache.
the class ParallelGatewaySenderQueue method getNumEntriesOverflowOnDiskTestOnly.
public long getNumEntriesOverflowOnDiskTestOnly() {
long numEntriesOnDisk = 0;
for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) {
DiskRegionStats diskStats = prQ.getDiskRegionStats();
if (diskStats == null) {
if (logger.isDebugEnabled()) {
logger.debug("{}: DiskRegionStats for shadow PR is null. Returning the numEntriesOverflowOnDisk as 0", this);
}
return 0;
}
if (logger.isDebugEnabled()) {
logger.debug("{}: DiskRegionStats for shadow PR is NOT null. Returning the numEntriesOverflowOnDisk obtained from DiskRegionStats", this);
}
numEntriesOnDisk += diskStats.getNumOverflowOnDisk();
}
return numEntriesOnDisk;
}
Aggregations