You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sn...@apache.org on 2016/08/04 17:49:28 UTC
cassandra git commit: Collect metrics on queries by consistency level
Repository: cassandra
Updated Branches:
refs/heads/trunk ffdf6c79c -> 221f27a6d
Collect metrics on queries by consistency level
patch by sankalp kohli; reviewed by Robert Stupp for CASSANDRA-7384
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/221f27a6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/221f27a6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/221f27a6
Branch: refs/heads/trunk
Commit: 221f27a6d510e0820718b0669754d6d9b42e2d2d
Parents: ffdf6c7
Author: sankalp kohli <sa...@apple.com>
Authored: Thu Aug 4 19:47:21 2016 +0200
Committer: Robert Stupp <sn...@snazy.de>
Committed: Thu Aug 4 19:47:21 2016 +0200
----------------------------------------------------------------------
CHANGES.txt | 4 +-
.../apache/cassandra/service/StorageProxy.java | 40 ++++++++++++++++++--
2 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/221f27a6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1636e3a..98f9c24 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.10
+ * Collect metrics on queries by consistency level (CASSANDRA-7384)
* Add support for GROUP BY to SELECT statement (CASSANDRA-10707)
* Deprecate memtable_cleanup_threshold and update default for memtable_flush_writers (CASSANDRA-12228)
* Upgrade to OHC 0.4.4 (CASSANDRA-12133)
@@ -57,10 +58,7 @@ Merged from 2.1:
* cannot use cql since upgrading python to 2.7.11+ (CASSANDRA-11850)
* Allow STCS-in-L0 compactions to reduce scope with LCS (CASSANDRA-12040)
-<<<<<<< HEAD
-=======
->>>>>>> cassandra-3.9
3.8
* RTE from new CDC column breaks in flight queries (CASSANDRA-12236)
* Fix hdr logging for single operation workloads (CASSANDRA-12145)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/221f27a6/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 bc8c46c..1bfa1b0 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -100,6 +100,8 @@ public class StorageProxy implements StorageProxyMBean
private static final CASClientRequestMetrics casWriteMetrics = new CASClientRequestMetrics("CASWrite");
private static final CASClientRequestMetrics casReadMetrics = new CASClientRequestMetrics("CASRead");
private static final ViewWriteMetrics viewWriteMetrics = new ViewWriteMetrics("ViewWrite");
+ private static final Map<ConsistencyLevel, ClientRequestMetrics> readMetricsMap = new EnumMap<>(ConsistencyLevel.class);
+ private static final Map<ConsistencyLevel, ClientRequestMetrics> writeMetricsMap = new EnumMap<>(ConsistencyLevel.class);
private static final double CONCURRENT_SUBREQUESTS_MARGIN = 0.10;
@@ -166,6 +168,12 @@ public class StorageProxy implements StorageProxyMBean
.execute(counterWriteTask(mutation, targets, responseHandler, localDataCenter));
}
};
+
+ for(ConsistencyLevel level : ConsistencyLevel.values())
+ {
+ readMetricsMap.put(level, new ClientRequestMetrics("Read-" + level.name()));
+ writeMetricsMap.put(level, new ClientRequestMetrics("Write-" + level.name()));
+ }
}
/**
@@ -291,23 +299,28 @@ public class StorageProxy implements StorageProxyMBean
catch (WriteTimeoutException|ReadTimeoutException e)
{
casWriteMetrics.timeouts.mark();
+ writeMetricsMap.get(consistencyForPaxos).timeouts.mark();
throw e;
}
catch (WriteFailureException|ReadFailureException e)
{
casWriteMetrics.failures.mark();
+ writeMetricsMap.get(consistencyForPaxos).failures.mark();
throw e;
}
catch(UnavailableException e)
{
casWriteMetrics.unavailables.mark();
+ writeMetricsMap.get(consistencyForPaxos).unavailables.mark();
throw e;
}
finally
{
if(contentions > 0)
casWriteMetrics.contention.update(contentions);
- casWriteMetrics.addNano(System.nanoTime() - start);
+ final long latency = System.nanoTime() - start;
+ casWriteMetrics.addNano(latency);
+ writeMetricsMap.get(consistencyForPaxos).addNano(latency);
}
}
@@ -626,6 +639,7 @@ public class StorageProxy implements StorageProxyMBean
if (ex instanceof WriteFailureException)
{
writeMetrics.failures.mark();
+ writeMetricsMap.get(consistency_level).failures.mark();
WriteFailureException fe = (WriteFailureException)ex;
Tracing.trace("Write failure; received {} of {} required replies, failed {} requests",
fe.received, fe.blockFor, fe.failures);
@@ -633,6 +647,7 @@ public class StorageProxy implements StorageProxyMBean
else
{
writeMetrics.timeouts.mark();
+ writeMetricsMap.get(consistency_level).timeouts.mark();
WriteTimeoutException te = (WriteTimeoutException)ex;
Tracing.trace("Write timeout; received {} of {} required replies", te.received, te.blockFor);
}
@@ -642,18 +657,22 @@ public class StorageProxy implements StorageProxyMBean
catch (UnavailableException e)
{
writeMetrics.unavailables.mark();
+ writeMetricsMap.get(consistency_level).unavailables.mark();
Tracing.trace("Unavailable");
throw e;
}
catch (OverloadedException e)
{
writeMetrics.unavailables.mark();
+ writeMetricsMap.get(consistency_level).unavailables.mark();
Tracing.trace("Overloaded");
throw e;
}
finally
{
- writeMetrics.addNano(System.nanoTime() - startTime);
+ long latency = System.nanoTime() - startTime;
+ writeMetrics.addNano(latency);
+ writeMetricsMap.get(consistency_level).addNano(latency);
}
}
@@ -899,24 +918,30 @@ public class StorageProxy implements StorageProxyMBean
catch (UnavailableException e)
{
writeMetrics.unavailables.mark();
+ writeMetricsMap.get(consistency_level).unavailables.mark();
Tracing.trace("Unavailable");
throw e;
}
catch (WriteTimeoutException e)
{
writeMetrics.timeouts.mark();
+ writeMetricsMap.get(consistency_level).timeouts.mark();
Tracing.trace("Write timeout; received {} of {} required replies", e.received, e.blockFor);
throw e;
}
catch (WriteFailureException e)
{
writeMetrics.failures.mark();
+ writeMetricsMap.get(consistency_level).failures.mark();
Tracing.trace("Write failure; received {} of {} required replies", e.received, e.blockFor);
throw e;
}
finally
{
- writeMetrics.addNano(System.nanoTime() - startTime);
+ long latency = System.nanoTime() - startTime;
+ writeMetrics.addNano(latency);
+ writeMetricsMap.get(consistency_level).addNano(latency);
+
}
}
@@ -1517,6 +1542,7 @@ public class StorageProxy implements StorageProxyMBean
if (StorageService.instance.isBootstrapMode() && !systemKeyspaceQuery(group.commands))
{
readMetrics.unavailables.mark();
+ readMetricsMap.get(consistencyLevel).unavailables.mark();
throw new IsBootstrappingException();
}
@@ -1571,18 +1597,21 @@ public class StorageProxy implements StorageProxyMBean
{
readMetrics.unavailables.mark();
casReadMetrics.unavailables.mark();
+ readMetricsMap.get(consistencyLevel).unavailables.mark();
throw e;
}
catch (ReadTimeoutException e)
{
readMetrics.timeouts.mark();
casReadMetrics.timeouts.mark();
+ readMetricsMap.get(consistencyLevel).timeouts.mark();
throw e;
}
catch (ReadFailureException e)
{
readMetrics.failures.mark();
casReadMetrics.failures.mark();
+ readMetricsMap.get(consistencyLevel).failures.mark();
throw e;
}
finally
@@ -1590,6 +1619,7 @@ public class StorageProxy implements StorageProxyMBean
long latency = System.nanoTime() - start;
readMetrics.addNano(latency);
casReadMetrics.addNano(latency);
+ readMetricsMap.get(consistencyLevel).addNano(latency);
Keyspace.open(metadata.ksName).getColumnFamilyStore(metadata.cfName).metric.coordinatorReadLatency.update(latency, TimeUnit.NANOSECONDS);
}
@@ -1613,22 +1643,26 @@ public class StorageProxy implements StorageProxyMBean
catch (UnavailableException e)
{
readMetrics.unavailables.mark();
+ readMetricsMap.get(consistencyLevel).unavailables.mark();
throw e;
}
catch (ReadTimeoutException e)
{
readMetrics.timeouts.mark();
+ readMetricsMap.get(consistencyLevel).timeouts.mark();
throw e;
}
catch (ReadFailureException e)
{
readMetrics.failures.mark();
+ readMetricsMap.get(consistencyLevel).failures.mark();
throw e;
}
finally
{
long latency = System.nanoTime() - start;
readMetrics.addNano(latency);
+ readMetricsMap.get(consistencyLevel).addNano(latency);
// TODO avoid giving every command the same latency number. Can fix this in CASSADRA-5329
for (ReadCommand command : group.commands)
Keyspace.openAndGetStore(command.metadata()).metric.coordinatorReadLatency.update(latency, TimeUnit.NANOSECONDS);