IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 25, 2010, 12:50:29 PM (16 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20100823

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/MachineOps.c

    r26521 r29540  
    11# include "pcontrol.h"
     2# define DEBUG 0
    23
    34static int MAX_UNWANTED_HOST_JOBS = 5;
     
    107108int AddMachineJob (Host *host, Job *job) {
    108109
     110  int i;
    109111  Machine *machine;
    110112
     
    114116  machine[0].NjobsRealhost ++;
    115117
    116   // skip jobs that do not have a targeted host
    117   if (job[0].hostname == NULL) {
    118     return (TRUE);
     118  // skip jobs that do not have a targeted host or any xhosts
     119  if (!job[0].hostname && !job[0].Nxhosts) {
     120    return (TRUE);
     121  }
     122
     123  for (i = 0; i < job[0].Nxhosts; i++) {
     124    // find machine matching the xhost name (these count against the unwanted host total)
     125    machine = FindMachineByName (job[0].xhosts[i]); // Can this fail?
     126    if (!machine) continue;
     127    machine[0].NjobsWanthost ++;
    119128  }
    120129
     
    134143int DelMachineJob (Host *host, Job *job) {
    135144
     145  int i;
    136146  Machine *machine;
    137147
     
    141151  machine[0].NjobsRealhost --;
    142152
    143   // skip jobs that do not have a targeted host
    144   if (job[0].hostname == NULL) {
    145     return (TRUE);
     153  // skip jobs that do not have a targeted host or any xhosts
     154  if (!job[0].hostname && !job[0].Nxhosts) {
     155    return (TRUE);
     156  }
     157
     158  for (i = 0; i < job[0].Nxhosts; i++) {
     159    // find machine matching the xhost name (these count against the unwanted host total)
     160    machine = FindMachineByName (job[0].xhosts[i]); // Can this fail?
     161    if (!machine) continue;
     162    machine[0].NjobsWanthost --;
    146163  }
    147164
     
    175192int CheckMachineJobs (Host *host, Job *job) {
    176193
     194  int i;
    177195  Machine *machine;
    178196
    179197  machine = FindMachineByName (job[0].hostname);
    180   if (machine == NULL) return (TRUE);
    181   // fprintf (stderr, "wanthost: %s, Ntotal: %d, Nmax: %d\n", job[0].hostname, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS);
    182   // if (machine[0].NjobsWanthost + machine[0].NjobsRealhost >= machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS) {
    183   if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) {
    184     // fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", job[0].hostname, job[0].argv[0]);
    185     return (FALSE);
    186   }
     198  if (machine) {
     199    if (DEBUG) fprintf (stderr, "wanthost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS);
     200    if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) {
     201      if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]);
     202      return (FALSE);
     203    }
     204  }
     205
     206  for (i = 0; i < job[0].Nxhosts; i++) {
     207    machine = FindMachineByName (job[0].xhosts[i]);
     208    if (machine) {
     209      if (DEBUG) fprintf (stderr, "xhost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS);
     210      if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) {
     211        if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]);
     212        return (FALSE);
     213      }
     214    }
     215  }   
    187216
    188217  machine = FindMachineByName (host[0].hostname);
    189   // fprintf (stderr, "realhost: %s, Ntotal: %d, Nmax: %d\n", host[0].hostname, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS);
    190   if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) {
    191     // fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", job[0].hostname, job[0].argv[0]);
    192     return (FALSE);
    193   }
     218  if (machine) {
     219    if (DEBUG) fprintf (stderr, "realhost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS);
     220    if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) {
     221      if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]);
     222      return (FALSE);
     223    }
     224  }
     225
    194226  return (TRUE);
    195227}
Note: See TracChangeset for help on using the changeset viewer.