Пример #1
0
        public Task OnReportTaskFailure(string taskId, long instanceId)
        {
            PendingCommandContext startContext  = this.pendingStartCommands.Get(taskId);
            PendingCommandContext finishContext = this.pendingFinishCommands.Get(taskId);

            if (startContext != null)
            {
                if (startContext.ShouldInjectFault)
                {
                    return(Task.Factory.StartNew(() => { throw new InvalidOperationException("OnReportTaskFailure: Injected Fault"); }));
                }

                if (startContext.InstanceId == instanceId)
                {
                    startContext.Fail(Trace.CreateException(
                                          TraceType,
                                          NativeTypes.FABRIC_ERROR_CODE.E_FAIL,
                                          "Task failure reported"));
                    this.pendingStartCommands.Remove(startContext.MapKey);
                }
                else if (finishContext != null)
                {
                    startContext.Cancel();
                    this.pendingStartCommands.Remove(startContext.MapKey);
                }
                else if (finishContext == null)
                {
                    this.ProcessStartCommand(startContext);
                }
            }

            if (finishContext != null)
            {
                if (finishContext.ShouldInjectFault)
                {
                    return(Task.Factory.StartNew(() => { throw new InvalidOperationException("OnReportTaskFailure: Injected Fault"); }));
                }

                if (finishContext.InstanceId == instanceId)
                {
                    finishContext.Fail(Trace.CreateException(
                                           TraceType,
                                           NativeTypes.FABRIC_ERROR_CODE.E_FAIL,
                                           "Task failure reported"));
                    this.pendingFinishCommands.Remove(finishContext.MapKey);
                }
                else
                {
                    this.ProcessFinishCommand(finishContext);
                }
            }

            return(Utility.CreateCompletedTask <object>(null));
        }
Пример #2
0
        private void OnInfrastructureTaskRequestComplete(Task prevTask, PendingCommandContext commandContext)
        {
            var ex = prevTask.Exception;

            if (ex != null)
            {
                Exception translated = Utility.TryTranslateManagedExceptionToCOM(ex.InnerException);
                commandContext.Fail(translated == null ? ex.InnerException : translated);
            }
            else
            {
                // Do nothing: wait for the ack from CM
            }
        }