Merge branch 'cassandra-2.0' into cassandra-2.1 Conflicts: CHANGES.txt src/java/org/apache/cassandra/io/sstable/SSTableReader.java src/java/org/apache/cassandra/tools/NodeCmd.java src/java/org/apache/cassandra/utils/IFilter.java src/java/org/apache/cassandra/utils/obs/IBitSet.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9aaea248 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9aaea248 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9aaea248 Branch: refs/heads/cassandra-2.1 Commit: 9aaea2485f9e79a4e9bd3fcf80070a3c7aa1be46 Parents: b106292 7a14a77 Author: Aleksey Yeschenko <alek...@apache.org> Authored: Fri Nov 28 03:12:05 2014 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Fri Nov 28 03:12:05 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/ColumnFamilyStore.java | 15 ++++ .../cassandra/db/ColumnFamilyStoreMBean.java | 18 +++++ .../io/compress/CompressionMetadata.java | 9 +++ .../cassandra/io/sstable/SSTableReader.java | 21 ++++++ .../cassandra/metrics/ColumnFamilyMetrics.java | 36 ++++++++++ .../cassandra/metrics/KeyspaceMetrics.java | 27 +++++++ .../org/apache/cassandra/tools/NodeProbe.java | 4 ++ .../org/apache/cassandra/tools/NodeTool.java | 74 +++++++++++++++----- .../cassandra/utils/AlwaysPresentFilter.java | 6 ++ .../org/apache/cassandra/utils/IFilter.java | 6 ++ .../cassandra/utils/Murmur3BloomFilter.java | 6 ++ .../org/apache/cassandra/utils/obs/IBitSet.java | 6 ++ .../cassandra/utils/obs/OffHeapBitSet.java | 6 ++ .../apache/cassandra/utils/obs/OpenBitSet.java | 6 ++ 15 files changed, 224 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index e5f7c28,8f4add9..2f11996 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,20 -1,5 +1,21 @@@ -2.0.12: +2.1.3 + * Handle abort() in SSTableRewriter properly (CASSANDRA-8320) + * Fix high size calculations for prepared statements (CASSANDRA-8231) + * Centralize shared executors (CASSANDRA-8055) + * Fix filtering for CONTAINS (KEY) relations on frozen collection + clustering columns when the query is restricted to a single + partition (CASSANDRA-8203) + * Do more aggressive entire-sstable TTL expiry checks (CASSANDRA-8243) + * Add more log info if readMeter is null (CASSANDRA-8238) + * add check of the system wall clock time at startup (CASSANDRA-8305) + * Support for frozen collections (CASSANDRA-7859) + * Fix overflow on histogram computation (CASSANDRA-8028) + * Have paxos reuse the timestamp generation of normal queries (CASSANDRA-7801) + * Fix incremental repair not remove parent session on remote (CASSANDRA-8291) + * Improve JBOD disk utilization (CASSANDRA-7386) + * Log failed host when preparing incremental repair (CASSANDRA-8228) +Merged from 2.0: + * Expose off-heap memory usage stats (CASSANDRA-7897) * Ignore Paxos commits for truncated tables (CASSANDRA-7538) * Validate size of indexed column values (CASSANDRA-8280) * Make LCS split compaction results over all data directories (CASSANDRA-8329) http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/db/ColumnFamilyStore.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/io/sstable/SSTableReader.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/io/sstable/SSTableReader.java index 1fe4330,f0e9e65..0a34b4a --- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java +++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java @@@ -1186,7 -664,25 +1198,16 @@@ public class SSTableReader extends SSTa } /** + * Returns the amount of memory in bytes used off heap by the bloom filter. + * @return the amount of memory in bytes used off heap by the bloom filter + */ + public long getBloomFilterOffHeapSize() + { + return bf.offHeapSize(); + } + + /** - * Returns the amount of memory in bytes used off heap by the index summary. - * @return the amount of memory in bytes used off heap by the index summary - */ - public long getIndexSummaryOffHeapSize() - { - return indexSummary.offHeapSize(); - } - - /** - * @return An estimate of the number of keys in this SSTable. + * @return An estimate of the number of keys in this SSTable based on the index summary. */ public long estimatedKeys() { http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aaea248/src/java/org/apache/cassandra/tools/NodeProbe.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/tools/NodeProbe.java index 1d05887,261d416..38d0f74 --- a/src/java/org/apache/cassandra/tools/NodeProbe.java +++ b/src/java/org/apache/cassandra/tools/NodeProbe.java @@@ -970,179 -922,6 +970,183 @@@ public class NodeProbe implements AutoC return spProxy.getReadRepairRepairedBackground(); } + // JMX getters for the o.a.c.metrics API below. + /** + * Retrieve cache metrics based on the cache type (KeyCache, RowCache, or CounterCache) + * @param cacheType KeyCach, RowCache, or CounterCache + * @param metricName Capacity, Entries, HitRate, Size, Requests or Hits. + */ + public Object getCacheMetric(String cacheType, String metricName) + { + try + { + switch(metricName) + { + case "Capacity": + case "Entries": + case "HitRate": + case "Size": + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName), + JmxReporter.GaugeMBean.class).getValue(); + case "Requests": + case "Hits": + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName), + JmxReporter.MeterMBean.class).getCount(); + default: + throw new RuntimeException("Unknown cache metric name."); + + } + } + catch (MalformedObjectNameException e) + { + throw new RuntimeException(e); + } + } + + /** + * Retrieve ColumnFamily metrics + * @param ks Keyspace for which stats are to be displayed. + * @param cf ColumnFamily for which stats are to be displayed. + * @param metricName View {@link org.apache.cassandra.metrics.ColumnFamilyMetrics}. + */ + public Object getColumnFamilyMetric(String ks, String cf, String metricName) + { + try + { + String type = cf.contains(".") ? "IndexColumnFamily": "ColumnFamily"; + ObjectName oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=%s,keyspace=%s,scope=%s,name=%s", type, ks, cf, metricName)); + switch(metricName) + { + case "BloomFilterDiskSpaceUsed": + case "BloomFilterFalsePositives": + case "BloomFilterFalseRatio": ++ case "BloomFilterOffHeapMemoryUsed": ++ case "IndexSummaryOffHeapMemoryUsed": ++ case "CompressionMetadataOffHeapMemoryUsed": + case "CompressionRatio": + case "EstimatedColumnCountHistogram": + case "EstimatedRowSizeHistogram": + case "KeyCacheHitRate": + case "LiveSSTableCount": + case "MaxRowSize": + case "MeanRowSize": + case "MemtableColumnsCount": + case "MemtableLiveDataSize": ++ case "MemtableOffHeapSize": + case "MinRowSize": + case "RecentBloomFilterFalsePositives": + case "RecentBloomFilterFalseRatio": + case "SnapshotsSize": + return JMX.newMBeanProxy(mbeanServerConn, oName, JmxReporter.GaugeMBean.class).getValue(); + case "LiveDiskSpaceUsed": + case "MemtableSwitchCount": + case "SpeculativeRetries": + case "TotalDiskSpaceUsed": + case "WriteTotalLatency": + case "ReadTotalLatency": + case "PendingFlushes": + return JMX.newMBeanProxy(mbeanServerConn, oName, JmxReporter.CounterMBean.class).getCount(); + case "ReadLatency": + case "CoordinatorReadLatency": + case "CoordinatorScanLatency": + case "WriteLatency": + return JMX.newMBeanProxy(mbeanServerConn, oName, JmxReporter.TimerMBean.class); + case "LiveScannedHistogram": + case "SSTablesPerReadHistogram": + case "TombstoneScannedHistogram": + return JMX.newMBeanProxy(mbeanServerConn, oName, JmxReporter.HistogramMBean.class); + default: + throw new RuntimeException("Unknown column family metric."); + } + } + catch (MalformedObjectNameException e) + { + throw new RuntimeException(e); + } + } + + /** + * Retrieve Proxy metrics + * @param scope RangeSlice, Read or Write + */ + public JmxReporter.TimerMBean getProxyMetric(String scope) + { + try + { + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=ClientRequest,scope=" + scope + ",name=Latency"), + JmxReporter.TimerMBean.class); + } + catch (MalformedObjectNameException e) + { + throw new RuntimeException(e); + } + } + + /** + * Retrieve Proxy metrics + * @param metricName CompletedTasks, PendingTasks, BytesCompacted or TotalCompactionsCompleted. + */ + public Object getCompactionMetric(String metricName) + { + try + { + switch(metricName) + { + case "BytesCompacted": + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName), + JmxReporter.CounterMBean.class); + case "CompletedTasks": + case "PendingTasks": + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName), + JmxReporter.GaugeMBean.class).getValue(); + case "TotalCompactionsCompleted": + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName), + JmxReporter.MeterMBean.class); + default: + throw new RuntimeException("Unknown compaction metric."); + } + } + catch (MalformedObjectNameException e) + { + throw new RuntimeException(e); + } + } + + /** + * Retrieve Proxy metrics + * @param metricName Exceptions, Load, TotalHints or TotalHintsInProgress. + */ + public long getStorageMetric(String metricName) + { + try + { + return JMX.newMBeanProxy(mbeanServerConn, + new ObjectName("org.apache.cassandra.metrics:type=Storage,name=" + metricName), + JmxReporter.CounterMBean.class).getCount(); + } + catch (MalformedObjectNameException e) + { + throw new RuntimeException(e); + } + } + + public double[] metricPercentilesAsArray(JmxReporter.HistogramMBean metric) + { + return new double[]{ metric.get50thPercentile(), + metric.get75thPercentile(), + metric.get95thPercentile(), + metric.get98thPercentile(), + metric.get99thPercentile(), + metric.getMin(), + metric.getMax()}; + } + public TabularData getCompactionHistory() { return compactionProxy.getCompactionHistory();