- Timestamp:
- 01/08/12 16:37:22 (13 years ago)
- Location:
- trunk/pbs_drmaa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pbs_drmaa/job.c
r50 r54 47 47 48 48 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 49 static void pbsdrmaa_job_control( fsd_job_t *self, int action ); 50 51 static void pbsdrmaa_job_update_status( fsd_job_t *self ); 52 53 static void pbsdrmaa_job_on_missing( fsd_job_t *self ); 54 55 static void pbsdrmaa_job_on_missing_standard( fsd_job_t *self ); 56 57 static void pbsdrmaa_job_update( fsd_job_t *self, struct batch_status* ); 58 59 static int pbsdrmaa_job_read_exit_status( const char *job_id, const char *job_state_dir_prefix); 64 60 65 61 fsd_job_t * … … 475 471 pbsdrmaa_session_t *pbssession = (pbsdrmaa_session_t*)self->session; 476 472 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) 478 474 fsd_log_info(("Job on missing but WT is running. Skipping...")); /* TODO: try to provide implementation that uses accounting/server log files */ 479 475 else … … 485 481 { 486 482 fsd_drmaa_session_t *session = self->session; 483 pbsdrmaa_session_t *pbssession = (pbsdrmaa_session_t *)session; 484 int exit_status = -1; 487 485 488 unsigned missing_mask = 0;489 490 486 fsd_log_enter(( "({job_id=%s})", self->job_id )); 491 487 fsd_log_warning(( "Job %s missing from DRM queue", self->job_id )); 492 488 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 ) 494 492 { 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_DONE503 && (self->state & ~missing_mask) )504 fsd_exc_raise_fmt(505 FSD_DRMAA_ERRNO_INVALID_JOB,506 "self %s missing from queue", self->job_id507 );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) == 0516 && session->missing_jobs == FSD_IGNORE_MISSING_JOBS )517 { /* assume everthing was ok */518 493 self->state = DRMAA_PS_DONE; 519 self->exit_status = 0;494 self->exit_status = exit_status; 520 495 } 521 496 else 522 { /* job aborted */497 { 523 498 self->state = DRMAA_PS_FAILED; 524 self->exit_status = -1;499 self->exit_status = exit_status; 525 500 } 526 501 527 502 fsd_cond_broadcast( &self->status_cond); 528 503 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 507 int 508 pbsdrmaa_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 42 42 }; 43 43 44 void45 pbsdrmaa_job_on_missing_standard( fsd_job_t *self );46 44 47 45 #endif /* __PBS_DRMAA__JOB_H */
Note: See TracChangeset
for help on using the changeset viewer.