Ejemplo n.º 1
0
        private async Task <OrchestrationState> ConvertFromAsync(OrchestrationInstanceStatus orchestrationInstanceStatus, string instanceId)
        {
            var orchestrationState = new OrchestrationState();

            if (!Enum.TryParse(orchestrationInstanceStatus.RuntimeStatus, out orchestrationState.OrchestrationStatus))
            {
                throw new ArgumentException($"{orchestrationInstanceStatus.RuntimeStatus} is not a valid OrchestrationStatus value.");
            }

            orchestrationState.OrchestrationInstance = new OrchestrationInstance
            {
                InstanceId  = instanceId,
                ExecutionId = orchestrationInstanceStatus.ExecutionId,
            };

            orchestrationState.Name            = orchestrationInstanceStatus.Name;
            orchestrationState.Version         = orchestrationInstanceStatus.Version;
            orchestrationState.Status          = orchestrationInstanceStatus.CustomStatus;
            orchestrationState.CreatedTime     = orchestrationInstanceStatus.CreatedTime;
            orchestrationState.LastUpdatedTime = orchestrationInstanceStatus.LastUpdatedTime;

            string[] results = await Task.WhenAll(
                this.GetOrchestrationInputAsync(orchestrationInstanceStatus),
                this.GetOrchestrationOutputAsync(orchestrationInstanceStatus));

            orchestrationState.Input  = results[0];
            orchestrationState.Output = results[1];

            return(orchestrationState);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override async Task <OrchestrationState> GetStateAsync(string instanceId, string executionId)
        {
            if (instanceId == null)
            {
                throw new ArgumentNullException(nameof(instanceId));
            }

            var         stopwatch     = new Stopwatch();
            TableResult orchestration = await this.InstancesTable.ExecuteAsync(TableOperation.Retrieve <OrchestrationInstanceStatus>(instanceId, ""));

            stopwatch.Stop();
            this.stats.StorageRequests.Increment();
            this.stats.TableEntitiesRead.Increment(1);

            AnalyticsEventSource.Log.FetchedInstanceStatus(
                this.storageAccountName,
                this.taskHubName,
                instanceId,
                executionId ?? string.Empty,
                stopwatch.ElapsedMilliseconds,
                Utils.ExtensionVersion);

            OrchestrationInstanceStatus orchestrationInstanceStatus = (OrchestrationInstanceStatus)orchestration.Result;

            if (orchestrationInstanceStatus == null)
            {
                return(null);
            }

            return(await this.ConvertFromAsync(orchestrationInstanceStatus, instanceId));
        }
        async Task <string> GetOrchestrationInputAsync(OrchestrationInstanceStatus orchestrationInstanceStatus)
        {
            if (string.IsNullOrEmpty(orchestrationInstanceStatus.InputBlobName))
            {
                return(orchestrationInstanceStatus.Input);
            }

            return(await this.messageManager.DownloadAndDecompressAsBytesAsync(orchestrationInstanceStatus.InputBlobName));
        }
        /// <inheritdoc />
        public override async Task <OrchestrationState> GetStateAsync(string instanceId, string executionId)
        {
            if (instanceId == null)
            {
                throw new ArgumentNullException(nameof(instanceId));
            }

            var         stopwatch     = new Stopwatch();
            TableResult orchestration = await this.InstancesTable.ExecuteAsync(TableOperation.Retrieve <OrchestrationInstanceStatus>(instanceId, ""));

            stopwatch.Stop();
            this.stats.StorageRequests.Increment();
            this.stats.TableEntitiesRead.Increment(1);

            AnalyticsEventSource.Log.FetchedInstanceStatus(
                this.storageAccountName,
                this.taskHubName,
                instanceId,
                executionId ?? string.Empty,
                stopwatch.ElapsedMilliseconds);

            OrchestrationInstanceStatus orchestrationInstanceStatus = (OrchestrationInstanceStatus)orchestration.Result;

            if (orchestrationInstanceStatus == null)
            {
                return(null);
            }

            var orchestrationState = new OrchestrationState();

            if (!Enum.TryParse(orchestrationInstanceStatus.RuntimeStatus, out orchestrationState.OrchestrationStatus))
            {
                throw new ArgumentException($"{orchestrationInstanceStatus.RuntimeStatus} is not a valid OrchestrationStatus value.");
            }

            orchestrationState.OrchestrationInstance = new OrchestrationInstance
            {
                InstanceId  = instanceId,
                ExecutionId = orchestrationInstanceStatus.ExecutionId,
            };

            orchestrationState.Name            = orchestrationInstanceStatus.Name;
            orchestrationState.Version         = orchestrationInstanceStatus.Version;
            orchestrationState.Status          = orchestrationInstanceStatus.CustomStatus;
            orchestrationState.CreatedTime     = orchestrationInstanceStatus.CreatedTime;
            orchestrationState.LastUpdatedTime = orchestrationInstanceStatus.LastUpdatedTime;

            string[] results = await Task.WhenAll(
                this.GetOrchestrationInputAsync(orchestrationInstanceStatus),
                this.GetOrchestrationOutputAsync(orchestrationInstanceStatus));

            orchestrationState.Input  = results[0];
            orchestrationState.Output = results[1];

            return(orchestrationState);
        }