Package com.codahale.metrics.WeightedSnapshot

Examples of com.codahale.metrics.WeightedSnapshot.WeightedSample


    public void update(long value, long timestamp) {
        rescaleIfNeeded();
        lockForRegularUsage();
        try {
            final double itemWeight = weight(timestamp - startTime);
            final WeightedSample sample = new WeightedSample(value, itemWeight);
            final double priority = itemWeight / ThreadLocalRandom.current().nextDouble();
           
            final long newCount = count.incrementAndGet();
            if (newCount <= size) {
                values.put(priority, sample);
View Full Code Here


                this.startTime = currentTimeInSeconds();
                final double scalingFactor = exp(-alpha * (startTime - oldStartTime));

                final ArrayList<Double> keys = new ArrayList<Double>(values.keySet());
                for (Double key : keys) {
                    final WeightedSample sample = values.remove(key);
                    final WeightedSample newSample = new WeightedSample(sample.value, sample.weight * scalingFactor);
                    values.put(key * scalingFactor, newSample);
                }

                // make sure the counter is in sync with the number of stored samples.
                count.set(values.size());
View Full Code Here

TOP

Related Classes of com.codahale.metrics.WeightedSnapshot.WeightedSample

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.