source: trunk/slurm_drmaa/job.c @ 14

Revision 14, 18.6 KB checked in by mmatloka, 14 years ago (diff)

support for slurm 2.2 - fix

  • Property svn:executable set to *
  • Property svn:keywords set to Id
RevLine 
[5]1/* $Id$ */
[1]2/*
3 * PSNC DRMAA for SLURM
[13]4 * Copyright (C) 2011 Poznan Supercomputing and Networking Center
[1]5 *
6 *  This program is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19#include <string.h>
20#include <stdlib.h>
21#include <unistd.h>
22#include <signal.h>
23
24#include <drmaa_utils/common.h>
25#include <drmaa_utils/conf.h>
26#include <drmaa_utils/datetime.h>
27#include <drmaa_utils/drmaa.h>
28#include <drmaa_utils/drmaa_util.h>
29#include <drmaa_utils/environ.h>
30#include <drmaa_utils/template.h>
31
32#include <slurm_drmaa/job.h>
33#include <slurm_drmaa/session.h>
34#include <slurm_drmaa/util.h>
35
36#include <slurm/slurm.h>
37#include <stdint.h>
38
39static void
40slurmdrmaa_job_control( fsd_job_t *self, int action )
41{
42        slurmdrmaa_job_t *slurm_self = (slurmdrmaa_job_t*)self;
43        job_desc_msg_t job_desc;
44
45        fsd_log_enter(( "({job_id=%s}, action=%d)", self->job_id, action ));
46
47        fsd_mutex_lock( &self->session->drm_connection_mutex );
48        TRY
49         {
50                switch( action )
51                 {
52                        case DRMAA_CONTROL_SUSPEND:
53                                if(slurm_suspend(fsd_atoi(self->job_id)) == -1) {
54                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_suspend error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
55                                }
[7]56                                slurm_self->user_suspended = true;
[1]57                                break;
58                        case DRMAA_CONTROL_HOLD:
59                                /* change priority to 0*/
60                                slurm_init_job_desc_msg(&job_desc);
61                                slurm_self->old_priority = job_desc.priority;
62                                job_desc.job_id = atoi(self->job_id);
63                                job_desc.priority = 0;
[13]64                                job_desc.alloc_sid = 0;
[1]65                                if(slurm_update_job(&job_desc) == -1) {
66                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_update_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
67                                }
68                                break;
69                        case DRMAA_CONTROL_RESUME:
70                                if(slurm_resume(fsd_atoi(self->job_id)) == -1) {
71                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_resume error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
72                                }
[7]73                                slurm_self->user_suspended = false;
[1]74                                break;
75                        case DRMAA_CONTROL_RELEASE:
76                          /* change priority back*/
77                                slurm_init_job_desc_msg(&job_desc);
78                                job_desc.priority = 1;
79                                job_desc.job_id = atoi(self->job_id);
80                                if(slurm_update_job(&job_desc) == -1) {
81                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_update_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
82                                }
83                                break;
84                        case DRMAA_CONTROL_TERMINATE:
85                                if(slurm_kill_job(fsd_atoi(self->job_id),SIGKILL,0) == -1) {
86                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_terminate_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
87                                }
88                                break;
89                        default:
90                                fsd_exc_raise_fmt(
91                                                FSD_ERRNO_INVALID_ARGUMENT,
92                                                "job::control: unknown action %d", action );
93                 }
94                                       
95                fsd_log_debug(("job::control: successful"));
96         }
97        FINALLY
98         {
99                fsd_mutex_unlock( &self->session->drm_connection_mutex );
100         }
101        END_TRY
102
103        fsd_log_return(( "" ));
104}
105
106
107static void
108slurmdrmaa_job_update_status( fsd_job_t *self )
109{
110        job_info_msg_t *job_info = NULL;
[7]111        slurmdrmaa_job_t * slurm_self = (slurmdrmaa_job_t *) self;
[1]112        fsd_log_enter(( "({job_id=%s})", self->job_id ));
113
114        fsd_mutex_lock( &self->session->drm_connection_mutex );
115        TRY
116        {
117                if ( slurm_load_job( &job_info, fsd_atoi(self->job_id), SHOW_ALL) ) {
118                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_load_jobs error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
119        }
120               
121                self->exit_status = job_info->job_array[0].exit_code;
122                fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
123
124                switch(job_info->job_array[0].job_state)
125                {
126                        case JOB_PENDING:
127                                switch(job_info->job_array[0].state_reason)
128                                {
[13]129                                        case WAIT_NO_REASON:   /* not set or job not pending */
130                                        case WAIT_PRIORITY:    /* higher priority jobs exist */
131                                        case WAIT_DEPENDENCY:  /* dependent job has not completed */
132                                        case WAIT_RESOURCES:   /* required resources not available */
133                                        case WAIT_PART_NODE_LIMIT:   /* request exceeds partition node limit */
134                                        case WAIT_PART_TIME_LIMIT:   /* request exceeds partition time limit */
135                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
[1]136                                        case WAIT_PART_STATE:
[13]137                                        #endif
138                                        #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
139                                        case WAIT_PART_DOWN:   /* requested partition is down */
140                                        case WAIT_PART_INACTIVE:  /* requested partition is inactive */
141                                        #endif
[1]142                                                self->state = DRMAA_PS_QUEUED_ACTIVE;
143                                                break;
[13]144                                        #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
145                                        case WAIT_HELD_USER:   /* job is held by user */
146                                        #endif
[1]147                                                self->state = DRMAA_PS_USER_ON_HOLD;
148                                                break;
[13]149                                        case WAIT_HELD:  /* job is held by administrator */
150                                                self->state = DRMAA_PS_SYSTEM_ON_HOLD;
151                                                break;
152                                        case WAIT_TIME:  /* job waiting for specific begin time */
153                                        case WAIT_LICENSES:  /* job is waiting for licenses */
154                                        case WAIT_ASSOC_JOB_LIMIT:  /* user/bank job limit reached */
155                                        case WAIT_ASSOC_RESOURCE_LIMIT:  /* user/bank resource limit reached */
156                                        case WAIT_ASSOC_TIME_LIMIT:  /* user/bank time limit reached */
157                                        case WAIT_RESERVATION:    /* reservation not available */
158                                        case WAIT_NODE_NOT_AVAIL:  /* required node is DOWN or DRAINED */
159                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
[1]160                                        case WAIT_TBD1:
[13]161                                        #endif                                 
[1]162                                        case WAIT_TBD2:
163                                                self->state = DRMAA_PS_QUEUED_ACTIVE;
164                                                break;
[13]165                                        case FAIL_DOWN_PARTITION:  /* partition for job is DOWN */
166                                        case FAIL_DOWN_NODE:       /* some node in the allocation failed */
167                                        case FAIL_BAD_CONSTRAINTS: /* constraints can not be satisfied */
168                                        case FAIL_SYSTEM:          /* slurm system failure */
169                                        case FAIL_LAUNCH:          /* unable to launch job */
170                                        case FAIL_EXIT_CODE:       /* exit code was non-zero */
171                                        case FAIL_TIMEOUT:         /* reached end of time limit */
172                                        case FAIL_INACTIVE_LIMIT:  /* reached slurm InactiveLimit */
173                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
[1]174                                        case FAIL_BANK_ACCOUNT:
[13]175                                        #else
176                                        case FAIL_ACCOUNT:         /* invalid account */
177                                        #endif
[14]178                                       
179                                        #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
[13]180                                        case FAIL_QOS:             /* invalid QOS */
181                                        case WAIT_QOS_THRES:       /* required QOS threshold has been breached */
[14]182                                        #endif
[1]183                                                self->state = DRMAA_PS_FAILED;
184                                                break;
185                                        default:
186                                                fsd_log_error(("job_state_reason = %d, assert(0)",job_info->job_array[0].state_reason));
187                                                fsd_assert(false);
188       
189                                }
190                                break;
191                        case JOB_RUNNING:
192                                self->state = DRMAA_PS_RUNNING;
193                                break;
194                        case JOB_SUSPENDED:
[7]195                                if(slurm_self->user_suspended == true)
196                                        self->state = DRMAA_PS_USER_SUSPENDED;
197                                else
198                                        self->state = DRMAA_PS_SYSTEM_SUSPENDED; /* assume SYSTEM - suspendig jobs is administrator only */
[1]199                                break;
200                        case JOB_COMPLETE:
201                                self->state = DRMAA_PS_DONE;
202                                break;
203                        case JOB_CANCELLED:
204                                self->exit_status = -1;
205                        case JOB_FAILED:
206                        case JOB_TIMEOUT:
207                        case JOB_NODE_FAIL:
208                                self->state = DRMAA_PS_FAILED;
209                                break;
210                        default: /*transient states */
211                                if(job_info->job_array[0].job_state >= 0x8000) {
212                                        fsd_log_debug(("state COMPLETING"));
213                                }
214                                else if (job_info->job_array[0].job_state >= 0x4000) {
215                                        fsd_log_debug(("state Allocated nodes booting"));
216                                }
217                                else {
218                                        fsd_log_error(("job_state = %d, assert(0)",job_info->job_array[0].job_state));
219                                        fsd_assert(false);
220                                }
221                }
222
223                if(self->exit_status == -1) /* input,output,error path failure etc*/
224                        self->state = DRMAA_PS_FAILED;
225
226                fsd_log_debug(("state: %d ,state_reason: %d-> %s", job_info->job_array[0].job_state, job_info->job_array[0].state_reason, drmaa_job_ps_to_str(self->state)));
227
228                self->last_update_time = time(NULL);
229       
230                if( self->state >= DRMAA_PS_DONE )
231                        fsd_cond_broadcast( &self->status_cond );
232        }
233        FINALLY
234        {
235                if(job_info != NULL)
236                        slurm_free_job_info_msg (job_info);
237
238                fsd_mutex_unlock( &self->session->drm_connection_mutex );
239        }
240        END_TRY
241       
242        fsd_log_return(( "" ));
243}
244
245fsd_job_t *
246slurmdrmaa_job_new( char *job_id )
247{
248        slurmdrmaa_job_t *self = NULL;
249        self = (slurmdrmaa_job_t*)fsd_job_new( job_id );
250
251        fsd_realloc( self, 1, slurmdrmaa_job_t );
252
253        self->super.control = slurmdrmaa_job_control;
254        self->super.update_status = slurmdrmaa_job_update_status;
255        self->old_priority = UINT32_MAX;
[7]256        self->user_suspended = true;
[1]257        return (fsd_job_t*)self;
258}
259
260
261void
262slurmdrmaa_job_create_req(
263                fsd_drmaa_session_t *session,
264                const fsd_template_t *jt,
265                fsd_environ_t **envp,
266                job_desc_msg_t * job_desc,
267                int n_job /* ~job_step */
268                )
269{
270        fsd_expand_drmaa_ph_t *volatile expand = NULL;
271
272        TRY
273         {
274                expand = fsd_expand_drmaa_ph_new( NULL, NULL, fsd_asprintf("%d",n_job) );
275                slurmdrmaa_job_create( session, jt, envp, expand, job_desc, n_job);
276         }
277        EXCEPT_DEFAULT
278         {
279                fsd_exc_reraise();
280         }
281        FINALLY
282         {
283                if( expand )
284                        expand->destroy( expand );
285         }
286        END_TRY
287}
288
289static char *
290internal_map_file( fsd_expand_drmaa_ph_t *expand, const char *path,
291                bool *host_given, const char *name )
292{
293        const char *p;
294
295        for( p = path;  *p != ':';  p++ )
296                if( *p == '\0' )
297                        fsd_exc_raise_fmt( FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_FORMAT,
298                                                        "invalid format of drmaa_%s_path: missing colon", name );
299        if( host_given )
300                *host_given = ( p != path );
301
302        p++;
303
304        return expand->expand( expand, fsd_strdup(p), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD | FSD_DRMAA_PH_INCR );
305}
306
307void
308slurmdrmaa_job_create(
309                fsd_drmaa_session_t *session,
310                const fsd_template_t *jt,
311                fsd_environ_t **envp,
312                fsd_expand_drmaa_ph_t *expand,
313                job_desc_msg_t * job_desc,
314                int n_job
315                )
316{
317        const char *input_path_orig = NULL;
318        const char *output_path_orig = NULL;
319        const char *error_path_orig = NULL;
320        char *volatile input_path = NULL;
321        char *volatile output_path = NULL;
322        char *volatile error_path = NULL;
323        bool input_host = false;
324        bool output_host = false;
325        bool error_host = false;
326        bool join_files = false;
327        const char *value;
328        const char *const *vector;
329        const char *job_category = "default";
330       
331        slurmdrmaa_init_job_desc( job_desc );
332
333        slurm_init_job_desc_msg( job_desc );
334       
335        job_desc->user_id = getuid();
336        job_desc->group_id = getgid();
337
338        job_desc->env_size = 0;
339       
340        /* job name */
341        value = jt->get_attr( jt, DRMAA_JOB_NAME );
342        if( value )
343        {
344                job_desc->name = fsd_strdup(value);
345                fsd_log_debug(("# job_name = %s",job_desc->name));
346        }
347       
348        /* job state at submit */
349        value = jt->get_attr( jt, DRMAA_JS_STATE );
350        if( value )
351        {
352                if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
353                {}
354                else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
355                {
356                        job_desc->priority = 0;
357                        fsd_log_debug(("# hold = user"));
358                }
359                else
360                {
361                        fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE, "invalid value of drmaa_js_state attribute" );
362                }
363        }
364       
365        TRY
366        {
367                const char *command = NULL;
368                char *command_expanded = NULL;
369                char *temp_script_old = NULL;
370                char *temp_script = "";
371                const char *const *i;
372                int j;
373
374                /* remote command */
375                command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
376                if( command == NULL )
377                        fsd_exc_raise_msg(
378                                        FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
379                                        "drmaa_remote_command not set for job template"
380                                        );
381
382                command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
383
384                temp_script = fsd_asprintf("#!/bin/bash\n%s",command_expanded);
385                fsd_free(command_expanded);
386
387                /* arguments list */
388                vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
389
390                if( vector )
391                {
392                        for( i = vector, j = 2;  *i;  i++, j++ )
393                        {
394                                char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
395                               
396                                temp_script_old = fsd_strdup(temp_script);
397                               
398                                if (strcmp(temp_script, "") != 0) {
399                                        fsd_free(temp_script);
400                                }
401                                /* add too script */
402                                temp_script = fsd_asprintf("%s '%s'", temp_script_old, arg_expanded);
403                                fsd_free(temp_script_old);
404                                fsd_free(arg_expanded);
405                        }
406                }
407               
408                job_desc->script = fsd_asprintf("%s\n", temp_script);
409                fsd_log_debug(("# Script:\n%s", job_desc->script));
410                fsd_free(temp_script);
411        }
412        END_TRY
413       
414
415        /* start time */
416        value = jt->get_attr( jt, DRMAA_START_TIME );
417        if( value )
418        {
419                job_desc->begin_time = fsd_datetime_parse( value );
420                fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld", value, (long)job_desc->begin_time));
421        }
422
423        /* environment */
424        vector = jt->get_v_attr( jt, DRMAA_V_ENV );
425        if( vector )
426        {
427                const char *const *i;
428                unsigned j = 0;
429
430                for( i = vector;  *i;  i++ )
431                {
432                        job_desc->env_size++;
433                }
434                fsd_log_debug(("env_size = %d",job_desc->env_size));
435
436                fsd_log_debug(("# environment ="));
437                fsd_calloc(job_desc->environment, job_desc->env_size+1, char *);
438
439                for( i = vector;  *i;  i++,j++ )
440                {
441                        job_desc->environment[j] = fsd_strdup(*i);
442                        fsd_log_debug((" %s", job_desc->environment[j]));
443                }
444         }
445       
446        /* wall clock time hard limit */
447        value = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
448        if (value)
449        {
450                job_desc->time_limit = slurmdrmaa_datetime_parse( value );
451                fsd_log_debug(("# wct_hlimit = %s -> %ld",value,slurmdrmaa_datetime_parse( value )));
452        }
453
454               
455        /*expand->set(expand, FSD_DRMAA_PH_INCR,fsd_asprintf("%d", n_job));*/ /* set current value */
456        /* TODO: test drmaa_ph_incr */
457        /* job working directory */
458        value = jt->get_attr( jt, DRMAA_WD );
459        if( value )
460        {
461                char *cwd_expanded = expand->expand( expand, fsd_strdup(value), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_INCR );
462
463                expand->set( expand, FSD_DRMAA_PH_WD, fsd_strdup(cwd_expanded));
464
465                fsd_log_debug(("# work_dir = %s",cwd_expanded));
466                job_desc->work_dir = fsd_strdup(cwd_expanded);
467                fsd_free(cwd_expanded);
468        }
469        else
470        {
471                char cwdbuf[4096] = "";
472
473                if ((getcwd(cwdbuf, 4095)) == NULL) {
474                        char errbuf[256] = "InternalError";
475                        (void)strerror_r(errno, errbuf, 256); /*on error the default message would be returned */
476                        fsd_log_error(("getcwd failed: %s", errbuf));
477                        job_desc->work_dir = fsd_strdup(".");
478                } else {
479                        job_desc->work_dir = fsd_strdup(cwdbuf);
480                }
481
482                fsd_log_debug(("work_dir(default:CWD) %s", job_desc->work_dir));
483        }
484
485        TRY
486        {
487                /* input path */
488                input_path_orig = jt->get_attr( jt, DRMAA_INPUT_PATH );
489                if( input_path_orig )
490                {
491                        input_path = internal_map_file( expand, input_path_orig, &input_host,"input" );
492                        fsd_log_debug(( "\n  drmaa_input_path: %s -> %s", input_path_orig, input_path ));
493                }
494
495                /* output path */
496                output_path_orig = jt->get_attr( jt, DRMAA_OUTPUT_PATH );
497                if( output_path_orig )
498                {
499                        output_path = internal_map_file( expand, output_path_orig, &output_host,"output" );
500                        fsd_log_debug(( "\n  drmaa_output_path: %s -> %s", output_path_orig, output_path ));
501                }
502
503                /* error path */
504                error_path_orig = jt->get_attr( jt, DRMAA_ERROR_PATH );
505                if( error_path_orig )
506                {
507                        error_path = internal_map_file( expand, error_path_orig, &error_host,"error" );
508                        fsd_log_debug(( "\n  drmaa_error_path: %s -> %s", error_path_orig, error_path ));
509                }
510
511                /* join files */
512                value = jt->get_attr( jt, DRMAA_JOIN_FILES );
513                if( value )
514                {
515                        if( (value[0] == 'y' || value[0] == 'Y')  &&  value[1] == '\0' )
516                                join_files = true;
517                        else if( (value[0] == 'n' || value[0] == 'N')  &&  value[1] == '\0' )
518                                join_files = false;
519                        else
520                                fsd_exc_raise_msg(
521                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
522                                                "invalid value of drmaa_join_files attribute" );
523                }
524
525                if( join_files )
526                {
527                        if( output_path == NULL )
528                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES, "drmaa_join_files is set and output file is not given" );
529                        if( error_path!=NULL && 0 != strcmp( output_path, error_path ) )
530                                fsd_log_warning(( "Error file was given but will be ignored since drmaa_join_files was set." ));
531
532                        if (error_path)
533                                fsd_free(error_path);
534
535                         error_path = fsd_strdup(output_path);
536                }
537                else
538                {
539                        if( error_path == NULL  &&  output_path )
540                                error_path = fsd_strdup( "/dev/null" );
541                        if( output_path == NULL  &&  error_path )
542                                output_path = fsd_strdup( "/dev/null" );
543                }
544
545
546                /* email addresses to send notifications */
547                vector = jt->get_v_attr( jt, DRMAA_V_EMAIL );
548                if( vector  &&  vector[0] )
549                {
550                        /* only to one email address message may be send */
551                        job_desc->mail_user = fsd_strdup(vector[0]);
552                        fsd_log_debug(("# mail_user = %s\n",vector[0]));
553                        if( vector[1] != NULL )
554                        {
555                                fsd_log_error(( "LL only supports one e-mail notification address" ));
556                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"LL only supports one e-mail notification address");
557                        }
558                }
559
560                /* block email */
561                value = jt->get_attr( jt, DRMAA_BLOCK_EMAIL );
562                if( value )
563                {
564                        bool block;
565                        if( strcmp(value, "0") == 0 )
566                        {
567                                block = true;
568                                fsd_log_debug(("# block_email = true"));
569                                fsd_log_debug(("# mail_user delated"));
570                                fsd_free(job_desc->mail_user);
571                                job_desc->mail_user = NULL;
572                        }
573                        else if( strcmp(value, "1") == 0 )
574                                block = false;
575                        else
576                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"invalid value of drmaa_block_email attribute" );
577
578                        if( block && output_path == NULL )
579                        {
580                                fsd_log_debug(( "output path not set and we want to block e-mail, set to /dev/null" ));
581                                output_path = fsd_strdup( "/dev/null" );
582                        }
583                }
584
585                if( input_path )
586                {
587                        job_desc->std_in = fsd_strdup(input_path);
588                        fsd_log_debug(("# input = %s", input_path));
589                }
590
591                if( output_path )
592                {
593                        job_desc->std_out = fsd_strdup(output_path);
594                        fsd_log_debug(("# output = %s", output_path));
595                }
596
597                if( error_path )
598                {
599                        job_desc->std_err = fsd_strdup(error_path);
600                        fsd_log_debug(("# error = %s", error_path));
601                }
602         }
603        FINALLY
604        {
605                fsd_free( input_path );
606                fsd_free( output_path );
607                fsd_free( error_path );
608                input_path = NULL;
609                output_path = NULL;
610                error_path = NULL;
611        }
612        END_TRY                 
613       
614        /* native specification */
615        value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
616        if( value )
617        {
618                fsd_log_debug(("# Native specification: %s\n", value));
619                slurmdrmaa_parse_native(job_desc, value);
620        }
621               
622        /* job category */
623        value = jt->get_attr( jt, DRMAA_JOB_CATEGORY );
624        if( value )
625                job_category = value;
626
627        {
628                fsd_conf_option_t *category_value = NULL;
629                category_value = fsd_conf_dict_get( session->job_categories, job_category );
630
631                if( category_value != NULL )
632                {
633                        if( category_value->type != FSD_CONF_STRING )
634                                fsd_exc_raise_fmt(
635                                                FSD_ERRNO_INTERNAL_ERROR,
636                                                "configuration error: job category should be string"
637                                                );
638
639                        fsd_log_debug(("# Job category %s : %s\n",value,category_value->val.string));                   
640                        slurmdrmaa_parse_native(job_desc,category_value->val.string);                   
641                }
642                else
643                {
644                        if( value != NULL )
645                                fsd_exc_raise_fmt(
646                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
647                                                "invalid job category: %s", job_category
648                                                );
649                }
650        }
651       
652}               
653               
654
Note: See TracBrowser for help on using the repository browser.