//================================================================================================= void DAllocTracer::reportLeaks() { if(m_NbAllocs <= 1) DPrint("%i allocation performed.", m_NbAllocs); else DPrint("%i allocations performed.", m_NbAllocs); if(m_AllocMap.size()) { u32 size = 0; for(std::map<void*, DS_Allocation>::iterator it = m_AllocMap.begin(); it != m_AllocMap.end(); it++) { DWarning("%s(%i): Memory leak of %i bytes found.", it->second.pFile, it->second.line, it->second.size); size += it->second.size; free(it->first); } if(m_AllocMap.size() == 1) DWarning("%i block of memory has not been freed (%i bytes).", m_AllocMap.size(), size); else DWarning("%i blocks of memory have not been freed (%i bytes).", m_AllocMap.size(), size); } else DPrint("No memory leak found."); }
/* * HvB: Get all GroupNames that have a Fairshare target set */ int MGroupGetFSGroups() { int gindex; int fsindex = 0; mgcred_t *G; const char *FName = "MGroupGetFSGroups"; DBG(5,fFS) DPrint("%s\n", FName); for (gindex = 0; gindex < MAX_MGROUP + MAX_MHBUF; gindex++) { G = &MGroup[gindex]; if ((G == NULL) || (G->Name[0] == '\0') || (G->Name[0] == '\1')) continue; if (!strcmp(G->Name,ALL) || !strcmp(G->Name,"NOGROUP")) continue; if ( G->F.FSTarget > 0 ) { DBG(5,fFS) DPrint("Found FSGroup %s(%f) with key %d \n", G->Name, G->F.FSTarget, G->Key); FSGroupKeys[fsindex++] = G->Key; } } } /* MGroupGetFSGroups */
int MCPStoreSRList( mckpt_t *CP, /* I (utilized) */ sres_t *SRL) /* I */ { int srindex; sres_t *SR; const char *FName = "MCPStoreSRList"; DBG(3,fCKPT) DPrint("%s(CP,SRL)\n", FName); if ((CP == NULL) || (SRL == NULL)) return(FAILURE); for (srindex = 0;srindex < MAX_MSRES;srindex++) { SR = &SRes[srindex]; if ((SR->TaskCount == 0) && (SR->HostExpression[0] == '\0')) { DBG(9,fCKPT) DPrint("INFO: skipping empty SR[%02d]\n", srindex); continue; } DBG(4,fCKPT) DPrint("INFO: checkpointing SR '%s'\n", SR->Name); /* MSRToString(SR,tmpLine); MCPStoreObj(CP->fp,mcpSRes,SR->Name,tmpLine); */ /* checkpoint statistics and override values */ /* FORMAT: TYPE NAME TIME IDTME TOTME TCT ACCT STAR END */ fprintf(CP->fp,"%-9s %20s %9ld %6.2f %6.2f %3d %14s %9ld %9ld\n", MCPType[mcpSRes], SR->Name, MSched.Time, SR->IdleTime, SR->TotalTime, OSRes[srindex].TaskCount, (OSRes[srindex].A != NULL) ? OSRes[srindex].A->Name : NONE, OSRes[srindex].StartTime, OSRes[srindex].EndTime); } /* END for (srindex) */ fflush(CP->fp); return(FAILURE); } /* END MCPStoreSResList() */
/* HvB */ int MGroupSecondary( char *UName, /* I */ mjob_t *J) /* O */ { int i; int gindex; struct group *sec_grp; const char *FName = "MGroupSecondary"; DBG(5,fFS) DPrint("%s(%s)\n", FName, (UName != NULL) ? UName : "NULL"); /* MGroupGetFSGroups(); */ i=0; while ( FSGroupKeys[i] != -1 ) { DBG(5,fFS) DPrint("Checking if user(%s) is member of group(%s)\n", UName, MGroup[FSGroupKeys[i]].Name); if ( (sec_grp = getgrnam(MGroup[FSGroupKeys[i]].Name)) != NULL ) { gindex=0; while ( sec_grp->gr_mem[gindex] ) { if ( !strcmp(sec_grp->gr_mem[gindex], UName) ) { DBG(5,fFS) DPrint("Setting Group credentials for user %s to %s\n", UName, sec_grp->gr_name); if ( MGroupAdd(sec_grp->gr_name, &J->Cred.G) == FAILURE ) { DBG(1,fPBS) DPrint("ERROR: cannot add secondary group for job %s (Name: %s)\n", J->Name, sec_grp->gr_name); return(FAILURE); } else { return(SUCCESS); } } /* if !strcmp */ else { gindex++; } } /* while sec_grp */ } /* if sec_grp */ i++; } /* while FSGroupKeys[i] */ return(SUCCESS); } /* MGroupSecondary */
int MAcctLoadCP( mgcred_t *AS, char *Buf) { char tmpHeader[MAX_MNAME]; char AName[MAX_MNAME]; char *ptr; mgcred_t *A; long CkTime; mxml_t *E = NULL; const char *FName = "MAcctLoadCP"; DBG(4, fCKPT) DPrint("%s(AS,%s)\n", FName, (Buf != NULL) ? Buf : "NULL"); if (Buf == NULL) return (FAILURE); /* FORMAT: <HEADER> <GID> <CKTIME> <GSTRING> */ /* load CP header */ sscanf(Buf, "%s %s %ld", tmpHeader, AName, &CkTime); if (((long)MSched.Time - CkTime) > MCP.CPExpirationTime) return (SUCCESS); if (AS == NULL) { if (MAcctAdd(AName, &A) != SUCCESS) { DBG(5, fCKPT) DPrint("ALERT: cannot load CP account '%s'\n", AName); return (FAILURE); } } else { A = AS; } if ((ptr = strchr(Buf, '<')) == NULL) { return (FAILURE); } MXMLFromString(&E, ptr, NULL, NULL); MOFromXML((void *)A, mxoAcct, E); MXMLDestroyE(&E); return (SUCCESS); } /* END MAcctLoadCP() */
int UIShowGrid( char *RBuffer, /* I */ char *Buffer, /* O */ int FLAGS, /* I */ char *Auth, /* I */ long *BufSize) /* I */ { int sindex; char GStat[MAX_MNAME]; const char *FName = "UIShowGrid"; DBG(3,fUI) DPrint("%s(RBuffer,Buffer,%d,%s,BufSize)\n", FName, FLAGS, Auth); MUSScanF(RBuffer,"%x%s", sizeof(GStat), GStat); /* determine statistics type requested */ for (sindex = 0;MStatType[sindex] != 0;sindex++) { if (!strcasecmp(MStatType[sindex],GStat)) break; } /* END for (sindex) */ if (MStatType[sindex] == NULL) { DBG(2,fUI) DPrint("INFO: invalid stat type '%s' requested\n", GStat); sprintf(Buffer,"ERROR: invalid statistics type requested\n"); strcat(Buffer,"\nvalid statistics types:\n"); for (sindex = 0;MStatType[sindex] != 0;sindex++) { strcat(Buffer,MStatType[sindex]); strcat(Buffer,"\n"); } /* END for (sindex) */ return(FAILURE); } /* END if (MStatType[sindex] == NULL) */ MStatBuildGrid(sindex,Buffer,0); return(SUCCESS); } /* END UIShowGrid() */
void IdStorage::Release(uint16_t id) { auto storageIdx = (id - ref) / 8; if (storageIdx < storageSize) { byte bitpos = ((id - ref) % 8); storage[storageIdx] -= (1 << (bitpos)); } #if defined DEBUG && defined DEBUG_ASSERT else { DPrint("Invalid storageIdx:"); DPrint(storageIdx); DPrint(" >= "); DPrintln(storageSize); } #endif }
// // Register container type // bool XFileSystem::RegisterContainer ( XFSContainer *pContainer ) { m_pContainers[ m_nNumContainers++ ] = pContainer; DPrint( "XFileSystem::RegisterContainer : ext:\"" ); DPrint( pContainer->m_pContainerExt ); DPrint( "\", desc:\"" ); DPrint( pContainer->m_pDescription ); DPrint( "\" ...ok\n" ); return true; }
int MCfgGetDVal( char *Buf, char **CurPtr, const char *Parm, char *IndexName, int *Index, double *Value, char **SymTable) { char ValLine[MAX_MLINE]; char *ptr; int rc; const char *FName = "MCfgGetDVal"; DBG(7,fCONFIG) DPrint("%s(Buf,CurPtr,%s,%s,Index,Value,SymTable)\n", FName, Parm, (IndexName != NULL) ? IndexName : "NULL"); if ((Buf == NULL) || (Value == NULL)) return(FAILURE); ptr = Buf; if (CurPtr != NULL) ptr = MAX(ptr,*CurPtr); rc = MCfgGetVal(&ptr,Parm,IndexName,Index,ValLine,sizeof(ValLine),SymTable); if (CurPtr != NULL) *CurPtr = ptr; if (rc == FAILURE) return(FAILURE); *Value = strtod(ValLine,NULL); DBG(4,fCONFIG) DPrint("INFO: %s[%d] set to %lf\n", Parm, (Index != NULL) ? *Index : 0, *Value); return(SUCCESS); } /* END MCfgGetDVal() */
int MTraceGetResourceVersion( char *Buffer, /* I */ int *Version) /* O */ { char *ptr; char Line[MAX_MLINE]; int tmpI; const char *FName = "MTraceGetResourceVersion"; DBG(3,fSIM) DPrint("%s(Buffer,Version)\n", FName); if ((Buffer == NULL) || (Version == NULL)) { return(FAILURE); } if ((ptr = strstr(Buffer,TRACE_RESOURCE_VERSION_MARKER)) == NULL) { DBG(1,fSIM) DPrint("ALERT: cannot locate trace version marker\n"); *Version = -1; return(FAILURE); } ptr += (strlen(TRACE_RESOURCE_VERSION_MARKER) + 1); sscanf(ptr,"%64s", Line); tmpI = (int)strtol(Line,NULL,0); if (tmpI < 100) { *Version = -1; return(FAILURE); } *Version = tmpI; return(SUCCESS); } /* END MTraceGetResourceVersion() */
int MLocalCheckFairnessPolicy( mjob_t *J, long StartTime, char *Message) { const char *FName = "MLocalCheckFairnessPolicy"; DBG(6, fSCHED) DPrint("%s(%s,%ld,Message)\n", FName, (J != NULL) ? J->Name : "NULL", (unsigned long)StartTime); /* if (ContribJobLengthFairnessPolicy(J,StartTime,Message) == FAILURE) { return(FAILURE); } */ /* if (ContribASCBackgroundJobPolicy(J,StartTime,Message) == FAILURE) { return(FAILURE); } */ /* all local policies passed */ return (SUCCESS); } /* END MLocalFairnessPolicy() */
int MLocalQueueScheduleIJobs( int *Q, mpar_t *P) { mjob_t *J; int jindex; if ((Q == NULL) || (P == NULL)) { return (FAILURE); } /* NOTE: insert call to scheduling algorithm here */ for (jindex = 0; Q[jindex] != -1; jindex++) { J = MJob[Q[jindex]]; /* NYI */ DBG(7, fSCHED) DPrint("INFO: checking job '%s'\n", J->Name); } /* END for (jindex) */ return (FAILURE); } /* END MLocalQueueScheduleIJobs() */
int MCPLoadSys( mckpt_t *CP, /* I */ char *Line, /* I */ msched_t *S) /* I (modified) */ { char TempName[MAX_MNAME]; char tmpLine[MAX_MLINE]; long CkTime; char *ptr; const char *FName = "MCPLoadSys"; DBG(4,fCKPT) DPrint("%s(CP,Line,S)\n", FName); /* FORMAT: TY TM Name DATA */ sscanf(Line,"%s %ld %s", TempName, &CkTime, tmpLine); if ((ptr = strchr(Line,'<')) == NULL) { return(FAILURE); } MOFromString((void *)S,mxoSys,ptr); return(SUCCESS); } /* END MCPLoadSys() */
int MCPLoadSched( mckpt_t *CP, char *Line, msched_t *S) { char TempName[MAX_MNAME]; char tmpLine[MAX_MLINE]; long CkTime; char *ptr; const char *FName = "MCPLoadSched"; DBG(4,fCKPT) DPrint("%s(CP,Line,S)\n", FName); /* FORMAT: TY TM Name DATA */ sscanf(Line,"%s %ld %s", TempName, &CkTime, tmpLine); if ((ptr = strchr(Line,'<')) == NULL) { return(FAILURE); } MSchedFromString(S,ptr); return(SUCCESS); } /* END MCPLoadSched() */
int ContribAussieCheckReq( job_t *J, node_t *N, long StartTime) { int rindex; long Overlap; res_t *R; DBG(4,fCONFIG) DPrint("ContribAussieCheckReq(%s,%s)\n", J->Name, N->Name); for (rindex = 0;rindex < MAX_RESERVATION;rindex++) { R = N->R[rindex]; if (R == (res_t *)MAX_RES_DEPTH) continue; if (R == NULL) break; Overlap = MIN(R->EndTime,StartTime + J->SpecWCLimit[0]) - MAX(R->StartTime,StartTime); if (Overlap <= 0) { /* reservations do not overlap */ continue; } if (R->J == NULL) { /* reservation is not a job reservation */ continue; } if (((job_t *)R->J)->Cred.U != J->Cred.U) { /* users do not match */ continue; } /* overlapping job reservation for same user found */ return(FAILURE); } /* END for (rindex) */ return(SUCCESS); } /* END ContribAussieCheckReq() */
// // Looking for file containers // void XFileSystem::ScaningCntFiles ( ) { DPrint( "XFileSystem::ScaningCntFiles : start process\n" ); int i; int handle; int ret = 0; struct _finddata_t fileinfo; const char *pExt; handle = _findfirst( "*.*", &fileinfo ); if ( handle == -1 ) ret = -1; while ( ret == 0 ) { if ( !( fileinfo.attrib & _A_SUBDIR ) ) { FixFileName( fileinfo.name ); pExt = GetFileExtention( fileinfo.name ); // find container type for ( i = 0; i < m_nNumContainers; i++ ) if ( m_pContainers[ i ]->IsContainerExt( pExt ) ) { m_CntFiles[ m_nNumCntFiles ].m_nContainerID = i; strcpy( m_CntFiles[ m_nNumCntFiles ].m_pFileName, fileinfo.name ); m_pContainers[ i ]->Initialize( &m_CntFiles[ m_nNumCntFiles ] ); m_nNumCntFiles++; DPrint( ".found \"" ); DPrint( fileinfo.name ); DPrint( "\"\n" ); break; } } ret = _findnext( handle, &fileinfo ); if ( ret != 0 ) { _findclose( handle ); } } }
int MGroupFind( char *GName, /* I */ mgcred_t **GP) /* O */ { int gindex; unsigned long hashkey; mgcred_t *Gtmp; const char *FName = "MGroupFind"; DBG(7,fSTRUCT) DPrint("%s(%s,G)\n", FName, GName); if (GP != NULL) *GP = NULL; if ((GName == NULL) || (GName[0] == '\0')) { return(FAILURE); } hashkey = MAX(1,MUGetHash(GName) % MAX_MGROUP); for (gindex = hashkey; gindex < MAX_MGROUP + MAX_MHBUF; gindex++) { Gtmp = &MGroup[gindex]; if (Gtmp->Name[0] == '\0') { if (GP != NULL) *GP = Gtmp; break; } if ((hashkey != Gtmp->Key) || (strcmp(Gtmp->Name,GName))) { continue; } /* group found */ if (GP != NULL) *GP = Gtmp; return(SUCCESS); } /* END for (gindex) */ return(FAILURE); } /* END MGroupFind() */
int ShowJobHold( char *RBuffer, /* I */ char *Buffer, /* O */ int FLAGS, /* I */ char *Auth, /* I */ long *BufSize) /* I */ { char Line[MAX_MLINE]; mjob_t *J; const char *FName = "ShowJobHold"; DBG(2,fUI) DPrint("%s(RBuffer,Buffer,%d,%s,BufSize)\n", FName, FLAGS, Auth); sprintf(Buffer,"%ld\n", MSched.Time); for (J = MJob[0]->Next;(J != NULL) && (J != MJob[0]);J = J->Next) { if (J->Hold != 0) { DBG(2,fUI) DPrint("INFO: job '%s' added to hold list\n", J->Name); sprintf(Line,"%s %d\n", J->Name, J->Hold); strcat(Buffer,Line); } } /* END for (index) */ DBG(2,fUI) DPrint("INFO: ShowJobHold() buffer size: %d bytes\n", (int)strlen(Buffer)); return(SUCCESS); } /* END ShowJobHold() */
int MCPStoreQueue( mckpt_t *CP, /* I */ mjob_t **JL) /* I */ { mjob_t *J; char tmpLine[MAX_MLINE]; const char *FName = "MCPStoreQueue"; DBG(3,fCKPT) DPrint("%s(ckfp,Buffer)\n", FName); if ((JL == NULL) || (JL[0] == NULL) || (JL[0]->Next == NULL)) { return(SUCCESS); } for (J = JL[0]->Next;J != JL[0];J = J->Next) { if (J->Name[0] == '\0') continue; DBG(4,fCKPT) DPrint("INFO: checkpointing job '%s'\n", J->Name); /* create job XML */ MJobStoreCP(J,tmpLine); fprintf(CP->fp,"%-9s %20s %9ld %s\n", MCPType[mcpJob], J->Name, MSched.Time, tmpLine); } /* END for (jindex) */ return(SUCCESS); } /* END MCPStoreQueue() */
int MCPStoreAcctList( mckpt_t *CP, mgcred_t *AL) { int aindex; mgcred_t *A; char tmpLine[MAX_MLINE]; const char *FName = "MCPStoreAcctList"; DBG(3,fCKPT) DPrint("%s(CP,AL)\n", FName); /* store active account info */ for (aindex = 0;aindex < MAX_MACCT + MAX_MHBUF;aindex++) { A = &AL[aindex]; if (A->Name[0] == '\0') continue; if (A->Name[0] == '\1') continue; DBG(4,fCKPT) DPrint("INFO: checkpointing account '%s'\n", A->Name); MAcctToString(A,tmpLine); MCPStoreObj(CP->fp,mcpAcct,A->Name,tmpLine); } /* END for (aindex) */ return(SUCCESS); } /* END MCPStoreAcctList() */
int MCPStoreUserList( mckpt_t *CP, /* I */ mgcred_t **UL) /* I */ { int uindex; mgcred_t *U; char tmpLine[MAX_MLINE]; const char *FName = "MCPStoreUserList"; DBG(3,fCKPT) DPrint("%s(CP,UL)\n", FName); /* store active user info */ for (uindex = 0;uindex < MAX_MUSER + MAX_MHBUF;uindex++) { U = UL[uindex]; if ((U == NULL) || (U->Name[0] == '\0')) continue; if (U->Name[0] == '\1') continue; DBG(4,fCKPT) DPrint("INFO: checkpointing user '%s'\n", U->Name); MUserToString(U,tmpLine); MCPStoreObj(CP->fp,mcpUser,U->Name,tmpLine); } /* END for (uindex) */ return(SUCCESS); } /* END MCPStoreUserList() */
int MCPStoreGroupList( mckpt_t *CP, mgcred_t *GL) { int gindex; mgcred_t *G; char tmpLine[MAX_MLINE]; const char *FName = "MCPStoreGroupList"; DBG(3,fCKPT) DPrint("%s(CP,GL)\n", FName); /* store active group info */ for (gindex = 0;gindex < MAX_MGROUP + MAX_MHBUF;gindex++) { G = &GL[gindex]; if (G->Name[0] == '\0') continue; if (G->Name[0] == '\1') continue; DBG(4,fCKPT) DPrint("INFO: checkpointing group '%s'\n", G->Name); MGroupToString(G,tmpLine); MCPStoreObj(CP->fp,mcpGroup,G->Name,tmpLine); } /* END for (gindex) */ return(SUCCESS); } /* END MCPStoreGroupList() */
IdStorage& IdStorage::operator=(const IdStorage& other) { Cleanup(); if (other.storageSize > 0) { storage = (byte *)malloc(other.storageSize); if (storage == NULL) { #if defined DEBUG && defined DEBUG_ASSERT DPrint(F("* IdStorage alloc of ")); DPrint(other.storageSize); DPrintln(F(" out of memory")); #endif } else { storageSize = other.storageSize; memcpy(storage, other.storage, storageSize); } } ref = other.ref; return *this; }
int MCPWriteSystemStats( FILE *ckfp) { must_t *T; const char *FName = "MCPWriteSystemStats"; DBG(3,fCKPT) DPrint("%s(ckfp)\n", FName); /* must restore all statistics required to maintain stats */ T = &MPar[0].S; /* LABL TIME PHAVAIL PHBUSY ITM CT SJ MSA MSD NJA JAC MXF MB MQT TXF TB TQT PSR PSD PSU JE SPH WEF WIT */ fprintf(ckfp,"%-9s %9ld %10.3lf %10.3lf %ld %d %d %lf %lf %lf %lf %lf %d %ld %lf %d %ld %lf %lf %lf %d %lf %lf %d\n", MCPType[mcpSysStats], MSched.Time, MStat.TotalPHAvailable, MStat.TotalPHBusy, MStat.InitTime, T->Count, MStat.SuccessfulJobsCompleted, T->MSAvail, T->MSDedicated, T->NJobAcc, T->JobAcc, T->MaxXFactor, T->MaxBypass, T->MaxQTS, T->PSXFactor, T->Bypass, T->TotalQTS, T->PSRun, T->PSDedicated, T->PSUtilized, MStat.JobsEvaluated, MStat.SuccessfulPH, MStat.MinEff, MStat.MinEffIteration); fflush(ckfp); return(SUCCESS); } /* END MCPWriteSystemStats() */
int MAcctFind( char *AccountName, mgcred_t **A) { /* If found, return success with A pointing to Account. */ /* If not found, return failure with A pointing to */ /* first free Account if available, A set to NULL otherwise */ int aindex; int Key; char AName[MAX_MNAME]; DBG(5, fSTRUCT) DPrint("MAcctFind(%s,A)\n", (AccountName == NULL) ? "NULL" : AccountName); if (A != NULL) *A = NULL; if ((AccountName == NULL) || (AccountName[0] == '\0')) strcpy(AName, NONE); else MUStrCpy(AName, AccountName, sizeof(AName)); Key = (int)(MUGetHash(AName) % MAX_MACCT); for (aindex = Key; aindex < MAX_MACCT + MAX_MHBUF; aindex++) { if (MAcct[aindex].Name[0] == '\0') { if (A != NULL) *A = &MAcct[aindex]; break; } if (strcmp(MAcct[aindex].Name, AName) != 0) continue; /* Account found */ if (A != NULL) *A = &MAcct[aindex]; return (SUCCESS); } /* END for (aindex) */ return (FAILURE); } /* END MAcctFind() */
int MClassFind( char *CName, /* I */ mclass_t **C) /* O (optional) */ { int cindex; const char *FName = "MClassFind"; DBG(5,fSTRUCT) DPrint("%s(%s,C)\n", FName, (CName != NULL) ? CName : "NULL"); if (C != NULL) *C = NULL; if ((CName == NULL) || (CName[0] == '\0') || (C == NULL)) { return(FAILURE); } for (cindex = 1;MClass[cindex].Name[0] != '\0';cindex++) { if (!strcmp(MClass[cindex].Name,CName)) { *C = &MClass[cindex]; return(SUCCESS); } if (MClass[cindex].Name[0] == '\0') { *C = &MClass[cindex]; break; } } /* END for (cindex) */ return(FAILURE); } /* END MClassFind() */
int MLocalJobCheckNRes( mjob_t *J, /* I */ mnode_t *N, /* I */ long StartTime) /* I */ { const char *FName = "MLocalJobCheckNRes"; int rc = SUCCESS; DBG(8, fSCHED) DPrint("%s(%s,%s,%ld)\n", FName, J->Name, N->Name, StartTime); /* rc = ContribAussieJobCheckNRes(J,N,StartTime); */ return (rc); } /* END MLocalJobCheckNRes */
/* install the signal handlers, returns 0 on success, -1 on error */ int install_sigs() { /* added by jku: add exit handler */ if (set_sig_h(SIGINT, sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGINT signal handler can be installed\n"); goto error; } /* if we debug and write to a pipe, we want to exit nicely too */ if (set_sig_h(SIGPIPE, sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGINT signal handler can be installed\n"); goto error; } if (set_sig_h(SIGUSR1, sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGUSR1 signal handler can be installed\n"); goto error; } if (set_sig_h(SIGCHLD , sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGCHLD signal handler can be installed\n"); goto error; } if (set_sig_h(SIGTERM , sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGTERM signal handler can be installed\n"); goto error; } if (set_sig_h(SIGHUP , sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGHUP signal handler can be installed\n"); goto error; } if (set_sig_h(SIGUSR2 , sig_usr) == SIG_ERR ) { DPrint("ERROR: no SIGUSR2 signal handler can be installed\n"); goto error; } return 0; error: return -1; }
int MTraceLoadWorkload( char *Buffer, /* I */ int *TraceLen, /* I (optional,modified) */ mjob_t *J, /* O */ int Mode, /* I */ int *Version) /* O */ { char *tail; char *head; char *ptr; char *ptr2; char *tok; char *TokPtr; char Line[MAX_MLINE << 4]; char tmpLine[MAX_MLINE]; char MHostName[MAX_MNAME]; char MReqHList[MAX_MLINE << 2]; char Reservation[MAX_MNAME]; char tmpTaskRequest[MAX_MLINE]; char tmpSpecWCLimit[MAX_MLINE]; char tmpState[MAX_WORD]; char tmpOpsys[MAX_WORD]; char tmpArch[MAX_WORD]; char tmpNetwork[MAX_WORD]; char tmpMemCmp[MAX_WORD]; char tmpDiskCmp[MAX_WORD]; char tmpReqNFList[MAX_MLINE]; char tmpClass[MAX_MLINE]; char tmpRMName[MAX_MLINE]; char tmpCmd[MAX_MLINE]; char tmpRMXString[MAX_MLINE >> 2]; char tmpParName[MAX_MNAME]; char tmpJFlags[MAX_MLINE]; char tmpQReq[MAX_WORD]; char tmpASString[MAX_MLINE]; char tmpRMemBuf[MAX_MNAME]; char tmpRDiskBuf[MAX_MNAME]; char tmpDSwapBuf[MAX_MNAME]; char tmpDMemBuf[MAX_MNAME]; char tmpDDiskBuf[MAX_MNAME]; char UName[MAX_MNAME]; char GName[MAX_MNAME]; char AName[MAX_MNAME]; char SetString[MAX_MLINE]; unsigned long tmpQTime; unsigned long tmpDTime; unsigned long tmpSTime; unsigned long tmpCTime; unsigned long tmpSQTime; unsigned long tmpSDate; unsigned long tmpEDate; int TPN; int TasksAllocated; int index; int rc; int tindex; int nindex; mqos_t *QDef; mreq_t *RQ[MAX_MREQ_PER_JOB]; mnode_t *N; long ReqProcSpeed; const char *FName = "MTraceLoadWorkload"; DBG(5,fSIM) DPrint("%s(Buffer,TraceLen,J,%d,%d)\n", FName, Mode, (Version != NULL) ? *Version : -1); if (J == NULL) { DBG(5,fSIM) DPrint("ALERT: NULL job pointer passed in %s()\n", FName); return(FAILURE); } if (Buffer == NULL) { return(FAILURE); } if ((tail = strchr(Buffer,'\n')) == NULL) { /* assume line is '\0' terminated */ if (TraceLen != NULL) tail = Buffer + *TraceLen; else tail = Buffer + strlen(Buffer); } head = Buffer; MUStrCpy(Line,head,MIN(tail - head + 1,sizeof(Line))); DBG(6,fSIM) DPrint("INFO: parsing trace line '%s'\n", Line); if (TraceLen != NULL) *TraceLen = (tail - head) + 1; /* eliminate comments */ if ((ptr = strchr(Line,'#')) != NULL) { DBG(5,fSIM) DPrint("INFO: detected trace comment line, '%s'\n", Line); *ptr = '\0'; } if (Line[0] == '\0') { return(FAILURE); } /* look for VERSION settings */ if (!strncmp(Line,TRACE_WORKLOAD_VERSION_MARKER,strlen(TRACE_WORKLOAD_VERSION_MARKER))) { if (MTraceGetWorkloadVersion(Line,Version) == FAILURE) { DBG(0,fSIM) DPrint("ALERT: cannot determine workload trace version\n"); /* assume default version */ if (Version != NULL) *Version = DEFAULT_WORKLOAD_TRACE_VERSION; } else { DBG(3,fSIM) DPrint("INFO: workload trace version %d detected\n", (Version != NULL) ? *Version : -1); } return(FAILURE); } /* END if (!strncmp(Line,TRACE_WORKLOAD_VERSION_MARKER)) */ /* set default workload attributes */ memset(J,0,sizeof(mjob_t)); if (MReqCreate(J,NULL,&J->Req[0],FALSE) == FAILURE) { DBG(0,fSIM) DPrint("ALERT: cannot create job req\n"); return(FAILURE); } MRMJobPreLoad(J,NULL,0); RQ[0] = J->Req[0]; RQ[0]->Index = 0; J->StartCount = 0; J->R = NULL; switch(*Version) { case 230: /* Name NR TReq User Grop WClk Stat Clss QUT DST STT CMT netw Arch Opsy MemC RMem DskC RDsk Feat SQT TA TPN QO MO AC CM CC BP PU Part DPrc DMem DDisk DSwap STARTDATE ENDDATE MNODE RM HL RES RES1 RES2 RES3 OVERFLOW */ rc = sscanf(Line,"%64s %d %64s %64s %64s %64s %64s %64s %lu %lu %lu %lu %64s %64s %64s %64s %64s %64s %64s %64s %lu %d %d %64s %1024s %64s %1024s %1024s %d %lf %64s %d %64s %64s %64s %lu %lu %1024s %64s %1024s %64s %64s %1024s %s %s", J->Name, &J->Request.NC, tmpTaskRequest, UName, GName, tmpSpecWCLimit, tmpState, tmpClass, &tmpQTime, &tmpDTime, &tmpSTime, &tmpCTime, tmpNetwork, tmpArch, tmpOpsys, tmpMemCmp, tmpRMemBuf, tmpDiskCmp, tmpRDiskBuf, tmpReqNFList, &tmpSQTime, /* SystemQueueTime */ &TasksAllocated, /* allocated task count */ &TPN, tmpQReq, tmpJFlags, AName, tmpCmd, tmpRMXString, /* RM extension string */ &J->Bypass, /* Bypass */ &J->PSUtilized, /* PSUtilized */ tmpParName, /* partition used */ &RQ[0]->DRes.Procs, tmpDMemBuf, tmpDDiskBuf, tmpDSwapBuf, &tmpSDate, &tmpEDate, MHostName, tmpRMName, MReqHList, Reservation, SetString, /* resource sets required by job */ tmpASString, /* application simulator name */ tmpLine, /* RES1 */ tmpLine /* check for too many fields */ ); /* fail if all fields not read in */ switch (rc) { case 43: strcpy(MHostName,NONE); J->RM = &MRM[0]; break; case 44: /* canonical 230 trace */ if (isdigit(tmpRMName[0])) J->RM = &MRM[(int)strtol(tmpRMName,NULL,0)]; else J->RM = &MRM[0]; break; default: DBG(1,fSIM) DPrint("ALERT: version %d workload trace is corrupt '%s' (%d of %d fields read) ignoring line\n", *Version, Line, rc, 44); MJobDestroy(&J); return(FAILURE); /*NOTREACHED*/ break; } /* END switch(rc) */ RQ[0]->RequiredMemory = MURSpecToL(tmpRMemBuf,mvmMega,mvmMega); RQ[0]->RequiredDisk = MURSpecToL(tmpRDiskBuf,mvmMega,mvmMega); RQ[0]->DRes.Mem = MURSpecToL(tmpDMemBuf,mvmMega,mvmMega); RQ[0]->DRes.Swap = MURSpecToL(tmpDSwapBuf,mvmMega,mvmMega); RQ[0]->DRes.Disk = MURSpecToL(tmpDDiskBuf,mvmMega,mvmMega); if (Mode != msmProfile) { ptr = NULL; ptr2 = NULL; if (strcmp(tmpASString,NONE)) { if ((ptr = MUStrTok(tmpASString,":",&TokPtr)) != NULL) { ptr2 = MUStrTok(NULL,"|",&TokPtr); } } if (MASGetDriver((void **)&J->ASFunc,ptr,msdApplication) == SUCCESS) { (*J->ASFunc)(J,mascCreate,ptr2,NULL); } } /* END if (Mode != msmProfile) */ /* obtain job step number from LL based job name */ /* FORMAT: <FROM_HOST>.<CLUSTER>.<PROC> */ MUStrCpy(tmpLine,J->Name,sizeof(tmpLine)); if ((ptr = MUStrTok(tmpLine,".",&TokPtr)) != NULL) { MUStrCpy(J->SubmitHost,ptr,sizeof(J->SubmitHost)); if ((ptr = MUStrTok(NULL,".",&TokPtr)) != NULL) { J->Cluster = (int)strtol(ptr,NULL,0); if ((ptr = MUStrTok(NULL,".",&TokPtr)) != NULL) { J->Proc = (int)strtol(ptr,NULL,0); } } } /* adjust job flags */ if (Mode == msmProfile) { MUStrDup(&J->MasterHostName,MHostName); /* NOTE: flags may be specified as string or number */ if ((J->SpecFlags = strtol(tmpJFlags,NULL,0)) == 0) { MUBMFromString(tmpJFlags,MJobFlags,&J->SpecFlags); } } else { /* simulation mode */ if ((MSim.Flags & (1 << msimfIgnMode)) || (MSim.Flags & (1 << msimfIgnAll))) { J->SpecFlags = 0; } else { /* NOTE: flags may be specified as string or number */ if ((J->SpecFlags = strtol(tmpJFlags,NULL,0)) == 0) { MUBMFromString(tmpJFlags,MJobFlags,&J->SpecFlags); } if (J->SysFlags & (1 << mjfBackfill)) J->SysFlags ^= (1 << mjfBackfill); if ((J->SpecFlags & (1 << mjfHostList)) && (MSim.Flags & (1 << msimfIgnHostList))) { J->SpecFlags ^= (1 << mjfHostList); } } } /* END else (Mode == msmProfile) */ /* extract arbitrary job attributes */ /* FORMAT: JATTR:<ATTR>[=<VALUE>] */ { char *ptr; char *TokPtr; ptr = MUStrTok(tmpJFlags,"[]",&TokPtr); while (ptr != NULL) { if (!strncmp(ptr,"JATTR:",strlen("JATTR:"))) { MJobSetAttr(J,mjaGAttr,(void **)(ptr + strlen("JATTR:")),0,mSet); } ptr = MUStrTok(NULL,"[]",&TokPtr); } /* END while (ptr != NULL) */ } /* END BLOCK */ /* set default flags, remove set 'ignore' flags */ J->SpecFlags |= MSim.TraceDefaultJobFlags; for (index = 0;index < M64.INTBITS;index++) { if (!(MSim.TraceIgnoreJobFlags & (1 << index))) continue; if (!(J->SpecFlags & (1 << index))) continue; J->SpecFlags ^= (1 << index); } /* END for (index) */ /* load task info */ if (!strncmp(tmpTaskRequest,"PBS=",strlen("PBS="))) { char tmpLine[MAX_MLINE]; tpbsa_t tmpA; short TaskList[MAX_MTASK]; memset(&tmpA,0,sizeof(tmpA)); sprintf(tmpLine,"Resource_List,nodes,%s", &tmpTaskRequest[strlen("PBS=")]); MPBSJobSetAttr(J,NULL,tmpLine,&tmpA,TaskList,0); MPBSJobAdjustResources(J,&tmpA,J->RM); } else { ptr = MUStrTok(tmpTaskRequest,",",&TokPtr); tindex = 1; while (ptr != NULL) { if (strchr(ptr,'-') != NULL) { /* NOTE: not handled */ } else { RQ[0]->TaskRequestList[tindex] = atoi(ptr); tindex++; } ptr = MUStrTok(NULL,",",&TokPtr); } RQ[0]->TaskRequestList[tindex] = 0; RQ[0]->TaskRequestList[0] = RQ[0]->TaskRequestList[1]; RQ[0]->TaskCount = RQ[0]->TaskRequestList[0]; J->Request.TC = RQ[0]->TaskRequestList[0]; RQ[0]->TasksPerNode = MAX(0,TPN); if (MPar[0].JobNodeMatch & (1 << nmExactNodeMatch)) { RQ[0]->NodeCount = RQ[0]->TaskCount; J->Request.NC = RQ[0]->TaskCount; } if (MPar[0].JobNodeMatch & (1 << nmExactProcMatch)) { if (RQ[0]->TasksPerNode >= 1) { RQ[0]->RequiredProcs = RQ[0]->TasksPerNode; RQ[0]->ProcCmp = mcmpEQ; } if (RQ[0]->TasksPerNode > J->Request.TC) { RQ[0]->TasksPerNode = 0; } } } /* END BLOCK */ /* process WCLimit constraints */ ptr = MUStrTok(tmpSpecWCLimit,",:",&TokPtr); tindex = 1; while (ptr != NULL) { if (strchr(ptr,'-') != NULL) { /* NOTE: not handled */ } else { J->SpecWCLimit[tindex] = strtol(ptr,NULL,0); tindex++; } ptr = MUStrTok(NULL,",:",&TokPtr); } /* END while (ptr != NULL) */ J->SpecWCLimit[tindex] = 0; J->SpecWCLimit[0] = J->SpecWCLimit[1]; J->SubmitTime = tmpQTime; J->DispatchTime = MAX(tmpDTime,tmpSTime); J->StartTime = MAX(tmpDTime,tmpSTime); J->CompletionTime = tmpCTime; J->SystemQueueTime = tmpSQTime; J->SpecSMinTime = tmpSDate; J->CMaxTime = tmpEDate; /* determine required reservation */ if (strcmp(Reservation,NONE) && strcmp(Reservation,J->Name)) { J->SpecFlags |= (1 << mjfAdvReservation); if (strcmp(Reservation,ALL) != 0) { strcpy(J->ResName,Reservation); } } /* determine job class */ if ((MSim.Flags & (1 << msimfIgnClass)) || (MSim.Flags & (1 << msimfIgnAll))) { mclass_t *C; MClassAdd("DEFAULT",&C); /* ignore specified classes */ RQ[0]->DRes.PSlot[0].count = 1; RQ[0]->DRes.PSlot[C->Index].count = 1; } else { int cindex; MUNumListFromString(RQ[0]->DRes.PSlot,tmpClass,eClass); for (cindex = 1;cindex < MAX_MCLASS;cindex++) { if (RQ[0]->DRes.PSlot[cindex].count > 0) { MClassAdd(MAList[eClass][cindex],NULL); } } /* END for (cindex) */ } if (Mode != msmProfile) { if ((strcmp(MReqHList,NONE) != 0) && !(MSim.Flags & (1 << msimfIgnHostList)) && !(MSim.Flags & (1 << msimfIgnAll))) { J->SpecFlags |= (1 << mjfHostList); ptr = MUStrTok(MReqHList,":",&TokPtr); nindex = 0; if (J->ReqHList == NULL) J->ReqHList = (mnalloc_t *)calloc(1,sizeof(mnalloc_t) * (MAX_MNODE_PER_JOB + 1)); J->ReqHList[0].N = NULL; while (ptr != NULL) { if (MNodeFind(ptr,&N) == FAILURE) { if (MSched.DefaultDomain[0] != '\0') { if ((tail = strchr(ptr,'.')) != NULL) { /* try short name */ MUStrCpy(MReqHList,ptr,MIN(sizeof(MReqHList),(tail - ptr + 1))); } else { /* append default domain */ if (MSched.DefaultDomain[0] == '.') { sprintf(MReqHList,"%s%s", ptr, MSched.DefaultDomain); } else { sprintf(MReqHList,"%s.%s", ptr, MSched.DefaultDomain); } } if (MNodeFind(MReqHList,&N) != SUCCESS) { DBG(1,fUI) DPrint("ALERT: cannot locate node '%s' for job '%s' hostlist\n", ptr, J->Name); N = NULL; } } else { DBG(1,fUI) DPrint("ALERT: cannot locate node '%s' for job '%s' hostlist\n", ptr, J->Name); N = NULL; } } /* END if (MNodeFind() == FAILURE) */ if (N != NULL) { if (J->ReqHList[nindex].N == N) { J->ReqHList[nindex].TC++; } else { if (J->ReqHList[nindex].N != NULL) nindex++; J->ReqHList[nindex].N = N; J->ReqHList[nindex].TC = 1; } } ptr = MUStrTok(NULL,":",&TokPtr); } /* END while (ptr != NULL) */ J->ReqHList[nindex + 1].N = NULL; } /* END if (strcmp(MReqHList,NONE)) */ else if ((J->SpecFlags & (1 << mjfHostList)) && (J->ReqHList == NULL)) { DBG(1,fSIM) DPrint("ALERT: job %s requests hostlist but has no hostlist specified\n", J->Name); J->SpecFlags ^= (1 << mjfHostList); } } /* END if (MODE != msmProfile) */ break; default: DBG(4,fSIM) DPrint("ALERT: cannot load version %d workload trace record\n", *Version); MJobDestroy(&J); return(FAILURE); /*NOTREACHED*/ break; } /* END switch(*Version) */ if (!strcmp(AName,NONE) || !strcmp(AName,"0")) { AName[0] = '\0'; } if ((strcmp(tmpRMXString,NONE) != 0) && (strcmp(tmpRMXString,"0") != 0)) { MJobSetAttr(J,mjaRMXString,(void **)tmpRMXString,mdfString,0); } if (RQ[0]->DRes.Procs == 0) RQ[0]->DRes.Procs = 1; if (J->SpecWCLimit[0] == (unsigned long)-1) J->SpecWCLimit[0] = MAX_MTIME; MUStrDup(&J->E.Cmd,tmpCmd); if (Mode == msmSim) { J->State = mjsIdle; J->EState = mjsIdle; J->Bypass = 0; J->PSUtilized = 0.0; J->SystemQueueTime = J->SubmitTime; J->SimWCTime = MAX(1,J->CompletionTime - J->StartTime); J->StartTime = 0; J->DispatchTime = 0; J->CompletionTime = 0; J->WCLimit = J->SpecWCLimit[0]; } else { /* profile mode */ int tmpI; tmpI = (int)strtol(tmpParName,NULL,0); if (tmpI > 0) { RQ[0]->PtIndex = tmpI; } else { mpar_t *P; MParFind(tmpParName,&P); RQ[0]->PtIndex = P->Index; } J->TaskCount = TasksAllocated; J->PSDedicated = MJobGetProcCount(J) * (J->CompletionTime - J->StartTime); J->WCLimit = J->SpecWCLimit[0]; for (index = 0;MJobState[index] != NULL;index++) { if (!strcmp(tmpState,MJobState[index])) { J->State = index; J->EState = index; break; } } /* END for (index) */ } if (J->State == mjsNotRun) { DBG(3,fSIM) DPrint("ALERT: ignoring job '%s' (job never ran, state '%s')\n", J->Name, MJobState[J->State]); MJobDestroy(&J); return(FAILURE); } /* check for timestamp corruption */ if (Mode == msmProfile) { /* profiler mode */ if (MSched.TraceFlags & (1 << tfFixCorruption)) { if (J->StartTime < J->DispatchTime) { DBG(2,fSIM) DPrint("WARNING: fixing job '%s' with corrupt dispatch/start times (%ld < %ld)\n", J->Name, J->DispatchTime, J->StartTime); J->DispatchTime = J->StartTime; } if (J->SubmitTime > J->StartTime) { DBG(2,fSIM) DPrint("WARNING: fixing job '%s' with corrupt queue/start times (%ld > %ld)\n", J->Name, J->SubmitTime, J->StartTime); if (J->SystemQueueTime > 0) J->SubmitTime = MIN(J->StartTime,J->SystemQueueTime); else J->SubmitTime = J->StartTime; } if (J->SystemQueueTime > J->DispatchTime) { DBG(2,fSIM) DPrint("WARNING: fixing job '%s' with corrupt system queue/dispatch times (%ld > %ld)\n", J->Name, J->SystemQueueTime, J->DispatchTime); J->SystemQueueTime = J->DispatchTime; } if (J->SystemQueueTime < J->SubmitTime) { DBG(2,fSIM) DPrint("WARNING: fixing job '%s' with corrupt system queue/queue time (%ld < %ld)\n", J->Name, J->SystemQueueTime, J->SubmitTime); J->SystemQueueTime = J->SubmitTime; } } /* END if (MSched.TraceFlags & (1 << tfFixCorruption)) */ if ((J->SubmitTime > J->DispatchTime) || (J->DispatchTime > J->CompletionTime)) { DBG(1,fSIM) DPrint("ALERT: ignoring job '%s' with corrupt queue/start/completion times (%ld > %ld > %ld)\n", J->Name, J->SubmitTime, J->DispatchTime, J->CompletionTime); MJobDestroy(&J); return(FAILURE); } } /* END if (Mode != msmSim) */ if (MJobSetCreds(J,UName,GName,AName) == FAILURE) { DBG(1,fSTRUCT) DPrint("ALERT: ignoring job '%s' with invalid authentication info (%s:%s:%s)\n", J->Name, UName, GName, AName); MJobDestroy(&J); return(FAILURE); } /* determine network */ if (strstr(tmpNetwork,MAList[eNetwork][0]) == NULL) { RQ[0]->Network = MUMAGetIndex(eNetwork,tmpNetwork,mAdd); } if (strstr(tmpOpsys,MAList[eOpsys][0]) == NULL) { if ((RQ[0]->Opsys = MUMAGetIndex(eOpsys,tmpOpsys,mAdd)) == FAILURE) { DBG(0,fSIM) DPrint("WARNING: cannot add opsys '%s' for job '%s'\n", tmpOpsys, J->Name); } } if (strstr(tmpArch,MAList[eArch][0]) == NULL) { if ((RQ[0]->Arch = MUMAGetIndex(eArch,tmpArch,mAdd)) == FAILURE) { DBG(0,fSIM) DPrint("WARNING: cannot add arch '%s' for job '%s'\n", tmpArch, J->Name); } } /* load feature values */ if ((MSched.ProcSpeedFeatureHeader[0] != '\0') && (MSched.ReferenceProcSpeed > 0)) { sprintf(tmpLine,"[%s", MSched.ProcSpeedFeatureHeader); if ((ptr = strstr(tmpReqNFList,tmpLine)) != NULL) { ReqProcSpeed = strtol(ptr + strlen(tmpLine),NULL,0); J->SimWCTime *= (long)((double)ReqProcSpeed / MSched.ReferenceProcSpeed); } } if ((MSched.Mode != msmSim) || !(MSim.Flags & (1 << msimfIgnFeatures))) { if (!strstr(tmpReqNFList,MAList[eFeature][0])) { tok = MUStrTok(tmpReqNFList,"[]",&TokPtr); do { MUGetMAttr(eFeature,tok,mAdd,RQ[0]->ReqFBM,sizeof(RQ[0]->ReqFBM)); } while ((tok = MUStrTok(NULL,"[]",&TokPtr)) != NULL); } } RQ[0]->MemCmp = MUCmpFromString(tmpMemCmp,NULL); RQ[0]->DiskCmp = MUCmpFromString(tmpDiskCmp,NULL); RQ[0]->NAccessPolicy = MSched.DefaultNAccessPolicy; RQ[0]->TaskCount = J->Request.TC; RQ[0]->NodeCount = J->Request.NC; MJobProcessExtensionString(J,J->RMXString); if ((MSim.Flags & (1 << msimfIgnQOS))) { tmpQReq[0] = '\0'; } { char *ptr; char *TokPtr; ptr = MUStrTok(tmpQReq,":",&TokPtr); if ((ptr != NULL) && (ptr[0] != '\0') && strcmp(ptr,"-1") && strcmp(ptr,"0") && strcmp(ptr,NONE) && strcmp(ptr,DEFAULT)) { if (MQOSAdd(ptr,&J->QReq) == FAILURE) { /* cannot locate requested QOS */ MQOSFind(DEFAULT,&J->QReq); } if (Mode == msmProfile) { if ((ptr = MUStrTok(NULL,":",&TokPtr)) != NULL) { MQOSAdd(ptr,&J->Cred.Q); } } } /* END if ((ptr != NULL) && ...) */ } /* END BLOCK */ if (Mode == msmSim) { if ((MQOSGetAccess(J,J->QReq,NULL,&QDef) == FAILURE) || (J->QReq == NULL) || (J->QReq == &MQOS[0])) { MJobSetQOS(J,QDef,0); } else { MJobSetQOS(J,J->QReq,0); } } /* END if (Mode == msmSim) */ if ((SetString[0] != '0') && (strcmp(SetString,NONE))) { /* FORMAT: ONEOF,FEATURE[,X:Y:Z] */ if ((ptr = MUStrTok(SetString,",: \t",&TokPtr)) != NULL) { /* determine selection type */ RQ[0]->SetSelection = MUGetIndex(ptr,(const char **)MResSetSelectionType,0,mrssNONE); if ((ptr = MUStrTok(NULL,",: \t",&TokPtr)) != NULL) { /* determine set attribute */ RQ[0]->SetType = MUGetIndex(ptr,(const char **)MResSetAttrType,0,mrstNONE); index = 0; if ((ptr = MUStrTok(NULL,", \t",&TokPtr)) != NULL) { /* determine set list */ while (ptr != NULL) { MUStrDup(&RQ[0]->SetList[index],ptr); index++; ptr = MUStrTok(NULL,", \t",&TokPtr); } } RQ[0]->SetList[index] = NULL; } /* END if ((ptr = MUStrTok(NULL)) != NULL) */ } /* END if ((ptr = MUStrTok(SetString)) != NULL) */ } /* END if ((SetString[0] != '0') && (strcmp(SetString,NONE))) */ if (MJobEval(J) == FAILURE) { /* job not properly formed */ DBG(1,fSTRUCT) DPrint("ALERT: ignoring job '%s' with corrupt configuration\n", J->Name); MJobDestroy(&J); return(FAILURE); } DBG(6,fSIM) DPrint("INFO: job '%s' loaded. class: %s opsys: %s arch: %s\n", J->Name, MUCAListToString(RQ[0]->DRes.PSlot,NULL,NULL), MAList[eOpsys][RQ[0]->Opsys], MAList[eArch][RQ[0]->Arch]); return(SUCCESS); } /* END MTraceLoadWorkload() */
int MTraceLoadComputeNode( char *NodeLine, /* I */ mnode_t *N, /* O */ int Version) /* I */ { char *tok; char *TokPtr; char tmpLine[MAX_MLINE]; char tmpNLine[MAX_MLINE]; char ResourceType[MAX_MNAME]; char EventType[MAX_MNAME]; long ETime; char Name[MAX_MNAME]; char OpsysString[MAX_MNAME]; char ArchString[MAX_MNAME]; char FeatureString[MAX_MLINE]; char ClassString[MAX_MLINE]; char NetworkString[MAX_MLINE]; char GResString[MAX_MLINE]; char tmpSwapBuf[MAX_MNAME]; char tmpMemBuf[MAX_MNAME]; char tmpDiskBuf[MAX_MNAME]; int SlotsUsed; char RMName[MAX_MNAME]; int FIndex; int SIndex; int cindex; int rc; /* set default resource attributes */ memset(N,0,sizeof(mnode_t)); N->Load = 0.0; N->Speed = 1.0; N->PtIndex = 0; switch(Version) { case 230: if (strchr(NodeLine,';') != NULL) { sprintf(tmpNLine,"IFS-;%.*s", MAX_MLINE, NodeLine); } else { MUStrCpy(tmpNLine,NodeLine,sizeof(tmpNLine)); } /* FORMAT: <RESOURCETYPE> <EVENTTYPE> <EVENTTIME> <NAME> <RMINDEX> <SWAP> <MEMORY> <DISK> <MAXPROCS> <SLOTSUSED> <FRAMEINDEX> <SLOTINDEX> <OPSYS> <ARCH> [<FEATURE>]* [<CLASS>]* [<NETWORK>]* [<GRES>]* <RES1> <RES2> <RES3> */ rc = MUSScanF(tmpNLine,"%x%s %x%s %ld %x%s %x%s %x%s %x%s %x%s %d %d %d %d %x%s %x%s %x%s %x%s %x%s %x%s %x%s %x%s %x%s %x%s", MAX_MNAME, ResourceType, MAX_MNAME, EventType, &ETime, MAX_MNAME, Name, MAX_MNAME, RMName, MAX_MNAME, tmpSwapBuf, MAX_MNAME, tmpMemBuf, MAX_MNAME, tmpDiskBuf, &N->CRes.Procs, &FIndex, &SIndex, &SlotsUsed, MAX_MNAME, OpsysString, MAX_MNAME, ArchString, MAX_MLINE, FeatureString, MAX_MLINE, ClassString, MAX_MLINE, NetworkString, MAX_MLINE, GResString, MAX_MLINE, tmpLine, /* RES1 */ MAX_MLINE, tmpLine, /* RES2 */ MAX_MLINE, tmpLine, /* RES3 */ MAX_MLINE, tmpLine /* check for too many lines */ ); if ((rc == EOF) || (rc != 21)) { DBG(3,fSIM) DPrint("ALERT: resource tracefile corruption (%d of %d fields detected) on line '%s'\n", rc, 21, NodeLine); return(FAILURE); } /* process node attributes */ N->CRes.Swap = MURSpecToL(tmpSwapBuf,mvmMega,mvmMega); N->CRes.Mem = MURSpecToL(tmpMemBuf,mvmMega,mvmMega); N->CRes.Disk = MURSpecToL(tmpDiskBuf,mvmMega,mvmMega); if (!strcmp(RMName,NONE)) MRMAdd(RMName,&N->RM); else MRMAdd(DEFAULT,&N->RM); /* load Opsys */ if (strstr(OpsysString,MAList[eOpsys][0]) == NULL) N->ActiveOS = MUMAGetIndex(eOpsys,OpsysString,mAdd); /* load Arch */ if (strstr(ArchString,MAList[eArch][0]) == NULL) N->Arch = MUMAGetIndex(eArch,ArchString,mAdd); memcpy(&N->ARes,&N->CRes,sizeof(N->ARes)); strcpy(N->Name,MNodeAdjustName(Name,0)); /* load classes */ if (MSim.Flags & ((1 << msimfIgnClass) | (1 << msimfIgnAll))) { mclass_t *C; /* ignore specified classes */ MClassAdd("DEFAULT",&C); N->CRes.PSlot[0].count = N->CRes.Procs; N->CRes.PSlot[C->Index].count = N->CRes.Procs; } else { MUNumListFromString(N->CRes.PSlot,ClassString,eClass); for (cindex = 1;cindex < MAX_MCLASS;cindex++) { if (N->CRes.PSlot[cindex].count > 0) MClassAdd(MAList[eClass][cindex],NULL); } } memcpy(N->ARes.PSlot,N->CRes.PSlot,sizeof(N->ARes.PSlot)); break; default: DBG(4,fSIM) DPrint("ALERT: cannot load version %d resource trace record\n", Version); return(FAILURE); /*NOTREACHED*/ break; } /* END switch(Version) */ if ((MSim.Flags & ((1 << msimfIgnFrame) | (1 << msimfIgnAll))) || (FIndex < 0)) { N->FrameIndex = -1; N->SlotIndex = -1; } else { MFrameAddNode(&MFrame[FIndex],N,SIndex); if ((N->FrameIndex > 0) && (N->FrameIndex < MAX_MFRAME) && (N->SlotIndex > 0) && (N->SlotIndex <= MAX_MSLOTPERFRAME)) { mhost_t *S; int nindex; S = &MSys[N->FrameIndex][N->SlotIndex]; S->SlotsUsed = SlotsUsed; for (nindex = 0;nindex < MAX_MNETTYPE;nindex++) strcpy(S->NetName[nindex],N->Name); if (!strstr(ClassString,"NONE")) S->Attributes |= (1 << attrBatch); S->MTime = MSched.Time; } /* END if ((N->FrameIndex > 0) ... ) */ } /* END else if (MSim.Flags & ((1 << msimfIgnFrame) | ...)) */ /* initialize statistics */ N->STTime = 0; N->SUTime = 0; N->SATime = 0; /* load state */ if (N->CRes.Procs <= 0) { N->State = mnsNone; } else { if (!strcmp(EventType,"AVAILABLE")) N->State = mnsIdle; else if (!strcmp(EventType,"DEFINED")) N->State = mnsDown; else if (!strcmp(EventType,"DRAINED")) N->State = mnsDrained; else N->State = mnsNONE; } /* END else (N->CRes.Procs <= 0) */ N->EState = N->State; memcpy(&N->ARes,&N->CRes,sizeof(N->ARes)); /* load features */ if (strstr(FeatureString,MAList[eFeature][0]) == NULL) { tok = MUStrTok(FeatureString,"[]",&TokPtr); do { MNodeProcessFeature(N,tok); DBG(6,fSIM) DPrint("INFO: feature '%s' added (%s)\n", tok, MUMAList(eFeature,N->FBM,sizeof(N->FBM))); } while ((tok = MUStrTok(NULL,"[]",&TokPtr)) != NULL); } /* load network adapters */ if (strstr(NetworkString,MAList[eNetwork][0]) == NULL) { tok = MUStrTok(NetworkString,"[]",&TokPtr); do { N->Network |= MUMAGetBM(eNetwork,tok,mAdd); DBG(6,fSIM) DPrint("INFO: network '%s' added (%s)\n", tok, MUListAttrs(eNetwork,N->Network)); } while ((tok = MUStrTok(NULL,"[]",&TokPtr)) != NULL); } /* load generic resources */ if (!strcmp(GResString,NONE) != 0) { MUNumListFromString(N->CRes.GRes,GResString,eGRes); } DBG(4,fSIM) DPrint("INFO: node '%s' F:%d/S:%d %06d %04d %06d %02d %02d %10s %10s %20s %20s\n", N->Name, N->FrameIndex, N->SlotIndex, N->CRes.Swap, N->CRes.Mem, N->CRes.Disk, N->CRes.Procs, SlotsUsed, OpsysString, ArchString, FeatureString, MUCAListToString(N->CRes.PSlot,NULL,NULL)); return(SUCCESS); } /* END MTraceLoadComputeNode() */