Changeset 54 for trunk


Ignore:
Timestamp:
01/08/12 16:37:22 (12 years ago)
Author:
mmamonski
Message:

Read exit status from file

Location:
trunk/pbs_drmaa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/pbs_drmaa/job.c

    r50 r54  
    4747 
    4848 
    49 static void 
    50 pbsdrmaa_job_control( fsd_job_t *self, int action ); 
    51  
    52 static void 
    53 pbsdrmaa_job_update_status( fsd_job_t *self ); 
    54  
    55 static void 
    56 pbsdrmaa_job_on_missing( fsd_job_t *self ); 
    57  
    58 void 
    59 pbsdrmaa_job_on_missing_standard( fsd_job_t *self ); 
    60  
    61 static void 
    62 pbsdrmaa_job_update( fsd_job_t *self, struct batch_status* ); 
    63  
     49static void pbsdrmaa_job_control( fsd_job_t *self, int action ); 
     50 
     51static void pbsdrmaa_job_update_status( fsd_job_t *self ); 
     52 
     53static void pbsdrmaa_job_on_missing( fsd_job_t *self ); 
     54 
     55static void pbsdrmaa_job_on_missing_standard( fsd_job_t *self ); 
     56 
     57static void pbsdrmaa_job_update( fsd_job_t *self, struct batch_status* ); 
     58 
     59static int pbsdrmaa_job_read_exit_status( const char *job_id, const char *job_state_dir_prefix); 
    6460 
    6561fsd_job_t * 
     
    475471        pbsdrmaa_session_t *pbssession = (pbsdrmaa_session_t*)self->session; 
    476472 
    477         if( pbssession->pbs_home != NULL && pbssession->super.wait_thread_started ) 
     473        if( pbssession->pbs_home != NULL && pbssession->super.wait_thread_started && self->submit_time) 
    478474                fsd_log_info(("Job on missing but WT is running. Skipping...")); /* TODO: try to provide implementation that uses accounting/server log files */ 
    479475        else 
     
    485481{ 
    486482        fsd_drmaa_session_t *session = self->session; 
     483        pbsdrmaa_session_t *pbssession = (pbsdrmaa_session_t *)session; 
     484        int exit_status = -1; 
    487485         
    488         unsigned missing_mask = 0; 
    489  
    490486        fsd_log_enter(( "({job_id=%s})", self->job_id )); 
    491487        fsd_log_warning(( "Job %s missing from DRM queue", self->job_id )); 
    492488 
    493         switch( session->missing_jobs ) 
     489        fsd_log_info(( "job_on_missing: last job_ps: %s (0x%02x)", drmaa_job_ps_to_str(self->state), self->state)); 
     490 
     491        if( (exit_status = pbsdrmaa_job_read_exit_status(self->job_id, pbssession->job_exit_status_file_prefix)) == 0 ) 
    494492        { 
    495                 case FSD_REVEAL_MISSING_JOBS:         missing_mask = 0;     break; 
    496                 case FSD_IGNORE_MISSING_JOBS:         missing_mask = 0x73;  break; 
    497                 case FSD_IGNORE_QUEUED_MISSING_JOBS:  missing_mask = 0x13;  break; 
    498         } 
    499         fsd_log_info(( "last job_ps: %s (0x%02x); mask: 0x%02x", 
    500                                 drmaa_job_ps_to_str(self->state), self->state, missing_mask )); 
    501  
    502         if( self->state < DRMAA_PS_DONE 
    503                         &&  (self->state & ~missing_mask) ) 
    504                 fsd_exc_raise_fmt( 
    505                                 FSD_DRMAA_ERRNO_INVALID_JOB, 
    506                                 "self %s missing from queue", self->job_id 
    507                                 ); 
    508  
    509         if( (self->flags & FSD_JOB_TERMINATED_MASK) == 0 ) 
    510         { 
    511                 self->flags &= FSD_JOB_TERMINATED_MASK; 
    512                 self->flags |= FSD_JOB_TERMINATED; 
    513         } 
    514  
    515         if( (self->flags & FSD_JOB_ABORTED) == 0 
    516                         &&  session->missing_jobs == FSD_IGNORE_MISSING_JOBS ) 
    517         { /* assume everthing was ok */ 
    518493                self->state = DRMAA_PS_DONE; 
    519                 self->exit_status = 0; 
     494                self->exit_status = exit_status; 
    520495        } 
    521496        else 
    522         { /* job aborted */ 
     497        { 
    523498                self->state = DRMAA_PS_FAILED; 
    524                 self->exit_status = -1; 
     499                self->exit_status = exit_status; 
    525500        } 
    526501 
    527502        fsd_cond_broadcast( &self->status_cond); 
    528503 
    529         fsd_log_return(( "; job_ps=%s, exit_status=%d", 
    530                                 drmaa_job_ps_to_str(self->state), self->exit_status )); 
    531 } 
    532  
     504        fsd_log_return(( "; job_ps=%s, exit_status=%d", drmaa_job_ps_to_str(self->state), self->exit_status )); 
     505} 
     506 
     507int 
     508pbsdrmaa_job_read_exit_status( const char *job_id, const char *job_state_dir_prefix) 
     509{ 
     510        char *status_file = NULL; 
     511        FILE *fhandle = NULL; 
     512        int exit_status = -1; 
     513 
     514        fsd_log_enter(("({job_id=%s, job_state_dir_prefix=%s})", job_id, job_state_dir_prefix)); 
     515 
     516        status_file = fsd_asprintf("%s/%s.exitcode", job_id, job_state_dir_prefix); 
     517 
     518        if ((fhandle = fopen(status_file, "r")) == NULL) 
     519         { 
     520                fsd_log_error(("Failed to open job status file: %s", status_file)); 
     521         } 
     522        else 
     523         { 
     524                (void)fscanf(fhandle, "%d", &exit_status); /*on error exit_status == -1 */ 
     525                fclose(fhandle); 
     526         } 
     527 
     528        fsd_free(status_file); 
     529 
     530        return exit_status; 
     531} 
     532 
  • trunk/pbs_drmaa/job.h

    r12 r54  
    4242}; 
    4343 
    44 void 
    45 pbsdrmaa_job_on_missing_standard( fsd_job_t *self ); 
    4644 
    4745#endif /* __PBS_DRMAA__JOB_H */ 
Note: See TracChangeset for help on using the changeset viewer.