mirror of https://github.com/apache/cassandra
expose counters for unavailable/timeout exceptions given to thrift clients
patch by scode; reviewed by driftx, eevans for CASSANDRA-3671
This commit is contained in:
parent
08e4fb35e8
commit
154daa03a6
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"/>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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");
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue