Beispiel #1
0
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() */
Beispiel #2
0
int MNodeLoadConfig(

  mnode_t *N,    /* I */
  char    *Buf)  /* I (optional) */

  {
  char *ptr;
  char *head;

  char  Value[MMAX_BUFFER];

  char  tmpSName[MMAX_NAME];
  char  tmpLName[MMAX_NAME];

  const char *FName = "MNodeLoadConfig";

  MDB(5,fSTRUCT) MLog("%s(%s,%s)\n",
    FName,
    (N != NULL) ? N->Name : "NULL",
    (Buf != NULL) ? Buf : "NULL");

  /* load specified node config info */

  if ((N == NULL) || (N->Name[0] == '\0'))
    {
    return(FAILURE);
    }
 
  /* search for parameters specified with both long and short names */

  /* search short names */

  MNodeAdjustName(N->Name,0,tmpSName);

  if (Buf != NULL)
    head = Buf;
  else
    head = MSched.ConfigBuffer;

  if (head == NULL)
    {
    return(FAILURE);
    }

  ptr = head;
 
  while (MCfgGetSVal(
           head,
           &ptr,
           MCredCfgParm[mxoNode],
           tmpSName,
           NULL,
           Value,
           sizeof(Value),
           0,
           NULL) != FAILURE)
    {
    /* node attribute located */

    /* FORMAT:  <ATTR>=<VALUE>[ <ATTR>=<VALUE>]... */

    if (MNodeProcessConfig(N,NULL,Value) == FAILURE)
      {
      return(FAILURE);
      } 
    }

  MNodeAdjustName(N->Name,1,tmpLName);

  if (strcmp(tmpSName,tmpLName))
    {
    /* search long names */

    ptr = MSched.ConfigBuffer;
 
    while (MCfgGetSVal(
             head,
             &ptr,
             MCredCfgParm[mxoNode],
             tmpLName,
             NULL,
             Value,
             sizeof(Value),
             0,
             NULL) != FAILURE)
      {
      /* node attribute located */
 
      /* FORMAT:  <ATTR>=<VALUE>[ <ATTR>=<VALUE>]... */
 
      if (MNodeProcessConfig(N,NULL,Value) == FAILURE)
        {
        return(FAILURE);
        }
      }
    }    /* END if (strcmp(tmpSName,tmpLName)) */

  return(SUCCESS);
  }  /* END MNodeLoadConfig() */