/** * {@inheritDoc} */ @Override public IObjectSizes getObject() throws Exception { boolean compressedOops = UnderlyingSystemInfo.IS_COMPRESSED_OOPS; if (!compressedOops) { return new ObjectSizes64Bits(); } else { return new ObjectSizes64BitsCompressedOops(); } }
/** * Returns object security expansion rate based on the property set and given buffer size. * * @param bufferSize * Buffer's size that expansion rate has to be calculated for. * @return Expansion rate in percentages. */ public float getObjectSecurityExpansionRate(long bufferSize) { return (getObjectSecurityExpansionRateBufferSize(bufferSize) + getObjectSecurityExpansionRateBufferOccupancy(bufferSize, getOldGenMax())) / 2; }
/** * {@inheritDoc} * <p> * This method is designed for multiply thread access. */ @Override public void analyzeNext() throws InterruptedException { analyzeProcessor.process(); }
/** * {@inheritDoc} * <p> * This method is thread safe. */ public boolean shouldEvict() { return getOccupancyPercentage() > Float.intBitsToFloat(evictionOccupancyPercentage.get()); }
/** * {@inheritDoc} */ @Override protected void processData(DefaultData defaultData, EntityManager entityManager) { buffer.put(new BufferElement<>((MethodSensorData) defaultData)); }
/** * {@inheritDoc} */ @Override @PostConstruct public synchronized void start() { super.start(); }
/** * Sets the current size of the buffer. * * @param currentSize * Size in bytes. */ public void setCurrentSize(long currentSize) { this.currentSize.set(currentSize); notifyEvictionIfNeeded(); }
/** * {@inheritDoc} * <p> * This method also performs the cleaning of the indexing tree if the cleaning flag is on. * <p> * This method is designed for multiply thread access. */ @Override public void indexNext() throws InterruptedException { indexProcessor.process(); }
/** * Default constructor. Just calls super class constructor. * * @param buffer * Buffer to work on. */ @Autowired public BufferIndexer(IBuffer<?> buffer) { super(buffer, "buffer-indexing-thread"); setPriority(NORM_PRIORITY); }
/** * {@inheritDoc} */ @Override public long getObjectSize(IObjectSizes objectSizes, boolean doAlign) { return getObjectSize(objectSizes); } }
/** * {@inheritDoc} */ @Override public long getObjectSize(IObjectSizes objectSizes, boolean doAlign) { return getObjectSize(objectSizes); } }
/** * {@inheritDoc} */ @Override public void work() throws InterruptedException { getBuffer().evict(); }
/** * {@inheritDoc} */ @Override public void work() throws InterruptedException { getBuffer().indexNext(); }
/** * {@inheritDoc} */ @Override public void work() throws InterruptedException { getBuffer().analyzeNext(); }
/** * Parameters generation for {@link #parametrizedExpansionRateTest(long)}. * * @return Buffer size. */ @DataProvider(name = "Buffer-Size-Provider") public Object[][] bufferSizeParameterProvider() { int size = 50; Object[][] parameters = new Object[size][1]; for (int i = 0; i < size; i++) { parameters[i][0] = getRandomLong(2000000000L); } return parameters; }
/** * Default constructor. Thread is set to be a daemon, to have highest priority and started. * * @param buffer * Buffer to work on. * @param threadName * How to name the thread. */ public BufferWorker(IBuffer<?> buffer, String threadName) { this.buffer = buffer; setName(threadName); setDaemon(true); setPriority(MAX_PRIORITY); }
/** * {@inheritDoc} */ @Override @PostConstruct public synchronized void start() { super.start(); }
/** * {@inheritDoc} * <p> * This method is thread safe. * <p> * Using this method does not provide any check for the supplied new maximum size. Thus, it is * responsibility of the user to assure that the given value is correct. */ @Override public void setMaxSize(long maxSize) { this.maxSize.set(maxSize); notifyEvictionIfNeeded(); }
/** * {@inheritDoc} */ @Override @PostConstruct public synchronized void start() { super.start(); }
/** * {@inheritDoc} * <p> * This method is thread safe. */ @Override public void setEvictionOccupancyPercentage(float evictionOccupancyPercentage) { this.evictionOccupancyPercentage.set(Float.floatToIntBits(evictionOccupancyPercentage)); notifyEvictionIfNeeded(); }