我们如何在Java Driver V4中使用loggingRetrypolicy和fallthroughRetrypolicy与驱动程序configloader?

发布于 2025-02-07 13:49:43 字数 1945 浏览 1 评论 0原文

我们的应用程序实施重试策略,例如使用驱动程序Cassandra-Driver-Core-3.1.0.jar.jar.jar.jar.jar..jar..jar..jar..dse6.8,我们正在将DataStax驱动程序版本升级到Java-driver-core-4.13.03.03.03.03.03.03.03.0 。

For policies DefaultRetryPolicy,ConsistencyDowngradingRetryPolicy we can programatically use its class name in DriverConfigLoader.But,how can we implement FallthroughRetryPolicy and LoggingRetryPolicies,as these policies aren't available in java-driver-core-4.13.0.?Trying to use driverconfigloader as below

DriverConfigLoader loader =
                DriverConfigLoader.programmaticBuilder().withClass(DefaultDriverOption.RETRY_POLICY,DefaultRetryPolicy.class).build();

我们应用程序中的loggingRetrypolicy如下:

public static RetryPolicy getRetryPolicy(String retryPolicyStr, boolean isLogingPolicy) {
        RetryPolicy retryPolicy = null;
        if (isLogingPolicy) {
            retryPolicy = new LoggingRetryPolicy(retryPolicyDataConvert(retryPolicyStr));
        } else {
            retryPolicy = retryPolicyDataConvert(retryPolicyStr);
        }
        
        return retryPolicy;
    }
    
    private static RetryPolicy retryPolicyDataConvert(String retryPolicyStr) {
        if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_DEFAULT.equals(retryPolicyStr)) {
            return DefaultRetryPolicy.INSTANCE;
        } else if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_DOWNGRADING.equals(retryPolicyStr)) {
            return DowngradingConsistencyRetryPolicy.INSTANCE;
        } else if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_FALLTHROUGH.equals(retryPolicyStr)) {
            return FallthroughRetryPolicy.INSTANCE;
        } 
        
        return null;
    }
Cluster.Builder builder = Cluster.builder();
builder.withRetryPolicy(CassandraPolicyDataTypeConvertUtil.getRetryPolicy(connectionInfo.getRetryPolicy(), connectionInfo.isLoggingRetryPolicy()));
    

有人可以为此提供帮助吗?

Our application implements retry policies such as FallthroughRetryPolicy and LoggingRetryPolicy using driver cassandra-driver-core-3.1.0.jar.To support keyspace metadata for DSE6.8,we are upgrading the datastax driver version to java-driver-core-4.13.0.

For policies DefaultRetryPolicy,ConsistencyDowngradingRetryPolicy we can programatically use its class name in DriverConfigLoader.But,how can we implement FallthroughRetryPolicy and LoggingRetryPolicies,as these policies aren't available in java-driver-core-4.13.0.?Trying to use driverconfigloader as below

DriverConfigLoader loader =
                DriverConfigLoader.programmaticBuilder().withClass(DefaultDriverOption.RETRY_POLICY,DefaultRetryPolicy.class).build();

LoggingRetryPolicy in our application is as below:

public static RetryPolicy getRetryPolicy(String retryPolicyStr, boolean isLogingPolicy) {
        RetryPolicy retryPolicy = null;
        if (isLogingPolicy) {
            retryPolicy = new LoggingRetryPolicy(retryPolicyDataConvert(retryPolicyStr));
        } else {
            retryPolicy = retryPolicyDataConvert(retryPolicyStr);
        }
        
        return retryPolicy;
    }
    
    private static RetryPolicy retryPolicyDataConvert(String retryPolicyStr) {
        if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_DEFAULT.equals(retryPolicyStr)) {
            return DefaultRetryPolicy.INSTANCE;
        } else if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_DOWNGRADING.equals(retryPolicyStr)) {
            return DowngradingConsistencyRetryPolicy.INSTANCE;
        } else if (CassandraConstants.CASSANDRACONNECTION_RETRYPOLICY_FALLTHROUGH.equals(retryPolicyStr)) {
            return FallthroughRetryPolicy.INSTANCE;
        } 
        
        return null;
    }
Cluster.Builder builder = Cluster.builder();
builder.withRetryPolicy(CassandraPolicyDataTypeConvertUtil.getRetryPolicy(connectionInfo.getRetryPolicy(), connectionInfo.isLoggingRetryPolicy()));
    

Can anyone please help on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌无敌 2025-02-14 13:49:43

fallthroughRetryPolicyloggingRetryPolicy在Cassandra Java驱动程序的4.x中不存在,因此您将无法使用它们。

Java驱动程序V4仅带有两个内置的重试策略:

  1. DefaultretreTryPoLicy
  2. consenty vernencyDownGradingRadingReTryPolicy(请勿使用)

我们不建议使用consement> consenty> consenty> consentimencyDowngradingGradingGradingReTryRicyPolicyPolicyPolicyPolicyPolicyPolicy。如果您决定使用它,请确保您完全理解后果。在所有情况下,要使用的正确重试策略是defaultretreTryPolicy,除非您有一个非常有用的情况并想要实施自己的重试策略。

有关更多信息,请参见在Java驱动程序v4 < /a>。干杯!

The FallthroughRetryPolicy and LoggingRetryPolicy do not exist in version 4.x of the Cassandra Java driver so you will not be able to use them.

Java driver v4 only comes with two built-in retry policies:

  1. DefaultRetryPolicy
  2. ConsistencyDowngradingRetryPolicy (do NOT use)

We do not recommend using ConsistencyDowngradingRetryPolicy. If you decide to use it, make sure you fully comprehend the consequences. In all cases, the correct retry policy to use is DefaultRetryPolicy unless you have a very edge case and want to implement your own retry policy.

For more info, see Retries in Java driver v4. Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文