how to get the list of active job owners(by using c# and hpc api)?
-
jueves, 21 de julio de 2011 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
Todas las respuestas
-
jueves, 28 de julio de 2011 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- Marcado como respuesta Ben.Alterzon domingo, 31 de julio de 2011 7:25
-
domingo, 31 de julio de 2011 7:25
thank you very much!!!!!!!!!
Ben