/// <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); }
public void OnVpnConnecting(VpnState state) { DisableReversed(); Disable(); _appFilter.RemoveAll(); _permittedRemoteAddress.RemoveAll(); if (_serviceSettings.SplitTunnelSettings.Mode == SplitTunnelMode.Permit) { _appFilter.Add(_serviceSettings.SplitTunnelSettings.AppPaths, Action.SoftBlock); } }
/// <summary> /// GetFailedAndCanceledTasks /// </summary> /// <param name="scheduler">scheduler</param> /// <param name="job">job</param> /// <returns>ISchedulerTask</returns> public static List <ISchedulerTask> GetFailedAndCanceledTasks(IScheduler scheduler, 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(); filters = scheduler.CreateFilterCollection(); filters.Add(FilterOperator.Equal, PropId.Task_State, TaskState.Canceled); var canceledTasks = job.GetTaskList(filters, null, true).Cast <ISchedulerTask>().ToList(); return(failedTasks.Append(canceledTasks).ToList()); }
public Dictionary <int, ISchedulerJob> GetJobs(DateTime lastDate) { IFilterCollection jobFilters = hpcScheduler.CreateFilterCollection(); jobFilters.Add(FilterOperator.GreaterThanOrEqual, PropId.Job_StartTime, lastDate); ISchedulerCollection jobs = hpcScheduler.GetJobList(jobFilters, null); Dictionary <int, ISchedulerJob> jobDict = new Dictionary <int, ISchedulerJob>(); foreach (ISchedulerJob job in jobs) { if (job.State == JobState.Running) { updateMinimum(job); } else { continue; } if (!jobDict.ContainsKey(job.Id)) { jobDict[job.Id] = job; } } lastMinStartTime = tempMinStartTime; lastGetJobsRun = jobs; return(jobDict); }
public Dictionary <int, ISchedulerJob> GetJobs(JobState state) { IFilterCollection jobFilters = hpcScheduler.CreateFilterCollection(); jobFilters.Add(FilterOperator.Equal, PropId.Job_State, state); ISchedulerCollection jobs = hpcScheduler.GetJobList(jobFilters, null); Dictionary <int, ISchedulerJob> jobDict = new Dictionary <int, ISchedulerJob>(); foreach (ISchedulerJob job in jobs) { updateMinimum(job); if (!jobDict.ContainsKey(job.Id)) { jobDict[job.Id] = job; } } if (state == JobState.Running) //|| state == JobState.Finished || state == JobState.Finishing ) { lastMinStartTime = tempMinStartTime; } return(jobDict); }
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); }
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); }
static void createLogData() { IFilterCollection jobFilters = scheduler.CreateFilterCollection(); jobFilters.Add(FilterOperator.GreaterThanOrEqual, PropId.Job_StartTime, jobMinStartDate); ISchedulerCollection jobs = scheduler.GetJobList(jobFilters, null); //getJobs (jobFilters); DateTime now = DateTime.Now; foreach (ISchedulerJob job in jobs) { generateTaskLogLines(now, job, getTasks(job, TaskState.Failed)); generateTaskLogLines(now, job, getTasks(job, TaskState.Finished)); } }
public static bool TryGetJob(IScheduler scheduler, string username, int jobID, out ISchedulerJob job) { IFilterCollection filter = scheduler.CreateFilterCollection(); filter.Add(FilterOperator.Equal, PropId.Job_UserName, username); if (scheduler.GetJobIdList(filter, null).Contains(jobID)) { job = scheduler.OpenJob(jobID); } else { job = null; } return(job != null); }
private void Enable() { _splitTunnelClient.EnableExcludeMode( _serviceSettings.SplitTunnelSettings.AppPaths, _serviceSettings.SplitTunnelSettings.Ips); if (_serviceSettings.SplitTunnelSettings.AppPaths.Length > 0) { _appFilter.Add(_serviceSettings.SplitTunnelSettings.AppPaths, Action.SoftPermit); } if (_serviceSettings.SplitTunnelSettings.Ips.Length > 0) { _permittedRemoteAddress.Add(_serviceSettings.SplitTunnelSettings.Ips, Action.SoftPermit); } _enabled = true; }
static void getMinimumStartDate() { taskMaxEndDate = new DateTime(1970, 1, 1); tempMaxEndDate = new DateTime(1970, 1, 1); jobMinStartDate = new DateTime(3000, 1, 1); tempMinStartDate = new DateTime(3000, 1, 1); ISchedulerCollection jobs; while (true) { IFilterCollection jobFilter = scheduler.CreateFilterCollection(); jobFilter.Add(FilterOperator.Equal, PropId.Job_State, JobState.Running); jobs = scheduler.GetJobList(jobFilter, null); foreach (ISchedulerJob job in jobs) { tempMinStartDate = job.StartTime < tempMinStartDate ? job.StartTime : tempMinStartDate; ISchedulerCollection tasks = getTasks(job, TaskState.Finished); foreach (ISchedulerTask task in tasks) { tempMaxEndDate = task.EndTime > tempMaxEndDate ? task.EndTime : tempMaxEndDate; } } if (jobs.Count > 0) { info("There are now running jobs. Sleeping (" + runningJobPollDuration + ")"); return; } else { warn("There are no running jobs. Sleeping (" + runningJobPollDuration + ")"); } Thread.Sleep(runningJobPollDuration * 1000); } taskMaxEndDate = tempMaxEndDate; jobMinStartDate = tempMinStartDate; }
static int iRoundToSecondsMinimum = 10; // If a TimeSpan takes more than 10 seconds, round off the milliseconds /// <summary> /// Command Line entrypoint /// </summary> /// <param name="args">parsed parameter string</param> /// <returns></returns> static int Main(string[] args) { // In case it has been renamed, find out what the current name in use is // Filename for Help or Error messages Location l = new Location(); sExeFilename = Path.GetFileNameWithoutExtension(Path.GetFileName(l.locationFullPath)); if (ParseParameters(args) == false) { return(-1); } // If no job id or user is defined, give help message if ((jobId == 0) && (userName == null)) { help(sExeFilename); return(-1); } try { using (IScheduler scheduler = new Scheduler()) { ISchedulerCollection jobs = null; IFilterCollection filter = null; ISortCollection sort = null; scheduler.Connect(clusterName); // Filter the jobs requested by the parameters, either a single job or a range, and/or a user filter = scheduler.CreateFilterCollection(); if (jobIdRange != 0) { filter.Add(FilterOperator.GreaterThanOrEqual, JobPropertyIds.Id, jobId); filter.Add(FilterOperator.LessThanOrEqual, JobPropertyIds.Id, jobIdRange); } else { filter.Add(FilterOperator.Equal, JobPropertyIds.Id, jobId); } if (userName != null) { filter.Add(FilterOperator.Equal, JobPropertyIds.Owner, userName); } // Sort the jobs relative to when they were created sort = scheduler.CreateSortCollection(); sort.Add(SortProperty.SortOrder.Ascending, PropId.Job_CreateTime); jobs = scheduler.GetJobList(filter, sort); // Be sure the job(s) can be found if (jobs.Count == 0) { Console.Error.WriteLine(sExeFilename + NOJOBSFOUND); return(-1); } else { foreach (ISchedulerJob job in jobs) { if (bVerbose) { Console.WriteLine("job {0} project: {1}", job.Id, job.Project); } // Is the job part of the project? if ((projectName != null) && (job.Project != projectName)) { continue; } else if ((projectNameIgnore != null) && (job.Project.Equals(projectNameIgnore, StringComparison.InvariantCultureIgnoreCase) == false)) { continue; } else // Exact match overrides StartsWith and Contains, only test them if previous tests are not attempted { if ((projectNameBegins != null) && (job.Project.StartsWith(projectNameBegins, StringComparison.InvariantCultureIgnoreCase) == false)) { continue; } if ((projectNameContains != null) && (job.Project.Contains(projectNameContains) == false)) { continue; } } iFilteredJobs++; Console.WriteLine("Job {0} - {1}", job.Id, job.State); Console.WriteLine(job.Name); collectAllocatedInfo(job); } } // Jobs were found within the range, but none had the appropriate project criteria if (iFilteredJobs <= 0) { Console.Error.WriteLine(sExeFilename + NOJOBSFOUND); return(-1); } // Round up/down to seconds if greater than minimum if (tsAllJobUsage.TotalSeconds >= iRoundToSecondsMinimum) { if (tsAllJobUsage.Milliseconds >= 500) { tsAllJobUsage = tsAllJobUsage.Add(TimeSpan.FromMilliseconds(1000 - tsAllJobUsage.Milliseconds)); } else { tsAllJobUsage = tsAllJobUsage.Subtract(TimeSpan.FromMilliseconds(tsAllJobUsage.Milliseconds)); } } // If a range of jobs was given, or other criteria created selected multiple jobs, show summary if ((jobIdRange > 0) || (iFilteredJobs > 1)) { Console.WriteLine("Number of jobs: {0}", iFilteredJobs); Console.WriteLine("Number of {0}: {1}", bNodesOnly ? "nodes" : "cores", iAllJobThreads); Console.WriteLine("{0} usage across all jobs: {1}", bNodesOnly ? "Node" : "Core", tsAllJobUsage); } } } catch (Exception e) { Console.Error.WriteLine("Exception!"); Console.Error.WriteLine(e.Message); } return(iFilteredJobs); }