Click or drag to resize

IJobScheduler Interface

Provides the methods used to submit and monitor jobs to a job scheduler.

Namespace:  AGI.Parallel.Client
Assembly:  AGI.Parallel.Client (in AGI.Parallel.Client.dll) Version: 2.7.0.1440 (2.7.0.1440)
Syntax
public interface IJobScheduler : IDisposable

The IJobScheduler type exposes the following members.

Properties
  NameDescription
Public propertyId
Gets the id of this job scheduler.
Public propertyIsConnected
Gets a value indicating whether the job scheduler is connected.
Top
Methods
  NameDescription
Public methodCancelJob
Cancels the job with the specified id.
Public methodCancelTask
Cancels the task with the specified id.
Public methodConnect
Connects client to specified job scheduler.
Public methodCreateJob
Returns a new job that can later be used to submit to the job scheduler.
Public methodDisconnect
Disconnects client from specified job scheduler.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodCode exampleGetMaximumHostCount
Returns the maximum number of hosts that is available to the job scheduler.
Public methodSubmitJob
Submits job to the job scheduler so the job scheduler can add the job to its queue.
Public methodWaitUntilDone
Blocks until all tasks in this job complete or the operation times out. The callback passed in for the heartbeat is called with the period specified by the millisecondsHeartbeat argument.
Top
Remarks
After creating an instance of this class, call the Connect method to connect to the cluster. You can then submit and monitor jobs.
Examples
using System;
using AGI.Parallel.Client;
using AGI.Parallel.Infrastructure;

namespace CodeSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create the ClusterJobScheduler class.
            // Specify the hostname and optionally the port number in the ClusterJobScheduler constructor.
            // You must ensure you call the Dispose method. In this method we are utilizing the using statement.
            using (IJobScheduler scheduler = new ClusterJobScheduler("localhost"))
            {
                // Before you use any methods on the object, you must call Connect.
                try
                {
                    scheduler.Connect();

                    // Create a job, add a task, and submit.
                    Job job = scheduler.CreateJob();
                    job.AddTask(new HelloTask());

                    job.Submit();
                    job.WaitUntilDone();
                    Console.WriteLine("Result: " + job.Tasks[0].Result);
                }
                catch (JobSchedulerException e)
                {
                    Console.WriteLine("JobSchedulerException: " + e);
                }
            }
        }

        [Serializable]
        public class HelloTask : Task
        {
            public override void Execute()
            {
                Result = "Hello from Task";
            }
        }
    }
}
See Also

STK Parallel Computing Server 2.7 API for .NET