int getJobIdList (char *jobIdStr, int *numJobIds, LS_LONG_INT **jobIdList) { int jobId; LS_LONG_INT lsbJobId; LS_LONG_INT *temp, *jobIds; struct idxList *idxListP = NULL, *idx; int sizeOfJobIdArray = MAX_JOB_IDS; int i, j, errCode; *numJobIds = 0; if ((errCode = getJobIdIndexList (jobIdStr, &jobId, &idxListP)) != LSBE_NO_ERROR) { return(errCode); } if (jobId <= 0) return(LSBE_BAD_JOBID); if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { mbdDie(MASTER_MEM); } if (idxListP == NULL) { jobIds[0] = jobId; *numJobIds = 1; *jobIdList = jobIds; return(LSBE_NO_ERROR); } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j+= idx->step) { lsbJobId = LSB_JOBID(jobId, j); if (*numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc(jobIds, sizeOfJobIdArray * sizeof(LS_LONG_INT))) == NULL) { mbdDie(MASTER_MEM); } jobIds = temp; } for (i = 0; i < *numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == (*numJobIds)) { jobIds[(*numJobIds)++] = lsbJobId; } } } freeIdxList(idxListP); *jobIdList = jobIds; return (LSBE_NO_ERROR); }
int getOneJobId (char *string, LS_LONG_INT * outJobId, int options) { int jobId = 0; struct idxList *idxListP = NULL; if (getJobIdIndexList (string, &jobId, &idxListP, 0)) { return (-1); } if (jobId == 0) { fprintf (stderr, "%s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 1006, "Job Id = 0 is out of valid range"))); /* catgets 1006 */ freeIdxList (idxListP); return (-1); } if (idxListP == NULL) { *outJobId = jobId; return (0); } if ((idxListP->next != NULL) | (idxListP->start != idxListP->end) | (idxListP->step != 1)) { fprintf (stderr, "%s: %s.\n", string, (_i18n_msg_get (ls_catd, NL_SETN, 1007, "Illegal job array index. One element only"))); /* catgets 1007 */ freeIdxList (idxListP); return (-1); } *outJobId = LSB_JOBID (jobId, idxListP->start); freeIdxList (idxListP); return (0); }
static LS_LONG_INT lsfdrmaa_job_id_atoi( const char *job_id_str ) { int job_id; int job_array_idx; const char *s = job_id_str; char *end; job_id = strtol( s, &end, 10 ); if( s == end ) goto error; s = end; switch( *s ) { case '\0': job_array_idx = 0; break; case '[': s++; job_array_idx = strtol( s, &end, 10 ); if( s == end ) goto error; s = end; if( *s++ == ']' && *s++ == '\0' ) {} else goto error; break; default: goto error; } return LSB_JOBID( job_id, job_array_idx ); error: fsd_exc_raise_fmt( FSD_DRMAA_ERRNO_INVALID_JOB, "invalid LSF job id: %s", job_id_str ); }
/* handleNewJobArray() */ void handleNewJobArray(struct jData *jarray, struct idxList *idxList, int maxJLimit) { struct idxList *idxPtr; struct jData *jPtr; int numJobs = 0; int i; int userPending = 0; addJobIdHT(jarray); jarray->nodeType = JGRP_NODE_ARRAY; jarray->nextJob = NULL; if (mSchedStage != M_STAGE_REPLAY) { putOntoTree(jarray, JOB_NEW); } else { putOntoTree(jarray, JOB_REPLAY); } jarray->uPtr = getUserData(jarray->userName); if (jarray->shared->jobBill.options2 & SUB2_HOLD) { userPending = 1; } jPtr = jarray; for (idxPtr = idxList; idxPtr; idxPtr = idxPtr->next) { for (i = idxPtr->start; i <= idxPtr->end; i += idxPtr->step) { if (getJobData(LSB_JOBID((LS_LONG_INT)jarray->jobId, i))) continue; jPtr->nextJob = copyJData(jarray); numJobs++; jPtr = jPtr->nextJob; jPtr->nodeType = JGRP_NODE_JOB; jPtr->nextJob = NULL; jPtr->jobId = LSB_JOBID((LS_LONG_INT)jarray->jobId, i); addJobIdHT(jPtr); inPendJobList(jPtr, PJL, 0); if (userPending) { jPtr->newReason = PEND_USER_STOP; jPtr->jStatus = JOB_STAT_PSUSP; } } } ARRAY_DATA(jarray->jgrpNode)->maxJLimit = maxJLimit; if (mSchedStage != M_STAGE_REPLAY) log_newjob(jarray); if (mSchedStage != M_STAGE_REPLAY) { updQaccount(jarray, jarray->shared->jobBill.maxNumProcessors * numJobs, jarray->shared->jobBill.maxNumProcessors * numJobs, 0, 0, 0, 0); updUserData(jarray, jarray->shared->jobBill.maxNumProcessors * numJobs, jarray->shared->jobBill.maxNumProcessors * numJobs, 0, 0, 0, 0); } if (mSchedStage == M_STAGE_REPLAY) { if (maxUserPriority > 0) { if (jarray->shared->jobBill.userPriority < 0) { modifyJobPriority(jarray, maxUserPriority/2); for (jPtr = jarray->nextJob; jPtr; jPtr = jPtr->nextJob) { modifyJobPriority(jPtr, maxUserPriority/2); } } else { modifyJobPriority(jarray, jarray->shared->jobBill.userPriority); for (jPtr = jarray->nextJob; jPtr; jPtr = jPtr->nextJob) { modifyJobPriority(jPtr, jPtr->shared->jobBill.userPriority); } } } } ARRAY_DATA(jarray->jgrpNode)->counts[getIndexOfJStatus(jarray->nextJob->jStatus)] = numJobs; ARRAY_DATA(jarray->jgrpNode)->counts[JGRP_COUNT_NJOBS] = numJobs; updJgrpCountByOp(jarray->jgrpNode, 1); }
int getSpecJobIds (int argc, char **argv, LS_LONG_INT ** jobIds0, int *options) { int numJobIds = 0; static LS_LONG_INT *jobIds = NULL; int i; int j; LS_LONG_INT *temp; int jobId; LS_LONG_INT lsbJobId; int sizeOfJobIdArray = MAX_JOB_IDS; struct idxList *idxListP = NULL, *idx; static char fName[] = "getSpecJobIds"; if (jobIds) free (jobIds); if (argc < optind + 1) { *jobIds0 = NULL; return (0); } if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { perror ("calloc"); exit (-1); } for (; argc > optind; optind++) { if (getJobIdIndexList (argv[optind], &jobId, &idxListP, 0)) { exit (-1); } if (idxListP == NULL) { if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((jobIds = realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { fprintf (stderr, I18N_FUNC_FAIL, fName, "malloc"); exit (-1); } } if (jobId == 0) { if (options) *options = CUR_JOB; numJobIds = 0; break; } for (i = 0; i < numJobIds; i++) if (jobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds] = jobId; numJobIds++; } continue; } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j += idx->step) { lsbJobId = LSB_JOBID (jobId, j); if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { fprintf (stderr, I18N_FUNC_FAIL, fName, "malloc"); exit (-1); } jobIds = temp; } for (i = 0; i < numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds] = lsbJobId; numJobIds++; } } } freeIdxList (idxListP); } *jobIds0 = jobIds; return (numJobIds); }
int getJobIdList (char *jobIdStr, LS_LONG_INT ** jobIdList) { int numJobIds = 0; int jobId; LS_LONG_INT lsbJobId; LS_LONG_INT *temp, *jobIds; struct idxList *idxListP = NULL, *idx; int sizeOfJobIdArray = MAX_JOB_IDS; int i, j; if (getJobIdIndexList (jobIdStr, &jobId, &idxListP, 0)) { return (-1); } if (jobId <= 0) return (-1); if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { return (-1); } if (idxListP == NULL) { jobIds[0] = jobId; numJobIds = 1; *jobIdList = jobIds; return (numJobIds); } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j += idx->step) { lsbJobId = LSB_JOBID (jobId, j); if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { return (-1); } jobIds = temp; } for (i = 0; i < numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds++] = lsbJobId; } } } freeIdxList (idxListP); *jobIdList = jobIds; return (numJobIds); }