In this section we will learn how to leverage the flexibility of the ClassAd mechanism to attach sophisticated requirements and preferences to jobs so that they find the "best possible machine" to run on.
In this examples section, we will express constraints that users generally desire to give a flavor of Condor's mechanisms. However, keep in mind that Condor's flexibility lies in the fact that ClassAds can contain arbitrary expressions: feel free to be creative and try out expressions of your own!
First, change into a directory where we will build and link a job for Condor that we will use in all the following examples:
% cd ~/examples/requirements/common
Now, lets compile the loop.C program and link it for Condor:
% condor_compile g++ loop.C -o loop.remote
Now we can look at some specific examples.
First, change into a directory with an example job:
% cd ~/examples/requirements/example1
We will now place some constraints on where the job will run. Users sometimes want their jobs to only run on specific machines that they choose. Assume that you want your job to run only on your neighbors' machines.
Load the submit command file example1.cmd into your favorite editor.
% emacs example1.cmdor
% pico example1.cmdor
% vi example1.cmd
You will see the following Requirements expression:
Requirements = Name=="infn-corsiLL.corsi.infn.it" || \ Name=="infn-corsiRR.corsi.infn.it"Edit the Requirements line and change infn-corsiLL and infn-corsiRR to the machine names of your left and right neighbors.
Now submit example1 by typing:
% condor_submit example1.cmd
You can view the ClassAd of the submitted job by typing
% condor_q -longFind out where your job is running by typing
% condor_status -runand viewing the entry where your username is listed as the RemoteUser of a machine.
First, change into a directory with an example job:
% cd ~/examples/requirements/example2
In this exercise, we will choose machines to run on not by their names, but by their attributes.
View the contents of the example2a submit command file.
% cat example2a.cmd
The requirements expression asks for any machine with more than 32Mb of physical memory and more than 100 Mb of virtual memory. Submit this example by typing:
% condor_submit example2a.cmd
You can find the machine your job runs on by typing:
% condor_status -runIf you find that your job is running on infn-corsiXX, type
% condor_status -long infn-corsiXXand view the ClassAd of infn-corsiXX to verify that it does indeed satisfy the job's constraints.
Similarly, example2b (in the same directory), asks for machines which have a certain MIPS (Million Instructions Per Second) and KFLOPS (Kilo Floating point Operations Per Second) rating. Feel free to edit the command file and edit the expression to include other criteria, and submit it by typing:
% condor_submit example2b.cmdIf you'd like to, use condor_status to find the machine your job is running on, and view the ClassAd of the machine.
First, change into a directory with an example job:
% cd ~/examples/requirements/example3The flexibility of the Rank mechanism allows submitters to specify arbitrary values over machines. For example, they can place weights on machine attributes as in example3. Lets look at the submit file:
% cat example3.cmd
Notice the Rank expression:
Rank = ( Memory>=32 ) * \ ( 10*Mips + 2*KFlops + 100*Memory + 8*VirtualMemory )The Rank expression states that all machines will less than 32 Mb of memory are weighted equally (at zero), and machines with 32 Mb or more memory are weighted according to their Mips, KFlops, Memory and VirtualMemory.
Submit this example by typing:
% condor_submit example3.cmdand find the machine which is running your job with:
% condor_status -run
That's it, we're done!