Ejemplo n.º 1
0
        public void SetException(Exception e)
        {
            lock (_stateLock)
            {
                try
                {
                    if (HasEnded())
                    {
                        // Note that this is possible if the job is already DONE, but a
                        // Task Close is triggered prior to the DONE signal propagates to the
                        // Driver. If the Task Close handler is not implemented, the Handler will
                        // mark the Task with an Exception, although for all intents and purposes
                        // the Task is already done and should not be affected.
                        return;
                    }

                    if (!_lastException.IsPresent())
                    {
                        _lastException = Optional <Exception> .Of(e);
                    }

                    State = TaskState.Failed;
                    _taskLifeCycle.Stop();
                }
                finally
                {
                    Heartbeat();
                }
            }
        }
Ejemplo n.º 2
0
 public void SetException(Exception e)
 {
     lock (_stateLock)
     {
         if (!_lastException.IsPresent())
         {
             _lastException = Optional <Exception> .Of(e);
         }
         State = TaskState.Failed;
         _taskLifeCycle.Stop();
         Heartbeat();
     }
 }
Ejemplo n.º 3
0
        public void SetResult(byte[] result)
        {
            _result = Optional <byte[]> .OfNullable(result);

            if (State == TaskState.Running)
            {
                State = TaskState.Done;
            }
            else if (State == TaskState.SuspendRequested)
            {
                State = TaskState.Suspended;
            }
            else if (State == TaskState.CloseRequested)
            {
                State = TaskState.Done;
            }
            _taskLifeCycle.Stop();
            Heartbeat();
        }
Ejemplo n.º 4
0
        public void SetException(Exception e)
        {
            lock (_heartBeatManager)
            {
                try
                {
                    if (!_lastException.IsPresent())
                    {
                        _lastException = Optional <Exception> .Of(e);
                    }

                    State = TaskState.Failed;
                    _taskLifeCycle.Stop();
                }
                finally
                {
                    Heartbeat();
                }
            }
        }
Ejemplo n.º 5
0
        public void SetResult(byte[] result)
        {
            lock (_heartBeatManager)
            {
                _result = Optional <byte[]> .OfNullable(result);

                // This can throw an Exception.
                _taskLifeCycle.Stop();

                switch (State)
                {
                case TaskState.SuspendRequested:
                    State = TaskState.Suspended;
                    break;

                case TaskState.Running:
                case TaskState.CloseRequested:
                    State = TaskState.Done;
                    break;
                }

                Heartbeat();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Runs the Task Stop Handlers
 /// </summary>
 /// <exception cref="TaskStopHandlerException">If any of the Task Stop Handlers throws an exception</exception>
 public void RunTaskStopHandlers()
 {
     _taskLifeCycle.Stop();
 }