Using Resources
JAMS Resources are powerful tools that can help you allocate how batch Jobs are run. Resources let you define the necessary requirements (weight) for all Jobs, allowing JAMS to determine which Jobs can or cannot run concurrently. You can also use Resources to create maintenance windows that will prevent Jobs from running for a specified time. This is helpful during upgrades or maintenance activities, such as moving the JAMS Scheduler or backing up the database.
Resources can be assigned to Folders and Jobs. The Resource is defined by setting a specific quantity. Jobs will then use a portion of this quantity when they run. If you assign the Resource at the Folder level, all Jobs within the Folder will inherit the Resource setting.
Determining the Resource Quantity to Assign
When manually modifying Resources, how do you know how much or how little to assign to a particular Job? JAMS provides several ways to determine if a Resource is working above or below its effective allocation.
Insert the Quantity Available and Quantity in Use Columns
To see what Resources are currently active, use the Column Chooser to insert the Quantity Available and Quantity in Use columns in the Resource Definitions View.
Access the Monitor
Open the Monitor to view the status of all Jobs. If a Job has stalled or displays a ‘Waiting for Resources’ description, consider adjusting the Resource allocation.
Run a Script
You can run the following PowerShell script to return the quantity of Resources that are currently in use.
#### Report Resource Usage
Import-Module JAMS
$JAMSServer = "localhost"
$JAMSDefaultServer = $JAMSServer
New-PSDrive JD JAMS $JAMSServer -ErrorAction SilentlyContinue
$jamsentries = get-jamsentry -server $JAMSServer
$EntryReport= @()
$ResourceReport= @()
foreach ($jamsentry in $jamsentries){
$entry=get-jamsentry $jamsentry.jamsentry
$resourcerequirements = $entry.Elements | where-object {($_ -is [MVPSI.JAMS.ResourceRequirement])}
foreach ($resourcerequirement in $resourcerequirements){
write-output "$($entry.jamsentry) $($entry.Name) $($entry.CurrentState) $($ResourceRequirement.ResourceName) $($ResourceRequirement.QuantityRequired) $($ResourceRequirement.ElementState)"
$out = New-Object psobject
$out | Add-Member noteproperty Entry-Entry $($entry.jamsentry)
$out | Add-Member noteproperty Entry-Name $($entry.Name)
$out | Add-Member noteproperty Entry-ResourceName $($ResourceRequirement.ResourceName)
$out | Add-Member noteproperty Entry-QuantityRequired $($ResourceRequirement.QuantityRequired)
$out | Add-Member noteproperty Entry-ElementState $($ResourceRequirement.ElementState)
$EntryReport += $out
}
}
$EntryReport | ft
write-output "`n*** Resources ***"
$resources = Get-Childitem -Path JD:\Resources
foreach ($resource in $resources) {
$out = New-Object psobject
$out | Add-Member noteproperty Resource-Name $($resource.Name)
$out | Add-Member noteproperty Resource-QuantityAvailable $($resource.QuantityAvailable)
$out | Add-Member noteproperty Resource-QuantityInUse $($resource.QuantityInUse)
$ResourceReport += $out
}
$ResourceReport | ft
Resource Allocation
JAMS will automatically control how each Job acquires and releases the Resources assigned to them. Before a Job runs, JAMS compares the available Resource pool with the quantity required by the Job. If the available Resources exceed the required amount by the Job, the Job will execute. When the Job is completed, the Resources are released and added back to the available Resource pool.
The Resource quantity available can be manually increased or decreased at any time. You can make the modifications in one place, the Resource Definition, and it is available to all Jobs that need it.
As your batch processes move from one operating system to another, JAMS continues to enforce the assigned Resources requirements.
Resource Behavior
Resources have some unique characteristics that are listed below:
- Jobs inherit the Resources that have been defined in their respective Folders.
- Jobs can reduce or increase the inherited Resource requirements.
- Jobs can add their own Resource requirements.
- Sufficient Resources must be available for a Job to run.
- Resources can be specific to an Agent or server.
- Resources can be used on any operating system that is supported by JAMS.
- The available Resource quantity can be increased or decreased at any time.
- Requirements for different Resources can be added to the same Folder or Job.
Resource Definitions View
The Resource Definitions screen lets you view all existing Resources, create new Resources, and modify existing Resources. Each Resource displays the following:
- Resource Name – The name to identify a Resource.
- Description – The description to provide more information about the Resource.
You can add additional columns by using the Column Chooser. Right-click a column heading, and select Column Chooser.
Adding a Resource Definition
You can create a Resource definition to use with your Jobs. When you create the Resource, you have full access to it. If you want others to be able to modify or create a Job with that resource requirement, ensure the Security settings are configured properly for that user. However, users do not need permissions on a Resource to create/update a Job in a Folder that inherits the Resource requirement from a parent Folder.
-
Click Resources from the Shortcuts menu.
-
Click +.
-
In the Name field, enter a name for the Resource.
-
In the QtyAvailable field, enter a quantity for the Resource.
-
Click Ok.
-
Click the Available tab.
-
To track the Resource separately for each Agent, do the following:
- Select the Agent Specific? checkbox.
- To give an Agent its own quantity, click in the field under Agent Name and select the Agent. Agents with no row use the Resource-level Quantity Available.
- In the Quantity Available field, enter the Resource quantity for the Agent.
-
Click the Security tab to select the access level for the Resource for any other users who will modify the Resource or reference the Resource in their Jobs.
-
Click Save and Close.
Inheriting a Resource Definition from a Folder
Jobs can inherit the Resources defined within their Folder. This inheritance feature simplifies the assignment of Resources to any Job. If you set a Resource on a Job, that setting will override the inheritance from the Folder.
Follow the steps described in the section: Adding a Resource to a Job or Folder.
Adding a Resource to a Job or Folder
- Click Definitions from the Shortcuts menu.
- Right-click a Job or Folder, and select Properties.
- Click the Schedule tab.
- Click +.
- Select This Job depends on a | Resource.
- In the Resource field, select the name of the Resource you want to add.
- In the Quantity Required field, select the number of Resources this Job or Folder requires to run. You can also enter a negative number to reduce the required Resources. This allows inherited Resource requirements to be overridden.
- Click Finish.
- Click Save and Close.
Modifying a Resource Definition
You can modify a Resource by changing its name, description, quantity available, and security settings. You can also add or remove Resource requirements from an Agent.
-
Click Resources from the Shortcuts menu.
-
Double-click a Resource to open its definitions window.
-
Click the Resource tab to change the name or description of the Resource.
-
Click the Available tab to do the following:
- Modify the Quantity Available for the Resource.
- Add, delete, or modify the Agent names that will have Resource requirements. See the section below for details.
-
Click the Security tab to select the access level for the Resource for any other users who will modify the Resource or reference the Resource in their Jobs.
-
Click Save and Close.
For a complete listing and description of each Resource property, refer to the Resource Properties topic.
Deleting a Resource Definition
Before deleting a Resource, ensure all Job and Folders that currently use it have been updated to remove references to it. To view where it is referenced, double-click the Resource and select the References tab.
- Click Resources from the Shortcuts menu.
- Click the Resource you want to delete.
- Right-click the Resource, and select Delete.
- Click Yes.
You must have the proper level of access to the Resource Definition to add or delete a Resource.
Resource Requirements for Agents
Adding a Resource requirement to an Agent is optional. When you add a Resource requirement to an Agent, that Agent gets its own quantity of the Resource, separate from every other Agent. This is useful when you want to restrict the number of Jobs that will run on one Agent as compared to another Agent. If an Agent has a lower load capacity than another Agent, enter a lower quantity on that Agent and a higher quantity on the Agent with a greater load capacity. JAMS will check the available Resources on the Agent before the Job runs.
When Agent Specific? is selected, the Resource-level Quantity Available is no longer an overall limit across Agents. It becomes the default quantity for each Agent that has no row under Agent Details, and each of those Agents gets that full quantity for itself. An Agent that has its own row uses that row's quantity instead, even when the Resource-level value is 0.
For example, a Resource has Quantity Available set to 2, Agent Specific? selected, and one Agent Details row giving AgentA a quantity of 5. Up to 5 Jobs can hold the Resource on AgentA, and up to 2 on every other Agent.
Adding a Resource Requirement to an Agent
- Click Resources from the Shortcuts menu.
- Double-click the Resource that you want to edit.
- Click the Available tab.
- Under Agent Details, ensure the Agent Specific? checkbox is selected.
- Under Agent Name, click the row to select an Agent.
- Under Quantity Available, enter the quantity of Resources that are available to that Agent.
- Click Save and Close.
Deleting a Resource Requirement from an Agent
- Click Resources from the Shortcuts menu.
- Double-click the Resource that you want to edit.
- Click the Available tab.
- Under Agent Name, click in the row to select an Agent to remove.
- Press the Delete key.
- Click OK.
- Click Save and Close.
Pausing Jobs with an Agent-Specific Resource
A common way to create a maintenance window is to set a Resource's Quantity Available to 0 so that no Job requiring it can start. When Agent Specific? is selected, this does not pause Jobs on an Agent that has its own non-zero quantity under Agent Details. New Jobs can still start on those Agents.
To pause every Job that uses the Resource, do one of the following:
- Clear Agent Specific? and set Quantity Available to 0. JAMS then tracks one quantity for the Resource across all Agents. Saving the Resource with Agent Specific? cleared deletes every row under Agent Details, so record each Agent's quantity first and add the rows again when the maintenance window ends.
- Set Quantity Available to 0 for every Agent listed under Agent Details, and set the Resource-level Quantity Available to 0. This keeps the Agent Details rows. Record each Agent's quantity first so you can restore it when the maintenance window ends.
Jobs that are already running when you change the quantity are not stopped. The change prevents new Jobs from acquiring the Resource.