/** * Updates the object security expansion rate. */ @PropertyUpdate(properties = { "buffer.minObjectExpansionRate", "buffer.maxObjectExpansionRate", "buffer.maxObjectExpansionRateActiveTillBufferSize", "buffer.minObjectExpansionRateActiveFromBufferSize", "buffer.maxObjectExpansionRateActiveFromOccupancy", "buffer.minObjectExpansionRateActiveTillOccupancy" }) protected void updateObjectSecurityExpansionRate() { this.objectSizes.setObjectSecurityExpansionRate(bufferProperties.getObjectSecurityExpansionRate(maxSize.get())); }
/** * General Parameterized test to assure that no matter how big buffer size is, expansion rate * will be between min and max related. * * @param bufferSize * Buffer size. */ @Test(dataProvider = "Buffer-Size-Provider") public void parametrizedExpansionRateTest(long bufferSize) { float expansionRate = bufferProperties.getObjectSecurityExpansionRate(bufferSize); assertThat(expansionRate, is(lessThanOrEqualTo(bufferProperties.getMaxObjectExpansionRate()))); assertThat(expansionRate, is(greaterThanOrEqualTo(bufferProperties.getMinObjectExpansionRate()))); float relatedToSize = bufferProperties.getObjectSecurityExpansionRateBufferSize(bufferSize); float relatedToOccupancy = bufferProperties.getObjectSecurityExpansionRateBufferOccupancy(bufferSize, bufferProperties.getOldGenMax()); assertThat(expansionRate, is(equalTo((relatedToSize + relatedToOccupancy) / 2))); }
/** * Updates the buffer size and to it related properties. */ @PropertyUpdate(properties = { "buffer.minOldSpaceOccupancy", "buffer.maxOldSpaceOccupancy", "buffer.minOldSpaceOccupancyActiveTillOldGenSize", "buffer.maxOldSpaceOccupancyActiveFromOldGenSize" }) protected void updateBufferSizeAndRelated() { this.maxSize.set(bufferProperties.getInitialBufferSize()); this.objectSizes.setObjectSecurityExpansionRate(bufferProperties.getObjectSecurityExpansionRate(maxSize.get())); this.flagsSetOnBytes = bufferProperties.getFlagsSetOnBytes(this.maxSize.get()); }
/** * 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) + "%"); } }
@Test public void increaseExpansionRate() throws Exception { long bufferSize = bufferProperties.getInitialBufferSize(); Configuration configuration = propertyManager.getConfiguration(); SingleProperty<Float> maxExpansionRate = configuration.forLogicalName("buffer.maxObjectExpansionRate"); float oldExpansionrate = bufferProperties.getObjectSecurityExpansionRate(bufferSize); ConfigurationUpdate configurationUpdate = new ConfigurationUpdate(); configurationUpdate.addPropertyUpdate(maxExpansionRate.createAndValidatePropertyUpdate(Float.valueOf(maxExpansionRate.getValue().floatValue() + 0.1f))); propertyManager.updateConfiguration(configurationUpdate, false); float newExpansionrate = bufferProperties.getObjectSecurityExpansionRate(bufferSize); assertThat(newExpansionrate, is(greaterThan(oldExpansionrate))); }