public DelayStrategy(TimeSpan delayTime, Func <TimeSpan, TimeSpan> getNextDelayTime) { ThrowIf.OutOfRange(delayTime, TimeSpan.Zero, TimeSpan.MaxValue, "delayTime"); ThrowIf.Null(getNextDelayTime, "getNextDelayTime"); this.delayTime = delayTime; this.getNextDelayTime = getNextDelayTime; }
private static Predicate <IRetryContext> ResultCountConstraint <TList, TItem>(FabricRequest request, int expectedResultCount, Func <int, int, bool> condition) where TList : IList <TItem> { ThrowIf.OutOfRange(expectedResultCount, 0, int.MaxValue, "expectedResultCount"); return(delegate(IRetryContext r) { Predicate <IRetryContext> errorCodeChecker = FabricRequestProcessor.SuccessRetryErrorCodeProcessor(request); // Only check the instance count if the request was a success AND the error code is S_OK. Some resolve requests // are used to check if the service has been deleted properly and will not have an S_OK success associated with them... if (errorCodeChecker(r) && request.OperationResult.ErrorCode == 0) { OperationResult <TList> actualResult = (OperationResult <TList>)request.OperationResult; int actualResultLength = actualResult.Result.Count(); if (condition(actualResultLength, expectedResultCount)) { r.ShouldRetry = false; r.Succeeded = true; TestabilityTrace.TraceSource.WriteNoise("FabricRequestProcessor", "{0}: Request succeeded with expected result count: '{1}'", r.ActivityId, actualResultLength); } else { ResolveServiceRequest tempRequest = request as ResolveServiceRequest; if (tempRequest != null && typeof(TItem) == typeof(TestServicePartitionInfo)) { tempRequest.PreviousResult = actualResult.Result.First() as TestServicePartitionInfo; } r.ShouldRetry = true; r.Succeeded = false; TestabilityTrace.TraceSource.WriteInfo( "FabricRequestProcessor", "{0}: Request failed in result count validation. Expected result count: '{1}'. Actual result count : '{2}'", r.ActivityId, expectedResultCount, actualResultLength); } } return r.Succeeded; }); }
public ActionStore( IReliableStateManager stateManager, IStatefulServicePartition partition, IReliableDictionary <Guid, byte[]> actionTable, IReliableDictionary <Guid, byte[]> historyTable, IReliableDictionary <string, bool> stoppedNodeTable, long maxStoredActionCount, int storedActionCleanupIntervalInSeconds, int completedActionKeepDurationInSeconds, bool isTestMode, CancellationToken cancellationToken) { ThrowIf.Null(stateManager, "stateManager"); ThrowIf.Null(actionTable, "actionTable"); ThrowIf.Null(historyTable, "historyTable"); ThrowIf.Null(stoppedNodeTable, "stoppedNodeTable"); ThrowIf.OutOfRange(maxStoredActionCount, 0, long.MaxValue, "maxStoredActionCount"); ThrowIf.OutOfRange(storedActionCleanupIntervalInSeconds, 0, int.MaxValue, "storedActionCleanupIntervalInSeconds"); ThrowIf.OutOfRange(completedActionKeepDurationInSeconds, 0, int.MaxValue, "completedActionKeepDurationInSeconds"); this.stateManager = stateManager; this.partition = partition; this.actionTable = actionTable; this.historyTable = historyTable; this.stoppedNodeTable = stoppedNodeTable; this.maxStoredActionCount = maxStoredActionCount; this.storedActionCleanupIntervalInSeconds = storedActionCleanupIntervalInSeconds; this.completedActionKeepDurationInSeconds = completedActionKeepDurationInSeconds; this.isTestMode = isTestMode; this.cancellationToken = cancellationToken; this.truncateTimer = new Timer(this.TruncateCallback, null, Timeout.Infinite, Timeout.Infinite); this.truncateTimer.Change(TimeSpan.FromSeconds(this.storedActionCleanupIntervalInSeconds), Timeout.InfiniteTimeSpan); cancellationToken.Register(this.CancelTimer); }
public RetryCountBasedCondition(int maxRetryCount) { ThrowIf.OutOfRange(maxRetryCount, 0, int.MaxValue, "maxRetryCount"); this.maxRetryCount = maxRetryCount; }