Search in sources :

Example 11 with DiskRegionStats

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());
}
Also used : DiskRegionStats(org.apache.geode.internal.cache.DiskRegionStats) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) DiskRegion(org.apache.geode.internal.cache.DiskRegion) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics) DiskRegion(org.apache.geode.internal.cache.DiskRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) File(java.io.File) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 12 with DiskRegionStats

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;
}
Also used : DiskRegionStats(org.apache.geode.internal.cache.DiskRegionStats) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Example 13 with DiskRegionStats

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;
}
Also used : DiskRegionStats(org.apache.geode.internal.cache.DiskRegionStats) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Aggregations

DiskRegionStats (org.apache.geode.internal.cache.DiskRegionStats)13 LocalRegion (org.apache.geode.internal.cache.LocalRegion)9 AttributesFactory (org.apache.geode.cache.AttributesFactory)8 DiskRegion (org.apache.geode.internal.cache.DiskRegion)8 File (java.io.File)7 DiskStore (org.apache.geode.cache.DiskStore)7 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)7 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)7 Region (org.apache.geode.cache.Region)6 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 Test (org.junit.Test)6 Cache (org.apache.geode.cache.Cache)3 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)3 ObjectSizer (org.apache.geode.cache.util.ObjectSizer)2 DistributedSystem (org.apache.geode.distributed.DistributedSystem)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 CacheListenerAdapter (org.apache.geode.cache.util.CacheListenerAdapter)1 CachePerfStats (org.apache.geode.internal.cache.CachePerfStats)1