Updated Branches: refs/heads/cassandra-1.2 806a45225 -> 0e18f23c5 refs/heads/cassandra-2.0 ab31b217c -> 1daf19165 refs/heads/trunk 76acc8040 -> d141daa20
Move hints and exception count to o.a.c.metrics patch by yukim; reviewed by jbellis for CASSANDRA-6017 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0e18f23c Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0e18f23c Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0e18f23c Branch: refs/heads/cassandra-1.2 Commit: 0e18f23c5cb7080b3bbaee15b87001b323fd1c29 Parents: 806a452 Author: Yuki Morishita <yu...@apache.org> Authored: Fri Sep 13 11:46:01 2013 -0500 Committer: Yuki Morishita <yu...@apache.org> Committed: Fri Sep 13 11:46:01 2013 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/metrics/StorageMetrics.java | 3 +++ .../apache/cassandra/service/CassandraDaemon.java | 5 ++--- .../org/apache/cassandra/service/StorageProxy.java | 17 ++++++++--------- .../apache/cassandra/service/StorageService.java | 2 +- .../cassandra/service/StorageServiceMBean.java | 1 + 6 files changed, 16 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index e124ac0..ad32460 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,7 @@ * Replace the deprecated MapMaker with CacheLoader (CASSANDRA-6007) * Add SSTableDeletingNotification to DataTracker (CASSANDRA-6010) * Fix snapshots in use get deleted during snapshot repair (CASSANDRA-6011) + * Move hints and exception count to o.a.c.metrics (CASSANDRA-6017) 1.2.9 http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/src/java/org/apache/cassandra/metrics/StorageMetrics.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/metrics/StorageMetrics.java b/src/java/org/apache/cassandra/metrics/StorageMetrics.java index 3cda71e..ab7b886 100644 --- a/src/java/org/apache/cassandra/metrics/StorageMetrics.java +++ b/src/java/org/apache/cassandra/metrics/StorageMetrics.java @@ -27,4 +27,7 @@ import com.yammer.metrics.core.MetricName; public class StorageMetrics { public static final Counter load = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics", "Storage", "Load")); + public static final Counter exceptions = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics", "Storage", "Exceptions")); + public static final Counter totalHintsInProgress = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics", "Storage", "TotalHintsInProgress")); + public static final Counter totalHints = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics", "Storage", "TotalHints")); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/src/java/org/apache/cassandra/service/CassandraDaemon.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java index af21f07..b2fc367 100644 --- a/src/java/org/apache/cassandra/service/CassandraDaemon.java +++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java @@ -45,6 +45,7 @@ import org.apache.cassandra.db.commitlog.CommitLog; import org.apache.cassandra.db.compaction.CompactionManager; import org.apache.cassandra.io.FSError; import org.apache.cassandra.io.util.FileUtils; +import org.apache.cassandra.metrics.StorageMetrics; import org.apache.cassandra.thrift.ThriftServer; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.utils.CLibrary; @@ -123,8 +124,6 @@ public class CassandraDaemon private static final CassandraDaemon instance = new CassandraDaemon(); - static final AtomicInteger exceptions = new AtomicInteger(); - public Server thriftServer; public Server nativeServer; @@ -188,7 +187,7 @@ public class CassandraDaemon { public void uncaughtException(Thread t, Throwable e) { - exceptions.incrementAndGet(); + StorageMetrics.exceptions.inc(); logger.error("Exception in thread " + t, e); Tracing.trace("Exception in thread " + t, e); for (Throwable e2 = e; e2 != null; e2 = e2.getCause()) http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/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 23d73ec..be92213 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -61,6 +61,7 @@ import org.apache.cassandra.locator.IEndpointSnitch; import org.apache.cassandra.locator.TokenMetadata; import org.apache.cassandra.metrics.ClientRequestMetrics; import org.apache.cassandra.metrics.ReadRepairMetrics; +import org.apache.cassandra.metrics.StorageMetrics; import org.apache.cassandra.net.*; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.utils.ByteBufferUtil; @@ -82,7 +83,6 @@ public class StorageProxy implements StorageProxyMBean public static final StorageProxy instance = new StorageProxy(); private static volatile int maxHintsInProgress = 1024 * FBUtilities.getAvailableProcessors(); - private static final AtomicInteger totalHintsInProgress = new AtomicInteger(); private static final CacheLoader<InetAddress, AtomicInteger> hintsInProgress = new CacheLoader<InetAddress, AtomicInteger>() { public AtomicInteger load(InetAddress inetAddress) @@ -90,7 +90,6 @@ public class StorageProxy implements StorageProxyMBean return new AtomicInteger(0); } }; - private static final AtomicLong totalHints = new AtomicLong(); private static final ClientRequestMetrics readMetrics = new ClientRequestMetrics("Read"); private static final ClientRequestMetrics rangeMetrics = new ClientRequestMetrics("RangeSlice"); private static final ClientRequestMetrics writeMetrics = new ClientRequestMetrics("Write"); @@ -488,10 +487,10 @@ public class StorageProxy implements StorageProxyMBean // The idea is that if we have over maxHintsInProgress hints in flight, this is probably due to // a small number of nodes causing problems, so we should avoid shutting down writes completely to // healthy nodes. Any node with no hintsInProgress is considered healthy. - if (totalHintsInProgress.get() > maxHintsInProgress + if (StorageMetrics.totalHintsInProgress.count() > maxHintsInProgress && (getHintsInProgressFor(destination).get() > 0 && shouldHint(destination))) { - throw new OverloadedException("Too many in flight hints: " + totalHintsInProgress.get()); + throw new OverloadedException("Too many in flight hints: " + StorageMetrics.totalHintsInProgress.count()); } if (FailureDetector.instance.isAlive(destination)) @@ -583,7 +582,7 @@ public class StorageProxy implements StorageProxyMBean private static Future<Void> submitHint(HintRunnable runnable) { - totalHintsInProgress.incrementAndGet(); + StorageMetrics.totalHintsInProgress.inc(); getHintsInProgressFor(runnable.target).incrementAndGet(); return (Future<Void>) StageManager.getStage(Stage.MUTATION).submit(runnable); } @@ -599,7 +598,7 @@ public class StorageProxy implements StorageProxyMBean } assert hostId != null : "Missing host ID for " + target.getHostAddress(); mutation.toHint(ttl, hostId).apply(); - totalHints.incrementAndGet(); + StorageMetrics.totalHints.inc(); } private static void sendMessagesToOneDC(MessageOut message, Collection<InetAddress> targets, boolean localDC, AbstractWriteResponseHandler handler) @@ -1685,7 +1684,7 @@ public class StorageProxy implements StorageProxyMBean } finally { - totalHintsInProgress.decrementAndGet(); + StorageMetrics.totalHintsInProgress.dec(); getHintsInProgressFor(target).decrementAndGet(); } } @@ -1695,7 +1694,7 @@ public class StorageProxy implements StorageProxyMBean public long getTotalHints() { - return totalHints.get(); + return StorageMetrics.totalHints.count(); } public int getMaxHintsInProgress() @@ -1710,7 +1709,7 @@ public class StorageProxy implements StorageProxyMBean public int getHintsInProgress() { - return totalHintsInProgress.get(); + return (int) StorageMetrics.totalHintsInProgress.count(); } public void verifyNoHintsInProgress() http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/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 2c3a1c8..7a5bbbc 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -3859,7 +3859,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE public int getExceptionCount() { - return CassandraDaemon.exceptions.get(); + return (int)StorageMetrics.exceptions.count(); } public void rescheduleFailedDeletions() http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e18f23c/src/java/org/apache/cassandra/service/StorageServiceMBean.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java index 2c63b46..4fbed9c 100644 --- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java +++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java @@ -403,6 +403,7 @@ public interface StorageServiceMBean extends NotificationEmitter public void joinRing() throws IOException; public boolean isJoined(); + @Deprecated public int getExceptionCount(); public void setStreamThroughputMbPerSec(int value);