Esempio n. 1
0
        public ScheduleProxy(OrchestrationContext context, Type @interface, bool useFullyQualifiedMethodNames)
        {
            this.context = context;
            interfaze = @interface;
            this.useFullyQualifiedMethodNames = useFullyQualifiedMethodNames;

            //If type can be determined by name
            returnTypes = interfaze.GetMethods()
                .Where(method => !method.IsSpecialName)
                .GroupBy(method => NameVersionHelper.GetDefaultName(method))
                .Where(group => group.Select(method => method.ReturnType).Distinct().Count() == 1)
                .Select(group => new
                {
                    Name = group.Key,
                    ReturnType = group.Select(method => method.ReturnType).Distinct().Single()
                })
                .ToDictionary(info => info.Name, info => info.ReturnType);
        }
Esempio n. 2
0
        public override async Task <bool> RunTask(OrchestrationContext context, MigrateOrchestrationData input)
        {
            this.Initialize(context);

            string subscriptionId = input.SubscriptionId;

            // Only update ttl for enabled subscription
            if (!input.IsDisabled)
            {
                this.status.TtlUpdated = await this.antaresReplatMigrationTasks.UpdateTtl(subscriptionId);

                //this.LogOrchestrationEvent(TraceEventType.Information, "Updated Websites ttl for Subscription '{0}' with result '{1}'".FormatInvariant(subscriptionId,
                //    this.status.TtlUpdated.ToString()));

                // Wait for 1 hour (after TTL update) before starting actual migration to guarantee zero downtime for website
                this.status.TtlUpdateTimerFired = await this.Context.CreateTimer(this.Context.CurrentUtcDateTime.AddSeconds(10), true);
            }

            bool subscriptionLocked = await this.LockSubscription(input.SubscriptionId);

            //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' locked result: {1}".FormatInvariant(subscriptionId, subscriptionLocked.ToString()));

            Application[] apps = await this.managementDatabaseTasks.GetApplicationNames(subscriptionId);

            //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' has '{1}' apps to migrate".FormatInvariant(subscriptionId, apps.Length.ToString()));

            try
            {
                if (subscriptionLocked)
                {
                    if (Validate())
                    {
                        if (input.IsDisabled)
                        {
                            //this.LogOrchestrationEvent(TraceEventType.Information, "Enabling Subscription '{0}' before migration".FormatInvariant(subscriptionId));
                            await this.antaresReplatMigrationTasks.EnableSubscription(input.SubscriptionId);
                        }

                        //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' validated for starting migration".FormatInvariant(subscriptionId));

                        this.status.TotalApplication = apps.Length;
                        this.status.IsMigrated       = await this.ApplyAction(apps, (id, app) => this.MigrateApplication(id, input.SubscriptionId, app));

                        //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' migration result: {1}".FormatInvariant(subscriptionId,
                        //    this.status.IsMigrated));

                        if (this.status.IsMigrated)
                        {
                            this.status.ApplicationsMigrated.Clear();

                            // All Apps redeployed now switch DNS hostname
                            this.status.IsFlipped = await this.ApplyAction(apps, (i, app) => this.antaresReplatMigrationTasks.UpdateWebSiteHostName(subscriptionId, app));

                            //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' flipped result: {1}".FormatInvariant(subscriptionId,
                            //    this.status.IsFlipped));
                        }

                        if (this.status.IsFlipped)
                        {
                            this.status.IsWhitelisted = await SafeTaskInvoke <bool>(() => this.antaresReplatMigrationTasks.WhitelistSubscription(subscriptionId));

                            //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' IsWhitelisted result: {1}".FormatInvariant(subscriptionId,
                            //    this.status.IsWhitelisted));
                        }

                        if (!this.status.IsSuccess)
                        {
                            // TODO: Cleanup all deployed apps (Rollback)
                        }
                    }
                }
            }
            catch (Exception)
            {
                //this.LogOrchestrationEvent(TraceEventType.Error, "Failed to Migrate Subscription '{0}'".FormatInvariant(
                //    subscriptionId), e.ToString());
            }

            if (subscriptionLocked)
            {
                if (input.IsDisabled)
                {
                    //this.LogOrchestrationEvent(TraceEventType.Information, "Disable Subscription '{0}' after migration".FormatInvariant(subscriptionId));
                    await this.antaresReplatMigrationTasks.DisableSubscription(input.SubscriptionId);
                }

                // Unlock subscription
                await this.managementDatabaseTasks.UpsertSubscriptionLock(subscriptionId, isLocked : false);

                //this.LogOrchestrationEvent(TraceEventType.Information, "Subscription '{0}' Unlocked".FormatInvariant(subscriptionId));
            }

            if (this.status.IsSuccess)
            {
                // wait 5 minutes before cleaning up private stamps
                await this.Context.CreateTimer(this.Context.CurrentUtcDateTime.AddSeconds(5), true);

                this.status.IsCleaned = await SafeTaskInvoke <bool>(() => this.antaresReplatMigrationTasks.CleanupPrivateStamp(subscriptionId));

                //this.LogOrchestrationEvent(TraceEventType.Information, "Private stamp cleaned for Subscription '{0}', Result: {1}".FormatInvariant(
                //    subscriptionId, this.status.IsCleaned));
            }

            //this.LogOrchestrationEvent(TraceEventType.Information, "Migration result for Subscription '{0}': {1}".FormatInvariant(
            //            subscriptionId, this.status.IsSuccess));
            return(this.status.IsSuccess);
        }
 private static List <OrchestrationAction> GetCollectedActions(OrchestrationContext orchestrationContext)
 {
     var(_, actions) = orchestrationContext.OrchestrationActionCollector.WaitForActions(new ManualResetEvent(true));
     return(actions);
 }
Esempio n. 4
0
        public override async Task <string> Execute(OrchestrationContext innerContext, string serializedInput)
        {
            if (this.FunctionInvocationCallback == null)
            {
                throw new InvalidOperationException($"The {nameof(this.FunctionInvocationCallback)} has not been assigned!");
            }

            if (!this.config.MessageDataConverter.IsDefault)
            {
                innerContext.MessageDataConverter = this.config.MessageDataConverter;
            }

            if (!this.config.ErrorDataConverter.IsDefault)
            {
                innerContext.ErrorDataConverter = this.config.ErrorDataConverter;
            }

            this.context.InnerContext = innerContext;
            this.context.RawInput     = serializedInput;

            this.Config.TraceHelper.FunctionStarting(
                this.context.HubName,
                this.context.Name,
                this.context.InstanceId,
                this.Config.GetIntputOutputTrace(serializedInput),
                FunctionType.Orchestrator,
                this.context.IsReplaying);

            var orchestratorInfo = this.Config.GetOrchestratorInfo(new FunctionName(this.context.Name));

            if (!this.context.IsReplaying)
            {
                this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorStartingAsync(
                                                 this.context.HubName,
                                                 this.context.Name,
                                                 this.context.InstanceId,
                                                 this.context.IsReplaying));
            }

            object returnValue;

            try
            {
                Task invokeTask = this.FunctionInvocationCallback();
                if (invokeTask is Task <object> resultTask)
                {
                    // Orchestrator threads cannot perform async I/O, so block on such out-of-proc threads.
                    // Possible performance implications; may need revisiting.
                    returnValue = orchestratorInfo.IsOutOfProc ? resultTask.Result : await resultTask;
                }
                else
                {
                    throw new InvalidOperationException("The WebJobs runtime returned a invocation task that does not support return values!");
                }
            }
            catch (Exception e)
            {
                string exceptionDetails = e.ToString();
                this.Config.TraceHelper.FunctionFailed(
                    this.context.HubName,
                    this.context.Name,
                    this.context.InstanceId,
                    exceptionDetails,
                    FunctionType.Orchestrator,
                    this.context.IsReplaying);

                if (!this.context.IsReplaying)
                {
                    this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorFailedAsync(
                                                     this.context.HubName,
                                                     this.context.Name,
                                                     this.context.InstanceId,
                                                     exceptionDetails,
                                                     this.context.IsReplaying));
                }

                var orchestrationException = new OrchestrationFailureException(
                    $"Orchestrator function '{this.context.Name}' failed: {e.Message}",
                    Utils.SerializeCause(e, this.config.ErrorDataConverter));

                this.context.OrchestrationException = ExceptionDispatchInfo.Capture(orchestrationException);

                throw orchestrationException;
            }
            finally
            {
                this.context.IsCompleted = true;
            }

            if (returnValue != null)
            {
                if (orchestratorInfo.IsOutOfProc)
                {
                    var jObj = returnValue as JObject;
                    if (jObj == null && returnValue is string jsonText)
                    {
                        jObj = JObject.Parse(jsonText);
                    }

                    if (jObj != null)
                    {
                        await this.outOfProcShim.HandleOutOfProcExecutionAsync(jObj);
                    }
                    else
                    {
                        throw new ArgumentException("Out of proc orchestrators must return a valid JSON schema.");
                    }
                }
                else
                {
                    this.context.SetOutput(returnValue);
                }
            }

            // release any locks that were held by the orchestration
            // just in case the application code did not do so already
            this.context.ReleaseLocks();

            string serializedOutput = this.context.GetSerializedOutput();

            this.Config.TraceHelper.FunctionCompleted(
                this.context.HubName,
                this.context.Name,
                this.context.InstanceId,
                this.Config.GetIntputOutputTrace(serializedOutput),
                this.context.ContinuedAsNew,
                FunctionType.Orchestrator,
                this.context.IsReplaying);
            if (!this.context.IsReplaying)
            {
                this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorCompletedAsync(
                                                 this.context.HubName,
                                                 this.context.Name,
                                                 this.context.InstanceId,
                                                 this.context.ContinuedAsNew,
                                                 this.context.IsReplaying));
            }

            return(serializedOutput);
        }
Esempio n. 5
0
 public override async Task <string> RunTask(OrchestrationContext context, string input)
 {
     return(await context.ScheduleTask <string>(typeof(WaitActivity), ""));
 }
Esempio n. 6
0
        internal void SendOutbox(OrchestrationContext innerContext, bool writeBackSuccessful, ResponseMessage serializationErrorMessage)
        {
            lock (this.outbox)
            {
                foreach (var message in this.outbox)
                {
                    if (message is LockMessage lockMessage)
                    {
                        this.Config.TraceHelper.SendingEntityMessage(
                            this.InstanceId,
                            this.ExecutionId,
                            lockMessage.Target.InstanceId,
                            lockMessage.EventName,
                            lockMessage.EventContent);

                        innerContext.SendEvent(lockMessage.Target, lockMessage.EventName, lockMessage.EventContent);
                    }
                    else if (message is ResultMessage resultMessage)
                    {
                        // Since for all of the operations in the batch, their effect on the entity state
                        // is lost, we don't want the calling orchestrations to think everything is o.k.
                        // They should be notified, so we replace all non-error operation results
                        // with an exception result.
                        if (!writeBackSuccessful && !resultMessage.IsError)
                        {
                            resultMessage.EventContent = serializationErrorMessage;
                        }

                        this.Config.TraceHelper.SendingEntityMessage(
                            this.InstanceId,
                            this.ExecutionId,
                            resultMessage.Target.InstanceId,
                            resultMessage.EventName,
                            resultMessage.EventContent);

                        innerContext.SendEvent(resultMessage.Target, resultMessage.EventName, resultMessage.EventContent);
                    }
                    else if (!writeBackSuccessful)
                    {
                        // all other messages (signals and fire-and-forget) are suppressed if the writeback failed
                        // this helps to keep the observer pattern correct, for example.
                    }
                    else if (message is OperationMessage operationMessage)
                    {
                        if (!operationMessage.EventContent.ScheduledTime.HasValue)
                        {
                            this.State.MessageSorter.LabelOutgoingMessage(operationMessage.EventContent, operationMessage.Target.InstanceId, DateTime.UtcNow, this.EntityMessageReorderWindow);
                        }

                        this.Config.TraceHelper.SendingEntityMessage(
                            this.InstanceId,
                            this.ExecutionId,
                            operationMessage.Target.InstanceId,
                            operationMessage.EventName,
                            operationMessage.EventContent);

                        innerContext.SendEvent(operationMessage.Target, operationMessage.EventName, operationMessage.EventContent);
                    }
                    else if (message is FireAndForgetMessage fireAndForgetMessage)
                    {
                        var dummyTask = innerContext.CreateSubOrchestrationInstance <object>(
                            fireAndForgetMessage.FunctionName,
                            DurableOrchestrationContext.DefaultVersion,
                            fireAndForgetMessage.InstanceId,
                            fireAndForgetMessage.Input,
                            new Dictionary <string, string>()
                        {
                            { OrchestrationTags.FireAndForget, "" }
                        });

                        System.Diagnostics.Debug.Assert(dummyTask.IsCompleted, "task should be fire-and-forget");
                    }
                }

                this.outbox.Clear();
            }
        }
Esempio n. 7
0
 public override void OnEvent(OrchestrationContext context, string name, string input)
 {
     this.resumeHandle?.SetResult(input);
 }
 public virtual DateTime GetNextExecutionTime(OrchestrationContext context)
 {
     return(context.CurrentUtcDateTime.AddSeconds(Math.Pow(2, targetOchestrationInvocationsCount)));
 }
 public override Task <string> RunTask(OrchestrationContext context, string input)
 {
     _test.InvokedContext = context;
     _test.InvokedInput   = input;
     return(Task.FromResult(input));
 }
            public override async Task <string> RunTask(OrchestrationContext context,
                                                        PrimitiveTypeOrchestrationInput input)
            {
                var activitiesClient = context.CreateClient <IPrimitiveTypeActivitiesClient>();

                Byte =
                    await
                    activitiesClient.ReturnByte(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                input.Str, input.Decimal);

                SByte =
                    await
                    activitiesClient.ReturnSByte(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                 input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                 input.Str, input.Decimal);

                Integer =
                    await
                    activitiesClient.ReturnInteger(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                   input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                   input.Bool, input.Str, input.Decimal);

                UInteger =
                    await
                    activitiesClient.ReturnUInteger(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                    input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                    input.Bool, input.Str, input.Decimal);

                Short =
                    await
                    activitiesClient.ReturnShort(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                 input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                 input.Str, input.Decimal);

                UShort =
                    await
                    activitiesClient.ReturnUShort(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                  input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                  input.Bool, input.Str, input.Decimal);

                Long =
                    await
                    activitiesClient.ReturnLong(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                input.Str, input.Decimal);

                ULong =
                    await
                    activitiesClient.ReturnULong(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                 input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                 input.Str, input.Decimal);

                Float =
                    await
                    activitiesClient.ReturnFloat(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                 input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                 input.Str, input.Decimal);

                Double =
                    await
                    activitiesClient.ReturnDouble(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                  input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                  input.Bool, input.Str, input.Decimal);

                Char =
                    await
                    activitiesClient.ReturnChar(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                input.Str, input.Decimal);

                Bool =
                    await
                    activitiesClient.ReturnBool(input.Byte, input.SByte, input.Integer, input.UInteger, input.Short,
                                                input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char, input.Bool,
                                                input.Str, input.Decimal);

                Str =
                    await
                    activitiesClient.ReturnString(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                  input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                  input.Bool, input.Str, input.Decimal);

                Decimal =
                    await
                    activitiesClient.ReturnDecimal(input.Byte, input.SByte, input.Integer, input.UInteger,
                                                   input.Short, input.UShort, input.Long, input.ULong, input.Float, input.Double, input.Char,
                                                   input.Bool, input.Str, input.Decimal);

                DateTime = await activitiesClient.ReturnDateTime(input.DateTime);

                TimeSpan = await activitiesClient.ReturnTimeSpan(input.TimeSpan);

                MyEnum = await activitiesClient.ReturnEnum(input.Enum);

                ByteArray = await activitiesClient.ReturnByteArray(new[] { input.Byte, input.Byte });

                SByteArray = await activitiesClient.ReturnSByteArray(new[] { input.SByte, input.SByte });

                IntegerArray = await activitiesClient.ReturnIntegerArray(new[] { input.Integer, input.Integer });

                UIntegerArray = await activitiesClient.ReturnUIntegerArray(new[] { input.UInteger, input.UInteger });

                ShortArray = await activitiesClient.ReturnShortArray(new[] { input.Short, input.Short });

                UShortArray = await activitiesClient.ReturnUShortArray(new[] { input.UShort, input.UShort });

                LongArray = await activitiesClient.ReturnLongArray(new[] { input.Long, input.Long });

                ULongArray = await activitiesClient.ReturnULongArray(new[] { input.ULong, input.ULong });

                FloatArray = await activitiesClient.ReturnFloatArray(new[] { input.Float, input.Float });

                DoubleArray = await activitiesClient.ReturnDoubleArray(new[] { input.Double, input.Double });

                CharArray = await activitiesClient.ReturnCharArray(new[] { input.Char, input.Char });

                BoolArray = await activitiesClient.ReturnBoolArray(new[] { input.Bool, input.Bool });

                StrArray = await activitiesClient.ReturnStrArray(new[] { input.Str, input.Str });

                DecimalArray = await activitiesClient.ReturnDecimalArray(new[] { input.Decimal, input.Decimal });

                DateTimeArray = await activitiesClient.ReturnDateTimeArray(new[] { input.DateTime, input.DateTime });

                TimeSpanArray = await activitiesClient.ReturnTimeSpanArray(new[] { input.TimeSpan, input.TimeSpan });

                MyEnumArray = await activitiesClient.ReturnEnumArray(new[] { input.Enum, input.Enum });

                return("Done");
            }
Esempio n. 11
0
 /// <summary>
 /// Abstract method which is called when concrete orchestration has to be started.
 /// </summary>
 /// <param name="context">OrchestrationContext</param>
 /// <param name="input">Orchestration input instance.</param>
 /// <param name="logger">Logger instance used for logging.</param>
 /// <returns></returns>
 protected abstract Task <TOutput> RunOrchestration(OrchestrationContext context, TInput input, ILogger logger);
 internal abstract HistoryEvent GetCompletedHistoryEvent(OrchestrationContext context, HistoryEvent scheduledHistoryEvent);
 internal abstract HistoryEvent GetScheduledHistoryEvent(OrchestrationContext context);
        public override async Task <int> RunTask(OrchestrationContext context, int input)
        {
            var subOrchestrationOutput = await context.CreateSubOrchestrationInstance <int>(EmptyOrchestration.Name, EmptyOrchestration.Version, input);

            return(subOrchestrationOutput);
        }
Esempio n. 15
0
        public override async Task <string> Execute(OrchestrationContext innerContext, string serializedInput)
        {
            // Supress "Variable is assigned but its value is never used" in Functions V1
#pragma warning disable CS0219
            OrchestrationRuntimeStatus status; // for reporting the status of the orchestration on App Insights
#pragma warning restore CS0219

            if (this.FunctionInvocationCallback == null)
            {
                throw new InvalidOperationException($"The {nameof(this.FunctionInvocationCallback)} has not been assigned!");
            }

            if (!this.config.MessageDataConverter.IsDefault)
            {
                innerContext.MessageDataConverter = this.config.MessageDataConverter;
            }

            if (!this.config.ErrorDataConverter.IsDefault)
            {
                innerContext.ErrorDataConverter = this.config.ErrorDataConverter;
            }

            this.context.InnerContext = innerContext;
            this.context.RawInput     = serializedInput;

            this.Config.TraceHelper.FunctionStarting(
                this.context.HubName,
                this.context.Name,
                this.context.InstanceId,
                this.Config.GetIntputOutputTrace(serializedInput),
                FunctionType.Orchestrator,
                this.context.IsReplaying);
            status = OrchestrationRuntimeStatus.Running;
#if !FUNCTIONS_V1
            // On a replay, the orchestrator will either go into a 'Completed'
            // state or a 'Failed' state. We want to avoid tagging them as
            // 'Running' while replaying because this could result in
            // Application Insights reporting the wrong status.
            if (!innerContext.IsReplaying)
            {
                DurableTaskExtension.TagActivityWithOrchestrationStatus(status, this.context.InstanceId);
            }
#endif

            var orchestratorInfo = this.Config.GetOrchestratorInfo(new FunctionName(this.context.Name));

            if (!this.context.IsReplaying)
            {
                this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorStartingAsync(
                                                 this.context.HubName,
                                                 this.context.Name,
                                                 this.context.InstanceId,
                                                 this.context.IsReplaying));
            }

            await this.InvokeUserCodeAndHandleResults(orchestratorInfo, innerContext);

            // release any locks that were held by the orchestration
            // just in case the application code did not do so already
            this.context.ReleaseLocks();

            string serializedOutput = this.context.GetSerializedOutput();

            this.Config.TraceHelper.FunctionCompleted(
                this.context.HubName,
                this.context.Name,
                this.context.InstanceId,
                this.Config.GetIntputOutputTrace(serializedOutput),
                this.context.ContinuedAsNew,
                FunctionType.Orchestrator,
                this.context.IsReplaying);
            status = OrchestrationRuntimeStatus.Completed;

            if (!this.context.IsReplaying)
            {
                this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorCompletedAsync(
                                                 this.context.HubName,
                                                 this.context.Name,
                                                 this.context.InstanceId,
                                                 this.context.ContinuedAsNew,
                                                 this.context.IsReplaying));
            }
#if !FUNCTIONS_V1
            DurableTaskExtension.TagActivityWithOrchestrationStatus(status, this.context.InstanceId);
#endif
            return(serializedOutput);
        }
Esempio n. 16
0
 public abstract Task<string> Execute(OrchestrationContext context, string input);
 public override void OnEvent(OrchestrationContext context, string name, string input)
 {
     _test.InvokedContext = context;
     _test.InvokedInput   = input;
     _test.EventRaised    = name;
 }
        public static void VerifyNoActionAdded(OrchestrationContext orchestrationContext)
        {
            var actions = DurableTestUtilities.GetCollectedActions(orchestrationContext);

            Assert.Empty(actions);
        }
 public override Task <string> RunTask(OrchestrationContext context, int input)
 {
     return(Task.FromResult($"Child '{input}' completed."));
 }
Esempio n. 20
0
 public override Task <string> RunTask(OrchestrationContext context, int input)
 {
     Count++;
     throw new InvalidOperationException("Test");
 }
Esempio n. 21
0
 public Guid GenerateGuid(
     OrchestrationContext context,
     OrchestrationGuidGenerator guidGenerator)
 {
     return(guidGenerator.NewGuid());
 }
Esempio n. 22
0
#pragma warning disable 1998
            public override async Task <string> RunTask(OrchestrationContext context, string input)
#pragma warning restore 1998
            {
                throw new Exception("something very bad happened");
            }
        public override async Task <string> Execute(OrchestrationContext innerContext, string serializedInput)
        {
#if !FUNCTIONS_V1
            // Adding "Tags" to activity allows using App Insights to query current state of entities
            var activity = Activity.Current;
            OrchestrationRuntimeStatus status = OrchestrationRuntimeStatus.Running;

            DurableTaskExtension.TagActivityWithOrchestrationStatus(status, this.context.InstanceId, true);
#endif

            if (this.operationBatch.Count == 0 &&
                this.lockRequest == null &&
                (this.toBeRescheduled == null || this.toBeRescheduled.Count == 0))
            {
                // we are idle after a ContinueAsNew - the batch is empty.
                // Wait for more messages to get here (via extended sessions)
                await this.doneProcessingMessages.Task;
            }

            if (!this.messageDataConverter.IsDefault)
            {
                innerContext.MessageDataConverter = this.messageDataConverter;
            }

            if (!this.errorDataConverter.IsDefault)
            {
                innerContext.ErrorDataConverter = this.errorDataConverter;
            }

            this.Config.TraceHelper.FunctionStarting(
                this.context.HubName,
                this.context.Name,
                this.context.InstanceId,
                this.Config.GetIntputOutputTrace(serializedInput),
                FunctionType.Entity,
                isReplay: false);

            if (this.NumberEventsToReceive > 0)
            {
                await this.doneProcessingMessages.Task;
            }

            // Commit the effects of this batch, if
            // we have not already run into an internal error
            // (in which case we will abort the batch instead of committing it)
            if (this.context.InternalError == null)
            {
                bool            writeBackSuccessful       = true;
                ResponseMessage serializationErrorMessage = null;

                if (this.RollbackFailedOperations)
                {
                    // the state has already been written back, since it is
                    // done right after each operation.
                }
                else
                {
                    // we are writing back the state here, after executing
                    // the entire batch of operations.
                    writeBackSuccessful = this.context.TryWriteback(out serializationErrorMessage);
                }

                // Reschedule all signals that were received before their time
                this.context.RescheduleMessages(innerContext, this.toBeRescheduled);

                // Send all buffered outgoing messages
                this.context.SendOutbox(innerContext, writeBackSuccessful, serializationErrorMessage);

                var jstate = JToken.FromObject(this.context.State);

                // continue as new
                innerContext.ContinueAsNew(jstate);
            }

            if (this.context.ErrorsPresent(out var description))
            {
                this.Config.TraceHelper.FunctionFailed(
                    this.context.HubName,
                    this.context.Name,
                    this.context.InstanceId,
                    description,
                    functionType: FunctionType.Entity,
                    isReplay: false);
            }
            else
            {
                this.Config.TraceHelper.FunctionCompleted(
                    this.context.HubName,
                    this.context.Name,
                    this.context.InstanceId,
                    this.Config.GetIntputOutputTrace(this.context.State.EntityState),
                    continuedAsNew: true,
                    functionType: FunctionType.Entity,
                    isReplay: false);
            }

            // The return value is not used.
            return(string.Empty);
        }
Esempio n. 24
0
 public override Task <string> RunTask(OrchestrationContext context, object input)
 {
     ChildInstanceId = context.OrchestrationInstance.InstanceId;
     return(Task.FromResult <string>(null));
 }
Esempio n. 25
0
 public override Task <string> RunTask(OrchestrationContext context, string input)
 {
     return(Task.FromResult("SOME_RESULT"));
 }
Esempio n. 26
0
 public OrchestrationEventReceiver(OrchestrationContext orchestrationContext)
     : this(orchestrationContext, new TypelessJsonDataConverter())
 {
 }
        private static void VerifyNoCallActivityActionAdded(OrchestrationContext orchestrationContext)
        {
            var actions = GetCollectedActions(orchestrationContext);

            Assert.Empty(actions);
        }
Esempio n. 28
0
 public override void OnEvent(OrchestrationContext context, string name, UtilitySignupOrchestrationEvent input)
 {
 }
Esempio n. 29
0
 public override void OnEvent(OrchestrationContext context, string name, string input)
 {
     base.OnEvent(context, name, input);
 }
 public sealed override void RaiseEvent(OrchestrationContext context, string name, string input)
 {
     EventReceiver.RaiseEvent(name, input);
 }
 public override void RaiseEvent(OrchestrationContext unused, string eventName, string serializedEventData)
 {
     this.context.RaiseEvent(eventName, serializedEventData);
 }
Esempio n. 32
0
        public override async Task <object> RunTask(OrchestrationContext context, object input)
        {
            var output = await context.CreateTimer <object>(DateTime.UtcNow.AddSeconds(2), input);

            return(output);
        }
Esempio n. 33
0
 public abstract void RaiseEvent(OrchestrationContext context, string name, string input);
Esempio n. 34
0
 public ScheduleProxy(OrchestrationContext context, Type @interface)
     : this(context, @interface, false)
 {
 }