【问题标题】:How must I use the Java API to facilitate failover?我必须如何使用 Java API 来促进故障转移?
【发布时间】:2012-12-03 14:33:26
【问题描述】:

我正在尝试从我的 java 应用程序中使用 Riak,如果集群中的一台机器出现故障,它将开始使用其他机器。我设法在 C# 中使用 Corrugated Iron 驱动程序做到了这一点,但似乎无法使其在 java 中工作。

我已确保我在 PBClusterConfig 中指定了不止一台 Riak 机器,即客户端“了解”集群中的所有机器。

我这样设置PBClusterConfig

BClusterConfig config = new PBClusterConfig(maxConnections);
for(RiakServerConfig server : servers) {
    PBClientConfig.Builder builder = new PBClientConfig.Builder();
    PBClientConfig serverConfig = builder
        .withHost(server.getHostname())
        .withPort(server.getPort())
        .build();

    config.addClient(serverConfig);
}

那么我的实际操作(只读写)是这样的:

client
    .createBucket(bucket)
    .withRetrier(DefaultRetrier.attempts(3))
    .execute()
    .store(key, value)
    .withRetrier(DefaultRetrier.attempts(3))
    .execute();

当 riak 集群正常时,此代码有效,但当其中一台机器出现故障时,几秒钟后我收到以下错误:com.basho.riak.client.RiakRetryFailedException: com.basho.riak.pbc.AcquireConnectionTimeoutException: timeout acquiring connection permit from pool

关于如何进行这项工作的任何想法?

【问题讨论】:

    标签: java api riak


    【解决方案1】:

    我相信还有一个outstanding issue regarding how the cluster client handles node failures。我在 riak 邮件列表中看到推荐的一种解决方法是安装例如HAProxy on the application server 并拥有此句柄故障转移。

    【讨论】:

      猜你喜欢
      • 2013-01-25
      • 1970-01-01
      • 2019-06-08
      • 2016-03-12
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2012-07-04
      • 2017-08-03
      相关资源
      最近更新 更多