I am using Spring data Couchbase in my application.I am using the CouchbaseOperations object to find out the cluster info with the following code.
List<Version> versions = this.couchbaseOperations.getCouchbaseClusterInfo().getAllVersions();
This gives me the version of the couchbase server which I am using.This is working fine.
But the issue is that it always gives me the version of Couchbase Server irrespective of whether the server is up or down.
So my use case is that, if my couchbase server is down, I need to display that Couchbase server is down.
So can anybody give me a method to check the status of Couchbase server using any inbuilt method in CouchbaseOperation object or CouchbaseTemplate object or any other method.
Thanks in advance.
It should be possible to check the status for every node of a bucket with
Integer timeoutInMs = 1000;
Bucket bucket = couchbaseConfig.couchbaseClient();
boolean isReachable = bucket.bucketManager().info().nodeList().get(0).isReachable(timeoutInMs);
If you have multiple buckets do this for every single one of them. If you have more nodes loop through them instead of only using get(0)
.