You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sc...@apache.org on 2012/03/06 07:07:23 UTC
[2/2] git commit: expose counters for unavailable/timeout exceptions
given to thrift clients
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/154daa03
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/154daa03
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/154daa03
Branch: refs/heads/cassandra-1.1
Commit: 154daa03a660a62b228000354319390305568b21
Parents: 08e4fb3
Author: Peter Schuller <pe...@infidyne.com>
Authored: Mon Mar 5 21:06:39 2012 -0800
Committer: Peter Schuller <pe...@infidyne.com>
Committed: Mon Mar 5 22:03:32 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/154daa03/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index dc2f1c5..86ab50a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,6 +17,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/154daa03/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/154daa03/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/154daa03/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/154daa03/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 25729ee..d4c4474 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>();
@@ -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/154daa03/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 5fddf4a..66e28f4 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;
@@ -431,6 +432,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");