source: trunk/slurm_drmaa/job.c @ 23

Revision 23, 19.7 KB checked in by mmamonski, 13 years ago (diff)

Follow up newer version of SLURM

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