igors
December 5, 2018, 6:24pm
1
Hello,
I am using Java SDK 2.6 and I am looking for a way to collect information about the cluster including health status, kv, query , index nodes etc…
In addition, is it possible to listen to the changes in the cluster connection status?
Please advice,
Thanks,
Igor Sandler
1 Like
Hi Igor,
CouchbaseCluster.diagnostics()
returns information about the state of the cluster. There’s also Bucket.ping()
. Sample usage and output are shown in this other thread:
Hi ,
I am using java SDK to connect to Couchbase cluster and wanted to know different options for getting connection status w.r.t cluster nodes before trying out detailed hands on.
I can figure out two options
1 - Handling couchbase connection exception
This will not be real time, as and when I try to operate something I may get this exception
2- Subscribing to SDK event bus
Will the SDK will publish me NodeConnectedEvent and NodeDisconnectedEvent in real time. Will subscribing to event b…
Thanks,
David
1 Like
igors
December 5, 2018, 8:14pm
3
Hi David,
I am using 2.x java client with CouchbaseCluster replaced by Cluster interface. When I call diagnosticts() I am getting the following response:
diagnostics:[{
“services” : { },
“sdk” : “couchbase-java-client/2.5.4 (git: 2.5.4, core: 1.5.4) (Windows 7/6.1 amd64; Java HotSpot™ 64-Bit Server VM 1.8.0_152-b16)”,
“id” : “d8a769d7-6ca2-4680-980a-281dd609165a”,
“version” : 1
}]
The ‘services’ tag comes back empty. In addition Bucket interface does not have ‘ping’ method.
Your thoughts?
Thanks,
Igor
Hi Igor,
Hmmm… Cluster.diagnostics()
only reports on established connections. If the client hasn’t actually connected to the services yet, you won’t see any results.
Bucket.ping()
was added in SDK 2.5.5. It actively connects to all services, so it’s probably the better tool for this use case.
Thanks,
David
And, if I recall correctly, we promoted this from uncommitted API to commited API in 2.6, so you’re much better off using 2.7 (current) or 2.6.
1 Like
igors
December 5, 2018, 10:54pm
6
Thank you very much!
It works as expected with 2.6.
Igor