Updated Branches: refs/heads/trunk a850abd16 -> 02b59eb1f
merge from 1.1 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/02b59eb1 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/02b59eb1 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/02b59eb1 Branch: refs/heads/trunk Commit: 02b59eb1fe4764bd2df5ad054c0173b9f8b6eb10 Parents: a850abd 99b245d Author: Jonathan Ellis <[email protected]> Authored: Tue Oct 30 10:39:29 2012 -0500 Committer: Jonathan Ellis <[email protected]> Committed: Tue Oct 30 10:41:34 2012 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 + .../cassandra/db/marshal/DynamicCompositeType.java | 20 +++- .../org/apache/cassandra/metrics/CacheMetrics.java | 15 ++- .../org/apache/cassandra/service/CacheService.java | 14 ++- .../cassandra/service/CacheServiceMBean.java | 92 ++++++++++----- 5 files changed, 105 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/02b59eb1/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 1416351,e69298f..69b4daa --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,47 -1,5 +1,48 @@@ -1.1.7 +1.2-beta2 + * add extension point for sstable components (CASSANDRA-4049) + * improve tracing output (CASSANDRA-4852, 4862) + * make TRACE verb droppable (CASSANDRA-4672) + * fix BulkLoader recognition of CQL3 columnfamilies (CASSANDRA-4755) + * Sort commitlog segments for replay by id instead of mtime (CASSANDRA-4793) + * Make hint delivery asynchronous (CASSANDRA-4761) + * Pluggable Thrift transport factories for CLI and cqlsh (CASSANDRA-4609, 4610) + * cassandra-cli: allow Double value type to be inserted to a column (CASSANDRA-4661) + * Add ability to use custom TServerFactory implementations (CASSANDRA-4608) + * optimize batchlog flushing to skip successful batches (CASSANDRA-4667) + * include metadata for system keyspace itself in schema tables (CASSANDRA-4416) + * add check to PropertyFileSnitch to verify presence of location for + local node (CASSANDRA-4728) + * add PBSPredictor consistency modeler (CASSANDRA-4261) + * remove vestiges of Thrift unframed mode (CASSANDRA-4729) + * optimize single-row PK lookups (CASSANDRA-4710) + * adjust blockFor calculation to account for pending ranges due to node + movement (CASSANDRA-833) + * Change CQL version to 3.0.0 and stop accepting 3.0.0-beta1 (CASSANDRA-4649) + * (CQL3) Make prepared statement global instead of per connection + (CASSANDRA-4449) + * Fix scrubbing of CQL3 created tables (CASSANDRA-4685) + * (CQL3) Fix validation when using counter and regular columns in the same + table (CASSANDRA-4706) + * Fix bug starting Cassandra with simple authentication (CASSANDRA-4648) + * Add support for batchlog in CQL3 (CASSANDRA-4545, 4738) + * Add support for multiple column family outputs in CFOF (CASSANDRA-4208) + * Support repairing only the local DC nodes (CASSANDRA-4747) + * Use rpc_address for binary protocol and change default port (CASSANRA-4751) + * Fix use of collections in prepared statements (CASSANDRA-4739) + * Store more information into peers table (CASSANDRA-4351, 4814) + * Configurable bucket size for size tiered compaction (CASSANDRA-4704) + * Run leveled compaction in parallel (CASSANDRA-4310) + * Fix potential NPE during CFS reload (CASSANDRA-4786) + * Composite indexes may miss results (CASSANDRA-4796) + * Move consistency level to the protocol level (CASSANDRA-4734, 4824) + * Fix Subcolumn slice ends not respected (CASSANDRA-4826) + * Fix Assertion error in cql3 select (CASSANDRA-4783) + * Fix list prepend logic (CQL3) (CASSANDRA-4835) + * Add booleans as literals in CQL3 (CASSANDRA-4776) + * Allow renaming PK columns in CQL3 (CASSANDRA-4822) + * Fix binary protocol NEW_NODE event (CASSANDRA-4679) +Merged from 1.1: + * add get[Row|Key]CacheEntries to CacheServiceMBean (CASSANDRA-4859) * fix get_paged_slice to wrap to next row correctly (CASSANDRA-4816) * fix indexing empty column values (CASSANDRA-4832) * allow JdbcDate to compose null Date objects (CASSANDRA-4830) @@@ -52,77 -10,9 +53,78 @@@ * fix potential infinite loop in get_count (CASSANDRA-4833) * fix compositeType.{get/from}String methods (CASSANDRA-4842) * (CQL) fix CREATE COLUMNFAMILY permissions check (CASSANDRA-4864) + * Fix DynamicCompositeType same type comparison (CASSANDRA-4711) + +1.2-beta1 + * add atomic_batch_mutate (CASSANDRA-4542, -4635) + * increase default max_hint_window_in_ms to 3h (CASSANDRA-4632) + * include message initiation time to replicas so they can more + accurately drop timed-out requests (CASSANDRA-2858) + * fix clientutil.jar dependencies (CASSANDRA-4566) + * optimize WriteResponse (CASSANDRA-4548) + * new metrics (CASSANDRA-4009) + * redesign KEYS indexes to avoid read-before-write (CASSANDRA-2897) + * debug tracing (CASSANDRA-1123) + * parallelize row cache loading (CASSANDRA-4282) + * Make compaction, flush JBOD-aware (CASSANDRA-4292) + * run local range scans on the read stage (CASSANDRA-3687) + * clean up ioexceptions (CASSANDRA-2116) + * add disk_failure_policy (CASSANDRA-2118) + * Introduce new json format with row level deletion (CASSANDRA-4054) + * remove redundant "name" column from schema_keyspaces (CASSANDRA-4433) + * improve "nodetool ring" handling of multi-dc clusters (CASSANDRA-3047) + * update NTS calculateNaturalEndpoints to be O(N log N) (CASSANDRA-3881) + * add UseCondCardMark XX jvm settings on jdk 1.7 (CASSANDRA-4366) + * split up rpc timeout by operation type (CASSANDRA-2819) + * rewrite key cache save/load to use only sequential i/o (CASSANDRA-3762) + * update MS protocol with a version handshake + broadcast address id + (CASSANDRA-4311) + * multithreaded hint replay (CASSANDRA-4189) + * add inter-node message compression (CASSANDRA-3127) + * remove COPP (CASSANDRA-2479) + * Track tombstone expiration and compact when tombstone content is + higher than a configurable threshold, default 20% (CASSANDRA-3442, 4234) + * update MurmurHash to version 3 (CASSANDRA-2975) + * (CLI) track elapsed time for `delete' operation (CASSANDRA-4060) + * (CLI) jline version is bumped to 1.0 to properly support + 'delete' key function (CASSANDRA-4132) + * Save IndexSummary into new SSTable 'Summary' component (CASSANDRA-2392, 4289) + * Add support for range tombstones (CASSANDRA-3708) + * Improve MessagingService efficiency (CASSANDRA-3617) + * Avoid ID conflicts from concurrent schema changes (CASSANDRA-3794) + * Set thrift HSHA server thread limit to unlimited by default (CASSANDRA-4277) + * Avoids double serialization of CF id in RowMutation messages + (CASSANDRA-4293) + * stream compressed sstables directly with java nio (CASSANDRA-4297) + * Support multiple ranges in SliceQueryFilter (CASSANDRA-3885) + * Add column metadata to system column families (CASSANDRA-4018) + * (cql3) Always use composite types by default (CASSANDRA-4329) + * (cql3) Add support for set, map and list (CASSANDRA-3647) + * Validate date type correctly (CASSANDRA-4441) + * (cql3) Allow definitions with only a PK (CASSANDRA-4361) + * (cql3) Add support for row key composites (CASSANDRA-4179) + * improve DynamicEndpointSnitch by using reservoir sampling (CASSANDRA-4038) + * (cql3) Add support for 2ndary indexes (CASSANDRA-3680) + * (cql3) fix defining more than one PK to be invalid (CASSANDRA-4477) + * remove schema agreement checking from all external APIs (Thrift, CQL and CQL3) (CASSANDRA-4487) + * add Murmur3Partitioner and make it default for new installations (CASSANDRA-3772, 4621) + * (cql3) update pseudo-map syntax to use map syntax (CASSANDRA-4497) + * Finer grained exceptions hierarchy and provides error code with exceptions (CASSANDRA-3979) + * Adds events push to binary protocol (CASSANDRA-4480) + * Rewrite nodetool help (CASSANDRA-2293) + * Make CQL3 the default for CQL (CASSANDRA-4640) + * update stress tool to be able to use CQL3 (CASSANDRA-4406) + * Accept all thrift update on CQL3 cf but don't expose their metadata (CASSANDRA-4377) + * Replace Throttle with Guava's RateLimiter for HintedHandOff (CASSANDRA-4541) + * fix counter add/get using CQL2 and CQL3 in stress tool (CASSANDRA-4633) + * Add sstable count per level to cfstats (CASSANDRA-4537) + * (cql3) Add ALTER KEYSPACE statement (CASSANDRA-4611) + * (cql3) Allow defining default consistency levels (CASSANDRA-4448) + * (cql3) Fix queries using LIMIT missing results (CASSANDRA-4579) + * fix cross-version gossip messaging (CASSANDRA-4576) + 1.1.6 * Wait for writes on synchronous read digest mismatch (CASSANDRA-4792) * fix commitlog replay for nanotime-infected sstables (CASSANDRA-4782) http://git-wip-us.apache.org/repos/asf/cassandra/blob/02b59eb1/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/02b59eb1/src/java/org/apache/cassandra/metrics/CacheMetrics.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/metrics/CacheMetrics.java index 7891998,0000000..3157511 mode 100644,000000..100644 --- a/src/java/org/apache/cassandra/metrics/CacheMetrics.java +++ b/src/java/org/apache/cassandra/metrics/CacheMetrics.java @@@ -1,107 -1,0 +1,116 @@@ +/* + * 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.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + +import com.yammer.metrics.Metrics; +import com.yammer.metrics.core.Gauge; +import com.yammer.metrics.core.Meter; +import com.yammer.metrics.core.MetricName; +import com.yammer.metrics.util.RatioGauge; + +import org.apache.cassandra.cache.ICache; + +/** + * Metrics for {@code ICache}. + */ +public class CacheMetrics +{ + public static final String GROUP_NAME = "org.apache.cassandra.metrics"; + public static final String TYPE_NAME = "Cache"; + + /** Cache capacity in bytes */ - public final Gauge<Long> capacityInBytes; ++ public final Gauge<Long> capacity; + /** Total number of cache hits */ + public final Meter hits; + /** Total number of cache requests */ + public final Meter requests; + /** cache hit rate */ + public final Gauge<Double> hitRate; - /** Total size of cache */ ++ /** Total size of cache, in bytes */ + public final Gauge<Long> size; ++ /** Total number of cache entries */ ++ public final Gauge<Integer> entries; + + private final AtomicLong lastRequests = new AtomicLong(0); + private final AtomicLong lastHits = new AtomicLong(0); + + /** + * Create metrics for given cache. + * + * @param type Type of Cache to identify metrics. + * @param cache Cache to measure metrics + */ + public CacheMetrics(String type, final ICache cache) + { - capacityInBytes = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CapacityInBytes", type), new Gauge<Long>() ++ capacity = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Capacity", type), new Gauge<Long>() + { + public Long value() + { + return cache.capacity(); + } + }); + hits = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Hits", type), "hits", TimeUnit.SECONDS); + requests = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Requests", type), "requests", TimeUnit.SECONDS); + hitRate = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "HitRate", type), new RatioGauge() + { + protected double getNumerator() + { + return hits.count(); + } + + protected double getDenominator() + { + return requests.count(); + } + }); + size = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Size", type), new Gauge<Long>() + { + public Long value() + { + return cache.weightedSize(); + } + }); ++ entries = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Entries", type), new Gauge<Integer>() ++ { ++ public Integer value() ++ { ++ return cache.size(); ++ } ++ }); + } + + // for backward compatibility + @Deprecated + public double getRecentHitRate() + { + long r = requests.count(); + long h = hits.count(); + try + { + return ((double)(h - lastHits.get())) / (r - lastRequests.get()); + } + finally + { + lastRequests.set(r); + lastHits.set(h); + } + } +} http://git-wip-us.apache.org/repos/asf/cassandra/blob/02b59eb1/src/java/org/apache/cassandra/service/CacheService.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/service/CacheService.java index ee39406,d63e775..21f007c --- a/src/java/org/apache/cassandra/service/CacheService.java +++ b/src/java/org/apache/cassandra/service/CacheService.java @@@ -242,7 -209,7 +242,7 @@@ public class CacheService implements Ca public long getRowCacheCapacityInBytes() { - return rowCache.getMetrics().capacityInBytes.value(); - return rowCache.getCapacity(); ++ return rowCache.getMetrics().capacity.value(); } public long getRowCacheCapacityInMB() @@@ -260,7 -227,7 +260,7 @@@ public long getKeyCacheCapacityInBytes() { - return keyCache.getMetrics().capacityInBytes.value(); - return keyCache.getCapacity() * AVERAGE_KEY_CACHE_ROW_SIZE; ++ return keyCache.getMetrics().capacity.value(); } public long getKeyCacheCapacityInMB() @@@ -279,14 -245,24 +279,24 @@@ public long getRowCacheSize() { - return rowCache.weightedSize(); + return rowCache.getMetrics().size.value(); } + public long getRowCacheEntries() + { + return rowCache.size(); + } + public long getKeyCacheSize() { - return keyCache.weightedSize() * AVERAGE_KEY_CACHE_ROW_SIZE; + return keyCache.getMetrics().size.value(); } + public long getKeyCacheEntries() + { + return keyCache.size(); + } + public void reduceCacheSizes() { reduceRowCacheSize(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/02b59eb1/src/java/org/apache/cassandra/service/CacheServiceMBean.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/service/CacheServiceMBean.java index a34d5ed,ccc7a42..8b8adf2 --- a/src/java/org/apache/cassandra/service/CacheServiceMBean.java +++ b/src/java/org/apache/cassandra/service/CacheServiceMBean.java @@@ -21,84 -21,55 +21,122 @@@ import java.util.concurrent.ExecutionEx public interface CacheServiceMBean { - public long getKeyCacheHits(); - public long getRowCacheHits(); - - public long getKeyCacheRequests(); - public long getRowCacheRequests(); - - public double getKeyCacheRecentHitRate(); - public double getRowCacheRecentHitRate(); - + public int getRowCacheSavePeriodInSeconds(); + public void setRowCacheSavePeriodInSeconds(int rcspis); + + public int getKeyCacheSavePeriodInSeconds(); + public void setKeyCacheSavePeriodInSeconds(int kcspis); + + /** + * invalidate the key cache; for use after invalidating row cache + */ + public void invalidateKeyCache(); + + /** + * invalidate the row cache; for use after bulk loading via BinaryMemtable + */ + public void invalidateRowCache(); + - public long getRowCacheCapacityInMB(); - public long getRowCacheCapacityInBytes(); + public void setRowCacheCapacityInMB(long capacity); + - public long getKeyCacheCapacityInMB(); - public long getKeyCacheCapacityInBytes(); + public void setKeyCacheCapacityInMB(long capacity); + - public long getRowCacheSize(); // in bytes - public long getRowCacheEntries(); - - public long getKeyCacheSize(); - public long getKeyCacheEntries(); - + /** + * sets each cache's maximum capacity to "reduce_cache_capacity_to" of its current size + */ + public void reduceCacheSizes(); + + /** + * save row and key caches + * + * @throws ExecutionException when attempting to retrieve the result of a task that aborted by throwing an exception + * @throws InterruptedException when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. + */ + public void saveCaches() throws ExecutionException, InterruptedException; ++ ++ // ++ // remaining methods are provided for backwards compatibility; modern clients should use CacheMetrics instead ++ // ++ + /** + * @see org.apache.cassandra.metrics.CacheMetrics#hits + */ + @Deprecated + public long getKeyCacheHits(); ++ ++ /** ++ * @see org.apache.cassandra.metrics.CacheMetrics#hits ++ */ + @Deprecated + public long getRowCacheHits(); + + /** + * @see org.apache.cassandra.metrics.CacheMetrics#requests + */ + @Deprecated + public long getKeyCacheRequests(); ++ ++ /** ++ * @see org.apache.cassandra.metrics.CacheMetrics#requests ++ */ + @Deprecated + public long getRowCacheRequests(); + + /** - * @see org.apache.cassandra.metrics.CacheMetrics#recentHitRate ++ * @see org.apache.cassandra.metrics.CacheMetrics#hitRate + */ + @Deprecated + public double getKeyCacheRecentHitRate(); - @Deprecated - public double getRowCacheRecentHitRate(); - - public int getRowCacheSavePeriodInSeconds(); - public void setRowCacheSavePeriodInSeconds(int rcspis); - - public int getKeyCacheSavePeriodInSeconds(); - public void setKeyCacheSavePeriodInSeconds(int kcspis); + + /** - * invalidate the key cache; for use after invalidating row cache ++ * @see org.apache.cassandra.metrics.CacheMetrics#hitRate + */ - public void invalidateKeyCache(); ++ @Deprecated ++ public double getRowCacheRecentHitRate(); + + /** - * invalidate the row cache; for use after bulk loading via BinaryMemtable ++ * @see org.apache.cassandra.metrics.CacheMetrics#capacity + */ - public void invalidateRowCache(); - ++ @Deprecated + public long getRowCacheCapacityInMB(); + /** - * @see org.apache.cassandra.metrics.CacheMetrics#capacityInBytes ++ * @see org.apache.cassandra.metrics.CacheMetrics#capacity + */ + @Deprecated + public long getRowCacheCapacityInBytes(); - public void setRowCacheCapacityInMB(long capacity); + ++ /** ++ * @see org.apache.cassandra.metrics.CacheMetrics#capacity ++ */ ++ @Deprecated + public long getKeyCacheCapacityInMB(); + /** - * @see org.apache.cassandra.metrics.CacheMetrics#capacityInBytes ++ * @see org.apache.cassandra.metrics.CacheMetrics#capacity + */ + @Deprecated + public long getKeyCacheCapacityInBytes(); - public void setKeyCacheCapacityInMB(long capacity); + + /** + * @see org.apache.cassandra.metrics.CacheMetrics#size + */ + @Deprecated + public long getRowCacheSize(); + + /** - * @see org.apache.cassandra.metrics.CacheMetrics#size ++ * @see org.apache.cassandra.metrics.CacheMetrics#entries + */ + @Deprecated - public long getKeyCacheSize(); ++ public long getRowCacheEntries(); + + /** - * sets each cache's maximum capacity to "reduce_cache_capacity_to" of its current size ++ * @see org.apache.cassandra.metrics.CacheMetrics#size + */ - public void reduceCacheSizes(); ++ @Deprecated ++ public long getKeyCacheSize(); + + /** - * save row and key caches - * - * @throws ExecutionException when attempting to retrieve the result of a task that aborted by throwing an exception - * @throws InterruptedException when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. ++ * @see org.apache.cassandra.metrics.CacheMetrics#entries + */ - public void saveCaches() throws ExecutionException, InterruptedException; ++ @Deprecated ++ public long getKeyCacheEntries(); }
