cumulativeSum.addBucket(lastBucket);
cumulativeSum.addBucket(lastBucket);
/** * Get the cumulative sum of all buckets ever since the JVM started without rolling for the given {@link HystrixRollingNumberEvent} type. * <p> * See {@link #getRollingSum(HystrixRollingNumberEvent)} for the rolling sum. * <p> * The {@link HystrixRollingNumberEvent} must be a "counter" type <code>HystrixRollingNumberEvent.isCounter() == true</code>. * * @param type HystrixRollingNumberEvent defining which counter to retrieve values from * @return cumulative sum of all increments and adds for the given {@link HystrixRollingNumberEvent} counter type */ public long getCumulativeSum(HystrixRollingNumberEvent type) { // this isn't 100% atomic since multiple threads can be affecting latestBucket & cumulativeSum independently // but that's okay since the count is always a moving target and we're accepting a "point in time" best attempt // we are however putting 'getValueOfLatestBucket' first since it can have side-affects on cumulativeSum whereas the inverse is not true return getValueOfLatestBucket(type) + cumulativeSum.get(type); }
/** * Force a reset of all rolling counters (clear all buckets) so that statistics start being gathered from scratch. * <p> * This does NOT reset the CumulativeSum values. */ public void reset() { // if we are resetting, that means the lastBucket won't have a chance to be captured in CumulativeSum, so let's do it here Bucket lastBucket = buckets.peekLast(); if (lastBucket != null) { cumulativeSum.addBucket(lastBucket); } // clear buckets so we start over again buckets.clear(); }
public void addBucket(Bucket lastBucket) { for (HystrixRollingNumberEvent type : HystrixRollingNumberEvent.values()) { if (type.isCounter()) { getAdder(type).add(lastBucket.getAdder(type).sum()); } if (type.isMaxUpdater()) { getMaxUpdater(type).update(lastBucket.getMaxUpdater(type).max()); } } }
/** * Get the cumulative sum of all buckets ever since the JVM started without rolling for the given {@link HystrixRollingNumberEvent} type. * <p> * See {@link #getRollingSum(HystrixRollingNumberEvent)} for the rolling sum. * <p> * The {@link HystrixRollingNumberEvent} must be a "counter" type <code>HystrixRollingNumberEvent.isCounter() == true</code>. * * @param type HystrixRollingNumberEvent defining which counter to retrieve values from * @return cumulative sum of all increments and adds for the given {@link HystrixRollingNumberEvent} counter type */ public long getCumulativeSum(HystrixRollingNumberEvent type) { // this isn't 100% atomic since multiple threads can be affecting latestBucket & cumulativeSum independently // but that's okay since the count is always a moving target and we're accepting a "point in time" best attempt // we are however putting 'getValueOfLatestBucket' first since it can have side-affects on cumulativeSum whereas the inverse is not true return getValueOfLatestBucket(type) + cumulativeSum.get(type); }
/** * Force a reset of all rolling counters (clear all buckets) so that statistics start being gathered from scratch. * <p> * This does NOT reset the CumulativeSum values. */ public void reset() { // if we are resetting, that means the lastBucket won't have a chance to be captured in CumulativeSum, so let's do it here Bucket lastBucket = buckets.peekLast(); if (lastBucket != null) { cumulativeSum.addBucket(lastBucket); } // clear buckets so we start over again buckets.clear(); }
public void addBucket(Bucket lastBucket) { for (HystrixRollingNumberEvent type : HystrixRollingNumberEvent.values()) { if (type.isCounter()) { getAdder(type).add(lastBucket.getAdder(type).sum()); } if (type.isMaxUpdater()) { getMaxUpdater(type).update(lastBucket.getMaxUpdater(type).max()); } } }