private async Task StartTransactions(List <TimeSpan> startingTransactions, List <TaskCompletionSource <long> > startCompletions) { try { StartTransactionsResponse startResponse = await this.tmService.StartTransactions(startingTransactions); List <long> startedIds = startResponse.TransactionId; // reply to clients with results for (int i = 0; i < startCompletions.Count; i++) { TransactionsStatisticsGroup.OnTransactionStarted(); startCompletions[i].SetResult(startedIds[i]); } // Refresh cached values using new values from TM. this.ReadOnlyTransactionId = Math.Max(this.ReadOnlyTransactionId, startResponse.ReadOnlyTransactionId); this.abortLowerBound = Math.Max(this.abortLowerBound, startResponse.AbortLowerBound); logger.Verbose(ErrorCode.Transactions_ReceivedTMResponse, "{0} Transactions started. readOnlyTransactionId {1}, abortLowerBound {2}", startingTransactions.Count, ReadOnlyTransactionId, abortLowerBound); } catch (Exception e) { logger.Error(ErrorCode.Transactions_TMError, "Transaction manager failed to start transactions.", e); foreach (var completion in startCompletions) { TransactionsStatisticsGroup.OnTransactionStartFailed(); completion.SetException(new OrleansStartTransactionFailedException(e)); } } startingTransactions.Clear(); startCompletions.Clear(); }
public Task <StartTransactionsResponse> StartTransactions(List <TimeSpan> timeouts) { var result = new StartTransactionsResponse { TransactionId = new List <long>() }; foreach (var timeout in timeouts) { result.TransactionId.Add(tm.StartTransaction(timeout)); } result.ReadOnlyTransactionId = tm.GetReadOnlyTransactionId(); result.AbortLowerBound = result.ReadOnlyTransactionId; return(Task.FromResult(result)); }