Exemple #1
0
        // retries until deleted
        public BlobStorageResponse DeleteContainer(string containername)
        {
            containername = LegalizeContainerName(containername);
            var completed_delegate = new GenUtils.Actions.CompletedDelegate <BlobStorageResponse, Object>(CompletedIfContainerIsGone);

            return(GenUtils.Actions.Retry <BlobStorageResponse>(delegate() { return MaybeDeleteContainer(containername); }, completed_delegate, completed_delegate_object: containername, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs));
        }
Exemple #2
0
        public void RetrySucceedsOnSubsequentTry()
        {
            retries = 0;
            var completed_delegate =
                new GenUtils.Actions.CompletedDelegate <int, object>(CompletedIfSeven);
            var r = GenUtils.Actions.Retry <int>(
                delegate() { return(RandomEvenNumber()); },
                completed_delegate,
                completed_delegate_object: null,
                wait_secs: 0,
                max_tries: 10000,
                timeout_secs: TimeSpan.FromSeconds(10000));

            Assert.That(retries == 7);
        }
Exemple #3
0
        public void RetrySucceedsOnFirstTry()
        {
            retries = 0;
            var completed_delegate =
                new GenUtils.Actions.CompletedDelegate <int, object>(CompletedIfIntIsTwo);
            var r = GenUtils.Actions.Retry <int>(
                delegate() { return(Twice(1)); },
                completed_delegate,
                completed_delegate_object: null,
                wait_secs: 0,
                max_tries: 1,
                timeout_secs: TimeSpan.FromSeconds(10000));

            Assert.AreEqual(2, r);
            Assert.AreEqual(1, retries);
        }
Exemple #4
0
        public void RetryTransmitsException()
        {
            var completed_delegate =
                new GenUtils.Actions.CompletedDelegate <int, object>(CompletedNever);

            try
            {
                var r = GenUtils.Actions.Retry <int>(
                    delegate() { return(ExceptionIfOdd(1)); },
                    completed_delegate,
                    completed_delegate_object: null,
                    wait_secs: 0,
                    max_tries: 100,
                    timeout_secs: TimeSpan.FromSeconds(5));
            }
            catch (Exception e)
            {
                Assert.AreEqual("OddNumberException", e.Message);
            }
        }
Exemple #5
0
        public void RetryEndsAfterMaxTriesExceeded()
        {
            var completed_delegate =
                new GenUtils.Actions.CompletedDelegate <int, object>(CompletedNever);

            try
            {
                var r = GenUtils.Actions.Retry <int>(
                    delegate() { return(RandomEvenNumber()); },
                    completed_delegate,
                    completed_delegate_object: null,
                    wait_secs: 1,
                    max_tries: 5,
                    timeout_secs: TimeSpan.FromSeconds(100));
            }
            catch (Exception e)
            {
                Assert.AreEqual(GenUtils.Actions.RetryExceededMaxTries, e);
            }
        }
Exemple #6
0
        public void RetryFailsWhenPassedFailingObject()
        {
            var completed_delegate =
                new GenUtils.Actions.CompletedDelegate <int, object>(CompletedIfObjectIsSeven);

            try
            {
                var r = GenUtils.Actions.Retry <int>(
                    delegate() { return(Twice(1)); },
                    completed_delegate,
                    completed_delegate_object: -7,
                    wait_secs: 0,
                    max_tries: 3,
                    timeout_secs: TimeSpan.FromSeconds(10000));
            }
            catch (Exception e)
            {
                var exceeded_tries = (e == GenUtils.Actions.RetryExceededMaxTries);
                var timed_out      = (e == GenUtils.Actions.RetryTimedOut);
                Assert.That(exceeded_tries || timed_out);
            }
        }
Exemple #7
0
 public HttpResponse RetryAcquireLease(string containername, string blobname)
 {
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<HttpResponse, Object>(HttpUtils.CompletedIfStatusEqualsExpected);
     return GenUtils.Actions.Retry<HttpResponse>(delegate() { return AcquireLease(containername, blobname); }, completed_delegate, completed_delegate_object:HttpStatusCode.Created, wait_secs: 10, max_tries: 12, timeout_secs: TimeSpan.FromSeconds(120));
 }
 public void RetryTransmitsException()
 {
     var completed_delegate =
         new GenUtils.Actions.CompletedDelegate<int, object>(CompletedNever);
     try
     {
         var r = GenUtils.Actions.Retry<int>(
             delegate() { return ExceptionIfOdd(1); },
             completed_delegate,
             completed_delegate_object: null,
             wait_secs: 0,
             max_tries: 100,
             timeout_secs: TimeSpan.FromSeconds(5));
     }
     catch (Exception e)
     {
         Assert.AreEqual("OddNumberException", e.Message);
     }
 }
 public void RetryEndsAfterMaxTriesExceeded()
 {
     var completed_delegate =
         new GenUtils.Actions.CompletedDelegate<int, object>(CompletedNever);
     try
     {
         var r = GenUtils.Actions.Retry<int>(
             delegate() { return RandomEvenNumber(); },
             completed_delegate,
             completed_delegate_object: null,
             wait_secs: 1,
             max_tries: 5,
             timeout_secs: TimeSpan.FromSeconds(100));
     }
     catch (Exception e)
     {
         Assert.AreEqual(GenUtils.Actions.RetryExceededMaxTries, e);
     }
 }
Exemple #10
0
 public void RetrySucceedsOnFirstTry()
 {
     retries = 0;
     var completed_delegate =
         new GenUtils.Actions.CompletedDelegate<int, object>(CompletedIfIntIsTwo);
     var r = GenUtils.Actions.Retry<int>(
         delegate() { return Twice(1); },
         completed_delegate,
         completed_delegate_object: null,
         wait_secs: 0,
         max_tries: 1,
         timeout_secs: TimeSpan.FromSeconds(10000));
     Assert.AreEqual(2, r);
     Assert.AreEqual(1, retries);
 }
Exemple #11
0
 public void RetrySucceedsOnSubsequentTry()
 {
     retries = 0;
     var completed_delegate =
         new GenUtils.Actions.CompletedDelegate<int, object>(CompletedIfIntEndsWithZero);
     var r = GenUtils.Actions.Retry<int>(
         delegate() { return RandomEvenNumber(); },
         completed_delegate,
         completed_delegate_object: null,
         wait_secs: 0,
         max_tries: 10000,
         timeout_secs: TimeSpan.FromSeconds(10000));
     Assert.That(Convert.ToString(r).EndsWith("0"));
     Assert.That(retries > 1);
 }
Exemple #12
0
        public HttpResponse RetryAcquireLease(string containername, string blobname)
        {
            var completed_delegate = new GenUtils.Actions.CompletedDelegate <HttpResponse, Object>(HttpUtils.CompletedIfStatusEqualsExpected);

            return(GenUtils.Actions.Retry <HttpResponse>(delegate() { return AcquireLease(containername, blobname); }, completed_delegate, completed_delegate_object: HttpStatusCode.Created, wait_secs: 10, max_tries: 12, timeout_secs: TimeSpan.FromSeconds(120)));
        }
Exemple #13
0
        public TableStorageListDictResponse DeleteEntity(string tablename, string partkey, string rowkey)
        {
            var completed_delegate = new GenUtils.Actions.CompletedDelegate <TableStorageListDictResponse, Object>(CompletedIfNotFound);

            return(GenUtils.Actions.Retry <TableStorageListDictResponse>(delegate() { return MaybeDeleteEntity(tablename, partkey, rowkey); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs));
        }
Exemple #14
0
 // retries until deleted
 public BlobStorageResponse DeleteContainer(string containername)
 {
     containername = LegalizeContainerName(containername);
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<BlobStorageResponse, Object>(CompletedIfContainerIsGone);
     return GenUtils.Actions.Retry<BlobStorageResponse>(delegate() { return MaybeDeleteContainer(containername); }, completed_delegate, completed_delegate_object: containername, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs);
 }
Exemple #15
0
 // waits and retries if container is being deleted
 public BlobStorageResponse CreateContainer(string containername, bool is_public, Hashtable headers)
 {
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<BlobStorageResponse, Object>(CompletedIfContainerIsNotBeingDeleted);
     return GenUtils.Actions.Retry<BlobStorageResponse>(delegate() { return MaybeCreateContainer(containername, is_public, (Hashtable)headers.Clone()); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs);
 }
Exemple #16
0
 public TableStorageListDictResponse DeleteEntity(string tablename, string partkey, string rowkey)
 {
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<TableStorageListDictResponse, Object>(CompletedIfNotFound);
     return GenUtils.Actions.Retry<TableStorageListDictResponse>(delegate() { return MaybeDeleteEntity(tablename, partkey, rowkey); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs);
 }
Exemple #17
0
 public TableStorageHttpResponse CreateTable(string tablename)
 {
     var completed_delegate = new GenUtils.Actions.CompletedDelegate<TableStorageHttpResponse, Object>(CompletedIfCreated);
     return GenUtils.Actions.Retry<TableStorageHttpResponse>(delegate() { return MaybeCreateTable(tablename); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs);
 }
Exemple #18
0
        // waits and retries if container is being deleted
        public BlobStorageResponse CreateContainer(string containername, bool is_public, Hashtable headers)
        {
            var completed_delegate = new GenUtils.Actions.CompletedDelegate <BlobStorageResponse, Object>(CompletedIfContainerIsNotBeingDeleted);

            return(GenUtils.Actions.Retry <BlobStorageResponse>(delegate() { return MaybeCreateContainer(containername, is_public, (Hashtable)headers.Clone()); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs));
        }
Exemple #19
0
 public void RetryFailsWhenPassedFailingObject()
 {
     var completed_delegate =
         new GenUtils.Actions.CompletedDelegate<int, object>(CompletedIfObjectIsSeven);
     try
     {
         var r = GenUtils.Actions.Retry<int>(
             delegate() { return Twice(1); },
             completed_delegate,
             completed_delegate_object: -7,
             wait_secs: 0,
             max_tries: 3,
             timeout_secs: TimeSpan.FromSeconds(10000));
     }
     catch (Exception e)
     {
         var exceeded_tries = (e == GenUtils.Actions.RetryExceededMaxTries);
         var timed_out = (e == GenUtils.Actions.RetryTimedOut);
         Assert.That(exceeded_tries || timed_out);
     }
 }
Exemple #20
0
        public TableStorageHttpResponse CreateTable(string tablename)
        {
            var completed_delegate = new GenUtils.Actions.CompletedDelegate <TableStorageHttpResponse, Object>(CompletedIfCreated);

            return(GenUtils.Actions.Retry <TableStorageHttpResponse>(delegate() { return MaybeCreateTable(tablename); }, completed_delegate, completed_delegate_object: null, wait_secs: StorageUtils.wait_secs, max_tries: StorageUtils.max_tries, timeout_secs: StorageUtils.timeout_secs));
        }