This is an automated email from the ASF dual-hosted git repository.

adelapena pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 976b8395f981c5956ef617ea90b483e8e15d576d
Merge: 531b4cde43 2208235ce9
Author: Andrés de la Peña <a.penya.gar...@gmail.com>
AuthorDate: Mon Apr 17 14:52:40 2023 +0100

    Merge branch 'cassandra-4.1' into trunk

 CHANGES.txt                                        |   1 +
 .../tools/nodetool/stats/TableStatsHolder.java     |   2 +
 .../cassandra/tools/nodetool/TableStatsTest.java   |  29 +++++
 .../nodetool/stats/TableStatsPrinterTest.java      | 141 ++++++++++++++++++++-
 4 files changed, 171 insertions(+), 2 deletions(-)

diff --cc 
src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java
index d9eece9afa,60132d1fed..80660611d2
--- a/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java
@@@ -117,10 -119,10 +117,12 @@@ public class TableStatsHolder implement
      private Map<String, Object> convertStatsTableToMap(StatsTable table)
      {
          Map<String, Object> mpTable = new HashMap<>();
+         mpTable.put("sstable_count", table.sstableCount);
+         mpTable.put("old_sstable_count", table.oldSSTableCount);
          mpTable.put("sstables_in_each_level", table.sstablesInEachLevel);
          mpTable.put("sstable_bytes_in_each_level", 
table.sstableBytesInEachLevel);
 +        mpTable.put("max_sstable_size", table.maxSSTableSize);
 +        mpTable.put("twcs", table.twcs);
          mpTable.put("space_used_live", table.spaceUsedLive);
          mpTable.put("space_used_total", table.spaceUsedTotal);
          mpTable.put("space_used_by_snapshots_total", 
table.spaceUsedBySnapshotsTotal);
diff --cc 
test/unit/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinterTest.java
index 0bf4e1ce28,81687ba7c0..3ac83850a1
--- 
a/test/unit/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinterTest.java
+++ 
b/test/unit/org/apache/cassandra/tools/nodetool/stats/TableStatsPrinterTest.java
@@@ -394,6 -382,136 +395,142 @@@ public class TableStatsPrinterTest exte
          }
      }
  
+     @Test
+     public void testJsonPrinter() throws Exception
+     {
+         TestTableStatsHolder holder = new 
TestTableStatsHolder(testKeyspaces.subList(2, 3), "", 0); // kesypace3
+         StatsPrinter<StatsHolder> printer = TableStatsPrinter.from("json", 
false);
+         try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream())
+         {
+             printer.print(holder, new PrintStream(byteStream));
+             Assertions.assertThat(byteStream.toString())
+                       .isEqualTo("{\n" +
+                                  "  \"keyspace3\" : {\n" +
+                                  "    \"write_latency_ms\" : \"NaN\",\n" +
+                                  "    \"tables\" : {\n" +
+                                  "      \"table6\" : {\n" +
+                                  "        
\"average_tombstones_per_slice_last_five_minutes\" : 6.0,\n" +
+                                  "        \"top_tombstone_partitions\" : 
null,\n" +
+                                  "        
\"bloom_filter_off_heap_memory_used\" : \"667408\",\n" +
++                                 "        \"twcs\" : null,\n" +
+                                  "        \"bytes_pending_repair\" : 0,\n" +
+                                  "        \"memtable_switch_count\" : 6,\n" +
+                                  "        
\"maximum_tombstones_per_slice_last_five_minutes\" : 6,\n" +
+                                  "        \"memtable_cell_count\" : 6666,\n" +
+                                  "        \"memtable_data_size\" : 
\"1000000\",\n" +
+                                  "        
\"average_live_cells_per_slice_last_five_minutes\" : 5.0,\n" +
+                                  "        \"local_read_latency_ms\" : 
\"1.000\",\n" +
+                                  "        \"sstable_count\" : 1000,\n" +
+                                  "        \"local_write_latency_ms\" : 
\"0.500\",\n" +
+                                  "        \"pending_flushes\" : 66,\n" +
+                                  "        
\"compacted_partition_minimum_bytes\" : 6,\n" +
+                                  "        \"local_read_count\" : 5,\n" +
+                                  "        \"sstable_compression_ratio\" : 
0.68,\n" +
++                                 "        \"max_sstable_size\" : 0,\n" +
+                                  "        \"dropped_mutations\" : 
\"666666\",\n" +
+                                  "        \"top_size_partitions\" : null,\n" +
+                                  "        \"bloom_filter_false_positives\" : 
400,\n" +
+                                  "        \"off_heap_memory_used_total\" : 
\"162470810\",\n" +
+                                  "        \"memtable_off_heap_memory_used\" : 
\"161803398\",\n" +
+                                  "        
\"index_summary_off_heap_memory_used\" : \"3\",\n" +
+                                  "        \"bloom_filter_space_used\" : 
\"101112\",\n" +
+                                  "        \"sstables_in_each_level\" : [ 
],\n" +
+                                  "        
\"compacted_partition_maximum_bytes\" : 20,\n" +
+                                  "        \"sstable_bytes_in_each_level\" : [ 
],\n" +
+                                  "        \"space_used_total\" : \"0\",\n" +
+                                  "        \"local_write_count\" : 0,\n" +
+                                  "        \"droppable_tombstone_ratio\" : 
\"0.66667\",\n" +
+                                  "        
\"compression_metadata_off_heap_memory_used\" : \"1\",\n" +
++                                 "        \"local_read_write_ratio\" : 
\"0.00000\",\n" +
+                                  "        \"number_of_partitions_estimate\" : 
6,\n" +
+                                  "        \"bytes_repaired\" : 0,\n" +
+                                  "        
\"maximum_live_cells_per_slice_last_five_minutes\" : 2,\n" +
+                                  "        \"space_used_live\" : 
\"666666\",\n" +
+                                  "        \"compacted_partition_mean_bytes\" 
: 3,\n" +
+                                  "        \"bloom_filter_false_ratio\" : 
\"0.03000\",\n" +
+                                  "        \"old_sstable_count\" : 0,\n" +
+                                  "        \"bytes_unrepaired\" : 0,\n" +
+                                  "        \"percent_repaired\" : 0.0,\n" +
+                                  "        \"space_used_by_snapshots_total\" : 
\"0\"\n" +
+                                  "      }\n" +
+                                  "    },\n" +
+                                  "    \"read_latency_ms\" : 0.0,\n" +
+                                  "    \"pending_flushes\" : 66,\n" +
+                                  "    \"write_count\" : 0,\n" +
+                                  "    \"read_latency\" : 0.0,\n" +
+                                  "    \"read_count\" : 5\n" +
+                                  "  },\n" +
+                                  "  \"total_number_of_tables\" : 0\n" +
+                                  "}\n");
+         }
+     }
+ 
+     @Test
+     public void testYamlPrinter() throws Exception
+     {
+         TestTableStatsHolder holder = new 
TestTableStatsHolder(testKeyspaces.subList(2, 3), "", 0); // kesypace3
+         StatsPrinter<StatsHolder> printer = TableStatsPrinter.from("yaml", 
false);
+         try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream())
+         {
+             printer.print(holder, new PrintStream(byteStream));
+             Assertions.assertThat(byteStream.toString())
+                       .isEqualTo("keyspace3:\n" +
+                                  "  write_latency_ms: .NaN\n" +
+                                  "  tables:\n" +
+                                  "    table6:\n" +
+                                  "      
average_tombstones_per_slice_last_five_minutes: 6.0\n" +
+                                  "      top_tombstone_partitions: null\n" +
+                                  "      bloom_filter_off_heap_memory_used: 
'667408'\n" +
++                                 "      twcs: null\n" +
+                                  "      bytes_pending_repair: 0\n" +
+                                  "      memtable_switch_count: 6\n" +
+                                  "      
maximum_tombstones_per_slice_last_five_minutes: 6\n" +
+                                  "      memtable_cell_count: 6666\n" +
+                                  "      memtable_data_size: '1000000'\n" +
+                                  "      
average_live_cells_per_slice_last_five_minutes: 5.0\n" +
+                                  "      local_read_latency_ms: '1.000'\n" +
+                                  "      sstable_count: 1000\n" +
+                                  "      local_write_latency_ms: '0.500'\n" +
+                                  "      pending_flushes: 66\n" +
+                                  "      compacted_partition_minimum_bytes: 
6\n" +
+                                  "      local_read_count: 5\n" +
+                                  "      sstable_compression_ratio: 0.68\n" +
++                                 "      max_sstable_size: 0\n" +
+                                  "      dropped_mutations: '666666'\n" +
+                                  "      top_size_partitions: null\n" +
+                                  "      bloom_filter_false_positives: 400\n" +
+                                  "      off_heap_memory_used_total: 
'162470810'\n" +
+                                  "      memtable_off_heap_memory_used: 
'161803398'\n" +
+                                  "      index_summary_off_heap_memory_used: 
'3'\n" +
+                                  "      bloom_filter_space_used: '101112'\n" +
+                                  "      sstables_in_each_level: []\n" +
+                                  "      compacted_partition_maximum_bytes: 
20\n" +
+                                  "      sstable_bytes_in_each_level: []\n" +
+                                  "      space_used_total: '0'\n" +
+                                  "      local_write_count: 0\n" +
+                                  "      droppable_tombstone_ratio: 
'0.66667'\n" +
+                                  "      
compression_metadata_off_heap_memory_used: '1'\n" +
++                                 "      local_read_write_ratio: '0.00000'\n" +
+                                  "      number_of_partitions_estimate: 6\n" +
+                                  "      bytes_repaired: 0\n" +
+                                  "      
maximum_live_cells_per_slice_last_five_minutes: 2\n" +
+                                  "      space_used_live: '666666'\n" +
+                                  "      compacted_partition_mean_bytes: 3\n" +
+                                  "      bloom_filter_false_ratio: 
'0.03000'\n" +
+                                  "      old_sstable_count: 0\n" +
+                                  "      bytes_unrepaired: 0\n" +
+                                  "      percent_repaired: 0.0\n" +
+                                  "      space_used_by_snapshots_total: '0'\n" 
+
+                                  "  read_latency_ms: 0.0\n" +
+                                  "  pending_flushes: 66\n" +
+                                  "  write_count: 0\n" +
+                                  "  read_latency: 0.0\n" +
+                                  "  read_count: 5\n" +
+                                  "total_number_of_tables: 0\n" +
+                                  "\n");
+         }
+     }
+ 
      /**
       * A test version of TableStatsHolder to hold a test vector instead of 
gathering stats from a live cluster.
       */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to