本文整理汇总了C#中Scheduler.OpenJob方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.OpenJob方法的具体用法?C# Scheduler.OpenJob怎么用?C# Scheduler.OpenJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scheduler
的用法示例。
在下文中一共展示了Scheduler.OpenJob方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
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;
//.........这里部分代码省略.........
示例2: showChangePriority
private void showChangePriority(object sender, ExecutedRoutedEventArgs e)
{
ChangePriorityDialog dlg = new ChangePriorityDialog();
dlg.Owner = this;
if (dlg.ShowDialog() == true)
{
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
double total = (double)dataGrid.SelectedItems.Count;
IList drviews = dataGrid.SelectedItems;
bool stop = false;
for (int i = 0; i < total && !stop; i++)
{
new Progress(this, dataGrid.SelectedItems.Count, "Changing priority",
(sndr, ea) =>
{
ProgressWorker w = (ProgressWorker)sndr;
Object[] args = (Object[])ea.Argument;
DataRowView drv = (DataRowView)drviews[i];
int eid = (int)drv["ID"];
SqlCommand cmd = new SqlCommand("SELECT Cluster, ClusterJobID FROM Experiments WHERE ID=" + eid, sql);
cmd.CommandTimeout = 0;
SqlDataReader r = cmd.ExecuteReader();
try
{
if (r.Read())
{
string cluster = (string)r["Cluster"];
int cjid = (int)r["ClusterJobID"];
Scheduler scheduler = new Scheduler();
scheduler.Connect(cluster);
ISchedulerJob job = scheduler.OpenJob(Convert.ToInt32(cjid));
JobState state = job.State;
if (state == JobState.Configuring ||
state == JobState.Queued ||
state == JobState.Running ||
state == JobState.Submitted ||
state == JobState.Validating)
{
switch (dlg.cmbPriority.SelectedIndex)
{
case 0: job.Priority = JobPriority.Lowest; break;
case 1: job.Priority = JobPriority.BelowNormal; break;
case 3: job.Priority = JobPriority.AboveNormal; break;
case 4: job.Priority = JobPriority.Highest; break;
default: job.Priority = JobPriority.Normal; break;
}
job.Commit();
}
}
r.Close();
if (w.WorkerReportsProgress)
w.ReportProgress((int)(100.0 * ((double)i / total)));
}
catch (Exception ex)
{
Dispatcher.Invoke(new Action(() =>
{
System.Windows.MessageBox.Show(this, "Exception: " + ex.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
}).Go();
}
}
Mouse.OverrideCursor = null;
}
示例3: Main
static void Main(string[] args)
{
try
{
SQLInterface sql = new SQLInterface(config.db);
if (!Directory.Exists(config.datadir))
Directory.CreateDirectory(config.datadir);
SortedSet<Job> myJobs = sql.FindJobs(config.datadir, config.username);
foreach (Job j in myJobs)
{
j.Download(sql);
// Global.Say(string.Format("Downloaded {0} batches for job #{1}. Average batch time: {2} sec.", j.BatchCount, j.MetaData.Id, j.AverageBatchTime));
}
Jobs jobs = new Jobs(config.datadir); // includes unfinished.
if (myJobs.Count > 0)
{
uint lastId = 0;
foreach (Job j in jobs)
{
if (j.MetaData.Id >= myJobs.Last().MetaData.Id &&
j.MetaData.Reference == 0)
{
j.MetaData.Reference = lastId;
j.MetaData.Save();
}
lastId = j.MetaData.Id;
}
Records records = new Records(config.datadir);
foreach (Job j in myJobs)
{
if (j.MetaData.isFinished)
{
Report r = new Report(j);
if (r.IsInteresting)
r.SendTo(config.developers);
records.Update(j);
}
else
{
try
{
string cluster = j.MetaData.Cluster;
uint cluster_jid = j.MetaData.ClusterJobId;
if (cluster != "" && cluster_jid != 0)
{
Scheduler scheduler = new Scheduler();
scheduler.Connect(cluster);
ISchedulerJob job = scheduler.OpenJob(Convert.ToInt32(cluster_jid));
if (job.State == JobState.Canceled &&
job.ErrorMessage.StartsWith("Canceled by the scheduler"))
{
Global.Say("Requeing job #" + j.MetaData.Id + " after the scheduler canceled it (# requeues = " + job.RequeueCount + ").");
try { job.Requeue(); }
catch (Exception ex) { Console.WriteLine("requeue-exception: " + ex.Message); }
}
}
}
catch (SchedulerException) { /* Ignore. */}
}
}
records.Save();
}
Aggregate();
}
catch (Exception ex)
{
Global.Say("Caught exception: " + ex.Message);
}
}
示例4: showRestartCommand
private void showRestartCommand(object sender, ExecutedRoutedEventArgs e)
{
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
try
{
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
double total = (double)dataGrid.SelectedItems.Count;
IList drviews = dataGrid.SelectedItems;
bool stop = false;
for (int i = 0; i < total && !stop; i++)
{
Progress p = new Progress(this, dataGrid.SelectedItems.Count, "Restarting",
(sndr, ea) =>
{
ProgressWorker w = (ProgressWorker)sndr;
Object[] args = (Object[])ea.Argument;
DataRowView drv = (DataRowView)drviews[i];
int eid = (int)drv["ID"];
string sharedDir = null;
string cluster = null;
string nodegroup = null;
string locality = null;
int clusterJobID = 0;
string executor = null;
string jobTemplate = null;
int jobTimeout = 0;
int taskTimeout = 0;
int priority = 2;
int min = 1, max = 100;
SqlCommand cmd = new SqlCommand("SELECT SharedDir, Cluster, Nodegroup, Locality, ClusterJobID, Executor, JobTemplate, JobTimeout, TaskTimeout FROM Experiments WHERE ID=" + eid + ";", sql);
cmd.CommandTimeout = 0;
SqlDataReader r = cmd.ExecuteReader();
while (r.Read())
{
sharedDir = (string)r[0];
cluster = (string)r[1];
nodegroup = (string)r[2];
locality = (string)r[3];
clusterJobID = (int)r[4];
executor = (string)r[5];
jobTemplate = (string)r[6];
jobTimeout = (int)r[7];
taskTimeout = (int)r[8];
}
r.Close();
Scheduler scheduler = new Scheduler();
scheduler.Connect(cluster);
try
{
ISchedulerJob job = scheduler.OpenJob(clusterJobID);
switch (job.Priority)
{
case JobPriority.Lowest: priority = 0; break;
case JobPriority.BelowNormal: priority = 1; break;
case JobPriority.Normal: priority = 2; break;
case JobPriority.AboveNormal: priority = 3; break;
case JobPriority.Highest: priority = 4; break;
}
if (locality == "Socket")
{
min = job.MinimumNumberOfSockets;
max = job.MaximumNumberOfSockets;
}
else if (locality == "Core")
{
min = job.MinimumNumberOfCores;
max = job.MaximumNumberOfCores;
}
else if (locality == "Node")
{
min = job.MinimumNumberOfNodes;
max = job.MaximumNumberOfNodes;
}
JobState state = job.State;
if (state == JobState.Running || state == JobState.Queued ||
state == JobState.Validating || state == JobState.Submitted ||
state == JobState.ExternalValidation)
scheduler.CancelJob(clusterJobID, "", true);
}
catch (SchedulerException)
{
// OK, job doesn't exist anymore.
}
catch (Exception ex)
{
Dispatcher.Invoke(new Action(() =>
System.Windows.MessageBox.Show(this, "Exception: " + ex.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Error)));
return;
}
//.........这里部分代码省略.........