internal void DoSetJobState(JobState state, Exception reason = null) { if (!this._disposed) { try { this._tracer.WriteMessage("PSChildJobProxy", "DoSetJobState", Guid.Empty, this, "BEGIN Set job state to {0} and call event handlers", new string[] { state.ToString() }); StructuredTracer.BeginProxyChildJobEventHandler(base.InstanceId); base.SetJobState(state, reason); StructuredTracer.EndProxyJobEventHandler(base.InstanceId); this._tracer.WriteMessage("PSChildJobProxy", "DoSetJobState", Guid.Empty, this, "END Set job state to {0} and call event handlers", new string[] { state.ToString() }); } catch (ObjectDisposedException) { } } }
public PeekRequest(JobState state) { if (state != JobState.Ready && state != JobState.Delayed && state != JobState.Buried) { throw new ArgumentOutOfRangeException("Cannot peek jobs in state " + state.ToString()); } _state = state; _id = null; }
private void _job_OnJobStateChanged(object sender, JobState newJobState) { lbl.Text = msg.Text = newJobState.ToString(); if (newJobState == JobState.Busy) { pbr.Style = ProgressBarStyle.Marquee; } else { pbr.Style = ProgressBarStyle.Blocks; } Application.DoEvents(); }
public virtual void TestFromYarnJobReport() { int jobStartTime = 612354; int jobFinishTime = 612355; JobState state = JobState.Running; JobId jobId = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <JobId>(); JobReport jobReport = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <JobReport>(); ApplicationId applicationId = ApplicationId.NewInstance(0, 0); jobId.SetAppId(applicationId); jobId.SetId(0); jobReport.SetJobId(jobId); jobReport.SetJobState(state); jobReport.SetStartTime(jobStartTime); jobReport.SetFinishTime(jobFinishTime); jobReport.SetUser("TestTypeConverter-user"); JobStatus jobStatus = TypeConverter.FromYarn(jobReport, "dummy-jobfile"); NUnit.Framework.Assert.AreEqual(jobStartTime, jobStatus.GetStartTime()); NUnit.Framework.Assert.AreEqual(jobFinishTime, jobStatus.GetFinishTime()); NUnit.Framework.Assert.AreEqual(state.ToString(), jobStatus.GetState().ToString() ); }
public async Task NotifyUserJobStateChange(string userId, JobState newJobState) { switch (newJobState) { case JobState.Submitting: case JobState.Uploading: case JobState.Encoding: case JobState.Finalizing: case JobState.Finished: await _jobUpdateHub.Clients.Group(userId).SendAsync( "jobStateChange", newJobState.ToString().ToLower()); break; case JobState.None: break; default: throw new ArgumentOutOfRangeException(nameof(newJobState), newJobState, $"{newJobState} is not a valid variant of the JobState enum"); } }
public virtual void TestJobsQueryStateNone() { WebResource r = Resource(); AList <JobState> JobStates = new AList <JobState>(Arrays.AsList(JobState.Values())); // find a state that isn't in use IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobsMap = appContext .GetAllJobs(); foreach (KeyValuePair <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> entry in jobsMap) { JobStates.Remove(entry.Value.GetState()); } NUnit.Framework.Assert.IsTrue("No unused job states", JobStates.Count > 0); JobState notInUse = JobStates[0]; ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce" ).Path("jobs").QueryParam("state", notInUse.ToString()).Accept(MediaType.ApplicationJson ).Get <ClientResponse>(); NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType() ); JSONObject json = response.GetEntity <JSONObject>(); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length()); NUnit.Framework.Assert.AreEqual("jobs is not null", JSONObject.Null, json.Get("jobs" )); }
public static JobStateExt ConvertIntToExt(this JobState jobState) { _ = Enum.TryParse(jobState.ToString(), out JobStateExt convert); return(convert); }
/// <summary> /// Do Set Job State /// </summary> /// <param name="state"></param> /// <param name="reason"></param> /// <returns>returns false if state transition is not possible. Return value is required to update SQM perf counters</returns> private bool DoSetJobState(JobState state, Exception reason = null) { if (IsFinishedState(_previousState) || _isDisposed) return false; lock (_syncObject) { if (IsFinishedState(_previousState) || _isDisposed) return false; // State should not be transitioned to suspended from stopping if (_previousState == JobState.Stopping && state == JobState.Suspended) return false; // State should not be transitioned to suspended from suspended if (_previousState == JobState.Suspended && state == JobState.Suspended) return false; if (state != _previousState && StructuredTracer.IsEnabled) { StructuredTracer.JobStateChanged(Id, InstanceId, state.ToString(), _previousState.ToString()); } #if DEBUG switch (_previousState) { case JobState.Running: Dbg.Assert(state != JobState.NotStarted && state != JobState.Blocked, "WorkflowJob invalid state transition from Running."); break; case JobState.Stopping: //Dbg.Assert( // state == JobState.Stopped || state == JobState.Failed || state == JobState.Completed, // "WorkflowJob invalid state transition from Stopping."); break; case JobState.Stopped: Dbg.Assert(false, "WorkflowJob should never transition after Stopped state."); break; case JobState.Suspending: Dbg.Assert( state == JobState.Suspended || state == JobState.Completed || state == JobState.Failed || state == JobState.Stopped || state == JobState.Stopping, "WorkflowJob invalid state transition from Suspending."); break; case JobState.Suspended: Dbg.Assert( state == JobState.Running || state == JobState.Stopping || state == JobState.Stopped || state == JobState.Completed || state == JobState.Failed, "WorkflowJob invalid state transition from Suspended."); break; case JobState.Failed: Dbg.Assert(false, "WorkflowJob should never transition after Failed state."); break; case JobState.Completed: Dbg.Assert(false, "WorkflowJob should never transition after Completed state."); break; case JobState.Disconnected: Dbg.Assert(false, "WorkflowJob should never be in a disconnected state"); break; case JobState.Blocked: Dbg.Assert(false, "WorkflowJob should never be in a blocked state"); break; default: break; } #endif _previousState = state; // Update JobMetadata if (_workflowInstance != null) { _workflowInstance.PSWorkflowContext.JobMetadata.Remove(Constants.JobMetadataStateReason); if (reason != null) { if (StructuredTracer.IsEnabled) { StructuredTracer.JobError(Id, InstanceId, Tracer.GetExceptionString(reason)); } _workflowInstance.PSWorkflowContext.JobMetadata.Add(Constants.JobMetadataStateReason, reason); } } } _tracer.WriteMessage(ClassNameTrace, "DoSetJobState", WorkflowGuidForTraces, this, "Setting state to {0}, Setting Reason to exception: {1}", state.ToString(), reason == null ? null : reason.ToString()); _workflowInstance.State = state; SetJobState(state, reason); _tracer.WriteMessage(ClassNameTrace, "DoSetJobState", WorkflowGuidForTraces, this, "Done setting state"); return true; }
private void update() { retry: try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; lblID.Content = this.Title = "Experiment #" + id.ToString(); SqlCommand cmd = new SqlCommand("SELECT SubmissionTime,Category," + "(SELECT COUNT(1) FROM JobQueue WHERE ExperimentID=" + id.ToString() + ") as Queued," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + ") as Finished," + "(SELECT SUM(SAT) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=0) as SAT," + "(SELECT SUM(UNSAT) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=0) as UNSAT," + "(SELECT SUM(UNKNOWN) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=0) as UNKNOWN," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=0 AND SAT+UNSAT > TargetSAT+TargetUNSAT AND UNKNOWN < TargetUNKNOWN) as OVR," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND (SAT+UNSAT < TargetSAT+TargetUNSAT OR UNKNOWN > TargetUNKNOWN)) as UDR," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=3) as BUG," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=4) as ERROR," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=5) as TIMEOUT," + "(SELECT COUNT(1) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=6) as MEMORYOUT," + "Memout as MaxMem,Timeout as MaxTime,Parameters,Cluster,ClusterJobID,Nodegroup,Locality,Creator,Note,Longparams " + "FROM Experiments WHERE ID=" + id.ToString(), sql); cmd.CommandTimeout = 0; SqlDataReader r = cmd.ExecuteReader(); if (!r.Read()) { throw new Exception("Error reading from SQL connection"); } txtSubmissionTime.Text = ((DateTime)r["SubmissionTime"]).ToString(); txtCategory.Text = (string)r["Category"]; int f = (int)r["Finished"]; int q = (int)r["Queued"]; lblTotal.Content = f + q; lblFinished.Content = f; lblRunning.Content = q; lblRunning.Foreground = (q == 0) ? System.Windows.Media.Brushes.Green : System.Windows.Media.Brushes.Red; lblSAT.Content = (DBNull.Value.Equals(r["SAT"])) ? 0 : (int)r["SAT"]; lblUNSAT.Content = (DBNull.Value.Equals(r["UNSAT"])) ? 0 : (int)r["UNSAT"]; lblUnknown.Content = (DBNull.Value.Equals(r["UNKNOWN"])) ? 0 : (int)r["UNKNOWN"]; lblOver.Content = (DBNull.Value.Equals(r["OVR"])) ? 0 : (int)r["OVR"]; lblUnder.Content = (DBNull.Value.Equals(r["UDR"])) ? 0 : (int)r["UDR"]; int bugs = (int)r["BUG"];; int prob = (int)r["ERROR"]; int toed = (int)r["TIMEOUT"]; int memoed = (int)r["MEMORYOUT"]; lblBug.Content = bugs; lblBug.Foreground = (bugs == 0) ? System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red; lblNonzero.Content = prob; lblNonzero.Foreground = (prob == 0) ? System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red; lblMemdout.Content = memoed; lblMemdout.Foreground = (memoed == 0) ? System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red; lblTimedout.Content = toed; lblTimedout.Foreground = (toed == 0) ? System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red; txtTimeout.Text = (string)r["MaxTime"]; txtMemout.Text = (string)r["MaxMem"]; if (r["Parameters"].Equals(DBNull.Value)) { txtParameters.Text = (string)r["Longparams"]; } else { txtParameters.Text = (string)r["Parameters"]; } string cluster = (string)r["Cluster"]; txtCluster.Text = cluster; int clusterJobID = (DBNull.Value.Equals(r["ClusterJobID"])) ? 0 : (int)r["ClusterJobID"]; txtNodeGroup.Text = (string)r["Nodegroup"]; txtLocality.Text = (string)r["Locality"]; txtCreator.Text = (string)r["Creator"]; txtNote.Text = (DBNull.Value.Equals(r["Note"])) ? "" : (string)r["Note"]; r.Close(); if (cluster != "" && clusterJobID != 0) { try { Scheduler scheduler = new Scheduler(); scheduler.Connect(cluster); ISchedulerJob job = scheduler.OpenJob(Convert.ToInt32(clusterJobID)); JobState state = job.State; lblClusterStatus.Content = state.ToString(); if (state == JobState.Running) { lblClusterStatus.Content += " (" + job.GetCounters().RunningTaskCount + " wrkrs)"; } if (state == JobState.Running || state == JobState.Queued || state == JobState.Validating || state == JobState.Finished || state == JobState.Finishing || state == JobState.Submitted || state == JobState.ExternalValidation) { lblClusterStatus.Foreground = System.Windows.Media.Brushes.Green; } else { lblClusterStatus.Foreground = System.Windows.Media.Brushes.Red; } } catch (SchedulerException) { lblClusterStatus.Content = "Job ID unknown to the cluster. Assume finished."; lblClusterStatus.Foreground = System.Windows.Media.Brushes.Orange; } catch { lblClusterStatus.Content = "Unable to retrieve status."; lblClusterStatus.Foreground = System.Windows.Media.Brushes.Orange; } } else { lblClusterStatus.Content = "Unable to retrieve status."; lblClusterStatus.Foreground = System.Windows.Media.Brushes.Black; } cmd = new SqlCommand("SELECT COUNT(*) FROM Data WHERE ExperimentID=" + id.ToString() + " AND ResultCode=4 AND (stderr LIKE '%INFRASTRUCTURE ERROR%' OR ReturnValue=-1073741515);", sql); r = cmd.ExecuteReader(); if (r.Read()) { int ierrs = (int)r[0]; if (ierrs == 0) { lblInfrastructureErrors.Content = ""; } else { lblInfrastructureErrors.Content = ierrs.ToString() + " infrastructure errors!"; } } r.Close(); } catch (SqlException ex) { if (ex.Number == -2) /* timeout */ goto { retry; }
/* * JobState */ public static MRProtos.JobStateProto ConvertToProtoFormat(JobState e) { return(MRProtos.JobStateProto.ValueOf(JobStatePrefix + e.ToString())); }
public static string GetSimplifiedStateString(this JobState state) { return(CultureInfo.InvariantCulture.TextInfo.ToTitleCase(state.ToString().ToLowerInvariant())); }
private bool DoSetJobState(JobState state, Exception reason = null) { bool flag; string str; if (this.IsFinishedState(this._previousState) || this._isDisposed) { return false; } else { lock (this._syncObject) { if (this.IsFinishedState(this._previousState) || this._isDisposed) { flag = false; } else { if (this._previousState != JobState.Stopping || state != JobState.Suspended) { if (state != this._previousState && PSWorkflowJob.StructuredTracer.IsEnabled) { PSWorkflowJob.StructuredTracer.JobStateChanged(base.Id, base.InstanceId, state.ToString(), this._previousState.ToString()); } this._previousState = state; if (this._workflowInstance != null) { this._workflowInstance.PSWorkflowContext.JobMetadata.Remove("Reason"); if (reason != null) { if (PSWorkflowJob.StructuredTracer.IsEnabled) { PSWorkflowJob.StructuredTracer.JobError(base.Id, base.InstanceId, Tracer.GetExceptionString(reason)); } this._workflowInstance.PSWorkflowContext.JobMetadata.Add("Reason", reason); } } PowerShellTraceSource powerShellTraceSource = this._tracer; string str1 = "PSWorkflowJob"; string str2 = "DoSetJobState"; Guid workflowGuidForTraces = this.WorkflowGuidForTraces; PSWorkflowJob pSWorkflowJob = this; string str3 = "Setting state to {0}, Setting Reason to exception: {1}"; string[] strArrays = new string[2]; strArrays[0] = (object)state.ToString(); string[] strArrays1 = strArrays; int num = 1; if (reason == null) { str = null; } else { str = reason.ToString(); } strArrays1[num] = str; powerShellTraceSource.WriteMessage(str1, str2, workflowGuidForTraces, pSWorkflowJob, str3, strArrays); this._workflowInstance.State = state; base.SetJobState(state, reason); this._tracer.WriteMessage("PSWorkflowJob", "DoSetJobState", this.WorkflowGuidForTraces, this, "Done setting state", new string[0]); return true; } else { flag = false; } } } return flag; } }