Click or drag to resize

JobExclusiveExecution Property

Gets or sets a value indicating whether the tasks on this job should have exclusive access to the resource it is running on.

Namespace:  AGI.Parallel.Client
Assembly:  AGI.Parallel.Client (in AGI.Parallel.Client.dll) Version: 2.9.0.1601 (2.9.0.1601)
Syntax
public bool ExclusiveExecution { get; set; }

Property Value

Type: Boolean
true if this the tasks on this job has exclusive access; otherwise, false.

Implements

IJobExclusiveExecution
Remarks
Tasks can either consume a single core of all the cores of an agent. An exclusive job means that all the task of a job will consume all the cores of an agent. The ExclusiveExecution flag prevents any other task to be executed concurrently.
Examples
using System;
using System.Threading;
using AGI.Parallel.Client;
using AGI.Parallel.Infrastructure;

namespace CodeSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IJobScheduler scheduler = new ClusterJobScheduler("localhost"))
            {
                scheduler.Connect();

                Job job = scheduler.CreateJob();

                // Set ExclusiveExecution to true
                job.ExclusiveExecution = true;

                for (int i = 0; i < 3; ++i)
                {
                    Task task = new OnlyTaskThatIsRunning();
                    job.AddTask(task);
                }

                job.Submit();
                job.WaitUntilDone();

                for (int i = 0; i < 3; ++i)
                {
                    DateTime start = job.Tasks[i].GetProperty<DateTime>(TaskProperties.HostStartTime);
                    DateTime end = job.Tasks[i].GetProperty<DateTime>(TaskProperties.HostEndTime);
                    Console.WriteLine("Task #{0} ran on {1} from {2} to {3}", i + 1, job.Tasks[i].Result, start, end);
                }
            }

            /*
             * The output of the application should resemble:
             * Task #1 ran on MyComputerName from 2/28/2013 5:34:24 PM to 2/28/2013 5:34:29 PM
             * Task #2 ran on MyComputerName from 2/28/2013 5:34:29 PM to 2/28/2013 5:34:34 PM
             * Task #3 ran on MyComputerName from 2/28/2013 5:34:34 PM to 2/28/2013 5:34:39 PM
             */
        }

        [Serializable]
        public class OnlyTaskThatIsRunning : Task
        {
            public override void Execute()
            {
                Thread.Sleep(5000);
                this.Result = Environment.MachineName;
            }
        }
    }
}
See Also

STK Parallel Computing Server 2.9 API for .NET