static void generateTaskLogLines(DateTime dt, ISchedulerJob job, ISchedulerCollection tasks) { StringBuilder buffer = new StringBuilder(); foreach (ISchedulerTask task in tasks) { tempMaxEndDate = task.EndTime > tempMaxEndDate ? task.EndTime : tempMaxEndDate; ISchedulerCore core; ISchedulerNode node; if (tracker.ContainsKey(task.TaskId)) { continue; } if (task.EndTime > taskMaxEndDate) { tracker[task.TaskId] = 1; buffer.Append(generateTaskLogLine(dt, job, task)); buffer.Append("\n"); //System.Console.WriteLine(generateTaskLogLine(task)); lineCounter++; } } if (buffer.ToString().Length != 0) { System.Console.WriteLine(buffer.ToString().Trim()); } }
public JobViewModel(ISchedulerJob _job, JobListViewModel _ParentViewModel) { this.ParentViewModel = _ParentViewModel; this.HpcScheduler = ParentViewModel.HpcScheduler; this.Job = _job; this.CreateTime = Job.CreateTime; this.Owner = Job.Owner; this.Name = Job.Name; this.State = Job.State.ToString(); this.StartTime = Job.StartTime; this.EndTime = Job.EndTime; this.JobID = Job.Id; this.CancelTaskListCommand = this.ParentViewModel.CancelTaskListCommand; this.RequeueTaskListCommand = this.ParentViewModel.RequeueTaskListCommand; CancelJobCommand = new DelegateCommand <object>(CancelJob, CanCancelJob); RequeueJobCommand = new DelegateCommand <object>(RequeueJob, CanRequeueJob); SelectCommand = new DelegateCommand <object>(Select, CanSelect); UnselectCommand = new DelegateCommand <object>(Unselect, CanUnselect); ParentViewModel.SelectAllCommand.RegisterCommand(SelectCommand); ParentViewModel.UnselectAllCommand.RegisterCommand(UnselectCommand); //this.Job = ParentViewModel.HpcScheduler.OpenJob(this.JobID); this.Job.OnJobState += new EventHandler <JobStateEventArg> (JobStateCallback); //(object o, JobStateEventArg arg) => //{ // this.State = Job.State.ToString(); // CancelJobCommand.RaiseCanExecuteChanged(); // RequeueJobCommand.RaiseCanExecuteChanged(); //} //); }
public SchedulerJob(ISchedulerJob job, DateTime next, ScheduleType type, bool async) { Job = job; NextExecuteDate = next; Async = async; ScheduleType = type; }
static Dictionary <string, string> makeDictionary(ISchedulerJob job, ISchedulerTask task) { Dictionary <string, string> taskDict = new Dictionary <string, string>(); List <string> nodes = new List <string>(task.AllocatedNodes); string allocatedNodes = string.Join(" ", nodes.ToArray()); //taskDict["AllocatedCoreIds"] = task.AllocatedCoreIds; taskDict["AllocatedNodes"] = allocatedNodes; taskDict["ChangeTime"] = task.ChangeTime.ToString(hpcDateTimeFormat); taskDict["CommandLine"] = task.CommandLine; taskDict["CreateTime"] = task.CreateTime.ToString(hpcDateTimeFormat); //taskDict["DependsOn"] = task.DependsOn; taskDict["EndTime"] = task.EndTime.ToString(hpcDateTimeFormat); //taskDict["EndValue"] = task.EndValue; //taskDict["EnvironmentVariables"] = task.EnvironmentVariables; taskDict["ErrorMessage"] = task.ErrorMessage; taskDict["ExitCode"] = "" + task.ExitCode; taskDict["MaximumNumberOfCores"] = "" + task.MaximumNumberOfCores; taskDict["MaximumNumberOfNodes"] = "" + task.MaximumNumberOfNodes; taskDict["MaximumNumberOfSockets"] = "" + task.MaximumNumberOfSockets; taskDict["MinimumNumberOfCores"] = "" + task.MinimumNumberOfCores; taskDict["MinimumNumberOfNodes"] = "" + task.MinimumNumberOfNodes; taskDict["MinimumNumberOfSockets"] = "" + task.MinimumNumberOfSockets; taskDict["Name"] = task.Name; taskDict["Output"] = task.Output; taskDict["ParentJobId"] = "" + task.ParentJobId; taskDict["PreviousState"] = "" + task.PreviousState; taskDict["RequeueCount"] = "" + task.RequeueCount; taskDict["RequiredNodes"] = "" + task.RequiredNodes; taskDict["StartTime"] = task.StartTime.ToString(hpcDateTimeFormat); taskDict["StartValue"] = "" + task.StartValue; taskDict["State"] = "" + task.State; taskDict["StdErrFilePath"] = task.StdErrFilePath; taskDict["StdInFilePath"] = task.StdInFilePath; taskDict["StdOutFilePath"] = task.StdOutFilePath; taskDict["TaskId"] = "" + task.TaskId; taskDict["WorkDirectory"] = task.WorkDirectory; List <string> groups = new List <string>(job.NodeGroups.ToArray()); string nodeGroups = "[" + string.Join(",", groups.ToArray()) + "]"; taskDict["NodeGroups"] = nodeGroups; if (task.EndTime < new DateTime(1970, 1, 1)) { taskDict["ElapsedTimeSec"] = "" + (DateTime.Now - task.StartTime).Milliseconds; } else { taskDict["ElapsedTimeSec"] = "" + (task.EndTime - task.StartTime).Milliseconds; } taskDict["Timestamp"] = DateTime.Now.ToString(hpcDateTimeFormat); //taskDict["ElapsedTimeSec"] = "" + (task.EndTime - task.StartTime).Milliseconds; return(taskDict); }
public TaskListViewModel(ISchedulerJob job, IEnumerable <VM> activeVMList, Scheduler hpcSched, CompositeCommand _CancelTaskListCommand, CompositeCommand _RequeueTaskListCommand) : base() { TaskList = new ObservableCollection <TaskViewModel>(); SelectAllCommand = new CompositeCommand(); UnselectAllCommand = new CompositeCommand(); CancelTaskListCommand = _CancelTaskListCommand; this.RequeueTaskListCommand = _RequeueTaskListCommand; //IEnumerable<VM> activeVMList = VMModel.GetInstance().ActiveVMList; try { //scheduler.Connect(JobListViewModel.MainNodeName); job.Refresh(); ISchedulerCollection tasks = job.GetTaskList(null, null, true); var query = from ISchedulerTask task in tasks where activeVMList.Any(j => task.AllocatedNodes.Contains(j.GetDomainName())) select task; foreach (ISchedulerTask task in query) { TaskList.Add(new TaskViewModel(task, job, this)); } } catch (Exception ex) { } //foreach (ISchedulerTask task in job.GetTaskList(null, null, true)) //{ // TaskList.Add(new TaskViewModel(task, job)); //} }
/// <summary> /// Dispose the job monitor entry /// </summary> /// <param name="disposing">indicating the disposing flag</param> private void Dispose(bool disposing) { if (Interlocked.Increment(ref this.disposeFlag) == 1) { if (disposing) { if (this.schedulerJob != null) { try { this.schedulerJob.OnJobState -= this.SchedulerJob_OnJobState; this.schedulerJob.OnTaskState -= this.SchedulerJob_OnTaskState; } catch (Exception e) { TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[JobMonitorEntry] Remove OnJobState/OnTaskState error: {0}", e); } this.schedulerJob = null; } this.scheduler = null; } } }
/// <summary> /// The job template that you specify for the job defines the initial default values and constraints for many of the job properties. /// Any changes that you make to properties must be made within the constraints of the template. /// </summary> /// <param name="jobName">the name of job</param> /// <param name="commandLine">the command line for the task</param> /// <param name="username">the name of the runas user, in the form domain\username</param> /// <param name="password">the password for the runas user</param> public void CreateJob(string jobName, string commandLine, string username, string password) { ISchedulerJob job = null; ISchedulerTask task = null; manualReset.Reset(); //create job job = _scheduler.CreateJob(); job.Name = jobName; //create task task = job.CreateTask(); task.CommandLine = commandLine; //add task to job job.AddTask(task); //specify the events that you want to receive job.OnJobState += OnJobStateCallback; job.OnTaskState += OnTaskStateCallback; //start the job _scheduler.SubmitJob(job, username, password); //block so the events get delivered manualReset.WaitOne(); }
static void Main(string[] args) { Console.Write("hpc: "); string serverName = Console.ReadLine(); Console.Write("user: "******"job template (<Enter> - 'default'): "); string jobTemplate = Console.ReadLine(); if (string.IsNullOrWhiteSpace(jobTemplate)) { jobTemplate = "Default"; } IScheduler scheduler = new Scheduler(); scheduler.Connect(serverName); ISchedulerJob job = scheduler.CreateJob(); job.SetJobTemplate(jobTemplate); ISchedulerTask task = job.CreateTask(); task.CommandLine = "dir"; job.AddTask(task); // Specify the events that you want to receive. job.OnJobState += JobStateCallback; job.OnTaskState += TaskStateCallback; // Start the job. scheduler.SubmitJob(job, user, null); manualEvent.WaitOne(); }
/// <summary> /// Returns the number of tasks that failed for reasons other than preemption /// </summary> /// <param name="schedulerJob"></param> /// <returns></returns> private int GetNonPreemptedFailedTaskCount(IScheduler scheduler, ISchedulerJob schedulerJob) { int ret = 0; try { // Filter by failed tasks that failed due to preemption IFilterCollection fc = scheduler.CreateFilterCollection(); fc.Add(FilterOperator.NotEqual, TaskPropertyIds.FailureReason, FailureReason.Preempted); fc.Add(FilterOperator.Equal, TaskPropertyIds.State, TaskState.Failed); // Only return the task Ids IPropertyIdCollection propIds = new PropertyIdCollection(); propIds.AddPropertyId(TaskPropertyIds.TaskId); using (ISchedulerRowSet failedTasks = schedulerJob.OpenTaskRowSet(propIds, fc, null, true)) { ret = failedTasks.GetCount(); } } catch (Exception ex) { TraceHelper.TraceEvent(this.sessionid, TraceEventType.Warning, "[JobMonitorEntry] Failed to get non-preempted failed task count : {0}", ex); } return(ret); }
/// <summary> /// Submit the job to the Microsoft HPC server. /// </summary> public override object Submit(Job myJob) { string PrjName = InteractiveShell.WorkflowMgm.CurrentProject; ISchedulerJob job = null; ISchedulerTask task = null; // Create a job and add a task to the job. job = m_scheduler.CreateJob(); job.Name = myJob.Name; job.Project = PrjName; job.MaximumNumberOfCores = myJob.NumberOfMPIProcs; job.MinimumNumberOfCores = myJob.NumberOfMPIProcs; job.UserName = m_Username; task = job.CreateTask(); task.MaximumNumberOfCores = myJob.NumberOfMPIProcs; task.MinimumNumberOfCores = myJob.NumberOfMPIProcs; task.WorkDirectory = myJob.DeploymentDirectory; using (var str = new StringWriter()) { str.Write("mpiexec "); str.Write(Path.GetFileName(myJob.EntryAssembly.Location)); foreach (string arg in myJob.CommandLineArguments) { str.Write(" "); str.Write(arg); } task.CommandLine = str.ToString(); } foreach (var kv in myJob.EnvironmentVars) { string name = kv.Key; string valu = kv.Value; task.SetEnvironmentVariable(name, valu); } task.StdOutFilePath = Path.Combine(myJob.DeploymentDirectory, "stdout.txt"); task.StdErrFilePath = Path.Combine(myJob.DeploymentDirectory, "stderr.txt"); if (m_ComputeNodes != null) { foreach (string node in m_ComputeNodes) { job.RequestedNodes.Add(node); } } job.AddTask(task); // Start the job. m_scheduler.SubmitJob(job, m_Password != null ? m_Username : null, m_Password); return(job.Id); }
public int Compare(int jobIdA, int jobIdB) { ISchedulerJob jobA = allJobs[jobIdA]; ISchedulerJob jobB = allJobs[jobIdB]; return(jobA.EndTime.CompareTo(jobB.EndTime)); }
/// <summary> /// collectAllocatedInfo - From a single job, collect a rowset of allocated resources and pass it on to core or node sorting /// </summary> /// <param name="job">ISchedulerJob job to collect allocation history</param> private static void collectAllocatedInfo(ISchedulerJob job) { if (bVerbose) { Console.WriteLine("Entering collectAllocatedInfo: job {0} project: {1}", job.Id, job.Project); } IPropertyIdCollection props = new PropertyIdCollection(); props.Add(AllocationProperties.NodeName); props.Add(AllocationProperties.NodeId); props.Add(AllocationProperties.CoreId); props.Add(AllocationProperties.StartTime); props.Add(AllocationProperties.EndTime); // OpenJobAllocationHistory returns information sorted by ascending AllocationProperties.StartTime using (ISchedulerRowEnumerator rows = job.OpenJobAllocationHistoryEnumerator(props)) { if (bNodesOnly) { NodeDuration(rows); } else { CoreDuration(rows); } } return; }
private void updateMinimum(ISchedulerJob job) { if (job.State == JobState.Running) { tempMinStartTime = job.StartTime < tempMinStartTime ? job.StartTime : tempMinStartTime; } }
static string generateTaskLogLine(DateTime dt, ISchedulerJob job, ISchedulerTask task) { /* * #Timestamp JobTask State TaskName AllocatedNodes StartTime EndTime ElapsedTimeSec ExitCode ErrorMessage Output WorkingDirectory Command * 26/01/2012 14:50:29 8149.1 Failed Task no. 29 LOGSCAPEHPC04 26/01/2012 14:50:29 26/01/2012 14:50:29 0 1 NULL NULL NULL @I am a useless app */ DateTime logDateStamp = new DateTime(); string jobTaskId = string.Format("{0}.{1}", task.ParentJobId, task.TaskId); TimeSpan duration = task.EndTime - task.StartTime; List <string> groups = new List <string>(job.NodeGroups.ToArray()); string nodeGroups = "[" + string.Join(",", groups.ToArray()) + "]"; List <string> nodes = new List <string>(task.AllocatedNodes); string allocatedNodes = string.Join(" ", nodes.ToArray()); string logline = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}", dt.ToString(hpcDateTimeFormat), task.TaskId, task.State, task.Name, allocatedNodes, task.StartTime, task.EndTime, duration, task.ExitCode, task.ErrorMessage, task.Output, task.WorkDirectory, nodeGroups, task.Name, task.CommandLine); logline = logline.Replace("\t\t", "\tNULL"); logline = logline + "\n" + "Changetime:" + task.ChangeTime; List <string> columns = new List <string>() { "Timestamp", "TaskId", "State", "AllocatedNodes", "StartTime", "EndTime", "ElapsedTimeSec", "ExitCode", "ErrorMessage", "Output", "WorkDirectory", "NodeGroups", "Name", "CommandLine" }; logline = mapToString(makeDictionary(job, task), columns, "\t"); return(logline); }
/// <summary> /// a parametric sweep is a parallel computing job that consists of running multiple iterations of same command using different input values and output files /// each occurrence of an asterisk found on the command line is replaced with the value /// </summary> /// <param name="jobName">the name of job</param> /// <param name="commandLine">a parametric command for the task</param> /// <param name="startValue">the starting instance value. the value must be > 0, inclusive</param> /// <param name="endValue">the ending value. >= startValue. inclusive</param> /// <param name="incrementValue">the increment value</param> /// <param name="username">the name of the runas user, in the form domain\username</param> /// <param name="password">the password for the runas user</param> public void CreateParametricJob(string jobName, string commandLine, int startValue, int endValue, int incrementValue, string username, string password) { ISchedulerJob job = null; ISchedulerTask task = null; manualReset.Reset(); //create a job job = _scheduler.CreateJob(); job.OnJobState += OnJobStateCallback; job.OnTaskState += OnTaskStateCallback; job.Name = jobName; task = job.CreateTask(); //each occurrence of an asterisk found on the command line is replaced with the value task.CommandLine = commandLine; task.Type = TaskType.ParametricSweep; task.StartValue = startValue; task.EndValue = endValue; task.IncrementValue = incrementValue; job.AddTask(task); _scheduler.SubmitJob(job, username, password); manualReset.WaitOne(); }
private List <ISchedulerTask> GetFailedTasks(ISchedulerJob job) { IFilterCollection filters = _scheduler.CreateFilterCollection(); filters.Add(FilterOperator.Equal, PropId.Task_State, TaskState.Failed); var failedTasks = job.GetTaskList(filters, null, true).Cast <ISchedulerTask>().ToList(); return(failedTasks); }
private static bool submit_job(IScheduler scheduler, string taskName, string workDir, List <string> requestedNodes, string userName, string password, bool waitFlag, string taskSuffix = "") { try { ISchedulerJob job = null; ISchedulerTask task = null; Console.WriteLine(" working dir: " + workDir); Console.WriteLine(" task: " + taskName); foreach (string node in requestedNodes) { job = scheduler.CreateJob(); job.UnitType = JobUnitType.Node; job.IsExclusive = true; StringCollection nodes = new StringCollection() { node }; Console.WriteLine(" node: " + node); job.RequestedNodes = nodes; job.Name = node + taskSuffix; task = job.CreateTask(); task.CommandLine = taskName; task.WorkDirectory = workDir; task.StdOutFilePath = workDir + "\\output.txt"; task.StdErrFilePath = workDir + "\\error.txt"; task.Name = node; job.AddTask(task); scheduler.SubmitJob(job, userName, password); } //if (waitFlag) //{ // Console.WriteLine("Waiting for job to finish..."); // while (job.State != JobState.Finished) // { // System.Threading.Thread.Sleep(5000); // } //} if (waitFlag) { Console.WriteLine("hit any key to continue"); Console.ReadKey(); } //manualEvent.WaitOne(); return(true); } catch (Exception e) { Console.WriteLine("unable to start job successfully: " + taskName); Console.WriteLine(e); return(false); } }
static ISchedulerCollection getTasksFilterByEndTime(ISchedulerJob job) { ISchedulerCollection tasks; IFilterCollection filters = scheduler.CreateFilterCollection(); filters.Add(FilterOperator.GreaterThanOrEqual, PropId.Task_EndTime, iterationStartTime); tasks = job.GetTaskList(filters, null, true); return(tasks); }
/// <summary> /// Initializes a new instance of the <see cref="WinHpcSchedulerJob"/> class. /// </summary> public WinHpcSchedulerJob() { // Discover the job's context from the environment String headNodeName = Environment.GetEnvironmentVariable("CCP_CLUSTER_NAME"); int jobId = Convert.ToInt32(Environment.GetEnvironmentVariable("CCP_JOBID")); // Connect to the head node and get the job IScheduler scheduler = new Scheduler(); scheduler.Connect(headNodeName); Job = scheduler.OpenJob(jobId); }
internal static void SetSessionBrokerNodes(ISchedulerJob schedulerJob, ICollection <string> nodeSSDLs) { // Add the broker nodes available to the session as env variables so that services only // process requests from BNs int i = 0; foreach (string ssdl in nodeSSDLs) { schedulerJob.SetEnvironmentVariable(string.Format(BrokerNameEnvVarNameTemplate, ++i), ssdl); } schedulerJob.SetEnvironmentVariable(BrokerCountEnvVarName, nodeSSDLs.Count.ToString()); }
public void ExecuteWait(IEnumerable <string> tasksCmdLines, int jobMinimumNumberOfCores = 1, int jobMaximumNumberOfCores = 1, int taskMinimumNumberOfCores = 1, int taskMaximumNumberOfCores = 1, string outFolder = "") { ISchedulerJob job = null; ISchedulerTask task = null; using (IScheduler scheduler = new Scheduler( )) { scheduler.Connect(headNodeName); job = scheduler.CreateJob( ); int i = 0; foreach (var taskDef in tasksCmdLines) { i++; task = job.CreateTask( ); task.CommandLine = taskDef; task.MinimumNumberOfCores = taskMinimumNumberOfCores; task.MaximumNumberOfCores = taskMaximumNumberOfCores; task.StdOutFilePath = createOutFileName(outFolder, "stdout", i); task.StdErrFilePath = createOutFileName(outFolder, "stderr", i); job.AddTask(task); } try { job.AutoCalculateMin = false; job.AutoCalculateMax = false; job.MinimumNumberOfCores = jobMinimumNumberOfCores; job.MaximumNumberOfCores = jobMaximumNumberOfCores; job.OnJobState += new EventHandler <JobStateEventArg>(jobStateCallback); job.OnTaskState += new EventHandler <TaskStateEventArg>(taskStateCallback); // Start the job. scheduler.SubmitJob(job, string.Empty, null); // Blocks so the events get delivered. One of your event // handlers need to set this event. manualEvent.WaitOne( ); } finally { job.OnJobState -= jobStateCallback; job.OnTaskState -= taskStateCallback; } } }
private static void SelectClusterNodes(ClusterEnvironment clusterEnv, ISchedulerJob job, ISchedulerTask[] tasks) { foreach (var node in clusterEnv.SelectedNodes) { foreach (var task in tasks) { if (ShouldSetTaskParameters(task)) { task.RequiredNodes.Add(node); } } } switch (clusterEnv.ScheduleProcessPer) { case ScheduleProcessPer.Socket: job.MinimumNumberOfSockets = job.MaximumNumberOfSockets = clusterEnv.NumberOfProcesses; foreach (var task in tasks) { if (ShouldSetTaskParameters(task)) { task.MinimumNumberOfSockets = task.MaximumNumberOfSockets = clusterEnv.NumberOfProcesses; } } break; case ScheduleProcessPer.Node: job.MinimumNumberOfNodes = job.MaximumNumberOfNodes = clusterEnv.NumberOfProcesses; foreach (var task in tasks) { if (ShouldSetTaskParameters(task)) { task.MinimumNumberOfNodes = task.MaximumNumberOfNodes = clusterEnv.NumberOfProcesses; } } break; case ScheduleProcessPer.Core: job.MinimumNumberOfCores = job.MaximumNumberOfCores = clusterEnv.NumberOfProcesses; foreach (var task in tasks) { if (ShouldSetTaskParameters(task)) { task.MinimumNumberOfCores = task.MaximumNumberOfCores = clusterEnv.NumberOfProcesses; } } break; } }
public virtual SchedulerJob ScheduleAsync(DateTime time, ISchedulerJob toExecute) { lock (_jobLocker) { var job = new SchedulerJob(toExecute, time.ToUniversalTime(), ScheduleType.Once, true); _jobs.Add(job); if (_semaphore.CurrentCount == 0) { _semaphore.Release(); } return(job); } }
public virtual SchedulerJob ScheduleAsync(TimeSpan ts, ISchedulerJob toExecute, bool recurring) { lock (_jobLocker) { var job = new SchedulerJob(toExecute, ts, recurring ? ScheduleType.Recurring : ScheduleType.Once, true); _jobs.Add(job); if (_semaphore.CurrentCount == 0) { _semaphore.Release(); } return(job); } }
public bool StartTrackingJob() { _scheduler = null; _job = null; if (HpcLibSettings.ActiveClusters.Contains(Cluster, StringComparer.CurrentCultureIgnoreCase) && Connect()) { _job = GetJob(); if (_job != null) { _job.OnJobState += new EventHandler <JobStateEventArg>(_job_OnJobState); _job.OnTaskState += new EventHandler <TaskStateEventArg>(_job_OnTaskState); RefreshJobStatus(); } } return(_scheduler != null && _job != null); }
static void Main(string[] args) { IScheduler scheduler = new Scheduler(); string clustername = null; string username = null; if (args.Length != 2) { Console.Error.WriteLine("Usage: Finish clustername username "); return; } clustername = args[0]; username = args[1]; scheduler.Connect(clustername); ISchedulerJob job = scheduler.CreateJob(); job.UnitType = JobUnitType.Core; job.MinimumNumberOfCores = 1; job.MaximumNumberOfCores = 1; scheduler.AddJob(job); ISchedulerTask task = job.CreateTask(); task.CommandLine = @"ping -t localhost"; job.AddTask(task); scheduler.SubmitJob(job, username, null); Console.WriteLine("job {0} Submitted ", job.Id); Thread.Sleep(12 * 1000); job.Refresh(); Console.WriteLine("Job {0} State {1}", job.Id, job.State); ((ISchedulerJobV3)job).Finish(); Thread.Sleep(10000); job.Refresh(); task.Refresh(); Console.WriteLine("After finish Job {0} State {1} message {2}", job.Id, job.State, task.Output); }
private static void OnTaskStateCallback(object sender, TaskStateEventArg args) { if (TaskState.Finished == args.NewState || TaskState.Failed == args.NewState || TaskState.Canceled == args.NewState) { try { IScheduler scheduler = (IScheduler)sender; ISchedulerJob job = scheduler.OpenJob(args.JobId); ISchedulerTask task = job.OpenTask(args.TaskId); } catch (Exception) { } } }
private static void ScheduleJob(ClusterEnvironment clusterEnv, ISchedulerJob job) { var jobPath = Path.Combine(Environment.GetEnvironmentVariable("CCP_HOME"), "Bin\\job.exe"); var info = new ProcessStartInfo(jobPath, "submit /id:" + job.Id + " /scheduler:" + clusterEnv.HeadNode); var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString("Submitting job using command " + info.FileName + " " + info.Arguments + Environment.NewLine); } LaunchRedirectedToVsOutputWindow(info); }
/// <summary> /// Get customized properties of a specified job /// </summary> /// <param name="job">scheduler job</param> /// <param name="propNames">customized property names</param> /// <returns>dictionary of propname, propvalue</returns> internal static Dictionary <string, string> GetCustomizedProperties(ISchedulerJob job, params string[] propNames) { Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (NameValue pair in job.GetCustomProperties()) { if (Array.Exists <string>(propNames, delegate(string name) { return(pair.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); })) { dic.Add(pair.Name, pair.Value); } } return(dic); }
private static void AddJobStateStatusUpdate(ISchedulerJob job, ISchedulerTask[] tasks) { job.OnTaskState += (sender, args) => { if (args.NewState == TaskState.Failed || args.NewState == TaskState.Finished) { string output = tasks[0].Output; if (!String.IsNullOrWhiteSpace(output)) { var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString(output); } } } }; }
private static void ScheduleJob(Scheduler scheduler, ISchedulerJob job) { var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString("Submitting job " + job.Id + Environment.NewLine); } var shell = (IVsUIShell)HpcSupportPackage.GetGlobalService(typeof(SVsUIShell)); IntPtr owner; if (ErrorHandler.Succeeded(shell.GetDialogOwnerHwnd(out owner))) { scheduler.SetInterfaceMode(false, owner); } ThreadPool.QueueUserWorkItem(x => { try { scheduler.SubmitJob(job, null, null); } catch (Exception ex) { string msg; msg = "Failed to submit job " + ex.ToString(); if (pane != null) { pane.OutputString(msg); } else { MessageBox.Show(msg, "Python Tools for Visual Studio"); } } }); }
private void CheckJob() { var states = JobState.Configuring | JobState.Submitted | JobState.Queued | JobState.Running | JobState.Validating | JobState.ExternalValidation; List<TtsHpcJob> listJobs = new List<TtsHpcJob>(MaxNumOfHpcJobs); IFilterCollection filters = this.scheduler.CreateFilterCollection(); filters.Add(FilterOperator.Equal, JobPropertyIds.Name, this.JobName); filters.Add(FilterOperator.HasBitSet, JobPropertyIds.State, states); filters.Add(FilterOperator.Equal, JobPropertyIds.UserName, this.UserName); filters.Add(FilterOperator.Equal, JobPropertyIds.Owner, Environment.UserDomainName + "\\" + Environment.UserName); ISchedulerCollection jobs = scheduler.GetJobList(filters, null); if (jobs.Count > 0) { this.containerJob = jobs[0] as ISchedulerJob; } }
private void CreateJob() { this.containerJob = this.scheduler.CreateJob(); this.containerJob.Name = this.JobName; this.containerJob.Priority = (JobPriority)this.Priority; this.containerJob.IsExclusive = this.IsExclusive; if (this.IsExclusive) { this.containerJob.MinimumNumberOfNodes = 1; if (this.MaxNodes > 0) { this.containerJob.MaximumNumberOfNodes = this.MaxNodes; } else { this.containerJob.MaximumNumberOfNodes = this.MaxCores; } } else { this.containerJob.MinimumNumberOfCores = 1; if (this.MaxCores > 0) { this.containerJob.MaximumNumberOfCores = this.MaxCores; } else { this.containerJob.MaximumNumberOfCores = this.MaxNodes; } } this.jobCreating = true; }
/// <summary> /// Create a HpcJob according to the inner task and job. /// </summary> /// <param name="taskIn">The inner task.</param> /// <param name="jobIn">The inner job.</param> /// <returns>The HpcJob.</returns> public static TtsHpcTaskJob CreateFromInnerJob(ISchedulerTask taskIn, ISchedulerJob jobIn) { TtsHpcTaskJob job = new TtsHpcTaskJob(); job.Id = taskIn.TaskId.JobTaskId; job.Name = taskIn.Name; job.State = TtsHpcTaskJob.ConvertState(taskIn.State); if (taskIn.AllocatedNodes != null && taskIn.AllocatedNodes.Count > 0) { job.Machine = taskIn.AllocatedNodes[0]; } job.Command = taskIn.CommandLine; job.LogFile = taskIn.StdOutFilePath; job.CpuTime = job.CpuTime; job.Priority = (HpcJobPriority)jobIn.Priority; return job; }
private void SetPriority(ISchedulerJob job, int priority) { if (priority == 0) job.Priority = JobPriority.Lowest; else if (priority == 1) job.Priority = JobPriority.BelowNormal; else if (priority == 2) job.Priority = JobPriority.Normal; else if (priority == 3) job.Priority = JobPriority.AboveNormal; else if (priority == 4) job.Priority = JobPriority.Highest; }