Esempio n. 1
0
        public async Task SignalTasksCompleted(TaskExecutionRequest request)
        {
            if (request.TaskOrchestratorInstanceId != CurrentRequest.TaskOrchestratorInstanceId)
            {
                // this would be bad but should never happen
            }
            CurrentRequest = null;
            await client.RaiseEventAsync(request.TaskOrchestratorInstanceId, "TasksCompleted", null);

            await RunNextTaskIfComputeIsAvailable();
        }
Esempio n. 2
0
        private async Task RunNextTaskIfComputeIsAvailable()
        {
            if (Status != ComputeSetStatus.Running)
            {
                if (Status == ComputeSetStatus.NotStarted)
                {
                    Entity.Current.StartNewOrchestration(nameof(Orchestrators.StartComputeSetOrchestrator), Entity.Current.EntityKey);
                    Status = ComputeSetStatus.Starting;
                }
                return;
            }

            var computeIsAvailable = CurrentRequest == null;

            if (!computeIsAvailable)
            {
                return;
            }

            if (!InstanceIdQueue.TryDequeue(out var instanceId))
            {
                // no pending tasks
                return;
            }

            // get the task hierarchy from the input of the orchestrator
            // (so the entity only needs to keep a queue of orchestration ids)
            var taskOrchestrator = await client.GetStatusAsync(instanceId);

            var taskHierarchy = taskOrchestrator.Input.ToObject <TaskHierarchy>();

            CurrentRequest = new TaskExecutionRequest
            {
                TaskOrchestratorInstanceId = instanceId,
                Tasks = taskHierarchy
            };
            Entity.Current.StartNewOrchestration(nameof(Orchestrators.TaskExecutionOrchestrator), CurrentRequest);
        }