Merge branch 'cassandra-3.0' into cassandra-3.7

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f000ff08
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f000ff08
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f000ff08

Branch: refs/heads/cassandra-3.7
Commit: f000ff08fde7a9b477d26ca1eea9bbe550564090
Parents: f40c632 4aaf2b3
Author: Yuki Morishita <[email protected]>
Authored: Tue May 31 17:03:23 2016 -0500
Committer: Yuki Morishita <[email protected]>
Committed: Tue May 31 17:03:23 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 src/java/org/apache/cassandra/tools/nodetool/TableStats.java | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f000ff08/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f000ff08/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/tools/nodetool/TableStats.java
index 01cd1c3,bb7f192..c457fb5
--- a/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/TableStats.java
@@@ -147,80 -179,61 +147,86 @@@ public class TableStats extends NodeToo
                          throw e;
                  }
  
 -                System.out.println("\t\tSpace used (live): " + format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "LiveDiskSpaceUsed"), 
humanReadable));
 -                System.out.println("\t\tSpace used (total): " + format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "TotalDiskSpaceUsed"), 
humanReadable));
 -                System.out.println("\t\tSpace used by snapshots (total): " + 
format((Long) probe.getColumnFamilyMetric(keyspaceName, tableName, 
"SnapshotsSize"), humanReadable));
 +                statsTable.spaceUsedLive = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "LiveDiskSpaceUsed"), 
humanReadable);
 +                statsTable.spaceUsedTotal = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "TotalDiskSpaceUsed"), 
humanReadable);
 +                statsTable.spaceUsedBySnapshotsTotal = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "SnapshotsSize"), 
humanReadable);
                  if (offHeapSize != null)
 -                    System.out.println("\t\tOff heap memory used (total): " + 
format(offHeapSize, humanReadable));
 -                System.out.println("\t\tSSTable Compression Ratio: " + 
probe.getColumnFamilyMetric(keyspaceName, tableName, "CompressionRatio"));
 +                {
 +                    statsTable.offHeapUsed = true;
 +                    statsTable.offHeapMemoryUsedTotal = format(offHeapSize, 
humanReadable);
  
 +                }
 +                statsTable.sstableCompressionRatio = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "CompressionRatio");
-                 statsTable.numberOfKeysEstimate = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "EstimatedPartitionCount");
+                 Object estimatedPartitionCount = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "EstimatedPartitionCount");
+                 if (Long.valueOf(-1L).equals(estimatedPartitionCount))
+                 {
+                     estimatedPartitionCount = 0L;
+                 }
 -                System.out.println("\t\tNumber of keys (estimate): " + 
estimatedPartitionCount);
++                statsTable.numberOfKeysEstimate = estimatedPartitionCount;
+ 
 -                System.out.println("\t\tMemtable cell count: " + 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableColumnsCount"));
 -                System.out.println("\t\tMemtable data size: " + format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableLiveDataSize"), 
humanReadable));
 +                statsTable.memtableCellCount = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableColumnsCount");
 +                statsTable.memtableDataSize = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableLiveDataSize"), 
humanReadable);
                  if (memtableOffHeapSize != null)
 -                    System.out.println("\t\tMemtable off heap memory used: " 
+ format(memtableOffHeapSize, humanReadable));
 -                System.out.println("\t\tMemtable switch count: " + 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableSwitchCount"));
 -                System.out.println("\t\tLocal read count: " + 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"ReadLatency")).getCount());
 +                {
 +                    statsTable.memtableOffHeapUsed = true;
 +                    statsTable.memtableOffHeapMemoryUsed = 
format(memtableOffHeapSize, humanReadable);
 +                }
 +                statsTable.memtableSwitchCount = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableSwitchCount");
 +                statsTable.localReadCount = 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "ReadLatency")).getCount();
 +
                  double localReadLatency = 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "ReadLatency")).getMean() 
/ 1000;
                  double localRLatency = localReadLatency > 0 ? 
localReadLatency : Double.NaN;
 -                System.out.printf("\t\tLocal read latency: %01.3f ms%n", 
localRLatency);
 -                System.out.println("\t\tLocal write count: " + 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"WriteLatency")).getCount());
 +                statsTable.localReadLatencyMs = localRLatency;
 +                statsTable.localWriteCount = 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"WriteLatency")).getCount();
 +
                  double localWriteLatency = 
((CassandraMetricsRegistry.JmxTimerMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "WriteLatency")).getMean() 
/ 1000;
                  double localWLatency = localWriteLatency > 0 ? 
localWriteLatency : Double.NaN;
 -                System.out.printf("\t\tLocal write latency: %01.3f ms%n", 
localWLatency);
 -                System.out.println("\t\tPending flushes: " + 
probe.getColumnFamilyMetric(keyspaceName, tableName, "PendingFlushes"));
 -                System.out.println("\t\tBloom filter false positives: " + 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"BloomFilterFalsePositives"));
 -                System.out.printf("\t\tBloom filter false ratio: %s%n", 
String.format("%01.5f", probe.getColumnFamilyMetric(keyspaceName, tableName, 
"RecentBloomFilterFalseRatio")));
 -                System.out.println("\t\tBloom filter space used: " + 
format((Long) probe.getColumnFamilyMetric(keyspaceName, tableName, 
"BloomFilterDiskSpaceUsed"), humanReadable));
 +                statsTable.localWriteLatencyMs = localWLatency;
 +                statsTable.pendingFlushes = 
probe.getColumnFamilyMetric(keyspaceName, tableName, "PendingFlushes");
 +
 +                statsTable.bloomFilterFalsePositives = 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"BloomFilterFalsePositives");
 +                statsTable.bloomFilterFalseRatio = 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"RecentBloomFilterFalseRatio");
 +                statsTable.bloomFilterSpaceUsed = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"BloomFilterDiskSpaceUsed"), humanReadable);
 +
                  if (bloomFilterOffHeapSize != null)
 -                    System.out.println("\t\tBloom filter off heap memory 
used: " + format(bloomFilterOffHeapSize, humanReadable));
 +                {
 +                    statsTable.bloomFilterOffHeapUsed = true;
 +                    statsTable.bloomFilterOffHeapMemoryUsed = 
format(bloomFilterOffHeapSize, humanReadable);
 +                }
 +
                  if (indexSummaryOffHeapSize != null)
 -                    System.out.println("\t\tIndex summary off heap memory 
used: " + format(indexSummaryOffHeapSize, humanReadable));
 +                {
 +                    statsTable.indexSummaryOffHeapUsed = true;
 +                    statsTable.indexSummaryOffHeapMemoryUsed = 
format(indexSummaryOffHeapSize, humanReadable);
 +                }
                  if (compressionMetadataOffHeapSize != null)
 -                    System.out.println("\t\tCompression metadata off heap 
memory used: " + format(compressionMetadataOffHeapSize, humanReadable));
 +                {
 +                    statsTable.compressionMetadataOffHeapUsed = true;
 +                    statsTable.compressionMetadataOffHeapMemoryUsed = 
format(compressionMetadataOffHeapSize, humanReadable);
 +                }
 +                statsTable.compactedPartitionMinimumBytes = (Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MinPartitionSize");
 +                statsTable.compactedPartitionMaximumBytes = (Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MaxPartitionSize");
 +                statsTable.compactedPartitionMeanBytes = (Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "MeanPartitionSize");
  
 -                System.out.println("\t\tCompacted partition minimum bytes: " 
+ format((Long) probe.getColumnFamilyMetric(keyspaceName, tableName, 
"MinPartitionSize"), humanReadable));
 -                System.out.println("\t\tCompacted partition maximum bytes: " 
+ format((Long) probe.getColumnFamilyMetric(keyspaceName, tableName, 
"MaxPartitionSize"), humanReadable));
 -                System.out.println("\t\tCompacted partition mean bytes: " + 
format((Long) probe.getColumnFamilyMetric(keyspaceName, tableName, 
"MeanPartitionSize"), humanReadable));
                  CassandraMetricsRegistry.JmxHistogramMBean histogram = 
(CassandraMetricsRegistry.JmxHistogramMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "LiveScannedHistogram");
 -                System.out.println("\t\tAverage live cells per slice (last 
five minutes): " + histogram.getMean());
 -                System.out.println("\t\tMaximum live cells per slice (last 
five minutes): " + histogram.getMax());
 -                histogram = (CassandraMetricsRegistry.JmxHistogramMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"TombstoneScannedHistogram");
 -                System.out.println("\t\tAverage tombstones per slice (last 
five minutes): " + histogram.getMean());
 -                System.out.println("\t\tMaximum tombstones per slice (last 
five minutes): " + histogram.getMax());
 +                statsTable.averageLiveCellsPerSliceLastFiveMinutes = 
histogram.getMean();
 +                statsTable.maximumLiveCellsPerSliceLastFiveMinutes = 
histogram.getMax();
  
 -                System.out.println("");
 +                histogram = (CassandraMetricsRegistry.JmxHistogramMBean) 
probe.getColumnFamilyMetric(keyspaceName, tableName, 
"TombstoneScannedHistogram");
 +                statsTable.averageTombstonesPerSliceLastFiveMinutes = 
histogram.getMean();
 +                statsTable.maximumTombstonesPerSliceLastFiveMinutes = 
histogram.getMax();
 +                statsTable.droppedMutations = format((Long) 
probe.getColumnFamilyMetric(keyspaceName, tableName, "DroppedMutations"), 
humanReadable);
 +                statsKeyspace.tables.add(statsTable);
              }
 -            System.out.println("----------------");
 +            holder.keyspaces.add(statsKeyspace);
          }
 +        // print out the keyspace and table statistics
 +        TableStatsPrinter printer = TableStatsPrinter.from(outputFormat);
 +        printer.print(holder, System.out);
      }
  
 -    private String format(long bytes, boolean humanReadable) {
 +    private String format(long bytes, boolean humanReadable)
 +    {
          return humanReadable ? FileUtils.stringifyFileSize(bytes) : 
Long.toString(bytes);
      }
  

Reply via email to