本文整理汇总了C#中RequestHandler.GetRetryDecision方法的典型用法代码示例。如果您正苦于以下问题:C# RequestHandler.GetRetryDecision方法的具体用法?C# RequestHandler.GetRetryDecision怎么用?C# RequestHandler.GetRetryDecision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler.GetRetryDecision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestHandlerRetryDecisionTest
public void RequestHandlerRetryDecisionTest()
{
var statement = new SimpleStatement("SELECT WILL FAIL");
var request = Session.GetRequest(statement);
var requestHandler = new RequestHandler<RowSet>(Session, request, statement);
//Using default retry policy the decision will always be to rethrow on read/write timeout
var expected = RetryDecision.RetryDecisionType.Rethrow;
var decision = requestHandler.GetRetryDecision(new ReadTimeoutException(ConsistencyLevel.Quorum, 1, 2, true));
Assert.AreEqual(expected, decision.DecisionType);
decision = requestHandler.GetRetryDecision(new WriteTimeoutException(ConsistencyLevel.Quorum, 1, 2, "SIMPLE"));
Assert.AreEqual(expected, decision.DecisionType);
decision = requestHandler.GetRetryDecision(new UnavailableException(ConsistencyLevel.Quorum, 2, 1));
Assert.AreEqual(expected, decision.DecisionType);
decision = requestHandler.GetRetryDecision(new Exception());
Assert.AreEqual(expected, decision.DecisionType);
//Expecting to retry when a Cassandra node is Bootstrapping/overloaded
expected = RetryDecision.RetryDecisionType.Retry;
decision = requestHandler.GetRetryDecision(new OverloadedException(null));
Assert.AreEqual(expected, decision.DecisionType);
decision = requestHandler.GetRetryDecision(new IsBootstrappingException(null));
Assert.AreEqual(expected, decision.DecisionType);
decision = requestHandler.GetRetryDecision(new TruncateException(null));
Assert.AreEqual(expected, decision.DecisionType);
}
示例2: DowngradingConsistencyRetryTest
public void DowngradingConsistencyRetryTest()
{
var dummyStatement = new SimpleStatement().SetRetryPolicy(DowngradingConsistencyRetryPolicy.Instance);
var handler = new RequestHandler<RowSet>(null, null, dummyStatement);
//Retry if 1 of 2 replicas are alive
var decision = handler.GetRetryDecision(new UnavailableException(ConsistencyLevel.Two, 2, 1));
Assert.True(decision != null && decision.DecisionType == RetryDecision.RetryDecisionType.Retry);
//Retry if 2 of 3 replicas are alive
decision = handler.GetRetryDecision(new UnavailableException(ConsistencyLevel.Three, 3, 2));
Assert.True(decision != null && decision.DecisionType == RetryDecision.RetryDecisionType.Retry);
//Throw if 0 replicas are alive
decision = handler.GetRetryDecision(new UnavailableException(ConsistencyLevel.Three, 3, 0));
Assert.True(decision != null && decision.DecisionType == RetryDecision.RetryDecisionType.Rethrow);
//Retry if 1 of 3 replicas is alive
decision = handler.GetRetryDecision(new ReadTimeoutException(ConsistencyLevel.All, 3, 1, false));
Assert.True(decision != null && decision.DecisionType == RetryDecision.RetryDecisionType.Retry);
}