/// <summary> /// Overrides the base ExecuteAsync() semantics to add a listener available for in-progress updates of information /// from the processing engine. /// </summary> public override Task <TSubGridRequestsResponse> ExecuteAsync() { PrepareForExecution(); // Construct the function to be used var func = new SubGridsRequestComputeFuncProgressive <TSubGridsRequestArgument, TSubGridRequestsResponse>(); return(Compute.BroadcastAsync(func, arg) .ContinueWith(result => result.Result.Aggregate((first, second) => (TSubGridRequestsResponse)first.AggregateWith(second))) .ContinueWith(x => { Log.LogInformation($"SubGridRequests.ExecuteAsync() for DM:{TRexTask.PipeLine.DataModelID} from node {TRexTask.TRexNodeID} for data type {TRexTask.GridDataType}"); return x.WaitAndUnwrapException(); })); }
/// <summary> /// Overrides the base Execute() semantics to add a listener available for in-progress updates of information /// from the processing engine. /// </summary> public override TSubGridRequestsResponse Execute() { const int TIME_LIMIT_MS = 30000; PrepareForExecution(); Task <ICollection <TSubGridRequestsResponse> > taskResult = null; var sw = Stopwatch.StartNew(); try { // Construct the function to be used var func = new SubGridsRequestComputeFuncProgressive <TSubGridsRequestArgument, TSubGridRequestsResponse>(); taskResult = Compute.BroadcastAsync(func, arg); if (!taskResult.Wait(TIME_LIMIT_MS)) { Log.LogWarning($"Progressive sub grid request from node {TRexTask.TRexNodeID} timeout out after {TIME_LIMIT_MS}ms"); } if (taskResult.Status != TaskStatus.RanToCompletion) { Log.LogWarning($"Progressive sub grid request from node {TRexTask.TRexNodeID}, project {TRexTask.PipeLine.DataModelID}, failed to complete inside its time limit ({TIME_LIMIT_MS}ms). Status is {taskResult.Status}. IsFaulted = {taskResult.IsFaulted}"); if (taskResult.Exception != null) { Log.LogError(taskResult.Exception, "Exception raised in Compute.BroadcastAsync()"); } } } finally { Log.LogInformation($"TaskResult {taskResult?.Status}: SubGridRequests.Execute() for DM:{TRexTask.PipeLine.DataModelID} from node {TRexTask.TRexNodeID} for data type {TRexTask.GridDataType} took {sw.ElapsedMilliseconds}ms"); } // Send the appropriate response to the caller return(taskResult.Result?.Count > 0 ? taskResult.Result.Aggregate((first, second) => (TSubGridRequestsResponse)first.AggregateWith(second)) : null); }