private static void SubmitViaAPI3(ClusterSubmitterArgs clusterArgs, IDistributable distributableObj) { Console.WriteLine(string.Format("Connecting to cluster {0} using API version 3 .", clusterArgs.Cluster)); using (IScheduler scheduler = new Scheduler()) { scheduler.Connect(clusterArgs.Cluster); ISchedulerJob job = scheduler.CreateJob(); job.Name = distributableObj.JobName; job.Priority = clusterArgs.Priority; if (clusterArgs.JobTemplate != null) { Microsoft.Hpc.Scheduler.IStringCollection jobTemplates = scheduler.GetJobTemplateList(); string decodedJobTemplate = System.Web.HttpUtility.UrlDecode(clusterArgs.JobTemplate); if (jobTemplates.Contains(decodedJobTemplate)) { job.SetJobTemplate(decodedJobTemplate); } else { Console.WriteLine(string.Format(Resource.Job_template, decodedJobTemplate)); foreach (var template in jobTemplates) { Console.Write("'" + template + "' "); } Console.WriteLine(Resource.SubmitViaAPI3); } } if (clusterArgs.NumCoresPerTask != null) { clusterArgs.IsExclusive = false; } IStringCollection nodesToUse = null; if (clusterArgs.NodeExclusionList != null && clusterArgs.NodeExclusionList.Count > 0) { nodesToUse = GetNodesToUse(clusterArgs, scheduler, job); } else if (clusterArgs.NodesToUseList != null && clusterArgs.NodesToUseList.Count > 0) { nodesToUse = scheduler.CreateStringCollection(); foreach (string nodeName in clusterArgs.NodesToUseList) { nodesToUse.Add(nodeName); } } else if (clusterArgs.NumCoresPerTask != null) { job.AutoCalculateMax = true; job.AutoCalculateMin = true; } else if (clusterArgs.IsExclusive) { job.UnitType = Microsoft.Hpc.Scheduler.Properties.JobUnitType.Node; if (clusterArgs.MinimumNumberOfNodes != null) { job.MaximumNumberOfNodes = clusterArgs.MaximumNumberOfNodes.Value; job.MinimumNumberOfNodes = clusterArgs.MinimumNumberOfNodes.Value; } } else if (clusterArgs.MinimumNumberOfCores != null) { if (clusterArgs.MaximumNumberOfCores == null) { job.AutoCalculateMax = true; } else { job.AutoCalculateMax = false; job.MaximumNumberOfCores = clusterArgs.MaximumNumberOfCores.Value; } job.MaximumNumberOfCores = clusterArgs.MaximumNumberOfCores ?? Math.Max(clusterArgs.TaskCount, scheduler.GetCounters().TotalCores); job.MinimumNumberOfCores = clusterArgs.MinimumNumberOfCores.Value; job.AutoCalculateMin = false; } else { job.AutoCalculateMax = true; job.AutoCalculateMin = true; } if (!clusterArgs.OnlyDoCleanup) { if (clusterArgs.TaskRange.IsContiguous()) { if (clusterArgs.TaskRange.LastElement > clusterArgs.TaskCount - 1) { clusterArgs.TaskRange = new RangeCollection(clusterArgs.TaskRange.FirstElement, clusterArgs.TaskCount - 1); } ISchedulerTask task = CreateTask(null, clusterArgs, job, distributableObj, nodesToUse); task.Type = TaskType.ParametricSweep; task.StartValue = 0; task.EndValue = clusterArgs.TaskCount - 1; job.AddTask(task); } else { job.AddTasks(clusterArgs.TaskRange.Select(taskNum => CreateTask((int)taskNum, clusterArgs, job, distributableObj, nodesToUse)).ToArray()); } } else { clusterArgs.Cleanup = true; } ISchedulerTask cleanupTask = null; if (clusterArgs.Cleanup) { cleanupTask = AddCleanupTaskToJob(clusterArgs, scheduler, job, distributableObj); } Console.WriteLine(Resource.Submitting_job); scheduler.SubmitJob(job, null, null); clusterArgs.JobID = job.Id; Console.WriteLine(job.Name + Resource.submitted); } }