scylladb / scylla-tools-java

Apache Cassandra, supplying tools for Scylla
Apache License 2.0
53 stars 85 forks source link

print more informative error when fail to parse sstable generation #362

Closed tchaikov closed 11 months ago

tchaikov commented 11 months ago

since scylla 5.4, the sstables are named with a uuid-based identifier instead of integer-based one. so the java tools inherited from cassandra 3.x branch do not support it, and throw an UnsupportedOperationException when parsing a sstable name with the integer-based generation. like:

$ sstablemetadata me-3gbp_1glu_4e6g020ns4px173el0-big-Data.db
Exception in thread "main" java.lang.NumberFormatException: For input string: "3gbp_1glu_4e6g020ns4px173el0"
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:652)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:280)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:228)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:217)
        at org.apache.cassandra.tools.SSTableMetadataViewer.main(SSTableMetadataViewer.java:150)

the user experience is poor when seeing this exception.

after this change, if the sstable's identifier is UUID-based, the tool would print a more user-friendly message in the stderr:

$ sstabledump  /home/kefu/.dtest/dtest-8xbyk741/test/node3/data/ks/test-4517d910968d11ee84e4ebb027ebcc17/me-3gbr_0z07_0dpts20r5i40t9onx3-big-Data.db
SSTable 'me-3gbr_0z07_0dpts20r5i40t9onx3-big-Data.db' uses UUID-based identifier. Please use 'scylla sstable' commands.

Fixes #360 Signed-off-by: Kefu Chai kefu.chai@scylladb.com

tchaikov commented 11 months ago

v2:

tchaikov commented 11 months ago

@denesb hi Botond, could you take another look? the latest revision should have addressed your comment.

tchaikov commented 11 months ago

v2:

denesb commented 11 months ago

Submodule update: scylladb/scylladb@3c125891f4997930777c596507d5551c5b2966cb