Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

java - "show version" in Cassandra and thrift protocol

I would like to make sure that I can connect to the db from Java service from time to time (like ping). This answer suggests to use show version.

My Java service is using the Cassandra thrift client (which is deprecated) and I couldn't find an example how to execute such a query.

I have a client of type org.apache.cassandra.thrift.Cassandra.Client. Those are the methods I found that are similar:

System.out.println("describe_schema_versions: " + nativeClient.describe_schema_versions());
System.out.println("describe_version: " + nativeClient.describe_version());
System.out.println("describe_snitch: " + nativeClient.describe_snitch());
System.out.println("describe_cluster_name: " + nativeClient.describe_cluster_name());
System.out.println("describe_keyspaces: " + nativeClient.describe_keyspaces());
System.out.println("describe_partitioner: " + nativeClient.describe_partitioner());
System.out.println("describe_token_map: " + nativeClient.describe_token_map());

How can I execute query to get Cassandra server version like this?

cqlsh> show version;
[cqlsh 3.1.8 | Cassandra 1.2.19 | CQL spec 3.0.5 | Thrift protocol 19.36.2]

Or is there an alternative query preferred as "ping"?

question from:https://stackoverflow.com/questions/65936156/show-version-in-cassandra-and-thrift-protocol

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

if you just want make a health check, i think run a simple query is a good choice.

 SELECT now() FROM system.local

here is the doc about how thrift client run query.
Cassandra.Client (apache-cassandra API) - Javadoc Extreme


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...