You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2014/06/13 14:45:20 UTC
[7/8] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1
Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts:
src/java/org/apache/cassandra/db/Keyspace.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5871b26b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5871b26b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5871b26b
Branch: refs/heads/trunk
Commit: 5871b26b2983b9da7282fa81fd5c726a63e9ce77
Parents: 1e13cbf bbd130e
Author: Brandon Williams <br...@apache.org>
Authored: Thu Jun 12 18:50:28 2014 -0500
Committer: Brandon Williams <br...@apache.org>
Committed: Fri Jun 13 07:42:00 2014 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 +-
src/java/org/apache/cassandra/db/Keyspace.java | 5 +
.../cassandra/metrics/KeyspaceMetrics.java | 267 +++++++++++++++++++
3 files changed, 273 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5871b26b/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 199a0ea,576355c..4af08dd
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,25 -1,22 +1,25 @@@
-2.0.9
+2.1.0
+ * Avoid incremental compaction on Windows (CASSANDRA-7365)
+ * Fix exception when querying a composite-keyed table with a collection index
+ (CASSANDRA-7372)
+ * Use node's host id in place of counter ids (CASSANDRA-7366)
* Fix native protocol CAS batches (CASSANDRA-7337)
+ * Reduce likelihood of contention on local paxos locking (CASSANDRA-7359)
+ * Upgrade to Pig 0.12.1 (CASSANDRA-6556)
+ * Make sure we clear out repair sessions from netstats (CASSANDRA-7329)
+ * Don't fail streams on failure detector downs (CASSANDRA-3569)
+ * Add optional keyspace to DROP INDEX statement (CASSANDRA-7314)
+ * Reduce run time for CQL tests (CASSANDRA-7327)
+ * Fix heap size calculation on Windows (CASSANDRA-7352)
+ * RefCount native frames from netty (CASSANDRA-7245)
+ * Use tarball dir instead of /var for default paths (CASSANDRA-7136)
+Merged from 2.0:
* Add per-CF range read request latency metrics (CASSANDRA-7338)
* Fix NPE in StreamTransferTask.createMessageForRetry() (CASSANDRA-7323)
- * Add conditional CREATE/DROP USER support (CASSANDRA-7264)
- * Swap local and global default read repair chances (CASSANDRA-7320)
- * Add missing iso8601 patterns for date strings (CASSANDRA-6973)
- * Support selecting multiple rows in a partition using IN (CASSANDRA-6875)
- * cqlsh: always emphasize the partition key in DESC output (CASSANDRA-7274)
- * Copy compaction options to make sure they are reloaded (CASSANDRA-7290)
- * Add option to do more aggressive tombstone compactions (CASSANDRA-6563)
- * Don't try to compact already-compacting files in HHOM (CASSANDRA-7288)
- * Add authentication support to shuffle (CASSANDRA-6484)
- * Cqlsh counts non-empty lines for "Blank lines" warning (CASSANDRA-7325)
* Make StreamSession#closeSession() idempotent (CASSANDRA-7262)
* Fix infinite loop on exception while streaming (CASSANDRA-7330)
- * Reference sstables before populating key cache (CASSANDRA-7234)
Merged from 1.2:
- 1.2.17
+ * Tracke metrics at a keyspace level (CASSANDRA-6539)
* Add replace_address_first_boot flag to only replace if not bootstrapped (CASSANDRA-7356)
* Enable keepalive for native protocol (CASSANDRA-7380)
* Check internal addresses for seeds (CASSANDRA-6523)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5871b26b/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/Keyspace.java
index ae9d9ef,d92bea7..9e39952
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@@ -61,6 -55,16 +62,8 @@@ public class Keyspac
private static final Logger logger = LoggerFactory.getLogger(Keyspace.class);
- /**
- * accesses to CFS.memtable should acquire this for thread safety.
- * CFS.maybeSwitchMemtable should aquire the writeLock; see that method for the full explanation.
- * <p/>
- * (Enabling fairness in the RRWL is observed to decrease throughput, so we leave it off.)
- */
- public static final ReentrantReadWriteLock switchLock = new ReentrantReadWriteLock();
-
+ public final KeyspaceMetrics metric;
+
// It is possible to call Keyspace.open without a running daemon, so it makes sense to ensure
// proper directories here as well as in CassandraDaemon.
static
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5871b26b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
index 0000000,4a0980f..b03c32c
mode 000000,100644..100644
--- a/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
@@@ -1,0 -1,202 +1,267 @@@
+ /*
+ * 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 java.util.ArrayList;
+ import java.util.List;
+
+ import com.yammer.metrics.Metrics;
+ import com.yammer.metrics.core.*;
+ import com.yammer.metrics.stats.Snapshot;
+
+ import org.apache.cassandra.db.ColumnFamilyStore;
+ import org.apache.cassandra.db.Keyspace;
+
+ /**
+ * Metrics for {@link ColumnFamilyStore}.
+ */
+ public class KeyspaceMetrics
+ {
+ /** Total amount of data stored in the memtable, including column related overhead. */
- public final Gauge<Long> memtableDataSize;
- /** Total amount of data stored in the memtables (2i and pending flush memtables included). */
- public final Gauge<Long> allMemtablesDataSize;
++ public final Gauge<Long> memtableLiveDataSize;
++ /** Total amount of data stored in the memtable that resides on-heap, including column related overhead and overwritten rows. */
++ public final Gauge<Long> memtableOnHeapDataSize;
++ /** Total amount of data stored in the memtable that resides off-heap, including column related overhead and overwritten rows. */
++ public final Gauge<Long> memtableOffHeapDataSize;
++ /** Total amount of data stored in the memtables (2i and pending flush memtables included) that resides on-heap. */
++ public final Gauge<Long> allMemtablesOnHeapDataSize;
++ /** Total amount of data stored in the memtables (2i and pending flush memtables included) that resides off-heap. */
++ public final Gauge<Long> allMemtablesOffHeapDataSize;
++ /** Total amount of live data stored in the memtables (2i and pending flush memtables included) that resides off-heap, excluding any data structure overhead */
++ public final Gauge<Long> allMemtablesLiveDataSize;
+ /** Total number of columns present in the memtable. */
+ public final Gauge<Long> memtableColumnsCount;
+ /** Number of times flush has resulted in the memtable being switched out. */
+ public final Gauge<Long> memtableSwitchCount;
+ /** Estimated number of tasks pending for this column family */
- public final Gauge<Integer> pendingTasks;
++ public final Gauge<Integer> pendingFlushes;
+ /** Estimate of number of pending compactios for this CF */
+ public final Gauge<Integer> pendingCompactions;
+ /** Disk space used by SSTables belonging to this CF */
+ public final Gauge<Long> liveDiskSpaceUsed;
+ /** Total disk space used by SSTables belonging to this CF, including obsolete ones waiting to be GC'd */
+ public final Gauge<Long> totalDiskSpaceUsed;
+ /** Disk space used by bloom filter */
+ public final Gauge<Long> bloomFilterDiskSpaceUsed;
+
+ private final MetricNameFactory factory;
+
+ /**
+ * Creates metrics for given {@link ColumnFamilyStore}.
+ *
+ * @param ks Keyspace to measure metrics
+ */
+ public KeyspaceMetrics(final Keyspace ks)
+ {
+ factory = new KeyspaceMetricNameFactory(ks);
+
+ memtableColumnsCount = Metrics.newGauge(factory.createMetricName("MemtableColumnsCount"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long total = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
+ total += cf.metric.memtableColumnsCount.value();
+ }
+ return total;
+ }
+ });
- memtableDataSize = Metrics.newGauge(factory.createMetricName("MemtableDataSize"), new Gauge<Long>()
++ memtableOnHeapDataSize = Metrics.newGauge(factory.createMetricName("MemtableOnHeapDataSize"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long total = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
- total += cf.metric.memtableDataSize.value();
++ total += cf.metric.memtableOnHeapSize.value();
+ }
+ return total;
+ }
+ });
- allMemtablesDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesDataSize"), new Gauge<Long>()
++ memtableOffHeapDataSize = Metrics.newGauge(factory.createMetricName("MemtableOffHeapDataSize"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long total = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
- total += cf.metric.allMemtablesDataSize.value();
++ total += cf.metric.memtableOffHeapSize.value();
++ }
++ return total;
++ }
++ });
++ memtableLiveDataSize = Metrics.newGauge(factory.createMetricName("MemtableLiveDataSize"), new Gauge<Long>()
++ {
++ public Long value()
++ {
++ long total = 0;
++ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
++ {
++ total += cf.metric.memtableLiveDataSize.value();
++ }
++ return total;
++ }
++ });
++ allMemtablesOnHeapDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesOnHeapDataSize"), new Gauge<Long>()
++ {
++ public Long value()
++ {
++ long total = 0;
++ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
++ {
++ total += cf.metric.allMemtablesOnHeapSize.value();
++ }
++ return total;
++ }
++ });
++ allMemtablesOffHeapDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesOffHeapDataSize"), new Gauge<Long>()
++ {
++ public Long value()
++ {
++ long total = 0;
++ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
++ {
++ total += cf.metric.allMemtablesOffHeapSize.value();
++ }
++ return total;
++ }
++ });
++ allMemtablesLiveDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesLiveDataSize"), new Gauge<Long>()
++ {
++ public Long value()
++ {
++ long total = 0;
++ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
++ {
++ total += cf.metric.allMemtablesLiveDataSize.value();
+ }
+ return total;
+ }
+ });
+ memtableSwitchCount = Metrics.newGauge(factory.createMetricName("MemtableSwitchCount"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long sum = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ sum += cf.metric.memtableSwitchCount.count();
+ return sum;
+ }
+ });
+ pendingCompactions = Metrics.newGauge(factory.createMetricName("PendingCompactions"), new Gauge<Integer>()
+ {
+ public Integer value()
+ {
+ int sum = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
+ sum += cf.metric.pendingCompactions.value();
+ }
+ return sum;
+ }
+ });
- pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Integer>()
++ pendingFlushes = Metrics.newGauge(factory.createMetricName("PendingFlushes"), new Gauge<Integer>()
+ {
+ public Integer value()
+ {
- return Keyspace.switchLock.getQueueLength();
++ int sum = 0;
++ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
++ {
++ sum += cf.metric.pendingFlushes.count();
++ }
++ return sum;
+ }
+ });
+ liveDiskSpaceUsed = Metrics.newGauge(factory.createMetricName("LiveDiskSpaceUsed"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long sum = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
+ sum += cf.metric.liveDiskSpaceUsed.count();
+ }
+ return sum;
+ }
+ });
+ totalDiskSpaceUsed = Metrics.newGauge(factory.createMetricName("TotalDiskSpaceUsed"), new Gauge<Long>()
+ {
+ public Long value()
+ {
+ long sum = 0;
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ {
+ sum += cf.metric.totalDiskSpaceUsed.count();
+ }
+ return sum;
+ }
+ });
+ bloomFilterDiskSpaceUsed = Metrics.newGauge(factory.createMetricName("BloomFilterDiskSpaceUsed"), new Gauge<Long>()
+ {
+ public Long value()
+ {
- long total = 0;
++ long total = 0;u
+ for (ColumnFamilyStore cf : ks.getColumnFamilyStores())
+ total += cf.metric.bloomFilterDiskSpaceUsed.value();
+ return total;
+ }
+ });
+ }
+
+ /**
+ * Release all associated metrics.
+ */
+ public void release()
+ {
- Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesDataSize"));
- Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableLiveDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableOnHeapDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableOffHeapDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesOnHeapDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesOffHeapDataSize"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesLiveDataSize"));
+ Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableSwitchCount"));
- Metrics.defaultRegistry().removeMetric(factory.createMetricName("PendingTasks"));
++ Metrics.defaultRegistry().removeMetric(factory.createMetricName("PendingFlushes"));
+ Metrics.defaultRegistry().removeMetric(factory.createMetricName("LiveDiskSpaceUsed"));
+ Metrics.defaultRegistry().removeMetric(factory.createMetricName("TotalDiskSpaceUsed"));
+ Metrics.defaultRegistry().removeMetric(factory.createMetricName("BloomFilterDiskSpaceUsed"));
+ }
+
+ class KeyspaceMetricNameFactory implements MetricNameFactory
+ {
+ private final String keyspaceName;
+
+ KeyspaceMetricNameFactory(Keyspace ks)
+ {
+ this.keyspaceName = ks.getName();
+ }
+
+ public MetricName createMetricName(String metricName)
+ {
+ String groupName = ColumnFamilyMetrics.class.getPackage().getName();
+
+ StringBuilder mbeanName = new StringBuilder();
+ mbeanName.append(groupName).append(":");
+ mbeanName.append("type=Keyspace");
+ mbeanName.append(",keyspace=").append(keyspaceName);
+ mbeanName.append(",name=").append(metricName);
+
+ return new MetricName(groupName, "keyspace", metricName, keyspaceName, mbeanName.toString());
+ }
+ }
+ }