Submitting Jobs to Xgrid

The final step is to submit the jobs you want to be executed on the distributed network of Xgrid agents.

Testing the job

The first step is to check that the job runs as a direct command from the Terminal. For example, suppose you have a command squares4 that takes two parameters, specifying the range of values you want to test. Then, assuming it's in your home directory, you could run this in the Terminal as follows:

./squares4 0 1

Submitting the job

The next step is to submit the job to Xgrid so it will be run on one of the Agents. To do this you give the command:

xgrid -job submit -h Phobos -p secretclient ./squares4 0 1

The parameters are as follows:

  • -job specifies the type of job.
  • -h specifies the host name of the Controller.
  • -p specifies the Client password defined on the Controller.

The command returns a job identifier, such as:

{
    jobIdentifier = 44;
}
You use this identifier to refer to the job in future commands to the Controller.

The job should new be listed in the Xgrid Admin window; see Xgrid Administration.

Collecting the results from the job

While the job is running, or when the job has finished, you can collect the results from the job with a command such as:

xgrid -job results -h Phobos -p secretclient -id 44

This returns the results you would have seen listed at the Terminal if you ran the job there.

Deleting the job

Finally you should delete the job to clear it from the Controller:

xgrid -job delete -h Phobos -p secretclient -id 44

Alternatively you can delete the job by selecting it in the Xgrid Admin window and pressing Delete.

Submitting a batch of jobs

You can take advantage of the Terminal's scripting to submit a batch of jobs in a single command.

Open TextEdit and, in necessary, choose Make Plain Text from the Format menu to make a plain text file.

Type in the sequence of xgrid commands you want to submit; for example:

xgrid -job submit -h Phobos -p secretclient ./squares4 0 1000
xgrid -job submit -h Phobos -p secretclient ./squares4 1000 2000
xgrid -job submit -h Phobos -p secretclient ./squares4 2000 3000
xgrid -job submit -h Phobos -p secretclient ./squares4 3000 4000
xgrid -job submit -h Phobos -p secretclient ./squares4 4000 5000

Here we are going to process 1000 successive samples in each job.

Save the text file as runsearcher.sh in the user's home directory.

Make the file executable by typing the following command at the Terminal:

chmod u+x runsquares4.sh

Now you can execute the script from the terminal by typing:

./runsquares4.sh

and this will submit the five specified jobs to the Controller.

Collecting a batch of results

In a similar way you can collect the output from a batch of jobs and write it to a text file for viewing. Assuming that the above five jobs were assigned ids 10 to 14, put the following commands into a text file called resultssquares4.sh:

Type in the sequence of xgrid commands you want to submit; for example:

xgrid -job results -h Phobos -p secretclient -id 10 >> outputsquares4.txt 
xgrid -job results -h Phobos -p secretclient -id 11 >> outputsquares4.txt
xgrid -job results -h Phobos -p secretclient -id 12 >> outputsquares4.txt
xgrid -job results -h Phobos -p secretclient -id 13 >> outputsquares4.txt
xgrid -job results -h Phobos -p secretclient -id 14 >> outputsquares4.txt

The Unix command >> outputsquares4.txt appends the output of the command to the specified text file. Now you can collect all the results by typing:

./resultssquares4.sh

blog comments powered by Disqus