cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject [3/3] git commit: expose counters for unavailable/timeout exceptions given to thrift clients
Date Tue, 06 Mar 2012 05:59:37 GMT
expose counters for unavailable/timeout exceptions given to thrift clients

patch by scode; reviewed by driftx, eevans for CASSANDRA-3671


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

Branch: refs/heads/trunk
Commit: 9c5ac8ff69db65dd5197062bbf60c10dc2371390
Parents: d27e73a
Author: Peter Schuller <peter.schuller@infidyne.com>
Authored: Mon Mar 5 21:06:39 2012 -0800
Committer: Peter Schuller <peter.schuller@infidyne.com>
Committed: Mon Mar 5 21:46:04 2012 -0800

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 build.xml                                          |    1 +
 lib/metrics-core-2.0.3.jar                         |  Bin 0 -> 80800 bytes
 .../cassandra/metrics/ClientRequestMetrics.java    |   32 +++++++++++++++
 .../org/apache/cassandra/service/StorageProxy.java |   20 +++++++++
 .../apache/cassandra/service/StorageService.java   |    8 ++++
 6 files changed, 62 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d0f3b65..75123a8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -23,6 +23,7 @@
  * Fix race between writes and read for cache (CASSANDRA-3862)
  * perform static initialization of StorageProxy on start-up (CASSANDRA-3797)
  * support trickling fsync() on writes (CASSANDRA-3950)
+ * expose counters for unavailable/timeout exceptions given to thrift clients (CASSANDRA-3671)
 Merged from 1.0:
  * remove the wait on hint future during write (CASSANDRA-3870)
  * (cqlsh) ignore missing CfDef opts (CASSANDRA-3933)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 1f8ec47..6908e9d 100644
--- a/build.xml
+++ b/build.xml
@@ -402,6 +402,7 @@ url=${svn.entry.url}?pathrev=${svn.entry.commit.revision}
           <dependency groupId="log4j" artifactId="log4j" version="1.2.16" />
           <dependency groupId="org.apache.cassandra" artifactId="cassandra-all" version="${version}"
/>
           <dependency groupId="org.apache.cassandra" artifactId="cassandra-thrift" version="${version}"
/>
+          <dependency groupId="com.yammer.metrics" artifactId="metrics-core" version="2.0.3"
/>
         </dependencyManagement>
         <developer id="alakshman" name="Avinash Lakshman"/>
         <developer id="antelder" name="Anthony Elder"/>

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/lib/metrics-core-2.0.3.jar
----------------------------------------------------------------------
diff --git a/lib/metrics-core-2.0.3.jar b/lib/metrics-core-2.0.3.jar
new file mode 100644
index 0000000..729e6e8
Binary files /dev/null and b/lib/metrics-core-2.0.3.jar differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java b/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
new file mode 100644
index 0000000..02ca0fe
--- /dev/null
+++ b/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.metrics;
+
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.Counter;
+
+public class ClientRequestMetrics
+{
+    public static final Counter readTimeouts = Metrics.newCounter(ClientRequestMetrics.class,
"ReadTimeouts");
+    public static final Counter writeTimeouts = Metrics.newCounter(ClientRequestMetrics.class,
"WriteTimeouts");
+    public static final Counter readUnavailables = Metrics.newCounter(ClientRequestMetrics.class,
"ReadUnavailables");
+    public static final Counter writeUnavailables = Metrics.newCounter(ClientRequestMetrics.class,
"WriteUnavailables");
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/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 2e791fc..223df4f 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -55,6 +55,7 @@ import org.apache.cassandra.io.util.FastByteArrayOutputStream;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.locator.IEndpointSnitch;
 import org.apache.cassandra.locator.TokenMetadata;
+import org.apache.cassandra.metrics.ClientRequestMetrics;
 import org.apache.cassandra.net.*;
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.utils.*;
@@ -202,6 +203,7 @@ public class StorageProxy implements StorageProxyMBean
         }
         catch (TimeoutException ex)
         {
+            ClientRequestMetrics.writeTimeouts.inc();
             if (logger.isDebugEnabled())
             {
                 List<String> mstrings = new ArrayList<String>(mutations.size());
@@ -211,6 +213,11 @@ public class StorageProxy implements StorageProxyMBean
             }
             throw ex;
         }
+        catch (UnavailableException e)
+        {
+            ClientRequestMetrics.writeUnavailables.inc();
+            throw e;
+        }
         catch (IOException e)
         {
             assert mostRecentMutation != null;
@@ -587,13 +594,26 @@ public class StorageProxy implements StorageProxyMBean
             throws IOException, UnavailableException, TimeoutException, InvalidRequestException
     {
         if (StorageService.instance.isBootstrapMode())
+        {
+            ClientRequestMetrics.readUnavailables.inc();
             throw new UnavailableException();
+        }
         long startTime = System.nanoTime();
         List<Row> rows;
         try
         {
             rows = fetchRows(commands, consistency_level);
         }
+        catch (UnavailableException e)
+        {
+            ClientRequestMetrics.readUnavailables.inc();
+            throw e;
+        }
+        catch (TimeoutException e)
+        {
+            ClientRequestMetrics.readTimeouts.inc();
+            throw e;
+        }
         finally
         {
             readStats.addNano(System.nanoTime() - startTime);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9c5ac8ff/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 7724df6..e59e384 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -35,6 +35,7 @@ import javax.management.ObjectName;
 import com.google.common.base.Supplier;
 import com.google.common.collect.*;
 
+import org.apache.cassandra.metrics.ClientRequestMetrics;
 import org.apache.log4j.Level;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
@@ -432,6 +433,13 @@ public class StorageService implements IEndpointStateChangeSubscriber,
StorageSe
             throw new AssertionError(e);
         }
 
+        if (!isClientMode)
+        {
+            // "Touch" metrics classes to trigger static initialization, such that all metrics
become available
+            // on start-up even if they have not yet been used.
+            new ClientRequestMetrics();
+        }
+
         if (Boolean.parseBoolean(System.getProperty("cassandra.load_ring_state", "true")))
         {
             logger_.info("Loading persisted ring state");


Mime
View raw message