Ejemplo n.º 1
0
        /// <inheritdoc />
        public override async Task <PipResultStatus> MaterializeOutputsAsync(RunnablePip runnablePip)
        {
            using (var operationContext = runnablePip.OperationContext.StartAsyncOperation(PipExecutorCounter.ExecuteStepOnAllRemotesDuration))
                using (runnablePip.EnterOperation(operationContext))
                {
                    Task <PipResultStatus>[] tasks = new Task <PipResultStatus> [m_workers.Length];

                    // Start from the remote workers
                    for (int i = m_workers.Length - 1; i >= 0; i--)
                    {
                        var worker = m_workers[i];
                        tasks[i] = Task.Run(() => worker.MaterializeOutputsAsync(runnablePip));
                    }

                    var results = await Task.WhenAll(tasks);

                    foreach (var result in results)
                    {
                        if (result.IndicatesFailure())
                        {
                            return(result);
                        }
                    }

                    return(results[0]);
                }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override async Task <PipResultStatus> MaterializeOutputsAsync(RunnablePip runnablePip)
        {
            using (var operationContext = runnablePip.OperationContext.StartAsyncOperation(PipExecutorCounter.ExecuteStepOnAllRemotesDuration))
                using (runnablePip.EnterOperation(operationContext))
                {
                    Task <PipResultStatus>[] tasks = new Task <PipResultStatus> [m_workers.Length];

                    Logger.Log.DistributionExecutePipRequest(operationContext, runnablePip.FormattedSemiStableHash, Name, nameof(PipExecutionStep.MaterializeOutputs));

                    // Start from the remote workers
                    for (int i = m_workers.Length - 1; i >= 0; i--)
                    {
                        var worker = m_workers[i];
                        tasks[i] = Task.Run(() => worker.MaterializeOutputsAsync(runnablePip));
                    }

                    var results = await Task.WhenAll(tasks);

                    Logger.Log.DistributionFinishedPipRequest(operationContext, runnablePip.FormattedSemiStableHash, Name, "MaterializeOutput");

                    foreach (var result in results)
                    {
                        if (result.IndicatesFailure())
                        {
                            return(result);
                        }
                    }

                    return(results[0]);
                }
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public override async Task <PipResultStatus> MaterializeOutputsAsync(RunnablePip runnablePip)
        {
            using (var operationContext = runnablePip.OperationContext.StartAsyncOperation(PipExecutorCounter.ExecuteStepOnAllRemotesDuration))
                using (runnablePip.EnterOperation(operationContext))
                {
                    Task <PipResultStatus>[] tasks = new Task <PipResultStatus> [m_workers.Length];

                    // Start from the remote workers
                    for (int i = m_workers.Length - 1; i >= 0; i--)
                    {
                        var worker = m_workers[i];
                        if (worker.IsLocal)
                        {
                            await m_localMaterializeOutputsSemaphore.WaitAsync();
                        }

                        tasks[i] = Task.Run(() => worker.MaterializeOutputsAsync(runnablePip));
                    }

                    // Await the local worker first to release the semaphore.
                    await tasks[LocalWorkerIndex];
                    m_localMaterializeOutputsSemaphore.Release();

                    var results = await Task.WhenAll(tasks);

                    foreach (var result in results)
                    {
                        if (result.IndicatesFailure())
                        {
                            return(result);
                        }
                    }

                    return(results[0]);
                }
        }