NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.Process.Job Class Reference
Collaboration diagram for Ntp.Common.Process.Job:

Public Member Functions

 Job (JobDescription description, JobScheduleDescription schedule, LogBase log)
 Initializes a new instance of the Job class. More...
 
void Execute ()
 Execute this Job. More...
 
override string ToString ()
 Returns a string that represents the current Job. More...
 

Static Public Member Functions

static void Reset ()
 

Public Attributes

string Runtime => Running ? DateTime.Now.Subtract(Started).ToString() : string.Empty
 Gets the time this Job have currently been running. More...
 
string TotalRuntime => Running ? (DateTime.Now.Subtract(Started) + time).ToString() : time.ToString()
 Gets the total time this Job have been running. More...
 

Properties

JobDescription Description [get]
 Gets the description. More...
 
int JobId [get]
 Gets the job identifier. More...
 
bool Postponed [get, set]
 Gets or sets a value indicating whether this Job has been postponed. More...
 
bool Queued [get, set]
 Gets or sets a value indicating whether this Job is queued for run. More...
 
int RunCount [get, private set]
 Gets the number of times this Job have been executed. More...
 
bool Running [get, private set]
 Gets or sets a value indicating whether this Job is running. More...
 
JobScheduleDescription Schedule [get]
 Gets the schedule. More...
 
DateTime Started [get, private set]
 Gets the time this this Job was started. More...
 
string State [get]
 Gets the current state of this Job. More...
 

Private Attributes

readonly LogBase log
 
TimeSpan time = new TimeSpan(0)
 

Static Private Attributes

static int nextJobId = 1
 
static readonly object NextJobLocker = new object()
 

Detailed Description

Definition at line 27 of file Job.cs.

Constructor & Destructor Documentation

Ntp.Common.Process.Job.Job ( JobDescription  description,
JobScheduleDescription  schedule,
LogBase  log 
)
inline

Initializes a new instance of the Job class.

Parameters
descriptionDescription.
scheduleSchedule.
logLog.

Definition at line 35 of file Job.cs.

36  {
37  lock (NextJobLocker)
38  {
39  JobId = nextJobId++;
40  }
41 
42  Description = description;
43  Schedule = schedule;
44  this.log = log;
45 
46  RunCount = 0;
47  }
static int nextJobId
Definition: Job.cs:50
readonly LogBase log
Definition: Job.cs:52
static readonly object NextJobLocker
Definition: Job.cs:49
JobScheduleDescription Schedule
Gets the schedule.
Definition: Job.cs:65
int RunCount
Gets the number of times this Job have been executed.
Definition: Job.cs:101
int JobId
Gets the job identifier.
Definition: Job.cs:59
JobDescription Description
Gets the description.
Definition: Job.cs:71

Member Function Documentation

void Ntp.Common.Process.Job.Execute ( )
inline

Execute this Job.

Definition at line 135 of file Job.cs.

References e.

Referenced by Ntp.Common.Process.Scheduler.ExecuteJob().

136  {
137  Started = DateTime.Now;
138 
139  // Narrow scope to reduce thread interference
140  var threadStart = DateTime.Now;
141 
142  Queued = false;
143  Postponed = false;
144  Running = true;
145  RunCount++;
146 
147  bool error = false;
148 
149  try
150  {
152  }
153  catch (Exception e)
154  {
155  error = true;
156  log.JobError(this, e);
157  }
158  finally
159  {
160  Running = false;
161  }
162 
163  time += DateTime.Now.Subtract(threadStart);
164  log.JobExecutionStatus(this, error);
165  }
bool Queued
Gets or sets a value indicating whether this Job is queued for run.
Definition: Job.cs:77
bool Postponed
Gets or sets a value indicating whether this Job has been postponed.
Definition: Job.cs:83
readonly LogBase log
Definition: Job.cs:52
DateTime Started
Gets the time this this Job was started.
Definition: Job.cs:95
void Execute()
Perform execution of this instance.
var e
Definition: bootstrap.min.js:6
TimeSpan time
Definition: Job.cs:53
int RunCount
Gets the number of times this Job have been executed.
Definition: Job.cs:101
bool Running
Gets or sets a value indicating whether this Job is running.
Definition: Job.cs:89
JobDescription Description
Gets the description.
Definition: Job.cs:71

Here is the caller graph for this function:

static void Ntp.Common.Process.Job.Reset ( )
inlinestatic

Definition at line 167 of file Job.cs.

Referenced by Ntp.Analyzer.Process.Initializer.InitializeScheduler().

168  {
169  lock (NextJobLocker)
170  {
171  nextJobId = 1;
172  }
173  }
static int nextJobId
Definition: Job.cs:50
static readonly object NextJobLocker
Definition: Job.cs:49

Here is the caller graph for this function:

override string Ntp.Common.Process.Job.ToString ( )
inline

Returns a string that represents the current Job.

Returns
A string that represents the current Job.

Definition at line 179 of file Job.cs.

180  {
181  var name = string.IsNullOrWhiteSpace(Description.Name) ? string.Empty : " " + Description.Name;
182  return $"{Description.JobType} job{name}";
183  }
JobDescription Description
Gets the description.
Definition: Job.cs:71

Member Data Documentation

readonly LogBase Ntp.Common.Process.Job.log
private

Definition at line 52 of file Job.cs.

int Ntp.Common.Process.Job.nextJobId = 1
staticprivate

Definition at line 50 of file Job.cs.

readonly object Ntp.Common.Process.Job.NextJobLocker = new object()
staticprivate

Definition at line 49 of file Job.cs.

string Ntp.Common.Process.Job.Runtime => Running ? DateTime.Now.Subtract(Started).ToString() : string.Empty

Gets the time this Job have currently been running.

The runtime.

Definition at line 124 of file Job.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Running().

TimeSpan Ntp.Common.Process.Job.time = new TimeSpan(0)
private

Definition at line 53 of file Job.cs.

string Ntp.Common.Process.Job.TotalRuntime => Running ? (DateTime.Now.Subtract(Started) + time).ToString() : time.ToString()

Gets the total time this Job have been running.

The runtime.

Definition at line 130 of file Job.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Proc().

Property Documentation

int Ntp.Common.Process.Job.JobId
get
bool Ntp.Common.Process.Job.Postponed
getset

Gets or sets a value indicating whether this Job has been postponed.

true if postponed; otherwise, false.

Definition at line 83 of file Job.cs.

Referenced by Ntp.Common.Process.Scheduler.PostponeJob(), and Ntp.Common.Process.Scheduler.QueueJob().

bool Ntp.Common.Process.Job.Queued
getset

Gets or sets a value indicating whether this Job is queued for run.

true if scheduled; otherwise, false.

Definition at line 77 of file Job.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Jobs(), Ntp.Common.Process.Scheduler.PostponeJob(), Ntp.Common.Process.Scheduler.QueueJob(), and Ntp.Common.Process.Scheduler.RunOneCycle().

int Ntp.Common.Process.Job.RunCount
getprivate set
bool Ntp.Common.Process.Job.Running
getprivate set

Gets or sets a value indicating whether this Job is running.

true if running; otherwise, false.

Definition at line 89 of file Job.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Jobs().

DateTime Ntp.Common.Process.Job.Started
getprivate set

Gets the time this this Job was started.

The started.

Definition at line 95 of file Job.cs.

string Ntp.Common.Process.Job.State
get

Gets the current state of this Job.

The state.

Definition at line 108 of file Job.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Proc(), and Ntp.Analyzer.Monitor.Server.Billboard.Running().


The documentation for this class was generated from the following file: