1JobManager(3pm)       User Contributed Perl Documentation      JobManager(3pm)
2
3
4

NAME

6       Globus::GRAM::JobManager - Base class for all Job Manager scripts
7

SYNOPSIS

9        $manager = new Globus::GRAM::JobManager($job_description);
10
11        $manager->log("Starting new operation");
12        $manager->nfssync($fileobj,$createflag);
13        $manager->respond($hashref);
14        $hashref = $manager->submit();
15        $hashref = $manager->poll();
16        $hashref = $manager->cancel();
17        $hashref = $manager->signal();
18        $hashref = $manager->make_scratchdir();
19        $hashref = $manager->remove_scratchdir();
20        $hashref = $manager->rewrite_urls();
21        $hashref = $manager->stage_in();
22        $hashref = $manager->stage_out();
23        $hashref = $manager->cache_cleanup();
24        $hashref = $manager->remote_io_file_create();
25        $hashref = $manager->proxy_relocate();
26        $hashref = $manager->proxy_update();
27        $scalar  = $manager->pipe_out_cmd(@arglist);
28        ($stderr, $rc) = $manager->pipe_err_cmd(@arglist);
29        $status  = $manager->fork_and_exec_cmd(@arglist);
30        $manager->append_path($hash, $variable, $path);
31        $scalar = $manager->setup_softenv();
32

DESCRIPTION

34       The Globus::GRAM::JobManager module implements the base behavior for a
35       Job Manager script interface. Scheduler-specific job manager scripts
36       must inherit from this module in order to be used by the job manager.
37
38   Methods
39       $manager = Globus::GRAM::JobManager->new($JobDescription)
40           Each Globus::GRAM::JobManager object is created by calling the
41           constructor with a single argument, a Globus::GRAM::JobDescription
42           object containing the information about the job request which the
43           script will be modifying.  Modules which subclass
44           Globus::GRAM::JobManager MUST call the super-class's constructor,
45           as in this code fragment:
46
47                my $proto = shift;
48                my $class = ref($proto) || $proto;
49                my $self = $class->SUPER::new(@_);
50
51                bless $self, $class;
52
53       $manager->log($string)
54           Log a message to the job manager log file. The message is preceded
55           by a timestamp.
56
57       $manager->nfssync($object,$create)
58           Send an NFS update by touching the file (or directory) in question.
59           If the $create is true, a file will be created. If it is false, the
60           $object will not be created.
61
62       $manager->respond($message)
63           Send a response to the job manager program. The response may either
64           be a hash reference consisting of a hash of (variable, value)
65           pairs, which will be returned to the job manager, or an already
66           formatted string.  This only needs to be directly called by a job
67           manager implementation when the script wants to send a partial
68           response while processing one of the scheduler interface methods
69           (for example, to indicate that a file has been staged).
70
71           The valid keys for a response are defined in the RESPONSES section.
72
73       $manager->submit()
74           Submit a job request to the scheduler. The default implementation
75           returns with the Globus::GRAM::Error::UNIMPLEMENTED error.
76           Scheduler specific subclasses should reimplement this method to
77           submit the job to the scheduler.
78
79           A scheduler which implements this method should return a hash
80           reference containing a scheduler-specific job identifier as the
81           value of the hash's JOB_ID key, and optionally, the a GRAM job
82           state as the value of the hash's JOB_STATE key if the job
83           submission was successful; otherwise a Globus::GRAM::Error value
84           should be returned.  The job state values are defined in the
85           Globus::GRAM::JobState module. The job parameters (as found in the
86           job rsl) are defined in Globus::GRAM::Jobdescription object in
87           $self->{JobDescription}.
88
89           For example:
90
91               return {JOB_STATE => Globus::GRAM::JobState::PENDING,
92                       JOB_ID => $job_id};
93
94       $manager->poll()
95           Poll a job's status. The default implementation returns with the
96           Globus::GRAM::Error::UNIMPLEMENTED error. Scheduler specific
97           subclasses should reimplement this method to poll the scheduler.
98
99           A scheduler which implements this method should return a hash
100           reference containing the JOB_STATE value. The job's ID can be
101           accessed by calling the $self->{JobDescription}->jobid() method.
102
103       $manager->cancel()
104           Cancel a job. The default implementation returns with the
105           Globus::GRAM::Error::UNIMPLEMENTED error. Scheduler specific
106           subclasses should reimplement this method to remove the job from
107           the scheduler.
108
109           A scheduler which implements this method should return a hash
110           reference containing the JOB_STATE value. The job's ID can be
111           accessed by calling the $self->{JobDescription}->jobid() method.
112
113       $manager->signal()
114           Signal a job. The default implementation returns with the
115           Globus::GRAM::Error::UNIMPLEMENTED error. Scheduler specific
116           subclasses should reimplement this method to remove the job from
117           the scheduler. The JobManager module can determine the job's ID,
118           the signal number, and the (optional) signal arguments from the Job
119           Description by calling it's job_id(), signal(), and and
120           signal_arg() methods, respectively.
121
122           Depending on the signal, it may be appropriate for the JobManager
123           object to return a hash reference containing a JOB_STATE update.
124
125       $manager->make_scratchdir()
126           Create a scratch directory for a job. The scratch directory
127           location is based on the JobDescription's scratch_dir_base() and
128           scratch_dir() methods.
129
130           If the scratch_dir() value is a relative path, then a directory
131           will be created as a subdirectory of
132           scratch_dir_base()/scratch_dir(), otherwise, it will be created as
133           a subdirectory of scratch_dir().  This method will return a hash
134           reference containing mapping SCRATCH_DIR to the absolute path of
135           newly created scratch directory if successful.
136
137       $manager->make_scratchdir()
138           Delete a job's scratch directory. All files and subdirectories of
139           the JobDescription's scratch_directory() will be deleted.
140
141       $manager->make_scratchdir()
142           Delete some job-related files. All files listed in the
143           JobDescription's file_cleanup() array will be deleted.
144
145       $manager->rewrite_urls()
146           Looks up URLs listed in the JobDescription's stdin() and
147           executable(), and replaces them with paths to locally cached
148           copies.
149
150       $manager->stage_in()
151           Stage input files need for the job from remote storage. The files
152           to be staged are defined by the array of [URL, path] pairs in the
153           job description's file_stage_in() and file_stage_in_shared()
154           methods.  The Globus::GRAM::JobManager module provides an
155           implementation of this functionality using the globus-url-copy and
156           globus-gass-cache programs.  Files which are staged in are not
157           automatically removed when the job terminates.
158
159           This function returns intermediate responses using the
160           Globus::GRAM::JobManager::response() method to let the job manager
161           know when each individual file has been staged.
162
163       $manager->stage_out()
164           Stage output files generated by this job to remote storage. The
165           files to be staged are defined by the array of [URL, destination]
166           pairs in the job description's file_stage_out() method. The
167           Globus::GRAM::JobManager module provides an implementation of this
168           functionality using the globus-url-copy program.  Files which are
169           staged out are not removed by this method.
170
171       $manager->cache_cleanup()
172           Clean up cache references in the GASS which match this job's cache
173           tag .
174
175       $manager->remote_io_file_create()
176           Create the remote I/O file in the job dir which will contain the
177           remote_io_url RSL attribute's value.
178
179       $manager->proxy_relocate()
180           Relocate the delegated proxy for job execution. Job Managers need
181           to override the default if they intend to relocate the proxy into
182           some common file system other than the cache. The job manager
183           program does not depend on the new location of the proxy. Job
184           Manager modules must not remove the default proxy.
185
186       $hashref = $manager->proxy_update();
187       $manager->append_path($ref, $var, $path)
188           Append $path to the value of $ref->{$var}, dealing with the case
189           where $ref->{$var} is not yet defined.
190
191       $manager->pipe_out_cmd(@arg)
192           Create a new process to run the first argument application with the
193           remaining arguments (which may be empty). No shell metacharacter
194           will be evaluated, avoiding a shell invocation. Stderr is
195           redirected to /dev/null and stdout is being captured by the parent
196           process, which is also the result returned.  In list mode, all
197           lines are returned, in scalar mode, only the first line is being
198           returned. The line termination character is already cut off. Use
199           this function as more efficient backticks, if you do not need shell
200           metacharacter evaluation.
201
202           Caution: This function deviates in two manners from regular
203           backticks.  Firstly, it chomps the line terminator from the output.
204           Secondly, it returns only the first line in scalar context instead
205           of a multiline concatinated string. As with regular backticks, the
206           result may be undefined in scalar context, if no result exists.
207
208           A child error code with an exit code of 127 indicates that the
209           application could not be run. The scalar result returned by this
210           function is usually undef'ed in this case.
211
212       ($stder, $rc) = $manager->pipe_err_cmd(@arg)
213           Create a new process to run the first argument application with the
214           remaining arguments (which may be empty). No shell metacharacter
215           will be evaluated, avoiding a shell invocation.
216
217           This method returns a list of two items, the standard error of the
218           program, and the exit code of the program.  If the error code is
219           127, then the application could not be run.  Standard output is
220           discarded.
221
222       $manager->fork_and_exec_cmd(@arg)
223           Fork off a child to run the first argument in the list. Remaining
224           arguments will be passed, but shell interpolation is avoided.
225           Signals SIGINT and SIGQUIT are ignored in the child process. Stdout
226           is appended to /dev/null, and stderr is dup2 from stdout. The
227           parent waits for the child to finish, and returns the value for the
228           CHILD_ERROR variable as result. Use this function as more efficient
229           system() call, if you can do not need shell metacharacter
230           evaluation.
231
232           Note that the inability to execute the program will result in a
233           status code of 127.
234
235       $manager->job_dir()
236           Return the temporary directory to store job-related files, which
237           have no need for file caching.
238
239       $manager->setup_softenv()
240           Either add a line to the specified command script file handle to
241           load the user's default SoftEnv configuration, or create a custom
242           SoftEnv script and add commands to the specified command script
243           file handle to load it.
244

RESPONSES

246       When returning from a job interface method, or when sending an
247       intermediate response via the response() method, the following hash
248       keys are valid:
249
250       ·   JOB_STATE
251
252           An integer job state value. These are enumerated in the
253           Globus::GRAM::JobState module.
254
255       ·   ERROR
256
257           An integer error code. These are enumerated in the
258           Globus::GRAM::Error module.
259
260       ·   JOB_ID
261
262           A string containing a job identifier, which can be used to poll,
263           cancel, or signal a job in progress. This response should only be
264           returned by the submit method.
265
266       ·   SCRATCH_DIR
267
268           A string containing the path to a newly-created scratch directory.
269           This response should only be returned by the make_scratchdir
270           method.
271
272       ·   STAGED_IN
273
274           A string containing the (URL, path) pair for a file which has now
275           been staged in. This response should only be returned by the
276           stage_in method.
277
278       ·   STAGED_IN_SHARED
279
280           A string containing the (URL, path) pair for a file which has now
281           been staged in and symlinked from the cache. This response should
282           only be returned by the stage_in_shared method.
283
284       ·   STAGED_OUT
285
286           A string containing the (path, URL) pair for a file which has now
287           been staged out by the script. This response should only be
288           returned by the stage_out method.
289
290
291
292perl v5.16.3                      2020-12-12                   JobManager(3pm)
Impressum