/** * 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 { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine( SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true ); 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; }
} else { this.poolAccessor = pool.createPoolAccessor(new Participant(), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT));
private DiskStore(DiskStorageFactory disk, Ehcache cache, Pool onHeapPool, Pool onDiskPool) { this.segments = new Segment[DEFAULT_SEGMENT_COUNT]; this.segmentShift = Integer.numberOfLeadingZeros(segments.length - 1); EventRateSimpleMovingAverage hitRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); EventRateSimpleMovingAverage missRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); OperationStatistic<GetOutcome> getStatistic = StatisticsManager.getOperationStatisticFor(getObserver); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.HIT), hitRate)); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.MISS), missRate)); this.onHeapPoolAccessor = onHeapPool.createPoolAccessor(new DiskStoreHeapPoolParticipant(hitRate, missRate), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)); this.onDiskPoolAccessor = onDiskPool.createPoolAccessor(new DiskStoreDiskPoolParticipant(hitRate, missRate), new DiskSizeOfEngine()); for (int i = 0; i < this.segments.length; ++i) { this.segments[i] = new Segment(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, disk, cache.getCacheConfiguration(), onHeapPoolAccessor, onDiskPoolAccessor, cache.getCacheEventNotificationService(), evictionObserver); } this.disk = disk; this.disk.bind(this); this.status.set(Status.STATUS_ALIVE); }
/** * {@inheritDoc} */ @Statistic(name = "size-in-bytes", tags = "local-heap") public long getInMemorySizeInBytes() { if (poolAccessor.getSize() < 0) { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine(SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true); 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(); }
SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)));
/** * 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; }
/** * 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 { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine( SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true ); 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; }
/** * 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 { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine( SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true ); 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; }
} else { this.poolAccessor = pool.createPoolAccessor(new Participant(), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT));
} else { this.poolAccessor = pool.createPoolAccessor(new Participant(), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT));
private DiskStore(DiskStorageFactory disk, Ehcache cache, Pool onHeapPool, Pool onDiskPool) { this.segments = new Segment[DEFAULT_SEGMENT_COUNT]; this.segmentShift = Integer.numberOfLeadingZeros(segments.length - 1); EventRateSimpleMovingAverage hitRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); EventRateSimpleMovingAverage missRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); OperationStatistic<GetOutcome> getStatistic = StatisticsManager.getOperationStatisticFor(getObserver); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.HIT), hitRate)); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.MISS), missRate)); this.onHeapPoolAccessor = onHeapPool.createPoolAccessor(new DiskStoreHeapPoolParticipant(hitRate, missRate), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)); this.onDiskPoolAccessor = onDiskPool.createPoolAccessor(new DiskStoreDiskPoolParticipant(hitRate, missRate), new DiskSizeOfEngine()); for (int i = 0; i < this.segments.length; ++i) { this.segments[i] = new Segment(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, disk, cache.getCacheConfiguration(), onHeapPoolAccessor, onDiskPoolAccessor, cache.getCacheEventNotificationService(), evictionObserver); } this.disk = disk; this.disk.bind(this); this.status.set(Status.STATUS_ALIVE); }
SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT));
private DiskStore(DiskStorageFactory disk, Ehcache cache, Pool onHeapPool, Pool onDiskPool) { this.segments = new Segment[DEFAULT_SEGMENT_COUNT]; this.segmentShift = Integer.numberOfLeadingZeros(segments.length - 1); EventRateSimpleMovingAverage hitRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); EventRateSimpleMovingAverage missRate = new EventRateSimpleMovingAverage(1, TimeUnit.SECONDS); OperationStatistic<GetOutcome> getStatistic = StatisticsManager.getOperationStatisticFor(getObserver); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.HIT), hitRate)); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.MISS), missRate)); this.onHeapPoolAccessor = onHeapPool.createPoolAccessor(new DiskStoreHeapPoolParticipant(hitRate, missRate), SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)); this.onDiskPoolAccessor = onDiskPool.createPoolAccessor(new DiskStoreDiskPoolParticipant(hitRate, missRate), new DiskSizeOfEngine()); for (int i = 0; i < this.segments.length; ++i) { this.segments[i] = new Segment(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, disk, cache.getCacheConfiguration(), onHeapPoolAccessor, onDiskPoolAccessor, cache.getCacheEventNotificationService(), evictionObserver); } this.disk = disk; this.disk.bind(this); this.status.set(Status.STATUS_ALIVE); }
private DiskStore(DiskStorageFactory disk, Ehcache cache, Pool onHeapPool, Pool onDiskPool) { this.segments = new Segment[DEFAULT_SEGMENT_COUNT]; this.segmentShift = Integer.numberOfLeadingZeros(segments.length - 1); this.onHeapPoolAccessor = onHeapPool.createPoolAccessor(this, SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache).equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)); this.onDiskPoolAccessor = onDiskPool.createPoolAccessor(this, new DiskSizeOfEngine()); for (int i = 0; i < this.segments.length; ++i) { this.segments[i] = new Segment(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, disk, cache.getCacheConfiguration(), onHeapPoolAccessor, onDiskPoolAccessor, cache.getCacheEventNotificationService()); } this.disk = disk; this.disk.bind(this); this.status.set(Status.STATUS_ALIVE); this.tierPinned = cache.getCacheConfiguration().getPinningConfiguration() != null && cache.getCacheConfiguration().getPinningConfiguration().getStore() == PinningConfiguration.Store.INCACHE; this.persistent = cache.getCacheConfiguration().isDiskPersistent(); }
/** * {@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(); }
/** * {@inheritDoc} */ @Statistic(name = "size-in-bytes", tags = "local-heap") public long getInMemorySizeInBytes() { if (poolAccessor.getSize() < 0) { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine(SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true); 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(); }
/** * {@inheritDoc} */ @Statistic(name = "size-in-bytes", tags = "local-heap") public long getInMemorySizeInBytes() { if (poolAccessor.getSize() < 0) { SizeOfEngine defaultSizeOfEngine = SizeOfEngineLoader.newSizeOfEngine(SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT), true); 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(); }
SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)));
SizeOfPolicyConfiguration.resolveMaxDepth(cache), SizeOfPolicyConfiguration.resolveBehavior(cache) .equals(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT)));