macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Distributed Tiger: Xgrid Comes of Age
Pages: 1, 2, 3, 4, 5

Submitting Jobs and Querying Job Status

To use xgrid to run a job, you use the -job option.




drew pbook: xgrid -job run /bin/hostname
myhost.name.com

Supplying the -job option with run causes the command, in this case /bin/hostname, to be run synchronously. That is, the xgrid command will wait until the job is finished before returning control.

Running jobs synchronously is fine for short tests, but anything more substantial is better handled asynchronously. The submit command is passed with the -job option to run jobs asynchronously.


drew pbook: xgrid -job submit /bin/hostname
{jobIdentifier = 7; }

What you will notice about this is that the output of the hostname command does not appear. Instead, a property list is printed, with a job identifier. The idea is to use this identifier in future xgrid commands in order to query the state of your job, or retrieve its results.

To find out how a job is proceeding, you supply the attributes keyword with the -job option, like so:


drew pbook: xgrid -job attributes -id 7
{
    jobAttributes = {
        activeCPUPower = 0; 
        applicationIdentifier = "com.apple.xgrid.cli"; 
        dateNow = 2005-07-31 13:42:29 +0200; 
        dateStarted = 2005-07-31 13:37:53 +0200; 
        dateStopped = 2005-07-31 13:37:54 +0200; 
        dateSubmitted = 2005-07-31 13:37:50 +0200; 
        jobStatus = Finished; 
        name = "/bin/hostname"; 
        percentDone = 100; 
        taskCount = 1; 
        undoneTaskCount = 0; 
    }; 
}

The job identifier returned when we submitted the job is supplied with the -id option when querying job status. As you can see, many job attributes are printed, including how much CPU power is currently assigned to it (activeCPUPower), the percentage of the job that is currently complete (percentDone), and the job status (jobStatus).

The output of this command indicates that the job is Finished, so we can now retrieve the results:


drew pbook: xgrid -job results -id 7
myhost.name.com

The results keyword is passed with the -job option when retrieving job output, and the job identifier also needs to be supplied, of course.

There are many other options for the xgrid command-line tool. You can get a list of them by issuing xgrid -h, and more detail is available via the man page (man xgrid). Particularly worthy of note is that you can indicate a particular controller with the -h option, and that there are many commands that give you control over running jobs, enabling you to suspend or stop them, for example.

Submitting Multitask Jobs

The xgrid command in Tiger is more powerful than the one in Technology Preview 2. For a start, you can submit jobs that include multiple tasks. When you submit a job with multiple tasks, the controller splits it up, and distributes the tasks over the available agents. When all tasks are complete, the job is finished.

To stipulate many tasks in a single command could get messy, so Apple has introduced a new batch mode of operation. When you are using the batch mode, you don't enter options after the xgrid command, but instead provide a property list file containing details of the various tasks. You can read about the structure of this property list in the Xgrid man page (man xgrid), but there is actually an easier way to get started.

Ernest ("Ernie") Prabhakar, Xgrid Product Manager at Apple, recommends that you run a standard nonbatch job, and then retrieve its specifications, using those as the basis for future batch runs. Here is an example that Ernie provided on the Xgrid mailing list: first you run a standard asynchronous Xgrid job, in this case the cal command.


drew pbook: xgrid -job submit /usr/bin/cal 3 2005
{jobIdentifier = 8; }

You monitor the job's attributes until its status is Finished.


drew pbook: xgrid -job attributes -id 8       
{
    jobAttributes = {
        activeCPUPower = 0; 
        applicationIdentifier = "com.apple.xgrid.cli"; 
        dateNow = 2005-08-07 11:33:16 +0200; 
        dateStarted = 2005-08-07 11:31:22 +0200; 
        dateStopped = 2005-08-07 11:31:25 +0200; 
        dateSubmitted = 2005-08-07 11:31:21 +0200; 
        jobStatus = Finished; 
        name = "/usr/bin/cal"; 
        percentDone = 100; 
        taskCount = 1; 
        undoneTaskCount = 0; 
    }; 
}

Pages: 1, 2, 3, 4, 5

Next Pagearrow