mirror of https://github.com/apache/cassandra
Move hints and exception count to o.a.c.metrics
patch by yukim; reviewed by jbellis for CASSANDRA-6017
This commit is contained in:
parent
806a45225b
commit
0e18f23c5c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue