【问题标题】:Couchbase Server StatusCouchbase 服务器状态
【发布时间】:2017-07-30 03:27:09
【问题描述】:

我在我的应用程序中使用 Spring 数据 Couchbase。我正在使用 CouchbaseOperations 对象通过以下代码查找集群信息。

List<Version> versions = this.couchbaseOperations.getCouchbaseClusterInfo().getAllVersions();

这为我提供了我正在使用的 couchbase 服务器的版本。这工作正常。 但问题是它总是给我 Couchbase Server 的版本,不管服务器是启动还是关闭。 所以我的用例是,如果我的 couchbase 服务器已关闭,我需要显示 Couchbase 服务器已关闭。
因此,任何人都可以给我一种方法来使用 CouchbaseOperation 对象或 CouchbaseTemplate 对象或任何其他方法中的任何内置方法检查 Couchbase 服务器的状态。 提前致谢。

【问题讨论】:

    标签: spring couchbase spring-boot-actuator spring-data-couchbase


    【解决方案1】:

    应该可以检查桶的每个节点的状态

    Integer timeoutInMs = 1000;
    Bucket bucket = couchbaseConfig.couchbaseClient();
    boolean isReachable = bucket.bucketManager().info().nodeList().get(0).isReachable(timeoutInMs);
    

    如果您有多个存储桶,请为每个存储桶执行此操作。如果您有更多节点循环通过它们而不是仅使用get(0)

    【讨论】:

    • 这正是我想要的。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    相关资源
    最近更新 更多