当前位置: 首页>>代码示例>>C#>>正文


C# Scheduler.CreateJob方法代码示例

本文整理汇总了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;
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:48,代码来源:HpcLauncher.cs


注:本文中的Scheduler.CreateJob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。