Created
May 6, 2015 18:19
Revisions
-
hyrmn created this gist
May 6, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ public class AzureFriendlyReplicationInformer : ReplicationInformer { public AzureFriendlyReplicationInformer(DocumentConvention conventions) : base(conventions) { } public override bool ShouldExecuteUsing(string operationUrl, int currentRequest, string method, bool primary) { if (primary == false) AssertValidOperation(method); var failureCounter = GetHolder(operationUrl); if (failureCounter.Value == 0 || failureCounter.ForceCheck) { failureCounter.LastCheck = SystemTime.UtcNow; return true; } if (currentRequest % CheckRepititionRate(failureCounter.Value) == 0) { failureCounter.LastCheck = SystemTime.UtcNow; return true; } if ((SystemTime.UtcNow - failureCounter.LastCheck) > conventions.MaxFailoverCheckPeriod) { failureCounter.LastCheck = SystemTime.UtcNow; return true; } return false; } private int CheckRepititionRate(long value) { if (value < 10000) return 1000; if (value < 100000) return 10000; return 100000; } }