本文整理汇总了C#中Scheduler.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.Connect方法的具体用法?C# Scheduler.Connect怎么用?C# Scheduler.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scheduler
的用法示例。
在下文中一共展示了Scheduler.Connect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseNodegroup
public ChooseNodegroup(string cluster)
{
InitializeComponent();
listBox.Items.Clear();
listBox.Items.Add("<Any>");
if (cluster != "")
{
try
{
Scheduler scheduler = new Scheduler();
scheduler.Connect(cluster);
IStringCollection ngs = scheduler.GetNodeGroupList();
foreach (String ng in ngs)
{
listBox.Items.Add(ng /*+ " (" + scheduler.GetNodesInNodeGroup(ng).Count().ToString() + ")" */ );
}
}
catch
{
}
}
Mouse.OverrideCursor = null;
}
示例2: Main
static void Main(string[] args)
{
string clusterName = null;
try
{
clusterName = args[0];
}
catch (Exception e)
{
Console.WriteLine("Unable to get clusterName from commandline args");
Console.WriteLine(e);
return;
}
IScheduler scheduler = null;
try
{
scheduler = new Scheduler();
scheduler.Connect(clusterName);
}
catch (Exception e)
{
Console.WriteLine("Unable to connect to cluster:\n " + clusterName);
Console.WriteLine(e);
return;
}
IStringCollection clusterNodes;// = new IStringCollection();
try
{
clusterNodes = scheduler.GetNodesInNodeGroup("ComputeNodes");
}
catch (Exception e)
{
Console.WriteLine("Unable to get cluster node list:\n " + clusterName);
Console.WriteLine(e);
return;
}
foreach(string nodename in clusterNodes)
{
Console.WriteLine("found node: " + nodename);
}
}
示例3: 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;
//.........这里部分代码省略.........
示例4: UpdateClusterWorker
private void UpdateClusterWorker(object newName) {
try {
string clusterName = (string)newName;
List<string> groups = new List<string>();
ISchedulerCollection nodes;
try {
using (var scheduler = new Scheduler()) {
scheduler.Connect(clusterName);
nodes = scheduler.GetNodeList(null, null);
using (var store = SchedulerStore.Connect(clusterName)) {
foreach (var group in store.GetNodeGroups()) {
groups.Add(group.Name);
}
}
}
} catch (SchedulerException) {
// unable to connect to the node.
return;
}
try {
this.BeginInvoke((Action)(() => {
_pickNodesCombo.SelectedIndexChanged -= PickNodesComboSelectedIndexChanged;
_pickNodesCombo.Items.Clear();
foreach (var group in groups) {
_pickNodesCombo.Items.Add(group);
if (group == _environment.PickNodesFrom ||
(String.IsNullOrWhiteSpace(_environment.PickNodesFrom) && group == "ComputeNodes")) {
_pickNodesCombo.SelectedIndex = _pickNodesCombo.Items.Count - 1;
}
}
if (_pickNodesCombo.SelectedIndex == -1) {
_pickNodesCombo.SelectedIndex = 0;
}
_pickNodesCombo.SelectedIndexChanged += PickNodesComboSelectedIndexChanged;
_nodesView.Items.Clear();
int totalCores = 0;
string[] selectedNodes = _environment.SelectedNodes;
foreach (ISchedulerNode node in nodes) {
if (!node.NodeGroups.Contains(_pickNodesCombo.Text)) {
continue;
}
totalCores += node.NumberOfCores;
var item = new ListViewItem(
new[] {
node.Name,
node.CpuSpeed.ToString(),
node.MemorySize.ToString(),
node.NumberOfCores.ToString(),
node.State.ToString()
}
);
if (selectedNodes != null && selectedNodes.Contains(node.Name)) {
item.Checked = true;
}
_nodesView.Items.Add(item);
}
_numOfProcsCombo.Items.Clear();
_numOfProcsCombo.TextChanged -= NumOfProcsComboChanged;
for (int i = 0; i < totalCores; i++) {
_numOfProcsCombo.Items.Add(i + 1);
if (i == _environment.NumberOfProcesses - 1) {
_numOfProcsCombo.SelectedIndex = i;
_lastNumProcsValue = _numOfProcsCombo.Text;
}
}
_numOfProcsCombo.TextChanged += NumOfProcsComboChanged;
}));
} catch (InvalidOperationException) {
// we could race here w/ the form being closed and the handle being disposed.
}
} catch (System.Net.Sockets.SocketException) {
}
}
示例5: 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);
}
}
示例6: 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;
}
示例7: deleteExperiment
private void deleteExperiment(object target, ExecutedRoutedEventArgs e)
{
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
System.Windows.MessageBoxResult r =
System.Windows.MessageBox.Show("Are you sure you want to delete the selected experiments?", "Sure?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
if (r == System.Windows.MessageBoxResult.Yes)
{
for (int i = 0; i < dataGrid.SelectedItems.Count; i++)
{
int id = (int)((DataRowView)dataGrid.SelectedItems[i])["ID"];
SqlDataReader rd = null;
try
{
SqlCommand cmd = new SqlCommand("SELECT Cluster,ClusterJobID,SharedDir,Executor FROM Experiments WHERE ID=" + id.ToString(), sql);
rd = cmd.ExecuteReader();
if (rd.Read())
{
string cluster = (string)rd["Cluster"];
object jobid = rd["ClusterJobID"];
object sharedDir = rd["SharedDir"];
object executor = rd["Executor"];
rd.Close();
if (cluster != "" && !DBNull.Value.Equals(jobid))
{
try
{
Scheduler scheduler = new Scheduler();
scheduler.Connect(cluster);
WindowInteropHelper helper = new WindowInteropHelper(this);
scheduler.SetInterfaceMode(false, helper.Handle);
scheduler.CancelJob((int)jobid, "Job aborted by user.");
}
catch { /* That's fine... */ }
}
if (!DBNull.Value.Equals(sharedDir) && !DBNull.Value.Equals(executor))
{
try
{
File.Delete((string)sharedDir + "\\" + (string)executor);
}
catch { /* That's fine... */ }
}
}
cmd = new SqlCommand("DELETE FROM JobQueue WHERE ExperimentID=" + id.ToString() + ";" +
"DELETE FROM Data WHERE ExperimentID=" + id.ToString() + ";" +
"DELETE FROM Experiments WHERE ID=" + id.ToString(), sql);
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
string msg = String.Format("Error: could not delete experiment #{0} because of: {1} ", id, ex.Message);
r = System.Windows.MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
}
finally
{
if (rd != null) rd.Close();
}
}
}
Mouse.OverrideCursor = null;
updateDataGrid();
}
示例8: 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;
}
//.........这里部分代码省略.........
示例9: LaunchFile
public int LaunchFile(string filename, bool debug) {
var clusterEnv = new ClusterEnvironment(_project.GetProperty(ClusterOptions.RunEnvironmentSetting));
if (debug) {
EnsureHiddenForm();
EnsureListenerThread();
}
string workingDir, publishUrl;
if (clusterEnv.HeadNode == "localhost") {
workingDir = _project.GetProperty(ClusterOptions.WorkingDirSetting);
if (String.IsNullOrWhiteSpace(workingDir)) {
workingDir = Path.Combine(Path.GetTempPath(), "HpcPyDebug" + Guid.NewGuid().ToString());
}
if (!Directory.Exists(workingDir)) {
Directory.CreateDirectory(workingDir);
}
publishUrl = "file://" + workingDir;
} else {
workingDir = GetWorkingDir(clusterEnv);
// make sure we have a valid deployement dir as well
string deploymentDir;
if (!TryGetDeploymentDir(out deploymentDir)) {
return VSConstants.S_OK;
}
publishUrl = deploymentDir;
}
string exe, arguments;
if (!TryBuildCommandLine(debug, clusterEnv, filename, workingDir, out exe, out arguments) ||
!TryPublishProject(clusterEnv, publishUrl)) {
return VSConstants.S_OK;
}
if (clusterEnv.HeadNode == "localhost") {
// run locally
if (debug) {
var startInfo = new ProcessStartInfo(exe, arguments);
LaunchRedirectedToVsOutputWindow(startInfo, false);
} else {
Process.Start(exe, arguments);
}
} else {
EnsureGeneralPane();
var commandLine = exe + " " + arguments;
var scheduler = new Scheduler();
scheduler.Connect(clusterEnv.HeadNode);
var job = CreateSchedulerJob(commandLine, clusterEnv, scheduler, debug);
scheduler.AddJob(job);
SetStatus("Scheduling job on server...");
ScheduleJob(scheduler, job);
}
return VSConstants.S_OK;
}