Constraints

A constraint (or dependency as it is often called) is a specification or condition that must be true before a triggerable object (Job, Plan or reference) is allowed to execute. An object triggered to run will not do so unless all the constraints (you can set more than one) have been met.

 

Constraints are configured on a Job or Plan's Constraints property sheet. The constraint properties are the same for both Jobs and Plans, with the only difference being there are two additional properties on the Job's Constraints property sheet (Dispatch Alert Delay and Maximum Dispatch) that are not present on the Plan's Constraint property sheet.

 

Constraints are not triggers. However, there is a type of trigger that uses the general constraints discussed here. This type of trigger is named Constraint Based Scheduling (CBS), which is configured on a Job or Plan's Triggers property sheet. While CBS is a trigger type, it should not be confused with the constraints described here, which are not triggers. They are conditions that must be met before an already triggered object can run.

 

ActiveBatch supports (4) General constraints: File, Job, Variable, and Resource. Additionally, it supports (2) Date/Time constraints: Date/Time exclusion list and Calendar object associations. Below is an image depicting a list of general constraints and action buttons that allow you to add, edit and remove general constraints. Additionally, the general constraints section includes: the Constraint Logic property, properties associated with a constraint failure, and a checkbox enabling the Business Day Semantics property.

 

When you click on the Add button, you will be prompted to select one of the 4 types of general constraints. Depending on which one you choose, the appropriate dialog window will open, providing you with additional property settings described in this section (each of the 4 general constraints are described in detail below). Please note you can add multiple constraints for any given Job or Plan, which can include a mix of the 4 general types, all of the same type, etc. In the image below, a Job and File constraint have been configured.

 

 

Let's look at the properties that are not specific to any particular general constraint type.

 

Use Business Day Semantics: This Boolean property indicates that this object (Job or Plan) is to use a Business Day instead of a normal Calendar Day. By default, a calendar day beginning at 0000 and ending at 2359 defines a day period. If Business Day Semantics is enabled, then an ActiveBatch Administrator established a business day, which is a 24 hour period with a start time something other than 0000. Please see your ActiveBatch Administrator for the Business Day definition that governs your system. It should be noted, however, that a Business Day, even though it spans past midnight, is still considered 1 day. For example, January 1, 0600 (the Business Day start) and January 2, 0559 (the Business Day end) are all considered January 1 in terms of a business day.

 

Constraint Logic: This section indicates how the various listed general constraints should be checked and in what order (the evaluation is done from left to right). When you save new constraints, the constraint label is automatically added to the Constraint Logic property. However, additional information may be required in the constraint logic property (for example, a comparison operator and value when using certain types of variable constraints). You can specify comparison, Boolean operators and parenthesis to ensure that any constraints match your expectations. Boolean logic operators, in English or VBScript-style, or arithmetic operators may be used (all arithmetic operations are integer based). For example, “and” or  &&  may be specified. A unique label identifies each constraint. In the above example, “JOBA” and “DataFile” constraints must both be met. See Constraint Logic Operators for a complete list of operators. Please note that you should exercise caution when performing logical operations on strings. Other than “0”, “1”, “False” and “True” the behavior when using logical operations on strings is undefined.

 

Note: When a constraint is removed from the "General" constraints list using the Remove button, you must always ensure that you also remove the associated label referencing that constraint (and its additional associated logic, if any) from the Constraint Logic property. Missing constraints whose labels remain in the Constraint Logic property are treated as false.

 

Note: A constraint in the "General" constraints list will be ignored if its label is not present in the Constraint Logic property.

 

If constraint logic fails: There are a few fields that control what actions should be taken if one or more constraints fail. In the above image, “JOBA” must complete successfully and the file c:\Temp\Temp.dat must be present, be at least 1000 bytes in size and created within the last five (5) hours - for this constraint to be satisfied. If you look at the bottom of the figure you’ll see an “If constraint logic fails” specification which indicates that the system should wait up to 15 minutes to determine whether the constraint failure has resolved itself.

 

Fail this Job/Plan: When checked, ActiveBatch fails the Job immediately if the constraint is not met after the trigger occurs. It will fail with a Failed Constraint state, where State is a column present in various instances views.

 

Wait: This indicates that the system should wait (the default behavior), and not fail the Job immediately. How long to wait is determined by the next set of paired controls. Wait. Check every <number> / <units> for <number> / units interval. Units is one of the following: Hours, Minutes or Seconds (the legal range of the number depends on the unit specified). Interval is one of the following: Days, Hours, Minutes, Seconds, Times or Forever. The default recheck interval is “Check every 2 minutes for 10 minutes”. This is the how long the system will check to see if the constraint is satisfied, and the check frequency. A instance whose constraint is not initially met will go into a Waiting Constraint state. If the constraint is not met within the specified time frame, the instance will fail with a Failed Constraint state, where State is a column present in various instances views.

 

Note: Job Scheduler performance can be negatively impacted by frequent constraint logic checks, especially if multiple Jobs are waiting on constraints at the same time. Every failed constraint check causes a round of instance preprocessing logic to run. This includes the Job Scheduler communicating with the ActiveBatch back-end database. For example, configuring a constraint check with a frequency of every couple of seconds and a duration of hours and days would not be recommended. This is especially true if there are many other Jobs waiting on constraints at the same time, also configured for frequent constraint checks. It is recommended you find the right balance when establishing constraint logic. Use the largest check interval with the shortest duration that is practical for your workflow.

 

Constraint Logic Operators

 

Operator Description

+

Addition

-

Subtraction

*

Multiplication

/

Division

%

Modulo

^

Raise to power

&&

Logical AND

AND

Logical AND

||

Logical OR

OR

Logical OR

!=

Not Equal

<>

Not Equal

NOT, !

NOT or Complement

==

Logical Equal

=

Equal

>=

Greater than or equal

>

Greater than

<=

Less than or equal

<

Less than

 

Note: You can force an instance to run that is waiting on constraint(s) using the "force run" operation.  You can also manually trigger an object and ignore constraints by checking the appropriate "ignore" options in the Trigger (Advanced) operation.

 

Instance Restart and Constraint Logic

This topic describes what happens to Constraints when an instance is restarted.

 

Instances can be restarted automatically through Completion properties or via the Restart operation. When an instance is restarted, the following constraint rules apply:

 

  1. The only variables that are re-evaluated are those marked as Volatile and those ActiveVariables that have never been re-evaluated before.

  2. File Constraint, Resource Constraint and Job Constraint are also re-evaluated.

  3. UserInput is only re-evaluated if the operator checks the “Use Latest Template Properties” checkbox on a Restart operation. Otherwise, the UserInput is considered as being met, if a value was entered, and no new input is requested as a result of the restart.

 

Instance Dispatch Options

Instance Dispatch options are applicable to Jobs only. The properties listed below are at the bottom of a Job's Constraints property sheet.

 

Both properties relate to events that will occur if a Job triggers but has not yet been dispatched to an Execution Agent to run. The reason the Job has not been dispatched does not matter (waiting constraint, waiting queue busy, etc.). The only thing that matters is the Job triggered, an instance has been created, and it has not been dispatched to an Agent to run yet. See below for more details.

 

  • Dispatch Alert Delay

    • This property is specified in minutes, and it is the amount of time that can pass before an alert goes out indicating that a Job instance has not yet been dispatched to an Agent to run. The factory default value is 5 minutes.  A value of 0 indicates that any delay is acceptable and not subject to an alert. Next, the alert must be configured by you for an alert to go out. The Alert type to configure is "Job/Plan Delayed in Starting". An email (or another supported notification type) can be used to alert interested ActiveBatch operator(s). As a final note, an instance's audit trail will include a "Late" audit if the amount of time passes that is specified in this property. If an alert was configured and went out successfully, you will also see a "Notification sent" audit in the instance's audit trail. As far as the instance is concerned, no action is taken against it. This is simply a notification method so you can be advised that Jobs are not moving as expected, and could cause problems if left unchecked.

  • Maximum Dispatch

    • This property is specified in days, hours, minutes, and seconds. It is the amount of time that can pass before a Job is automatically canceled by the system because the instance has not been dispatched to an Agent within the specified time frame. By default, no time is set, therefore no Jobs will be canceled for this reason unless you enter a time, and the time entered passes.

    • As an example, let’s say a Job is queued for execution at 0800 with a 1 hour maximum dispatch time. At 0900, if the Job has not transitioned to an executing state, the Job is aborted. If you wish to tie an alert to this condition, use the "Job/Plan Exceeded Dispatch Time" alert type.  It is not required that you send out an alert, but most likely there would be ActiveBatch operator(s) interested in knowing if a Job was auto-canceled by the system. When a Job is canceled for this reason, the instance's audit trail will state: "Dispatch time exceeded" and so will the instance's Exit Code Description (the State will be listed as "Aborted")

 

Note: Maximum Dispatch is particularly useful when a long running Job must begin to execute by a certain time in order to meet service level agreements or to avoid impacting other aspects of the business.

 

Note: The two options described above are not mutually exclusive.  For example, you may have an Dispatch Alert Delay configured for 30 minutes (tied to an alert), and you may have a Maximum Dispatch time configured for 60 minutes. This provides operators with 30 minutes, after the Alert delay notification is received, to try and resolve the issue - before the system auto-cancels the Job.