source: trunk/slurm_drmaa/job.c @ 13

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

support for slurm 2.2

  • 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
178                                        case FAIL_QOS:             /* invalid QOS */
179                                        case WAIT_QOS_THRES:       /* required QOS threshold has been breached */
[1]180                                                self->state = DRMAA_PS_FAILED;
181                                                break;
182                                        default:
183                                                fsd_log_error(("job_state_reason = %d, assert(0)",job_info->job_array[0].state_reason));
184                                                fsd_assert(false);
185       
186                                }
187                                break;
188                        case JOB_RUNNING:
189                                self->state = DRMAA_PS_RUNNING;
190                                break;
191                        case JOB_SUSPENDED:
[7]192                                if(slurm_self->user_suspended == true)
193                                        self->state = DRMAA_PS_USER_SUSPENDED;
194                                else
195                                        self->state = DRMAA_PS_SYSTEM_SUSPENDED; /* assume SYSTEM - suspendig jobs is administrator only */
[1]196                                break;
197                        case JOB_COMPLETE:
198                                self->state = DRMAA_PS_DONE;
199                                break;
200                        case JOB_CANCELLED:
201                                self->exit_status = -1;
202                        case JOB_FAILED:
203                        case JOB_TIMEOUT:
204                        case JOB_NODE_FAIL:
205                                self->state = DRMAA_PS_FAILED;
206                                break;
207                        default: /*transient states */
208                                if(job_info->job_array[0].job_state >= 0x8000) {
209                                        fsd_log_debug(("state COMPLETING"));
210                                }
211                                else if (job_info->job_array[0].job_state >= 0x4000) {
212                                        fsd_log_debug(("state Allocated nodes booting"));
213                                }
214                                else {
215                                        fsd_log_error(("job_state = %d, assert(0)",job_info->job_array[0].job_state));
216                                        fsd_assert(false);
217                                }
218                }
219
220                if(self->exit_status == -1) /* input,output,error path failure etc*/
221                        self->state = DRMAA_PS_FAILED;
222
223                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)));
224
225                self->last_update_time = time(NULL);
226       
227                if( self->state >= DRMAA_PS_DONE )
228                        fsd_cond_broadcast( &self->status_cond );
229        }
230        FINALLY
231        {
232                if(job_info != NULL)
233                        slurm_free_job_info_msg (job_info);
234
235                fsd_mutex_unlock( &self->session->drm_connection_mutex );
236        }
237        END_TRY
238       
239        fsd_log_return(( "" ));
240}
241
242fsd_job_t *
243slurmdrmaa_job_new( char *job_id )
244{
245        slurmdrmaa_job_t *self = NULL;
246        self = (slurmdrmaa_job_t*)fsd_job_new( job_id );
247
248        fsd_realloc( self, 1, slurmdrmaa_job_t );
249
250        self->super.control = slurmdrmaa_job_control;
251        self->super.update_status = slurmdrmaa_job_update_status;
252        self->old_priority = UINT32_MAX;
[7]253        self->user_suspended = true;
[1]254        return (fsd_job_t*)self;
255}
256
257
258void
259slurmdrmaa_job_create_req(
260                fsd_drmaa_session_t *session,
261                const fsd_template_t *jt,
262                fsd_environ_t **envp,
263                job_desc_msg_t * job_desc,
264                int n_job /* ~job_step */
265                )
266{
267        fsd_expand_drmaa_ph_t *volatile expand = NULL;
268
269        TRY
270         {
271                expand = fsd_expand_drmaa_ph_new( NULL, NULL, fsd_asprintf("%d",n_job) );
272                slurmdrmaa_job_create( session, jt, envp, expand, job_desc, n_job);
273         }
274        EXCEPT_DEFAULT
275         {
276                fsd_exc_reraise();
277         }
278        FINALLY
279         {
280                if( expand )
281                        expand->destroy( expand );
282         }
283        END_TRY
284}
285
286static char *
287internal_map_file( fsd_expand_drmaa_ph_t *expand, const char *path,
288                bool *host_given, const char *name )
289{
290        const char *p;
291
292        for( p = path;  *p != ':';  p++ )
293                if( *p == '\0' )
294                        fsd_exc_raise_fmt( FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_FORMAT,
295                                                        "invalid format of drmaa_%s_path: missing colon", name );
296        if( host_given )
297                *host_given = ( p != path );
298
299        p++;
300
301        return expand->expand( expand, fsd_strdup(p), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD | FSD_DRMAA_PH_INCR );
302}
303
304void
305slurmdrmaa_job_create(
306                fsd_drmaa_session_t *session,
307                const fsd_template_t *jt,
308                fsd_environ_t **envp,
309                fsd_expand_drmaa_ph_t *expand,
310                job_desc_msg_t * job_desc,
311                int n_job
312                )
313{
314        const char *input_path_orig = NULL;
315        const char *output_path_orig = NULL;
316        const char *error_path_orig = NULL;
317        char *volatile input_path = NULL;
318        char *volatile output_path = NULL;
319        char *volatile error_path = NULL;
320        bool input_host = false;
321        bool output_host = false;
322        bool error_host = false;
323        bool join_files = false;
324        const char *value;
325        const char *const *vector;
326        const char *job_category = "default";
327       
328        slurmdrmaa_init_job_desc( job_desc );
329
330        slurm_init_job_desc_msg( job_desc );
331       
332        job_desc->user_id = getuid();
333        job_desc->group_id = getgid();
334
335        job_desc->env_size = 0;
336       
337        /* job name */
338        value = jt->get_attr( jt, DRMAA_JOB_NAME );
339        if( value )
340        {
341                job_desc->name = fsd_strdup(value);
342                fsd_log_debug(("# job_name = %s",job_desc->name));
343        }
344       
345        /* job state at submit */
346        value = jt->get_attr( jt, DRMAA_JS_STATE );
347        if( value )
348        {
349                if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
350                {}
351                else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
352                {
353                        job_desc->priority = 0;
354                        fsd_log_debug(("# hold = user"));
355                }
356                else
357                {
358                        fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE, "invalid value of drmaa_js_state attribute" );
359                }
360        }
361       
362        TRY
363        {
364                const char *command = NULL;
365                char *command_expanded = NULL;
366                char *temp_script_old = NULL;
367                char *temp_script = "";
368                const char *const *i;
369                int j;
370
371                /* remote command */
372                command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
373                if( command == NULL )
374                        fsd_exc_raise_msg(
375                                        FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
376                                        "drmaa_remote_command not set for job template"
377                                        );
378
379                command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
380
381                temp_script = fsd_asprintf("#!/bin/bash\n%s",command_expanded);
382                fsd_free(command_expanded);
383
384                /* arguments list */
385                vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
386
387                if( vector )
388                {
389                        for( i = vector, j = 2;  *i;  i++, j++ )
390                        {
391                                char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
392                               
393                                temp_script_old = fsd_strdup(temp_script);
394                               
395                                if (strcmp(temp_script, "") != 0) {
396                                        fsd_free(temp_script);
397                                }
398                                /* add too script */
399                                temp_script = fsd_asprintf("%s '%s'", temp_script_old, arg_expanded);
400                                fsd_free(temp_script_old);
401                                fsd_free(arg_expanded);
402                        }
403                }
404               
405                job_desc->script = fsd_asprintf("%s\n", temp_script);
406                fsd_log_debug(("# Script:\n%s", job_desc->script));
407                fsd_free(temp_script);
408        }
409        END_TRY
410       
411
412        /* start time */
413        value = jt->get_attr( jt, DRMAA_START_TIME );
414        if( value )
415        {
416                job_desc->begin_time = fsd_datetime_parse( value );
417                fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld", value, (long)job_desc->begin_time));
418        }
419
420        /* environment */
421        vector = jt->get_v_attr( jt, DRMAA_V_ENV );
422        if( vector )
423        {
424                const char *const *i;
425                unsigned j = 0;
426
427                for( i = vector;  *i;  i++ )
428                {
429                        job_desc->env_size++;
430                }
431                fsd_log_debug(("env_size = %d",job_desc->env_size));
432
433                fsd_log_debug(("# environment ="));
434                fsd_calloc(job_desc->environment, job_desc->env_size+1, char *);
435
436                for( i = vector;  *i;  i++,j++ )
437                {
438                        job_desc->environment[j] = fsd_strdup(*i);
439                        fsd_log_debug((" %s", job_desc->environment[j]));
440                }
441         }
442       
443        /* wall clock time hard limit */
444        value = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
445        if (value)
446        {
447                job_desc->time_limit = slurmdrmaa_datetime_parse( value );
448                fsd_log_debug(("# wct_hlimit = %s -> %ld",value,slurmdrmaa_datetime_parse( value )));
449        }
450
451               
452        /*expand->set(expand, FSD_DRMAA_PH_INCR,fsd_asprintf("%d", n_job));*/ /* set current value */
453        /* TODO: test drmaa_ph_incr */
454        /* job working directory */
455        value = jt->get_attr( jt, DRMAA_WD );
456        if( value )
457        {
458                char *cwd_expanded = expand->expand( expand, fsd_strdup(value), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_INCR );
459
460                expand->set( expand, FSD_DRMAA_PH_WD, fsd_strdup(cwd_expanded));
461
462                fsd_log_debug(("# work_dir = %s",cwd_expanded));
463                job_desc->work_dir = fsd_strdup(cwd_expanded);
464                fsd_free(cwd_expanded);
465        }
466        else
467        {
468                char cwdbuf[4096] = "";
469
470                if ((getcwd(cwdbuf, 4095)) == NULL) {
471                        char errbuf[256] = "InternalError";
472                        (void)strerror_r(errno, errbuf, 256); /*on error the default message would be returned */
473                        fsd_log_error(("getcwd failed: %s", errbuf));
474                        job_desc->work_dir = fsd_strdup(".");
475                } else {
476                        job_desc->work_dir = fsd_strdup(cwdbuf);
477                }
478
479                fsd_log_debug(("work_dir(default:CWD) %s", job_desc->work_dir));
480        }
481
482        TRY
483        {
484                /* input path */
485                input_path_orig = jt->get_attr( jt, DRMAA_INPUT_PATH );
486                if( input_path_orig )
487                {
488                        input_path = internal_map_file( expand, input_path_orig, &input_host,"input" );
489                        fsd_log_debug(( "\n  drmaa_input_path: %s -> %s", input_path_orig, input_path ));
490                }
491
492                /* output path */
493                output_path_orig = jt->get_attr( jt, DRMAA_OUTPUT_PATH );
494                if( output_path_orig )
495                {
496                        output_path = internal_map_file( expand, output_path_orig, &output_host,"output" );
497                        fsd_log_debug(( "\n  drmaa_output_path: %s -> %s", output_path_orig, output_path ));
498                }
499
500                /* error path */
501                error_path_orig = jt->get_attr( jt, DRMAA_ERROR_PATH );
502                if( error_path_orig )
503                {
504                        error_path = internal_map_file( expand, error_path_orig, &error_host,"error" );
505                        fsd_log_debug(( "\n  drmaa_error_path: %s -> %s", error_path_orig, error_path ));
506                }
507
508                /* join files */
509                value = jt->get_attr( jt, DRMAA_JOIN_FILES );
510                if( value )
511                {
512                        if( (value[0] == 'y' || value[0] == 'Y')  &&  value[1] == '\0' )
513                                join_files = true;
514                        else if( (value[0] == 'n' || value[0] == 'N')  &&  value[1] == '\0' )
515                                join_files = false;
516                        else
517                                fsd_exc_raise_msg(
518                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
519                                                "invalid value of drmaa_join_files attribute" );
520                }
521
522                if( join_files )
523                {
524                        if( output_path == NULL )
525                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES, "drmaa_join_files is set and output file is not given" );
526                        if( error_path!=NULL && 0 != strcmp( output_path, error_path ) )
527                                fsd_log_warning(( "Error file was given but will be ignored since drmaa_join_files was set." ));
528
529                        if (error_path)
530                                fsd_free(error_path);
531
532                         error_path = fsd_strdup(output_path);
533                }
534                else
535                {
536                        if( error_path == NULL  &&  output_path )
537                                error_path = fsd_strdup( "/dev/null" );
538                        if( output_path == NULL  &&  error_path )
539                                output_path = fsd_strdup( "/dev/null" );
540                }
541
542
543                /* email addresses to send notifications */
544                vector = jt->get_v_attr( jt, DRMAA_V_EMAIL );
545                if( vector  &&  vector[0] )
546                {
547                        /* only to one email address message may be send */
548                        job_desc->mail_user = fsd_strdup(vector[0]);
549                        fsd_log_debug(("# mail_user = %s\n",vector[0]));
550                        if( vector[1] != NULL )
551                        {
552                                fsd_log_error(( "LL only supports one e-mail notification address" ));
553                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"LL only supports one e-mail notification address");
554                        }
555                }
556
557                /* block email */
558                value = jt->get_attr( jt, DRMAA_BLOCK_EMAIL );
559                if( value )
560                {
561                        bool block;
562                        if( strcmp(value, "0") == 0 )
563                        {
564                                block = true;
565                                fsd_log_debug(("# block_email = true"));
566                                fsd_log_debug(("# mail_user delated"));
567                                fsd_free(job_desc->mail_user);
568                                job_desc->mail_user = NULL;
569                        }
570                        else if( strcmp(value, "1") == 0 )
571                                block = false;
572                        else
573                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"invalid value of drmaa_block_email attribute" );
574
575                        if( block && output_path == NULL )
576                        {
577                                fsd_log_debug(( "output path not set and we want to block e-mail, set to /dev/null" ));
578                                output_path = fsd_strdup( "/dev/null" );
579                        }
580                }
581
582                if( input_path )
583                {
584                        job_desc->std_in = fsd_strdup(input_path);
585                        fsd_log_debug(("# input = %s", input_path));
586                }
587
588                if( output_path )
589                {
590                        job_desc->std_out = fsd_strdup(output_path);
591                        fsd_log_debug(("# output = %s", output_path));
592                }
593
594                if( error_path )
595                {
596                        job_desc->std_err = fsd_strdup(error_path);
597                        fsd_log_debug(("# error = %s", error_path));
598                }
599         }
600        FINALLY
601        {
602                fsd_free( input_path );
603                fsd_free( output_path );
604                fsd_free( error_path );
605                input_path = NULL;
606                output_path = NULL;
607                error_path = NULL;
608        }
609        END_TRY                 
610       
611        /* native specification */
612        value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
613        if( value )
614        {
615                fsd_log_debug(("# Native specification: %s\n", value));
616                slurmdrmaa_parse_native(job_desc, value);
617        }
618               
619        /* job category */
620        value = jt->get_attr( jt, DRMAA_JOB_CATEGORY );
621        if( value )
622                job_category = value;
623
624        {
625                fsd_conf_option_t *category_value = NULL;
626                category_value = fsd_conf_dict_get( session->job_categories, job_category );
627
628                if( category_value != NULL )
629                {
630                        if( category_value->type != FSD_CONF_STRING )
631                                fsd_exc_raise_fmt(
632                                                FSD_ERRNO_INTERNAL_ERROR,
633                                                "configuration error: job category should be string"
634                                                );
635
636                        fsd_log_debug(("# Job category %s : %s\n",value,category_value->val.string));                   
637                        slurmdrmaa_parse_native(job_desc,category_value->val.string);                   
638                }
639                else
640                {
641                        if( value != NULL )
642                                fsd_exc_raise_fmt(
643                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
644                                                "invalid job category: %s", job_category
645                                                );
646                }
647        }
648       
649}               
650               
651
Note: See TracBrowser for help on using the repository browser.