{"record":{"id":"505374cd764ea629","repo":"apache/cassandra","slug":"use-the-d-flag-to-quiet-this-error-and-get-the-ex-505374","errorCode":null,"errorMessage":"Use the -d flag to quiet this error and get the exact throughput in megabits/s","messagePattern":"Use the -d flag to quiet this error and get the exact throughput in megabits/s","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/GetStreamThroughput.java","lineNumber":80,"sourceCode":"                                      throughputInDouble > 0 ? throughputInDouble + \" MiB/s\" : \"unlimited\");\n        }\n        else if (streamThroughputDoubleMbit)\n        {\n            throughputInDouble = probe.getStreamThroughputAsDouble();\n            probe.output().out.printf(\"Current stream throughput: %s%n\",\n                                      throughputInDouble > 0 ? throughputInDouble + \" Mb/s\" : \"unlimited\");\n        }\n        else\n        {\n            throughputInDouble = probe.getStreamThroughputAsDouble();\n            throughput = probe.getStreamThroughput();\n\n            if (throughput <= 0)\n                probe.output().out.printf(\"Current stream throughput: unlimited%n\");\n            else if (DoubleMath.isMathematicalInteger(throughputInDouble))\n                probe.output().out.printf(\"Current stream throughput: %s%n\", throughput + \" Mb/s\");\n            else\n                throw new RuntimeException(\"Use the -d flag to quiet this error and get the exact throughput in megabits/s\");\n        }\n    }\n}\n","sourceCodeStart":62,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GetStreamThroughput.java#L62-L84","documentation":"When the stream throughput value is not a whole number and no flag forced exact display, getstreamthroughput refuses to print a rounded Mb/s value and throws a RuntimeException telling the user to re-run with -d to get the exact megabits/s figure. It is a deliberate guard against silently lossy output.","triggerScenarios":"Running `nodetool getstreamthroughput -d`-equivalent path (or an Mbit display path) where the configured throughput, converted to Mb/s, has a fractional part (e.g. 10 MiB/s -> 83.88608 Mb/s) and the code's integer-display branch is reached with a non-integer value.","commonSituations":"Displaying throughput in megabits/s after converting from a MiB setting whose conversion yields a fractional number; running the command with the flag combination that routes into the double-conversion branch.","solutions":["Re-run with the -d/--double flag to print the exact throughput in megabits/s.","Set the throughput to a value whose Mb/s conversion is a whole number.","Read the value via JMX directly if scripting needs the exact double."],"exampleFix":"// before\nnodetool getstreamthroughput  # throws for fractional Mb/s\n// after\nnodetool getstreamthroughput -d","handlingStrategy":"fallback","validationCode":"# Prefer the exact form when scripting\nvalue=$(nodetool getstreamthroughput -d)","typeGuard":null,"tryCatchPattern":"try:\n    out = run(['nodetool','getstreamthroughput'])\nexcept RuntimeError:\n    out = run(['nodetool','getstreamthroughput','-d'])  # exact Mb/s","preventionTips":["Always use -d when you need exact numeric output.","Avoid relying on human-formatted default output in scripts."],"tags":["cli","nodetool","throughput","rounding"],"backgroundTag":"invalid-cli-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}