public void TableIngressEgressBatch() { CloudTableClient tableClient = GenerateCloudTableClient(); TableBatchOperation batch = new TableBatchOperation(); for (int m = 0; m < 100; m++) { // Insert Entity DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", m.ToString()); insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[30 * 1024])); batch.InsertOrMerge(insertEntity); } // APM TestHelper.ValidateIngressEgress(Selectors.IfUrlContains("$batch"), () => { OperationContext opContext = new OperationContext(); currentTable.EndExecuteBatch(currentTable.BeginExecuteBatch(batch, new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext, null, null)); return(opContext.LastResult); }); // SYNC TestHelper.ValidateIngressEgress(Selectors.IfUrlContains("$batch"), () => { OperationContext opContext = new OperationContext(); currentTable.ExecuteBatch(batch, new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext); return(opContext.LastResult); }); }
void _execute(CloudTable table, TaskCompletionSource<bool> runTask = null) { DelayedBatchOperation op; if (runTask == null) { runTask = new TaskCompletionSource<bool>(TaskCreationOptions.AttachedToParent); var t = runTask.Task; } if (batchQueue.TryDequeue(out op)) { table.BeginExecuteBatch(op.TableBatchOperation, sync => { var ope = op; try { var resp = table.EndExecuteBatch(sync); } catch (Exception ex) { runTask.SetException(ex); return; } _execute(table, runTask); }, null); } else { lock (executeLock) { isExecuting = false; runTask.SetResult(true); } } }
public void TableBatchOperationCancellation() { CloudTableClient tableClient = GenerateCloudTableClient(); TableBatchOperation batch = new TableBatchOperation(); for (int m = 0; m < 100; m++) { // Insert Entity DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", m.ToString()); insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[30 * 1024])); batch.Insert(insertEntity); } TestHelper.ExecuteAPMMethodWithCancellation(4000, new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, XStoreSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) }, (options, opContext, callback, state) => currentTable.BeginExecuteBatch(batch, (TableRequestOptions)options, opContext, callback, state), (res) => currentTable.EndExecuteBatch(res)); }