cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: Replace countPendingHints with HintsCreated metric patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5746
Date Thu, 18 Jul 2013 20:26:55 GMT
Updated Branches:
  refs/heads/trunk d41b9e70c -> 06939dda2


Replace countPendingHints with HintsCreated metric
patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5746


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

Branch: refs/heads/trunk
Commit: 06939dda2cb307fe5489c9b7ca83ebc259f6cee2
Parents: d41b9e7
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Jul 18 13:26:11 2013 -0700
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Jul 18 13:26:51 2013 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 NEWS.txt                                        |  1 +
 .../cassandra/db/HintedHandOffManager.java      | 21 +++---------------
 .../cassandra/db/HintedHandOffManagerMBean.java |  8 -------
 .../cassandra/metrics/HintedHandoffMetrics.java | 23 +++++++++++++-------
 .../apache/cassandra/service/StorageProxy.java  |  2 +-
 .../apache/cassandra/db/HintedHandOffTest.java  |  2 +-
 7 files changed, 23 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 605df96..9a1a28b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.0-beta2
+ * Replace countPendingHints with Hints Created metric (CASSANDRA-5746)
  * Allow nodetool with no args, and with help to run without a server (CASSANDRA-5734)
  * Cleanup AbstractType/TypeSerializer classes (CASSANDRA-5744)
  * Remove unimplemented cli option schema-mwt (CASSANDRA-5754)
@@ -7,6 +8,7 @@
  * cqlsh: add missing table options to DESCRIBE output (CASSANDRA-5749)
  * Fix assertion error during repair (CASSANDRA-5757)
 
+
 2.0.0-beta1
  * Removed on-heap row cache (CASSANDRA-5348)
  * use nanotime consistently for node-local timeouts (CASSANDRA-5581)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 4418945..dc3d51a 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -59,6 +59,7 @@ Operations
       https://issues.apache.org/jira/browse/CASSANDRA-3919 for details.
     - CAS uses gc_grace_seconds to determine how long to keep unused paxos
       state around for, or a minimum of three hours.
+    - A new hints created metric is tracked per target, replacing countPendingHints
 
 Features
 --------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index 9f21451..6b69354 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -119,9 +119,11 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
      * Returns a mutation representing a Hint to be sent to <code>targetId</code>
      * as soon as it becomes available again.
      */
-    public static RowMutation hintFor(RowMutation mutation, int ttl, UUID targetId)
+    public RowMutation hintFor(RowMutation mutation, int ttl, UUID targetId)
     {
         assert ttl > 0;
+        metrics.incrCreatedHints(StorageService.instance.getTokenMetadata().getEndpointForHostId(targetId));
+
         UUID hintId = UUIDGen.getTimeUUID();
         // serialize the hint with id and version as a composite column name
         ByteBuffer name = comparator.decompose(hintId, MessagingService.current_version);
@@ -547,23 +549,6 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
         return result;
     }
 
-    public Map<String, Integer> countPendingHints()
-    {
-        Token.TokenFactory tokenFactory = StorageService.getPartitioner().getTokenFactory();
-
-        Map<String, Integer> result = new HashMap<String, Integer>();
-        for (Row row : getHintsSlice(Integer.MAX_VALUE))
-        {
-            if (row.cf == null) // ignore removed rows
-                continue;
-
-            int count = row.cf.getColumnCount();
-            if (count > 0)
-                result.put(tokenFactory.toString(row.key.token), count);
-        }
-        return result;
-    }
-
     private List<Row> getHintsSlice(int columnCount)
     {
         // Get count # of columns...

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/src/java/org/apache/cassandra/db/HintedHandOffManagerMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManagerMBean.java b/src/java/org/apache/cassandra/db/HintedHandOffManagerMBean.java
index 690a3eb..142272f 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManagerMBean.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManagerMBean.java
@@ -35,14 +35,6 @@ public interface HintedHandOffManagerMBean
      */
     public List<String> listEndpointsPendingHints();
 
-    /**
-     * List all the endpoints that this node has hints for, and
-     *  count the number of hints for each such endpoint.
-     *
-     * @return map of endpoint -> hint count
-     */
-    public Map<String, Integer> countPendingHints();
-
     /** force hint delivery to an endpoint **/
     public void scheduleHintDelivery(String host) throws UnknownHostException;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java b/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
index 1585342..ae1cbf3 100644
--- a/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
@@ -53,16 +53,23 @@ public class HintedHandoffMetrics
         }
     });
 
-    public void incrPastWindow(InetAddress address)
+    /** Total number of hints that have been created, This is not a cache. */
+    private final LoadingCache<InetAddress, Counter> createdHintCounts = CacheBuilder.newBuilder().build(new
CacheLoader<InetAddress, Counter>()
     {
-        try
-        {
-            notStored.get(address).mark();
-        }
-        catch (ExecutionException e)
+        public Counter load(InetAddress address)
         {
-            throw new RuntimeException(e); // this cannot happen
+            return Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "Hints_created-"
+ address.getHostAddress()));
         }
+    });
+
+    public void incrCreatedHints(InetAddress address)
+    {
+        createdHintCounts.getUnchecked(address).inc();
+    }
+
+    public void incrPastWindow(InetAddress address)
+    {
+        notStored.getUnchecked(address).mark();
     }
 
     public void log()
@@ -84,7 +91,7 @@ public class HintedHandoffMetrics
 
         public DifferencingCounter(InetAddress address)
         {
-            this.meter = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "Hints_not_stored-"
+ address.toString()));
+            this.meter = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "Hints_not_stored-"
+ address.getHostAddress()));
         }
 
         public long diffrence()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 3b5b69e..241d038 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -875,7 +875,7 @@ public class StorageProxy implements StorageProxyMBean
         assert ttl > 0;
         UUID hostId = StorageService.instance.getTokenMetadata().getHostId(target);
         assert hostId != null : "Missing host ID for " + target.getHostAddress();
-        HintedHandOffManager.hintFor(mutation, ttl, hostId).apply();
+        HintedHandOffManager.instance.hintFor(mutation, ttl, hostId).apply();
         totalHints.incrementAndGet();
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06939dda/test/unit/org/apache/cassandra/db/HintedHandOffTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/HintedHandOffTest.java b/test/unit/org/apache/cassandra/db/HintedHandOffTest.java
index 8bbf5a9..2f55770 100644
--- a/test/unit/org/apache/cassandra/db/HintedHandOffTest.java
+++ b/test/unit/org/apache/cassandra/db/HintedHandOffTest.java
@@ -65,7 +65,7 @@ public class HintedHandOffTest extends SchemaLoader
         RowMutation rm = new RowMutation(KEYSPACE4, ByteBufferUtil.bytes(1));
         rm.add(STANDARD1_CF, ByteBufferUtil.bytes(String.valueOf(COLUMN1)), ByteBufferUtil.EMPTY_BYTE_BUFFER,
System.currentTimeMillis());
 
-        HintedHandOffManager.hintFor(rm, HintedHandOffManager.calculateHintTTL(rm), UUID.randomUUID()).apply();
+        HintedHandOffManager.instance.hintFor(rm, HintedHandOffManager.calculateHintTTL(rm),
UUID.randomUUID()).apply();
 
         // flush data to disk
         hintStore.forceBlockingFlush();


Mime
View raw message