how to get the list of active job owners(by using c# and hpc api)?
-
2011年7月21日 11:03
hi ,
i would like to get via web application, using c# and hpc api, the list of all the job owners that are active(that mean that there jobs are running or queued.
thank in advanced for your help,
Ben
全部回复
-
2011年7月28日 22:36
Hi Ben,
Here is some short, console example:
using System; using System.Collections.Generic; using Microsoft.Hpc.Scheduler; using Microsoft.Hpc.Scheduler.Properties; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { using (IScheduler scheduler = new Scheduler()) { // Connect to scheduler scheduler.Connect("LOCALHOST"); // Specify, that we only want job owner to be returned IPropertyIdCollection properties = new PropertyIdCollection(); properties.Add(JobPropertyIds.Owner); // We need to filter jobs by eliminating states we don't need // (filters in the collection are combined with AND operator) IFilterCollection filters = scheduler.CreateFilterCollection(); filters.Add(FilterOperator.NotEqual, JobPropertyIds.State, JobState.Canceled); filters.Add(FilterOperator.NotEqual, JobPropertyIds.State, JobState.Finished); filters.Add(FilterOperator.NotEqual, JobPropertyIds.State, JobState.Failed); filters.Add(FilterOperator.NotEqual, JobPropertyIds.State, JobState.Configuring); // HashSet to store only unique user names HashSet<string> users = new HashSet<string>(); // Enumerate returned jobs and store owner names using (ISchedulerRowEnumerator rows = scheduler.OpenJobEnumerator(properties, filters, null)) { foreach (PropertyRow row in rows) { users.Add(row[JobPropertyIds.Owner].Value.ToString()); } } // Print result foreach (string user in users) Console.WriteLine(user); } } } }
Thanks,
Łukasz- 已标记为答案 Ben.Alterzon 2011年7月31日 7:25
-
2011年7月31日 7:25
thank you very much!!!!!!!!!
Ben