/** * {@inheritDoc} */ public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) { return new DefaultSizeOfEngine(this, maxDepth, abortWhenMaxDepthExceeded); }
/** * {@inheritDoc} */ @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); }
/** * {@inheritDoc} */ public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) { return new DefaultSizeOfEngine(this, maxDepth, abortWhenMaxDepthExceeded); }
/** * {@inheritDoc} */ public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) { return new DefaultSizeOfEngine(this, maxDepth, abortWhenMaxDepthExceeded); }
/** * {@inheritDoc} */ public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) { return new DefaultSizeOfEngine(this, maxDepth, abortWhenMaxDepthExceeded); }
/** * {@inheritDoc} */ @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); }
/** * {@inheritDoc} */ @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); }
/** * Measures the size of the memory store by using the sizeof engine. * <p/> * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * * @return the size, in bytes */ public final synchronized long getSizeInBytes() throws CacheException { DefaultSizeOfEngine defaultSizeOfEngine = new DefaultSizeOfEngine( SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT) ); long sizeInBytes = 0; for (Object o : map.entrySet()) { Map.Entry entry = (Map.Entry)o; Element element = (Element) entry.getValue(); if (element != null) { Size size = defaultSizeOfEngine.sizeOf(entry.getKey(), element, null); sizeInBytes += size.getCalculated(); } } return sizeInBytes; }
sizeOfPolicyConfiguration = getConfiguration().getSizeOfPolicyConfiguration(); return new DefaultSizeOfEngine( sizeOfPolicyConfiguration.getMaxDepth(), sizeOfPolicyConfiguration.getMaxDepthExceededBehavior().isAbort());
/** * {@inheritDoc} */ public long getInMemorySizeInBytes() { if (poolAccessor.getSize() < 0) { DefaultSizeOfEngine defaultSizeOfEngine = new DefaultSizeOfEngine( SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT) ); long sizeInBytes = 0; for (Object o : map.values()) { Element element = (Element)o; if (element != null) { Size size = defaultSizeOfEngine.sizeOf(element.getObjectKey(), element, map.storedObject(element)); sizeInBytes += size.getCalculated(); } } return sizeInBytes; } return poolAccessor.getSize(); }