public int getOffHeapObjects() { int objects = 0; OffHeapMemoryStats stats = getOffHeapStats(); if(null != stats) { objects = stats.getObjects(); } return objects; }
public int getOffHeapObjects() { int objects = 0; OffHeapMemoryStats stats = getOffHeapStats(); if(null != stats) { objects = stats.getObjects(); } return objects; }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); region.destroy(key, arg); assertEquals(1, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(1, ma.getStats().getObjects()); } } });
long numObjectsInOffHeapMemory = getOffHeapMemoryStats().getObjects(); int retryCount = 0; while (numObjectsInOffHeapMemory != 0 && retryCount < 31) { DistributedTestBase.sleepForMs(2000); retryCount++; numObjectsInOffHeapMemory = getOffHeapMemoryStats().getObjects();
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); region.put(key, newValue, arg); assertEquals(2, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(2, ma.getStats().getObjects()); } } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); assertEquals(1, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(1, ma.getStats().getObjects()); } region.destroyRegion(arg); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(0, ma.getStats().getObjects()); } } });
private void logOffHeapState(int chunkSize) { if (InternalDistributedSystem.getAnyInstance() != null) { LogWriter lw = InternalDistributedSystem.getAnyInstance().getLogWriter(); lw.info("OutOfOffHeapMemory allocating size of " + chunkSize + ". allocated=" + this.allocatedSize.get() + " compactions=" + this.compactCount.get() + " objects=" + stats.getObjects() + " free=" + stats.getFreeMemory() + " fragments=" + stats.getFragments() + " largestFragment=" + stats.getLargestFragment() + " fragmentation=" + stats.getFragmentation()); logFragmentState(lw); logTinyState(lw); // logBigState(lw); logHugeState(lw); } }
private void logOffHeapState(int chunkSize) { if (InternalDistributedSystem.getAnyInstance() != null) { LogWriter lw = InternalDistributedSystem.getAnyInstance().getLogWriter(); lw.info("OutOfOffHeapMemory allocating size of " + chunkSize + ". allocated=" + this.allocatedSize.get() + " compactions=" + this.compactCount.get() + " objects=" + this.ma.stats.getObjects() + " free=" + this.ma.stats.getFreeMemory() + " fragments=" + this.ma.stats.getFragments() + " largestFragment=" + this.ma.stats.getLargestFragment() + " fragmentation=" + this.ma.stats.getFragmentation()); logFragmentState(lw); logTinyState(lw); logHugeState(lw); } }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); try { region.put(key, oldValue, exception); fail("Should have thrown a CacheWriterException"); } catch (CacheWriterException ex) { assertNull(region.getEntry(key)); assertEquals(1, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(1, ma.getStats().getObjects()); } } } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); try { region.destroy(key, exception); fail("Should have thrown a CacheWriterException"); } catch (CacheWriterException ex) { assertNotNull(region.getEntry(key)); assertEquals(2, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(2, ma.getStats().getObjects()); } } } });
@Override public void beforeClose(SimpleMemoryAllocatorImpl allocator) { Log.getLogWriter().info("In " + this.getClass().getName() + ".beforeClose (of SimpleMemoryAllocator)"); if (OffHeapHelper.isOffHeapMemoryConfigured()) { int objectsStat = OffHeapHelper.getOffHeapMemoryStats().getObjects(); if (objectsStat != 0) { // wait for off-heap to drain after closing cache OffHeapHelper.waitForOffHeapSilence(30); // off-heap can only be draining, off-heap memory allocator is about to be closed, no incoming messages } try { OffHeapHelper.verifyOffHeapMemoryConsistencyOnce(); } catch (TestException e) { // log the error and write it to the blackboard synchronized (this.getClass()) { String errStr = this.getClass().getName() + " logged this exception in vmId " + myVmId + " (pid " + myPid + ") at " + new Date() + ": " + e.getMessage(); Log.getLogWriter().info(errStr); List aList = (List) OffHeapMemoryLifecycleBB.getBB().getSharedMap().get(OffHeapMemoryLifecycleBB.errorKey); if (aList == null) { aList = new ArrayList(); } aList.add(errStr); OffHeapMemoryLifecycleBB.getBB().getSharedMap().put(OffHeapMemoryLifecycleBB.errorKey, aList); } } } else { Log.getLogWriter().info("No off-heap memory in this member"); } }
long startObjectsStat = getOffHeapMemoryStats().getObjects(); final long msOfSilence = secondsOfSilence * 1000; Log.getLogWriter().info("Waiting for off-heap memory to be silent for " + secondsOfSilence + " seconds, current objects stat is " + startObjectsStat); long currentObjectsStat = getOffHeapMemoryStats().getObjects(); if (currentObjectsStat == startObjectsStat) { // stat is unchanged; see if we waited long enough long currentTime = System.currentTimeMillis();
public void run2() throws CacheException { Region region = createRegion(name); // Put key2 in the region before any callbacks are // registered, so it can be destroyed later region.put(key2, value2); assertEquals(1, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); LocalRegion reRegion; reRegion = (LocalRegion) region; RegionEntry re = reRegion.getRegionEntry(key2); MemoryChunkWithRefCount mc = (MemoryChunkWithRefCount) re._getValue(); assertEquals(1, mc.getRefCount()); assertEquals(1, ma.getStats().getObjects()); } } };
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); region.put(key, oldValue, arg); assertEquals(2, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(2, ma.getStats().getObjects()); LocalRegion reRegion; reRegion = (LocalRegion) region; MemoryChunkWithRefCount mc = (MemoryChunkWithRefCount) reRegion.getRegionEntry(key)._getValue(); assertEquals(1, mc.getRefCount()); } } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); try { region.destroyRegion(exception); fail("Should have thrown a CacheWriterException"); } catch (CacheWriterException ex) { if (region.isDestroyed()) { fail("should not have an exception if region is destroyed", ex); } assertEquals(1, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(1, ma.getStats().getObjects()); } } } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); try { region.put(key, newValue, exception); fail("Should have thrown a CacheWriterException"); } catch (CacheWriterException ex) { Region.Entry entry = region.getEntry(key); assertEquals(oldValue, entry.getValue()); assertEquals(2, region.size()); if (region.getAttributes().getEnableOffHeapMemory() && !(region instanceof PartitionedRegion)) { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore(); assertEquals(2, ma.getStats().getObjects()); LocalRegion reRegion; reRegion = (LocalRegion) region; MemoryChunkWithRefCount mc = (MemoryChunkWithRefCount) reRegion.getRegionEntry(key)._getValue(); assertEquals(1, mc.getRefCount()); } } } });
return; long startObjectsStat = getOffHeapMemoryStats().getObjects(); final long msOfSilence = secondsOfSilence * 1000; Log.getLogWriter().info("Waiting for off-heap memory to be silent for " + secondsOfSilence + " seconds across the system, current objects stat for this member is " + startObjectsStat); long currentObjectsStat = getOffHeapMemoryStats().getObjects(); if (currentObjectsStat == startObjectsStat) { // stat is unchanged; see if we waited long enough long lastChangeTime = MemScaleBB.getBB().getSharedCounters().read(MemScaleBB.lastOffHeapChangeTime);
long numObjectsInOffHeapMemory = getOffHeapMemoryStats().getObjects(); int retryCount = 0; while (numObjectsInOffHeapMemory != 0 && retryCount < 31) { MasterController.sleepForMs(2000); retryCount++; numObjectsInOffHeapMemory = getOffHeapMemoryStats().getObjects();
@Override public void initialize(OffHeapMemoryStats oldStats) { setFreeMemory(oldStats.getFreeMemory()); setMaxMemory(oldStats.getMaxMemory()); setUsedMemory(oldStats.getUsedMemory()); setObjects(oldStats.getObjects()); setReads(oldStats.getReads()); setCompactions(oldStats.getCompactions()); setFragments(oldStats.getFragments()); setLargestFragment(oldStats.getLargestFragment()); setCompactionTime(oldStats.getCompactionTime()); setFragmentation(oldStats.getFragmentation()); oldStats.close(); }
@Override public void initialize(OffHeapMemoryStats oldStats) { setFreeMemory(oldStats.getFreeMemory()); setMaxMemory(oldStats.getMaxMemory()); setUsedMemory(oldStats.getUsedMemory()); setObjects(oldStats.getObjects()); setReads(oldStats.getReads()); setCompactions(oldStats.getCompactions()); setFragments(oldStats.getFragments()); setLargestFragment(oldStats.getLargestFragment()); setCompactionTime(oldStats.getCompactionTime()); setFragmentation(oldStats.getFragmentation()); oldStats.close(); }