Repository: cassandra
Updated Branches:
  refs/heads/trunk b1abcd048 -> 8c19fd638


undeprecate cache recentHitRate metrics

patch by Chris Burroughs; reviewed by benedict for CASSANDRA-6591


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8c19fd63
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8c19fd63
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8c19fd63

Branch: refs/heads/trunk
Commit: 8c19fd638da7d5525e85d0cce41aa86e02798108
Parents: b1abcd0
Author: Chris Burroughs <chris.burroughs+apa...@gmail.com>
Authored: Fri Jun 12 12:22:30 2015 +0100
Committer: Benedict Elliott Smith <bened...@apache.org>
Committed: Fri Jun 12 12:22:30 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../apache/cassandra/metrics/CacheMetrics.java  |  29 ++++-
 .../org/apache/cassandra/utils/DynamicList.java |   2 +-
 .../apache/cassandra/utils/FasterRandom.java    | 116 -------------------
 .../cassandra/stress/generate/FasterRandom.java | 116 +++++++++++++++++++
 .../cassandra/stress/generate/values/Bytes.java |   2 +-
 .../stress/generate/values/Strings.java         |   2 +-
 7 files changed, 148 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b80f272..35e02a2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,7 @@
  * Change gossip stabilization to use endpoit size (CASSANDRA-9401)
  * Change default garbage collector to G1 (CASSANDRA-7486)
  * Populate TokenMetadata early during startup (CASSANDRA-9317)
+ * undeprecate cache recentHitRate (CASSANDRA-6591)
 
 
 2.2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/src/java/org/apache/cassandra/metrics/CacheMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/CacheMetrics.java 
b/src/java/org/apache/cassandra/metrics/CacheMetrics.java
index 8b00e1c..151268b 100644
--- a/src/java/org/apache/cassandra/metrics/CacheMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/CacheMetrics.java
@@ -37,8 +37,14 @@ public class CacheMetrics
     public final Meter hits;
     /** Total number of cache requests */
     public final Meter requests;
-    /** cache hit rate */
+    /** all time cache hit rate */
     public final Gauge<Double> hitRate;
+    /** 1m hit rate */
+    public final Gauge<Double> oneMinuteHitRate;
+    /** 5m hit rate */
+    public final Gauge<Double> fiveMinuteHitRate;
+    /** 15m hit rate */
+    public final Gauge<Double> fifteenMinuteHitRate;
     /** Total size of cache, in bytes */
     public final Gauge<Long> size;
     /** Total number of cache entries */
@@ -71,6 +77,27 @@ public class CacheMetrics
                 return Ratio.of(hits.getCount(), requests.getCount());
             }
         });
+        oneMinuteHitRate = 
Metrics.register(factory.createMetricName("OneMinuteHitRate"), new RatioGauge()
+        {
+            protected Ratio getRatio()
+            {
+                return Ratio.of(hits.getOneMinuteRate(), 
requests.getOneMinuteRate());
+            }
+        });
+        fiveMinuteHitRate = 
Metrics.register(factory.createMetricName("FiveMinuteHitRate"), new RatioGauge()
+        {
+            protected Ratio getRatio()
+            {
+                return Ratio.of(hits.getFiveMinuteRate(), 
requests.getFiveMinuteRate());
+            }
+        });
+        fifteenMinuteHitRate = 
Metrics.register(factory.createMetricName("FifteenMinuteHitRate"), new 
RatioGauge()
+        {
+            protected Ratio getRatio()
+            {
+                return Ratio.of(hits.getFifteenMinuteRate(), 
requests.getFifteenMinuteRate());
+            }
+        });
         size = Metrics.register(factory.createMetricName("Size"), new 
Gauge<Long>()
         {
             public Long getValue()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/src/java/org/apache/cassandra/utils/DynamicList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/DynamicList.java 
b/src/java/org/apache/cassandra/utils/DynamicList.java
index fc3d523..30f5160 100644
--- a/src/java/org/apache/cassandra/utils/DynamicList.java
+++ b/src/java/org/apache/cassandra/utils/DynamicList.java
@@ -238,7 +238,7 @@ public class DynamicList<E>
             canon.add(c);
             c++;
         }
-        FasterRandom rand = new FasterRandom();
+        ThreadLocalRandom rand = ThreadLocalRandom.current();
         assert list.isWellFormed();
         for (int loop = 0 ; loop < 100 ; loop++)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/src/java/org/apache/cassandra/utils/FasterRandom.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FasterRandom.java 
b/src/java/org/apache/cassandra/utils/FasterRandom.java
deleted file mode 100644
index 8235e3b..0000000
--- a/src/java/org/apache/cassandra/utils/FasterRandom.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*    http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.cassandra.utils;
-
-import java.util.Random;
-
-import org.apache.commons.math3.random.RandomGenerator;
-
-// based on http://en.wikipedia.org/wiki/Xorshift, but periodically we reseed 
with our stronger random generator
-// note it is also non-atomically updated, so expects to be used by a single 
thread
-public class FasterRandom implements RandomGenerator
-{
-    final Random random = new Random();
-
-    private long seed;
-    private int reseed;
-
-    public void setSeed(int seed)
-    {
-        setSeed((long) seed);
-    }
-
-    public void setSeed(int[] ints)
-    {
-        if (ints.length > 1)
-            setSeed (((long) ints[0] << 32) | ints[1]);
-        else
-            setSeed(ints[0]);
-    }
-
-    public void setSeed(long seed)
-    {
-        this.seed = seed;
-        rollover();
-    }
-
-    private void rollover()
-    {
-        this.reseed = 0;
-        random.setSeed(seed);
-        seed = random.nextLong();
-    }
-
-    public void nextBytes(byte[] bytes)
-    {
-        int i = 0;
-        while (i < bytes.length)
-        {
-            long next = nextLong();
-            while (i < bytes.length)
-            {
-                bytes[i++] = (byte) (next & 0xFF);
-                next >>>= 8;
-            }
-        }
-    }
-
-    public int nextInt()
-    {
-        return (int) nextLong();
-    }
-
-    public int nextInt(int i)
-    {
-        return Math.abs((int) nextLong() % i);
-    }
-
-    public long nextLong()
-    {
-        if (++this.reseed == 32)
-            rollover();
-
-        long seed = this.seed;
-        seed ^= seed >> 12;
-        seed ^= seed << 25;
-        seed ^= seed >> 27;
-        this.seed = seed;
-        return seed * 2685821657736338717L;
-    }
-
-    public boolean nextBoolean()
-    {
-        return ((int) nextLong() & 1) == 1;
-    }
-
-    public float nextFloat()
-    {
-        return Float.intBitsToFloat((int) nextLong());
-    }
-
-    public double nextDouble()
-    {
-        return Double.longBitsToDouble(nextLong());
-    }
-
-    public double nextGaussian()
-    {
-        return random.nextGaussian();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/tools/stress/src/org/apache/cassandra/stress/generate/FasterRandom.java
----------------------------------------------------------------------
diff --git 
a/tools/stress/src/org/apache/cassandra/stress/generate/FasterRandom.java 
b/tools/stress/src/org/apache/cassandra/stress/generate/FasterRandom.java
new file mode 100644
index 0000000..455fec4
--- /dev/null
+++ b/tools/stress/src/org/apache/cassandra/stress/generate/FasterRandom.java
@@ -0,0 +1,116 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*    http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.cassandra.stress.generate;
+
+import java.util.Random;
+
+import org.apache.commons.math3.random.RandomGenerator;
+
+// based on http://en.wikipedia.org/wiki/Xorshift, but periodically we reseed 
with our stronger random generator
+// note it is also non-atomically updated, so expects to be used by a single 
thread
+public class FasterRandom implements RandomGenerator
+{
+    final Random random = new Random();
+
+    private long seed;
+    private int reseed;
+
+    public void setSeed(int seed)
+    {
+        setSeed((long) seed);
+    }
+
+    public void setSeed(int[] ints)
+    {
+        if (ints.length > 1)
+            setSeed (((long) ints[0] << 32) | ints[1]);
+        else
+            setSeed(ints[0]);
+    }
+
+    public void setSeed(long seed)
+    {
+        this.seed = seed;
+        rollover();
+    }
+
+    private void rollover()
+    {
+        this.reseed = 0;
+        random.setSeed(seed);
+        seed = random.nextLong();
+    }
+
+    public void nextBytes(byte[] bytes)
+    {
+        int i = 0;
+        while (i < bytes.length)
+        {
+            long next = nextLong();
+            while (i < bytes.length)
+            {
+                bytes[i++] = (byte) (next & 0xFF);
+                next >>>= 8;
+            }
+        }
+    }
+
+    public int nextInt()
+    {
+        return (int) nextLong();
+    }
+
+    public int nextInt(int i)
+    {
+        return Math.abs((int) nextLong() % i);
+    }
+
+    public long nextLong()
+    {
+        if (++this.reseed == 32)
+            rollover();
+
+        long seed = this.seed;
+        seed ^= seed >> 12;
+        seed ^= seed << 25;
+        seed ^= seed >> 27;
+        this.seed = seed;
+        return seed * 2685821657736338717L;
+    }
+
+    public boolean nextBoolean()
+    {
+        return ((int) nextLong() & 1) == 1;
+    }
+
+    public float nextFloat()
+    {
+        return Float.intBitsToFloat((int) nextLong());
+    }
+
+    public double nextDouble()
+    {
+        return Double.longBitsToDouble(nextLong());
+    }
+
+    public double nextGaussian()
+    {
+        return random.nextGaussian();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/tools/stress/src/org/apache/cassandra/stress/generate/values/Bytes.java
----------------------------------------------------------------------
diff --git 
a/tools/stress/src/org/apache/cassandra/stress/generate/values/Bytes.java 
b/tools/stress/src/org/apache/cassandra/stress/generate/values/Bytes.java
index c247e48..3c15c87 100644
--- a/tools/stress/src/org/apache/cassandra/stress/generate/values/Bytes.java
+++ b/tools/stress/src/org/apache/cassandra/stress/generate/values/Bytes.java
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 
 import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.cassandra.utils.FasterRandom;
+import org.apache.cassandra.stress.generate.FasterRandom;
 
 public class Bytes extends Generator<ByteBuffer>
 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c19fd63/tools/stress/src/org/apache/cassandra/stress/generate/values/Strings.java
----------------------------------------------------------------------
diff --git 
a/tools/stress/src/org/apache/cassandra/stress/generate/values/Strings.java 
b/tools/stress/src/org/apache/cassandra/stress/generate/values/Strings.java
index db78eb7..b58fee2 100644
--- a/tools/stress/src/org/apache/cassandra/stress/generate/values/Strings.java
+++ b/tools/stress/src/org/apache/cassandra/stress/generate/values/Strings.java
@@ -21,7 +21,7 @@
 package org.apache.cassandra.stress.generate.values;
 
 import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.utils.FasterRandom;
+import org.apache.cassandra.stress.generate.FasterRandom;
 
 public class Strings extends Generator<String>
 {

Reply via email to