Ejemplo n.º 1
0
        public void TableOperationExecuteRetryAPM()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", "foo");

            for (int m = 0; m < 20; m++)
            {
                insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[50 * 1024]));
            }

            TestHelper.ExecuteAPMMethodWithRetry(3,
                                                 new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertUpstreamNetworkDelay(10000,
                                                                XStoreSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                                new BehaviorOptions(2)),
                // After 500 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    XStoreSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                    new BehaviorOptions(2))
            },
                                                 (options, opContext, callback, state) => currentTable.BeginExecute(TableOperation.Insert(insertEntity), (TableRequestOptions)options, opContext, callback, state),
                                                 (res) => currentTable.EndExecute(res));
        }
Ejemplo n.º 2
0
        public void TableServiceContextSaveChangesRetryAPM()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 100; m++)
            {
                // Insert Entity
                ComplexEntity insertEntity = new ComplexEntity("insert test", m.ToString());
                insertEntity.Binary = new byte[20 * 1024];
                ctx.AddObject(currentTable.Name, insertEntity);
            }

            TestHelper.ExecuteAPMMethodWithRetry(3,
                                                 new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertUpstreamNetworkDelay(10000,
                                                                AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                                new BehaviorOptions(2)),
                // After 500 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                    new BehaviorOptions(2))
            },
                                                 (options, opContext, callback, state) => ctx.BeginSaveChangesWithRetries(SaveChangesOptions.Batch, (TableRequestOptions)options, opContext, callback, state),
                                                 (res) => ctx.EndSaveChangesWithRetries(res));
        }