User`s guide
Program Independent Jobs for a Generic Scheduler
7-35
for ii = 1:props.NumberOfTasks
define scheduler command per task
end
submit job to scheduler
data_array = parse data returned from scheduler %possibly NumberOfTasks-by-2 matrix
setJobClusterData(cluster, job, data_array)
If your scheduler accepts only submissions of individual tasks, you might get return data
pertaining to only each individual tasks. In this case, your submit function might have
code structured like this:
for ii = 1:props.NumberOfTasks
submit task to scheduler
%Per-task settings:
data_array(1,ii) = ... parse string returned from scheduler
data_array(2,ii) = ... save ID returned from scheduler
etc
end
setJobClusterData(scheduler, job, data_array)
Define Scheduler Commands in User Functions
With the scheduler data (such as the scheduler’s ID for the job or task) now stored on
disk along with the rest of the job data, you can write code to control what the scheduler
should do when that particular job or task is canceled or destroyed.
For example, you might create these four functions:
• myCancelJob.m
• myDeleteJob.m
• myCancelTask.m
• myDeleteTask.m
Your myCancelJob.m function defines what you want to communicate to your scheduler
in the event that you use the cancel function on your job from the MATLAB client. The
toolbox takes care of the job state and any data management with the job data on disk,
so your myCancelJob.m function needs to deal only with the part of the job currently
running or queued with the scheduler. The toolbox function that retrieves scheduler
data from the job is getJobClusterData. Your cancel function might be structured
something like this:
function myCancelTask(sched, job)
array_data = getJobClusterData(clust, job)
job_id = array_data(...) % Extract the ID from the data, depending on how
% it was stored in the submit function above.