JobFailIfPreconditionsNotSatisfied Property |
Namespace: AGI.Parallel.Client
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(); // This should normally never be true. If it is true, count yourself lucky. job.TaskPreconditions.Add(CommonResources.AvailableCores, Operator.GreaterThan, 100); // Setting FailIfPreconditionsNotSatisfied to true ensures that the task fails immediately // if the precondition is not met. This prevents a task to be "stuck" in the task queue. job.FailIfPreconditionsNotSatisfied = true; for (int i = 0; i < 5; ++i) { job.AddTask(new TaskThatRequiresPrecondition()); } job.Submit(); job.WaitUntilDone(); for (int i = 0; i < 5; ++i) { Console.WriteLine("Task #{0} Status {1}", i + 1, job.Tasks[i].TaskStatus); } } /* * The output of the application should resemble: * Task #1 Status Failed * Task #2 Status Failed * Task #3 Status Failed * Task #4 Status Failed * Task #5 Status Failed */ } [Serializable] class TaskThatRequiresPrecondition : Task { public override void Execute() { } } } }
STK Parallel Computing Server 2.9 API for .NET