/** * Updates value of the {@link #evictionOccupancyPercentage}. */ @PropertyUpdate(properties = { "buffer.evictionOccupancyPercentage", "buffer.bytesMaintenancePercentage", }) protected void updateEvictionOccupancyPercentage() { this.evictionOccupancyPercentage.set(Float.floatToIntBits(bufferProperties.getEvictionOccupancyPercentage())); }
/** * Is executed after dependency injection is done to perform any initialization. * * @throws Exception * if an error occurs during {@link PostConstruct} */ @PostConstruct public void postConstruct() throws Exception { this.maxSize = new AtomicLong(bufferProperties.getInitialBufferSize()); this.evictionOccupancyPercentage = new AtomicInteger(Float.floatToIntBits(bufferProperties.getEvictionOccupancyPercentage())); this.objectSizes.setObjectSecurityExpansionRate(bufferProperties.getObjectSecurityExpansionRate(maxSize.get())); this.first = new AtomicReference<IBufferElement<E>>(emptyBufferElement); this.last = new AtomicReference<IBufferElement<E>>(emptyBufferElement); this.lastAnalyzed = new AtomicReference<IBufferElement<E>>(emptyBufferElement); this.lastIndexed = new AtomicReference<IBufferElement<E>>(emptyBufferElement); this.indexingTreeCleaningExecutorService = Executors.newFixedThreadPool(bufferProperties.getIndexingTreeCleaningThreads()); this.flagsSetOnBytes = bufferProperties.getFlagsSetOnBytes(this.maxSize.get()); // initialize processors this.analyzeProcessor = new AnalyzeBufferElementProcessor<>(this, lastAnalyzed, analyzeLock, nothingToAnalyze); this.indexProcessor = new IndexBufferElementProcessor<>(this, lastIndexed, indexingLock, nothingToIndex); if (log.isInfoEnabled()) { log.info("|-Using buffer with maximum size " + NumberFormat.getInstance().format(maxSize) + " bytes..."); log.info("|-Indexing tree maintenance on " + NumberFormat.getInstance().format(flagsSetOnBytes) + " bytes added/removed..."); log.info("|-Using object expansion rate of " + NumberFormat.getInstance().format(objectSizes.getObjectSecurityExpansionRate() * 100) + "%"); } }
if ((this.getBytesMaintenancePercentage() <= 0) && (this.getBytesMaintenancePercentage() > this.getEvictionOccupancyPercentage())) { throw new BeanInitializationException( "Buffer properties initialization error: The buffer bytes maintenance percentage that activate the clean and update of the indexing tree can not be less or equal than zero nor bigger that eviction occupancy percentage. Initialization value is: "
when(bufferProperties.getEvictionOccupancyPercentage()).thenReturn(0.1f); when(bufferProperties.getEvictionFragmentSizePercentage()).thenReturn(0.5f); buffer.postConstruct();
when(bufferProperties.getEvictionOccupancyPercentage()).thenReturn(0.99f); buffer.postConstruct();
when(bufferProperties.getEvictionOccupancyPercentage()).thenReturn(0.5f); when(bufferProperties.getEvictionFragmentSizePercentage()).thenReturn(0.35f); when(bufferProperties.getFlagsSetOnBytes(anyLong())).thenReturn(flagsSetOnBytes);