int ShowBackfillWindow( char *RBuffer, /* I */ char *Buffer, /* O */ int FLAGS, /* I */ char *Auth, /* I */ long *BufSize) /* I */ { int BFNodeCount; int BFProcCount; nodelist_t BFNodeList; long BFTime; long MinTime; long RequiredTime; long RequiredNodes; long RequiredProcs; char UserName[MAX_MNAME]; char GroupName[MAX_MNAME]; char AccountName[MAX_MNAME]; int Memory; char MemCmp[MAX_MNAME]; int DMemory; char PName[MAX_MNAME]; char CurrentPName[MAX_MNAME]; int index; int pindex; int mindex; int nindex; int ShowSMP; /* (boolean) */ char Affinity; int Type; int Flags; char QOSName[MAX_MNAME]; char ClassString[MAX_MLINE]; char FeatureString[MAX_MLINE]; mnode_t *N; mjob_t tmpJ; mjob_t *J; mreq_t tmpRQ; mcres_t DRes; mpar_t *P; mpar_t *SP; mrange_t ARange[MAX_MRANGE]; mrange_t RRange[2]; int NodeHeaderPrinted; int PCount; char tmpBuffer[MAX_MBUFFER]; const char *FName = "ShowBackfillWindow"; DBG(2,fUI) DPrint("%s(%s,Buffer,%d,%s,BufSize)\n", FName, RBuffer, FLAGS, Auth); if (MUSScanF(RBuffer,"%x%s %x%s %x%s %x%s %ld %ld %ld %d %d %x%s %d %d %x%s %x%s %x%s", sizeof(UserName), UserName, sizeof(GroupName), GroupName, sizeof(AccountName), AccountName, sizeof(PName), PName, &RequiredTime, &RequiredNodes, &RequiredProcs, &DMemory, &Memory, sizeof(MemCmp), MemCmp, &ShowSMP, &Flags, sizeof(ClassString), ClassString, sizeof(FeatureString), FeatureString, sizeof(QOSName), QOSName) == FAILURE) { /* invalid request string */ DBG(3,fUI) DPrint("INFO: cannot parse request\n"); sprintf(Buffer,"ERROR: cannot parse request\n"); return(FAILURE); } MParFind(PName,&SP); DBG(4,fUI) DPrint("INFO: locating backfill window for u: %s g: %s a: %s p: %s c: %s f: %s (%ld:%ld:%d)\n", UserName, GroupName, AccountName, MAList[ePartition][(SP != NULL) ? SP->Index : 0], ClassString, FeatureString, RequiredTime, RequiredNodes, Memory); if (ShowSMP == FALSE) /* NON-SMP */ { mindex = 0; if (Memory > 0) { for (mindex = 0;MComp[mindex] != NULL;mindex++) { if (!strcasecmp(MComp[mindex],MemCmp)) break; } if (MComp[mindex] == NULL) mindex = 0; } memset(&DRes,0,sizeof(DRes)); DRes.Procs = 1; DRes.Mem = DMemory; sprintf(Buffer,"backfill window (user: '******' group: '%s' partition: %s) %s\n", UserName, GroupName, PName, MULToDString((mulong *)&MSched.Time)); PCount = 0; for (pindex = 1;pindex < MAX_MPAR;pindex++) { if (MPar[pindex].ConfigNodes == 0) continue; PCount++; } index = 0; for (pindex = 0;pindex < MAX_MPAR;pindex++) { P = &MPar[pindex]; if ((SP != NULL) && (SP != P)) continue; if ((PCount == 1) && (SP == NULL) && (P->Index != 0)) break; if (P->ConfigNodes == 0) continue; MinTime = 0; DBG(7,fUI) DPrint("INFO: checking window in partition %s\n", P->Name); strcpy(CurrentPName,GLOBAL_MPARNAME); index = 0; while (MBFGetWindow( &BFNodeCount, &BFProcCount, BFNodeList, &BFTime, MinTime, P, UserName, GroupName, AccountName, mindex, Memory, MAX(1,RequiredTime), &DRes, ClassString, FeatureString, QOSName, (Flags & (1 << mcmVerbose)) ? tmpBuffer : NULL) == SUCCESS) { DBG(4,fUI) DPrint("INFO: located backfill window [%03d nodes : %06ld seconds]\n", BFNodeCount, BFTime); if ((BFTime >= RequiredTime) && (BFNodeCount >= RequiredNodes) && (BFProcCount >= RequiredProcs)) { if (strcasecmp(P->Name,CurrentPName) != 0) { if ((strcasecmp(CurrentPName,GLOBAL_MPARNAME)) && (index == 0)) { sprintf(Buffer,"%sno %s available\n", Buffer, (MSched.DisplayFlags & (1 << dfNodeCentric)) ? "nodes" : "procs"); } strcpy(CurrentPName,P->Name); sprintf(Buffer,"%s\npartition %s:\n", Buffer, P->Name); index = 0; } if (MSched.DisplayFlags & (1 << dfNodeCentric)) { /* node centric output */ if (BFNodeCount == 0) { sprintf(Buffer,"%sno nodes available\n", Buffer); } else if (BFTime < 100000000) { sprintf(Buffer,"%s%3d node%s available for %11s\n", Buffer, BFNodeCount, (BFNodeCount > 1) ? "s" : "", MULToTString(BFTime)); } else { sprintf(Buffer,"%s%3d node%s available with no timelimit\n", Buffer, BFNodeCount, (BFNodeCount > 1) ? "s" : ""); } } else { /* proc centric output */ if (BFProcCount == 0) { sprintf(Buffer,"%sno procs available\n", Buffer); } else if (BFTime < 100000000) { sprintf(Buffer,"%s%3d proc%s available for %11s\n", Buffer, BFProcCount, (BFProcCount > 1) ? "s" : "", MULToTString(BFTime)); } else { sprintf(Buffer,"%s%3d proc%s available with no timelimit\n", Buffer, BFProcCount, (BFProcCount > 1) ? "s" : ""); } } index++; } /* END if (BFTime) */ MinTime = BFTime; } /* END while (MBFGetWindow() == SUCCESS) */ if (Flags & (1 << mcmVerbose)) { strcat(Buffer,"\n\n"); strcat(Buffer,tmpBuffer); } } /* END for (pindex) */ if (index == 0) { sprintf(Buffer,"%sno procs available\n", Buffer); } strcat(Buffer,"\n\n"); } /* END if (ShowSMP == FALSE) */ else { /* SMP Mode */ RRange[0].StartTime = MSched.Time; RRange[0].EndTime = MAX_MTIME; RRange[1].EndTime = 0; memset(&tmpJ,0,sizeof(tmpJ)); memset(&tmpRQ,0,sizeof(tmpRQ)); J = &tmpJ; tmpRQ.DRes.Procs = 1; tmpRQ.DRes.Mem = DMemory; J->Req[0] = &tmpRQ; if (MJobSetCreds(J,ALL,ALL,ALL) == FAILURE) { DBG(3,fUI) DPrint("INFO: cannot setup showbf job creds\n"); sprintf(Buffer,"ERROR: cannot determine available resources\n"); return(FAILURE); } if (MQOSFind(QOSName,&J->QReq) == FAILURE) { /* cannot locate requested QOS */ MQOSFind(DEFAULT,&J->QReq); } MJobSetQOS(J,J->QReq,0); MJobBuildCL(J); sprintf(Buffer,"%s%20s %5s %6s %7s %7s %14s\n", Buffer, "HostName", "Procs", "Memory", "Disk", "Swap", "Time Available"); sprintf(Buffer,"%s%20s %5s %6s %7s %7s %14s\n", Buffer, "----------", "-----", "------", "-------", "-------", "--------------"); for (nindex = 0;nindex < MAX_MNODE;nindex++) { N = MNode[nindex]; if ((N == NULL) || (N->Name[0] == '\0')) break; if (N->Name[0] == '\1') continue; if ((N->State != mnsActive) && (N->State != mnsIdle)) continue; if ((SP != NULL) && (SP->Index != 0) && (N->PtIndex != SP->Index)) continue; NodeHeaderPrinted = FALSE; for (RRange[0].TaskCount = 1;RRange[0].TaskCount < N->CRes.Procs;RRange[0].TaskCount = ARange[0].TaskCount + 1) { if (MJobGetSNRange( J, J->Req[0], N, RRange, 1, &Affinity, &Type, ARange, &DRes, NULL) == SUCCESS) { if (ARange[0].StartTime != MSched.Time) { /* resources not available immediately */ break; } if (NodeHeaderPrinted == FALSE) { strcat(Buffer,"\n"); NodeHeaderPrinted = TRUE; } sprintf(Buffer,"%s%20s %5d %6d %7d %7d %14s\n", Buffer, N->Name, DRes.Procs, DRes.Mem, DRes.Disk, DRes.Swap, MULToTString(ARange[0].EndTime - MSched.Time)); } else { /* resources not available */ break; } } } /* END for (nindex) */ } /* END else (ShowSMP == FALSE) */ return(SUCCESS); } /* END ShowBackfillWindow() */
int __MSysTestJobGetSNRange() { #if 0 mjob_t tmpJ; mnode_t tmpN; mre_t RE[MMAX_RSV_DEPTH << 1]; mrsv_t *R[MMAX_RSV_DEPTH]; int RC[MMAX_RSV_DEPTH]; mreq_t tmpRQ; char tmpLine[MMAX_LINE]; mrange_t GRange[MMAX_RANGE]; mrange_t ARange[MMAX_RANGE]; char Affinity; enum MResourceAvailabilityPolicyEnum NAvailPolicy[mrLAST]; memset(&tmpJ,0,sizeof(tmpJ)); memset(&tmpN,0,sizeof(tmpN)); memset(&tmpRQ,0,sizeof(tmpRQ)); memset(NAvailPolicy,0,sizeof(NAvailPolicy)); /* configure general */ MSched.Time = 1213931845; MSched.MaxRsvPerNode = 8; /* MSched.RsvSearchAlgo = mrsaWide; */ mlog.logfp = stderr; mlog.Threshold = 8; /* configure reservation */ /* now = 1213931845 */ /* wclimit = 1440000 */ MRsvInitialize(&MRsv[0],NULL,"430806",FALSE); MRsv[0]->Type = mrtJob; MRsv[0]->StartTime = 1213931844; MRsv[0]->EndTime = 1215371844; MRsv[0]->DRes.Procs = 1; bmclear(&MRsv[0]->Flags); MRsv[0]->J = &tmpJ; MRsvInitialize(&MRsv[1],NULL,"elston.437",FALSE); MRsv[1]->Type = mrtUser; MRsv[1]->StartTime = 0; MRsv[1]->EndTime = MMAX_TIME - 1; MRsv[1]->DRes.Procs = 8; bmclear(&MRsv[1]->Flags); MUStrDup(&MRsv[1]->RsvGroup,"elston"); MUStrCpy(tmpLine,"USER==wightman",sizeof(tmpLine)); MACLLoadConfigLine(&MRsv[1]->ACL,tmpLine,mSet,NULL,FALSE); /* configure node */ strcpy(tmpN.Name,"tango065"); tmpN.CRes.Procs = 8; tmpN.ARes.Procs = 8; memcpy(tmpN.NAvailPolicy,NAvailPolicy,sizeof(tmpN.NAvailPolicy)); tmpN.NAvailPolicy[mrProc] = mrapDedicated; /* link node */ tmpN.R = R; tmpN.RE = RE; tmpN.RC = RC; tmpN.R[0] = MRsv[1]; tmpN.RC[0] = 1; tmpN.R[1] = MRsv[0]; tmpN.RC[1] = 8; tmpN.RE[0].Type = mreStart; tmpN.RE[0].BRes.Procs = 1; tmpN.RE[0].Time = 1213931845 - 1; tmpN.RE[0].Index = 1; tmpN.RE[1].Type = mreStart; tmpN.RE[1].BRes.Procs = 0; tmpN.RE[1].Time = 1213931845; tmpN.RE[1].Index = 0; tmpN.RE[2].Type = mreEnd; tmpN.RE[2].BRes.Procs = 8; tmpN.RE[2].Time = 1213931845 - 1 + 1440000; tmpN.RE[2].Index = 1; tmpN.RE[3].Type = mreEnd; tmpN.RE[3].BRes.Procs = 0; tmpN.RE[3].Time = 1213931845 - 1 + 1440000; tmpN.RE[3].Index = 0; tmpN.RE[4].Type = mreStart; tmpN.RE[4].BRes.Procs = 8; tmpN.RE[4].Time = 1213931845 - 1 + 1440000; tmpN.RE[4].Index = 0; tmpN.RE[5].Type = mreEnd; tmpN.RE[5].BRes.Procs = 8; tmpN.RE[5].Time = MMAX_TIME - 1; tmpN.RE[5].Index = 0; tmpN.RE[6].Type = mreNONE; MNode[0] = &tmpN; /* configure job */ strcpy(tmpJ.Name,"430806"); tmpJ.Req[0] = &tmpRQ; tmpJ.WCLimit = 1440000; tmpJ.SpecWCLimit[0] = 1440000; tmpJ.Request.TC = 8; MACLSet(&tmpJ.Cred.CL,maUser,(void *)"wightman",mcmpSEQ,mnmPositiveAffinity,0,FALSE); bmset(&tmpJ.Flags,mjfAdvRsv); MUStrDup(&tmpJ.ReqRID,"elston"); tmpRQ.DRes.Procs = 1; /* configure range requirements */ GRange[0].TC = 8; GRange[0].NC = 0; GRange[0].STime = 1213931845; GRange[0].ETime = 1213931845 + 1440000; GRange[1].ETime = 0; MJobGetSNRange( &tmpJ, &tmpRQ, &tmpN, GRange, MMAX_RANGE, &Affinity, NULL, ARange, NULL, FALSE, NULL); exit(0); /*NOTREACHED*/ #endif /* 0 */ return(SUCCESS); } /* __MSysTestJobGetSNRange() */