Example #1
0
        public void Kill()
        {
            bool killStreaming = false;

            lock (this)
            {
                switch (this.status)
                {
                case JobStatus.NotSubmitted:
                    throw new ApplicationException("Can't kill a job before it is submitted");

                case JobStatus.Waiting:
                    killStreaming = true;
                    break;

                case JobStatus.Running:
                    break;

                case JobStatus.Success:
                case JobStatus.Failure:
                case JobStatus.Cancelled:
                    return;
                }
            }

            if (killStreaming)
            {
                JobStatusCode streamingStatus = this.client.JobClient.GetJob(launchJob.JobId).StatusCode;
                if (streamingStatus == JobStatusCode.Initializing)
                {
                    this.client.JobClient.StopJob(launchJob.JobId);
                }
                else if (streamingStatus == JobStatusCode.Running)
                {
                    JobDetails details = this.client.JobClient.WaitForJobCompletion(launchJob, TimeSpan.MaxValue, CancellationToken.None);
                    if (details.StatusCode != JobStatusCode.Completed)
                    {
                        // nothing to do
                        return;
                    }
                    bool mustKill = this.started.Task.Result;
                }
            }

            Azure.Utils.KillJob(errorLocation);
        }
Example #2
0
 public Job(
     string jobId,
     string imageConversionMode,
     JobStatusCode status,
     string imageSource,
     string imageResult       = null,
     string statusDescription = null
     )
 {
     this.RowKey = jobId;
     this.imageConversionMode = imageConversionMode;
     this.status            = (int)status;
     this.imageSource       = imageSource;
     this.imageResult       = imageResult;
     this.statusDescription = statusDescription == null?
                              GetStatusMessage(status) :
                                  statusDescription;
 }
        /// <summary>
        /// Updates the job record's status and statusDescription.
        /// </summary>
        /// <param name="jobId">The job identifier.</param>
        /// <param name="status">Job status to set.</param>
        /// <param name="message">The statusDescription. Uses default messages if unspecified.</param>
        public async Task <TableResult> UpdateJobStatus(string jobId, JobStatusCode status, string message = null, string outputUrl = null)
        {
            Job job = await RetrieveJob(jobId);

            if (job != null)
            {
                job.status            = (int)status;
                job.statusDescription = message != null ?
                                        message :
                                        Job.GetStatusMessage(status);
                job.imageResult = outputUrl;
                return(await UpdateJob(job));
            }
            else
            {
                throw new ArgumentException($"Job ID {jobId} does not exist.");
            }
        }
Example #4
0
        public static string GetStatusMessage(JobStatusCode code)
        {
            switch (code)
            {
            case JobStatusCode.Received:
                return("Image Obtained");

            case JobStatusCode.Converting:
                return("Image Being Converted");

            case JobStatusCode.Success:
                return("Image Converted with success");

            case JobStatusCode.Failure:
                return("Image Failed Conversion");

            default:
                return("Unknown state!");
            }
        }
Example #5
0
        private JobStatus PpnJobStatusFromHdpJobStatus(JobStatusCode hadoopJobCode)
        {
            switch (hadoopJobCode)
            {
            case JobStatusCode.Canceled:
                return(JobStatus.Cancelled);

            case JobStatusCode.Completed:
                return(JobStatus.Success);

            case JobStatusCode.Failed:
                return(JobStatus.Failure);

            case JobStatusCode.Initializing:
                return(JobStatus.Waiting);

            case JobStatusCode.Running:
                return(JobStatus.Running);

            case JobStatusCode.Unknown:
                throw new ApplicationException("'Unknown' state for job running on cluster");
            }
            throw new ApplicationException("Undefined state in JobStatusCode not implemented in Peloponnese JobStatus enum.");
        }