Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-16938

Missed wait latencies in the output of `nodetool tpstats -F`

    XMLWordPrintableJSON

Details

    Description

      The output of nodetool tpstats -F json always prints an empty map for WaitLatencies:

      $ nodetool tpstats -F json
      (...)"WaitLatencies":{},(...)
      

      The same happens with yaml output:

      $ nodetool tpstats -F yaml
      (...)
      WaitLatencies: {}
      (...)
      

      This happens because this cast silently fails inside a try-catch with an empty catch block:

      String[] strValues = (String[]) Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey())))
                                            .map(D -> D.toString())
                                            .toArray();
      

      When we would need something like:

      String[] strValues = Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey())))
                                 .map(Object::toString)
                                 .toArray(String[]::new);
      

      This conversion from Double[] to String[] was introduced during CASSANDRA-16230. My guess is that the conversion was done trying to work around a malformed JSON output detected in the new tests added by that ticket. Without the conversion the output would be something like:

      $ nodetool tpstats -F json
      (...)"WaitLatencies":{"READ_RSP":[Ljava.lang.Double;@398dada8,(...)
      

      That's because json-simple doesn't handle well arrays. I think that instead of converting the array of doubles to an array of strings we can simply use jackson-mapper-asl to print the proper array.

      Attachments

        1. json-after.txt
          8 kB
          Andres de la Peña
        2. json-before.txt
          3 kB
          Andres de la Peña

        Activity

          People

            adelapena Andres de la Peña
            adelapena Andres de la Peña
            Andres de la Peña
            Ekaterina Dimitrova
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m