Exemplo n.º 1
0
        public IHttpActionResult JobFailed([FromBody] JobFailed jobFailed)
        {
            var isValidRequest = _validator.ValidateObject(jobFailed);

            if (!isValidRequest.Success)
            {
                return(BadRequest(isValidRequest.Message));
            }

            Task.Factory.StartNew(() =>
            {
                var workerNodeUri = Request.RequestUri.GetLeftPart(UriPartial.Authority);

                this.Log().InfoWithLineNumber(WhoAmI(Request) + ": Received job failed from a Node ( jobId, Node ) : ( " +
                                              jobFailed.JobId + ", " + workerNodeUri + " )");

                var progress = new JobDetail
                {
                    JobId   = jobFailed.JobId,
                    Created = DateTime.UtcNow,
                    Detail  = jobFailed.AggregateException.ToString()
                };

                _jobManager.CreateJobDetail(progress);

                _jobManager.UpdateResultForJob(jobFailed.JobId,
                                               "Failed",
                                               DateTime.UtcNow);

                _jobManager.AssignJobToWorkerNodes();
            });

            return(Ok());
        }
        public void ShouldReturnBadRequestIfJobFailedGetsInvalidJobFailedModel()
        {
            var jobFailed = new JobFailed();

            var response = ManagerController.JobFailed(jobFailed);

            Assert.IsInstanceOf(typeof(BadRequestErrorMessageResult), response);
        }
Exemplo n.º 3
0
 public void DoJob()
 {
     try
     {
         OnDoJob();
         JobFinished?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception err)
     {
         JobFailed?.Invoke(this, err);
         throw;
     }
 }
Exemplo n.º 4
0
        public void OnJobFailed(JobInfo job, string reason, string details = null, bool notifyUser = false)
        {
            using var scope       = scopeFactory.CreateScope();
            using var dataContext = scope.ServiceProvider.GetRequiredService <DataContext>();

            job.State     = JobState.Failed;
            job.Completed = DateTimeOffset.UtcNow;
            dataContext.SaveChanges();

            userLogger.LogInfo("Job failed", reason, userId: job.UserId, jobId: job.Id);
            JobFailed?.Invoke(this, new JobFailedEventArgs()
            {
                Job = job, Reason = reason, Details = details
            });
        }
 public void InvokeJobFailed(TranslationJob job)
 {
     JobFailed?.Invoke(job);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Method to handle action taken when a job is put in retry.
 /// This method is called after the retry has been marked in storage.
 /// </summary>
 /// <param name="msg">the Job retry message</param>
 protected virtual void OnJobRetry(JobFailed msg)
 {
 }
Exemplo n.º 7
0
 private void OnJobFailed(JobFailedEventArgs eventArgs) => JobFailed?.Invoke(this, eventArgs);