【问题标题】:Migration of Cassandra client Hector to java driver - replacement for ConnectionListener将 Cassandra 客户端 Hector 迁移到 java 驱动程序 - ConnectionListener 的替代品
【发布时间】:2016-08-04 03:45:38
【问题描述】:

目前我们正在将 Cassandra 客户端从 Hector 迁移到 Java 驱动程序,但无法找到 ConnectionListener 的替代品,因为这是为了避免重复客户端请求到同一个 DC,但由于某种原因已经关闭。

代码:

         if(getClusterConnectionListenerForDCId(dcId).isAllHostsInThisDCClusterDown())
             {
            /* directly return failure w/o even trying: this is vital, because if we keep trying to write to a all-downed cluster again and again,and since hector is stupid enough not to skip writing to cluster given that it already knew the cluster is all down, every single remote local-quorum call will need to wait until timeout (10 second) again and again, when cross-DC channel has hiccup.
*/
                            return false;
                }

        //overridden function of ConnectionManagerListener

        @Override
            public void onAllHostsDown() {
                //when all hosts are down for a particular cluster, we want to disable writing to that particular cluser
                //until at least one host of the cluster recovers
                mIsAllHostsInThisDCClusterDown = true;
                smIsAnyDCClusterAllHostsDown = true;
                logger.warn("all hosts are down for DC: " + mDcId);
            } 

【问题讨论】:

    标签: java cassandra datastax-java-driver hector


    【解决方案1】:

    但无法找到 ConnectionListener 的替代品,因为它用于避免重复客户端请求到同一个 DC,但由于某种原因已经关闭。

    你不再需要它了。使用 Java 驱动程序,您将拥有 DCAwareLoadBalancingStrategy,它将自动为您处理节点/DC 停机时间

    【讨论】:

      猜你喜欢
      • 2022-09-02
      • 1970-01-01
      • 2018-11-05
      • 2018-07-17
      • 2023-02-09
      • 2011-12-20
      • 2012-12-07
      • 2012-03-12
      • 2014-02-23
      相关资源
      最近更新 更多