Export (0) Print
Expand All

Getting a List of Jobs

You can retrieve lists of job identifiers or job objects. You can get a list of all jobs in the cluster or use filters to retrieve a subset of the jobs. The following C# and C++ examples show how to retrieve the job identifiers and job objects in the cluster. For an example that shows how to filter and sort the jobs, see Filtering and Sorting Lists of Objects.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Hpc.Scheduler;
using Microsoft.Hpc.Scheduler.Properties;

namespace Getting_a_List_of_Jobs
{
    class Program
    {
        static void Main(string[] args)
        {
            IScheduler scheduler = new Scheduler();

            try
            {
                scheduler.Connect("localhost");

                EnumerateJobIds(scheduler);
                Console.WriteLine();
                EnumerateJobs(scheduler);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        private static void EnumerateJobIds(IScheduler scheduler)
        {
            foreach (int jobId in scheduler.GetJobIdList(null, null))
            {
                Console.WriteLine("\nProperties for job {0}:", jobId);
                PrintJobProperties(scheduler.OpenJob(jobId));
            }
        }

        private static void EnumerateJobs(IScheduler scheduler)
        {
            foreach (ISchedulerJob job in scheduler.GetJobList(null, null))
            {
                Console.WriteLine("\nProperties for job {0}:", job.Id);
                PrintJobProperties(job);
            }
        }

        private static void PrintJobProperties(ISchedulerJob job)
        {
            // TODO: Print job properties.
        }
    }
}


Related topics

Using HPC

 

 

Show:
© 2014 Microsoft