我们如何在Java Driver V4中使用loggingRetrypolicy和fallthroughRetrypolicy与驱动程序configloader?
我们的应用程序实施重试策略,例如使用驱动程序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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fallthroughRetryPolicy
和loggingRetryPolicy
在Cassandra Java驱动程序的4.x中不存在,因此您将无法使用它们。Java驱动程序V4仅带有两个内置的重试策略:
DefaultretreTryPoLicy
consenty vernencyDownGradingRadingReTryPolicy
(请勿使用)我们不建议使用
consement> consenty> consenty> consentimencyDowngradingGradingGradingReTryRicyPolicyPolicyPolicyPolicyPolicyPolicy
。如果您决定使用它,请确保您完全理解后果。在所有情况下,要使用的正确重试策略是defaultretreTryPolicy
,除非您有一个非常有用的情况并想要实施自己的重试策略。有关更多信息,请参见在Java驱动程序v4 < /a>。干杯!
The
FallthroughRetryPolicy
andLoggingRetryPolicy
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:
DefaultRetryPolicy
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 isDefaultRetryPolicy
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!