本文整理汇总了C#中Scheduler.CreateJob方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.CreateJob方法的具体用法?C# Scheduler.CreateJob怎么用?C# Scheduler.CreateJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scheduler
的用法示例。
在下文中一共展示了Scheduler.CreateJob方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSchedulerJob
private ISchedulerJob CreateSchedulerJob(string commandLine, ClusterEnvironment clusterEnv, Scheduler scheduler, bool debug) {
var job = scheduler.CreateJob();
job.IsExclusive = true;
job.Name = debug ? "Python MPI Debugging Session" : "Python MPI Session";
string mpiExecCommand, deploymentDir;
if (!TryGetMpiExecCommand(clusterEnv.HeadNode, out mpiExecCommand) ||
!TryGetDeploymentDir(out deploymentDir)) {
// unreachable, we've already built the command line (which gets the MPI exec command as well) and checked that we could get the working
throw new InvalidOperationException();
}
string workingDir = GetWorkingDir(clusterEnv);
ISchedulerTask[] tasks;
var runTask = job.CreateTask();
runTask.Name = debug ? "Debug MPI Task" : "Run MPI Task";
if (!IsPathUnc(workingDir)) {
// we need to copy the files locally onto the cluster
var copyTask = job.CreateTask();
copyTask.Name = "Copy files";
copyTask.Type = TaskType.NodePrep;
var cleanupTask = job.CreateTask();
cleanupTask.Name = "Cleanup files";
tasks = new[] { copyTask, runTask, cleanupTask };
copyTask.CommandLine = String.Format("\"%WINDIR%\\System32\\cmd.exe\" /c mkdir \"{1}\" & robocopy /s \"{0}\" \"{1}\" & if not errorlevel 2 exit 0", deploymentDir, workingDir);
cleanupTask.CommandLine = String.Format("\"%WINDIR%\\System32\\cmd.exe\" /c rmdir /s /q \"{0}\"", workingDir);
cleanupTask.Type = TaskType.NodeRelease;
} else {
tasks = new[] { runTask };
}
runTask.CommandLine = commandLine;
runTask.WorkDirectory = workingDir;
job.NodeGroups.Add(clusterEnv.PickNodesFrom);
SetJobParameters(clusterEnv, job, tasks);
job.AddTasks(tasks);
job.OnJobState += JobStateChanged;
job.OnTaskState += OnTaskStateChange;
return job;
}