Merge branch 'cassandra-2.1' into cassandra-2.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/32bc8b0b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/32bc8b0b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/32bc8b0b Branch: refs/heads/cassandra-3.0 Commit: 32bc8b0b182176f0132522f821a1b13919efc63a Parents: 5c59d5a 20f12e9 Author: Yuki Morishita <[email protected]> Authored: Wed Aug 5 16:10:22 2015 -0500 Committer: Yuki Morishita <[email protected]> Committed: Wed Aug 5 16:10:22 2015 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/tools/NodeProbe.java | 16 ++------------ .../apache/cassandra/tools/nodetool/Info.java | 23 ++++++++++++++------ 3 files changed, 19 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/32bc8b0b/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 66e5a0c,9a475ea..72ad3cd --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,27 -1,8 +1,28 @@@ -2.1.9 +2.2.1 + * Log warning when using an aggregate without partition key (CASSANDRA-9737) + * Avoid grouping sstables for anticompaction with DTCS (CASSANDRA-9900) + * UDF / UDA execution time in trace (CASSANDRA-9723) + * Fix broken internode SSL (CASSANDRA-9884) +Merged from 2.1: * Cannot replace token does not exist - DN node removed as Fat Client (CASSANDRA-9871) * Fix handling of enable/disable autocompaction (CASSANDRA-9899) - * Commit log segment recycling is disabled by default (CASSANDRA-9896) * Add consistency level to tracing ouput (CASSANDRA-9827) + * Remove repair snapshot leftover on startup (CASSANDRA-7357) + * Use random nodes for batch log when only 2 racks (CASSANDRA-8735) + * Ensure atomicity inside thrift and stream session (CASSANDRA-7757) ++ * Fix nodetool info error when the node is not joined (CASSANDRA-9031) +Merged from 2.0: + * Log when messages are dropped due to cross_node_timeout (CASSANDRA-9793) + * Don't track hotness when opening from snapshot for validation (CASSANDRA-9382) + + +2.2.0 + * Allow the selection of columns together with aggregates (CASSANDRA-9767) + * Fix cqlsh copy methods and other windows specific issues (CASSANDRA-9795) + * Don't wrap byte arrays in SequentialWriter (CASSANDRA-9797) + * sum() and avg() functions missing for smallint and tinyint types (CASSANDRA-9671) + * Revert CASSANDRA-9542 (allow native functions in UDA) (CASSANDRA-9771) +Merged from 2.1: * Fix MarshalException when upgrading superColumn family (CASSANDRA-9582) * Fix broken logging for "empty" flushes in Memtable (CASSANDRA-9837) * Handle corrupt files on startup (CASSANDRA-9686) http://git-wip-us.apache.org/repos/asf/cassandra/blob/32bc8b0b/src/java/org/apache/cassandra/tools/NodeProbe.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/32bc8b0b/src/java/org/apache/cassandra/tools/nodetool/Info.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/tools/nodetool/Info.java index 5852fc7,0000000..0d9bd73 mode 100644,000000..100644 --- a/src/java/org/apache/cassandra/tools/nodetool/Info.java +++ b/src/java/org/apache/cassandra/tools/nodetool/Info.java @@@ -1,153 -1,0 +1,162 @@@ +/* + * 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.tools.nodetool; + +import io.airlift.command.Command; +import io.airlift.command.Option; + +import java.lang.management.MemoryUsage; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.management.InstanceNotFoundException; + +import org.apache.cassandra.db.ColumnFamilyStoreMBean; +import org.apache.cassandra.io.util.FileUtils; +import org.apache.cassandra.service.CacheServiceMBean; +import org.apache.cassandra.tools.NodeProbe; +import org.apache.cassandra.tools.NodeTool.NodeToolCmd; + +@Command(name = "info", description = "Print node information (uptime, load, ...)") +public class Info extends NodeToolCmd +{ + @Option(name = {"-T", "--tokens"}, description = "Display all tokens") + private boolean tokens = false; + + @Override + public void execute(NodeProbe probe) + { + boolean gossipInitialized = probe.isInitialized(); + + System.out.printf("%-23s: %s%n", "ID", probe.getLocalHostId()); + System.out.printf("%-23s: %s%n", "Gossip active", gossipInitialized); + System.out.printf("%-23s: %s%n", "Thrift active", probe.isThriftServerRunning()); + System.out.printf("%-23s: %s%n", "Native Transport active", probe.isNativeTransportRunning()); + System.out.printf("%-23s: %s%n", "Load", probe.getLoadString()); + if (gossipInitialized) + System.out.printf("%-23s: %s%n", "Generation No", probe.getCurrentGenerationNumber()); + else + System.out.printf("%-23s: %s%n", "Generation No", 0); + + // Uptime + long secondsUp = probe.getUptime() / 1000; + System.out.printf("%-23s: %d%n", "Uptime (seconds)", secondsUp); + + // Memory usage + MemoryUsage heapUsage = probe.getHeapMemoryUsage(); + double memUsed = (double) heapUsage.getUsed() / (1024 * 1024); + double memMax = (double) heapUsage.getMax() / (1024 * 1024); + System.out.printf("%-23s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax); + try + { + System.out.printf("%-23s: %.2f%n", "Off Heap Memory (MB)", getOffHeapMemoryUsed(probe)); + } + catch (RuntimeException e) + { + // offheap-metrics introduced in 2.1.3 - older versions do not have the appropriate mbeans + if (!(e.getCause() instanceof InstanceNotFoundException)) + throw e; + } + + // Data Center/Rack + System.out.printf("%-23s: %s%n", "Data Center", probe.getDataCenter()); + System.out.printf("%-23s: %s%n", "Rack", probe.getRack()); + + // Exceptions + System.out.printf("%-23s: %s%n", "Exceptions", probe.getStorageMetric("Exceptions")); + + CacheServiceMBean cacheService = probe.getCacheServiceMBean(); + + // Key Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds + System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", + "Key Cache", + probe.getCacheMetric("KeyCache", "Entries"), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Size")), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Capacity")), + probe.getCacheMetric("KeyCache", "Hits"), + probe.getCacheMetric("KeyCache", "Requests"), + probe.getCacheMetric("KeyCache", "HitRate"), + cacheService.getKeyCacheSavePeriodInSeconds()); + + // Row Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds + System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", + "Row Cache", + probe.getCacheMetric("RowCache", "Entries"), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("RowCache", "Size")), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("RowCache", "Capacity")), + probe.getCacheMetric("RowCache", "Hits"), + probe.getCacheMetric("RowCache", "Requests"), + probe.getCacheMetric("RowCache", "HitRate"), + cacheService.getRowCacheSavePeriodInSeconds()); + + // Counter Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds + System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", + "Counter Cache", + probe.getCacheMetric("CounterCache", "Entries"), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("CounterCache", "Size")), + FileUtils.stringifyFileSize((long) probe.getCacheMetric("CounterCache", "Capacity")), + probe.getCacheMetric("CounterCache", "Hits"), + probe.getCacheMetric("CounterCache", "Requests"), + probe.getCacheMetric("CounterCache", "HitRate"), + cacheService.getCounterCacheSavePeriodInSeconds()); + - // Tokens - List<String> tokens = probe.getTokens(); - if (tokens.size() == 1 || this.tokens) - for (String token : tokens) - System.out.printf("%-23s: %s%n", "Token", token); ++ // check if node is already joined, before getting tokens, since it throws exception if not. ++ if (probe.isJoined()) ++ { ++ // Tokens ++ List<String> tokens = probe.getTokens(); ++ if (tokens.size() == 1 || this.tokens) ++ for (String token : tokens) ++ System.out.printf("%-23s: %s%n", "Token", token); ++ else ++ System.out.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n", "Token", ++ tokens.size()); ++ } + else - System.out.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n", "Token", tokens.size()); ++ { ++ System.out.printf("%-23s: (node is not joined to the cluster)%n", "Token"); ++ } + } + + /** + * Returns the total off heap memory used in MB. + * @return the total off heap memory used in MB. + */ + private static double getOffHeapMemoryUsed(NodeProbe probe) + { + long offHeapMemUsedInBytes = 0; + // get a list of column family stores + Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies(); + + while (cfamilies.hasNext()) + { + Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next(); + String keyspaceName = entry.getKey(); + String cfName = entry.getValue().getColumnFamilyName(); + + offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "MemtableOffHeapSize"); + offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "BloomFilterOffHeapMemoryUsed"); + offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "IndexSummaryOffHeapMemoryUsed"); + offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "CompressionMetadataOffHeapMemoryUsed"); + } + + return offHeapMemUsedInBytes / (1024d * 1024); + } - } ++}
