Some grid nodes may have limited resource, and can only run limited number of concurrent jobs.
Project1, project2, and project3 are used to demonstrate the case where server node only permits to run two concurrent jobs.
- Trigger project1
- Trigger project2 right after you triggered project1, without waiting for its finish.
- Trigger project3 right after you triggered project2, without waiting for its finish.
- Switch to build log of these three configurations. You will see that project1 and project2 are actually doing the job (printing the message do my job with acquired resource...), while project3 is waiting for the resource (printing the message Executing pre-execute script...).
- After project1 or project2 finishes (in about 1 minute), project3 will acquire the resource and do the job.
Switch to master step definition of these three projects:
- the pre-execute action is defined as:
node.getResource("resource1", new java.util.concurrent.Semaphore(2)).acquire();
This tells QuickBuild to get node resource named resource1, and create the resource as a Java semaphore object with two permits if it does not already exist. And then acquire the resource by calling its acquire method before executing the step.
- the post-execute action is defined as:
This tells QuickBuild to release the node resource named resource1 before finishing the step.