Skip to content

Commit

Permalink
Merge branch 'cassandra-2.2' into cassandra-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffjirsa committed Feb 12, 2017
2 parents 8ec6090 + 7e05f39 commit 51e3660
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535)
* Reenable HeapPool (CASSANDRA-12900)
Merged from 2.2:
* Fix negative mean latency metric (CASSANDRA-12876)
* Use only one file pointer when creating commitlog segments (CASSANDRA-12539)
* Fix speculative retry bugs (CASSANDRA-13009)
* Fix handling of nulls and unsets in IN conditions (CASSANDRA-12981)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,12 @@ private class EstimatedHistogramReservoirSnapshot extends Snapshot
public EstimatedHistogramReservoirSnapshot(DecayingEstimatedHistogramReservoir reservoir)
{
final int length = reservoir.decayingBuckets.length();
final double rescaleFactor = forwardDecayWeight(clock.getTime());

this.decayingBuckets = new long[length];

for (int i = 0; i < length; i++)
this.decayingBuckets[i] = reservoir.decayingBuckets.get(i);
this.decayingBuckets[i] = Math.round(reservoir.decayingBuckets.get(i) / rescaleFactor);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,32 @@ public void testDecayingPercentile()
}
}

@Test
public void testDecayingMean()
{
{
TestClock clock = new TestClock();

DecayingEstimatedHistogramReservoir histogram = new DecayingEstimatedHistogramReservoir(DecayingEstimatedHistogramReservoir.DEFAULT_ZERO_CONSIDERATION, DecayingEstimatedHistogramReservoir.DEFAULT_BUCKET_COUNT, clock);

clock.addMillis(DecayingEstimatedHistogramReservoir.LANDMARK_RESET_INTERVAL_IN_MS - 1_000L);

while (clock.getTime() < DecayingEstimatedHistogramReservoir.LANDMARK_RESET_INTERVAL_IN_MS + 1_000L)
{
clock.addMillis(900);
for (int i = 0; i < 1_000_000; i++)
{
histogram.update(1000);
histogram.update(2000);
histogram.update(3000);
histogram.update(4000);
histogram.update(5000);
}
assertEquals(3000D, histogram.getSnapshot().getMean(), 500D);
}
}
}

private void assertEstimatedQuantile(long expectedValue, double actualValue)
{
assertTrue("Expected at least [" + expectedValue + "] but actual is [" + actualValue + "]", actualValue >= expectedValue);
Expand All @@ -363,6 +389,11 @@ private void assertEstimatedQuantile(long expectedValue, double actualValue)
public class TestClock extends Clock {
private long tick = 0;

public void addMillis(long millis)
{
tick += millis * 1_000_000L;
}

public void addSeconds(long seconds)
{
tick += seconds * 1_000_000_000L;
Expand Down

0 comments on commit 51e3660

Please sign in to comment.