Export (0) Print
Expand All

ActivationFilterResponse Enumeration

This enumeration defines the responses that a custom job activation filter can return to the HPC Job Scheduler Service. These responses tell the HPC Job Scheduler Service how to continue processing the job.


Namespace: Microsoft.Hpc.Scheduler.AddInFilter.HpcClient
Assembly: Microsoft.Hpc.Scheduler (in Microsoft.Hpc.Scheduler.dll)

'Usage
Dim instance As ActivationFilterResponse

public enum ActivationFilterResponse
public enum ActivationFilterResponse
public enum ActivationFilterResponse

Member nameDescription
AddResourcesToRunningJobAllow the candidate resources to be added to the running job. This enumeration member represents a value of 0.
DoNotRunHoldQueueDo not start the queued job, and do not start any other jobs of equal or lower priority until the job passes the activation filter or is canceled. The HPC Job Scheduler Service reruns the filter periodically until the job passes or is canceled. The scheduler behavior for this response value on a Running job is undefined. Use only when evaluating Queued jobs. This enumeration member represents a value of 1.
DoNotRunKeepResourcesAllowOtherJobsToScheduleDo not start the queued job, but reserve the candidate resources for the job and continue scheduling jobs on other resources. The HPC Job Scheduler Service reruns the filter periodically until the job passes or is canceled. The scheduler behavior for this response value on a Running job is undefined. Use only when evaluating Queued jobs. This enumeration member represents a value of 2.
FailJobMark the job as Failed with an error message that the job was failed by the activation filter. The scheduler behavior for this response value on a Running job is undefined. Use only when evaluating Queued jobs. This enumeration member represents a value of 4.
HoldJobReleaseResourcesAllowOtherJobsToScheduleHold the job, release the candidate resources, and continue scheduling other jobs. See remarks for more information. The scheduler behavior for this response value on a Running job is undefined. Use only when evaluating Queued jobs. This enumeration member represents a value of 3.
RejectAdditionOfResourcesDo not add the candidate resources to the Running job. This enumeration member represents a value of 1.
StartJobStart the job on the candidate resources. This enumeration member represents a value of 0.

Activation filters run when candidate resources are allocated to a queued or running job (candidate resources for a job are based on the job and task properties and on the scheduling policies). The return value from an activation filter determines how the HPC Job Scheduler Service will treat the job and its resources. Because activation filters run every time that resources are allocated to a job, the activation filter might run multiple times for the same job. For example, the activation filter can run when the job is about to be started, and then run again as new resources are about to be added to the job (dynamic growth).

The following code snippet illustrates how to use the filter response enumeration to tell the HPC Job Scheduler Service what action to take on the job. In this case, the filter is enforcing a policy that allows all jobs to start during non-business hours. If the off hours condition is met, the filter response is set to StartJob. The snippet is from the AFHoldUntil sample DLL filter in the Microsoft HPC Pack 2008 R2 SP2 SDK code samples.

               if (DuringOffHours()) {
                    logFile.WriteLine("AF: During Off Peak Hours, job starting");
                    return ActivationFilterResponse.StartJob;
                }

Distinguishing between Queued and Running jobs

Activation filters evaluate the allocation of resources to Queued and Running jobs. The following table summarizes which response values to use for each state. A check mark indicates that the response is valid.

Response Queued Running

AddResourcesToRunningJob

OK, equivalent to returning StartJob.

CheckSymbol screenshot

DoNotRunHoldQueue

CheckSymbol screenshot

Scheduler behavior undefined.

DoNotRunKeepResourcesAllowOtherJobsToSchedule

CheckSymbol screenshot

Scheduler behavior undefined.

FailJob

CheckSymbol screenshot

Scheduler behavior undefined.

HoldJobReleaseResourcesAllowOtherJobsToSchedule

CheckSymbol screenshot

Scheduler behavior undefined.

RejectAdditionOfResources

OK, equivalent to DoNotRunHoldQueue.

CheckSymbol screenshot

StartJob

CheckSymbol screenshot

OK, equivalent to returning AddResourcesToRunniingJob.

The following code snippet illustrates how to get the job state information from the job XML. The snippet is from the JobFlexLM sample DLL filter in the SP2 SDK code samples.

            // Get the job state to determine if this is an initial allocation or growing.
            jobidnode = job.SelectSingleNode(@"@State", nsmgr);
            if (jobidnode != null)
            {
                string JobStateStr = jobidnode.InnerXml;
                if (String.IsNullOrEmpty(JobStateStr))
                {
                    LogEvent(@"Unable to extract job state from job file");
                    return;
                }
                if (string.Compare(JobStateStr, "Running", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    _growing = true;
                }
            }
            else
            {
                LogEvent(@"Unable to extract job state from job file");
                return;
            }

Saving resources for a job

When the filter returns DoNotRunKeepResourcesAllowOtherJobstoSchedule, the number of resources that are reserved for the job depend on the Scheduling Mode: In Queued, up to the job’s maximum resources are reserved; in Balanced, the minimum resources are reserved. For more information, see HPC Job Scheduler policy configuration.

Holding a job

When the filter returns HoldJobReleaseResourcesAllowOtherJobsToSchedule, the job is put on hold until the date and time specified by the Hold Until job property (which can be set by the filter, see code snippet). After the hold period, the job is reevaluated by the filter program.

If the filter returns this response and no Hold Until value is specified for that job, the job is held for the amount of time specified by the Default Hold Duration cluster setting. The cluster administrator can change the setting, but the default value is 900 seconds (15 minutes).

The following code snippet illustrates how to set the HoldUntil job property. In this case, the filter is specifying that certain types of jobs should not be started until after business hours. To ensure that a job will not be re-evaluated for activation until after-hours, the filter program sets the HoldUntil job property. The snippet is from the AFHoldUntil sample DLL filter in the Microsoft HPC Pack 2008 R2 SP2 SDK code samples.


                            // If the job is not already set to delay until off peak hours, set it
                            // This property should be null, but could be non-null if some other
                            // thread has set it after scheduling called the activation filter
                            if ((job.HoldUntil == null) || (job.HoldUntil < peakEnd)) {
                                job.SetHoldUntil(peakEnd);
                                job.Commit();
                                logFile.WriteLine("Delay job {0} until off peak hours", jobId);
                            } else {
                                logFile.WriteLine("Job {0} already set to {1}", jobId, job.HoldUntil);
                            }

Platform Note: This class was introduced in Windows HPC Server 2008 R2 with Service Pack 2 (SP2) and is not supported in previous versions.


Development Platforms

Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

Target Platforms

Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, with HPC Pack Client Utilities




Build Date:

2013-04-22

Community Additions

ADD
Show:
© 2014 Microsoft