Exemplo n.º 1
0
int set_proc_ct(

  resource      *pprocsp,  /* I */
  pbs_attribute *pattr,    /* I */
  int            actmode)  /* I */

  {
  resource *pnodesp;
  resource_def *pndef;
  resource *ppct;
  resource_def *ppdef;

  if (actmode == ATR_ACTION_RECOV)
    {
    /* SUCCESS */

    return(0);
    }

  /* set "procct" to count of processors in "nodes" plus "procs" */

  ppdef = find_resc_def(svr_resc_def, "procct", svr_resc_size);

  if (ppdef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((ppct = find_resc_entry(pattr, ppdef)) == NULL)
    {
    if ((ppct = add_resource_entry(pattr, ppdef)) == 0)
      {
      return(PBSE_SYSTEM);
      }
    }

  pndef = find_resc_def(svr_resc_def, "nodes", svr_resc_size);
  if (pndef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pnodesp = find_resc_entry(pattr, pndef)) == NULL)
    {
    ppct->rs_value.at_val.at_long =
      pprocsp->rs_value.at_val.at_long;
    }
  else
    {
    ppct->rs_value.at_val.at_long =
      pprocsp->rs_value.at_val.at_long;

    count_proc(pnodesp->rs_value.at_val.at_str);
    }

  ppct->rs_value.at_flags |= ATR_VFLAG_SET;

  return(0);
  }  /* END set_proc_ct() */
Exemplo n.º 2
0
/* int initialize_procct - set pjob->procct plus the resource
 * procct in the Resource_List
 *
 * Assumes the nodes resource has been set on the Resource_List. This should
 * have been done in req_quejob with the set_nodes_attr() function or in
 * set_node_ct and/or set_proc_ct.
 *
 * Returns 0 on success. Non-zero on failure
 */
int initialize_procct(job *pjob)
{
    char id[] = "initialize_procct";
    resource     *pnodesp = NULL;
    resource_def *pnodes_def = NULL;
    resource     *pprocsp = NULL;
    resource_def *pprocs_def = NULL;
    resource     *procctp = NULL;
    resource_def *procct_def = NULL;
    pbs_attribute    *pattr = NULL;

    pattr = &pjob->ji_wattr[JOB_ATR_resource];
    if(pattr == NULL)
    {
        /* Something is really wrong. ji_wattr[JOB_ATR_resource] should always be set
           by the time this function is called */
        sprintf(log_buffer, "%s: Resource_List is NULL. Cannot proceed", id);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
        pbs_errno = PBSE_INTERNAL;
        return(ROUTE_PERM_FAILURE);
    }

    /* Has nodes been initialzed */
    if(pattr->at_flags & ATR_VFLAG_SET)
    {
        /* get the node spec from the nodes resource */
        pnodes_def = find_resc_def(svr_resc_def, "nodes", svr_resc_size);
        if(pnodes_def == NULL)
        {
            sprintf(log_buffer, "%s: Could not get nodes resource definition. Cannot proceed", id);
            log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
            pbs_errno = PBSE_INTERNAL;
            return(ROUTE_PERM_FAILURE);
        }
        pnodesp = find_resc_entry(pattr, pnodes_def);

        /* Get the procs count if the procs resource attribute is set */
        pprocs_def = find_resc_def(svr_resc_def, "procs", svr_resc_size);
        if(pprocs_def != NULL)
        {
            /* if pprocs_def is NULL we just go on. Otherwise we will get its value now */
            pprocsp = find_resc_entry(pattr, pprocs_def);
            /* We will evaluate pprocsp later. If it is null we do not care */
        }

        /* if neither pnodesp nor pprocsp are set, terminate */
        if(pnodesp == NULL && pprocsp == NULL)
        {
            /* nodes and procs were not set. Hopefully req_quejob set procct to 1 for us already */
            procct_def = find_resc_def(svr_resc_def, "procct", svr_resc_size);
            if(procct_def == NULL)
            {
                sprintf(log_buffer, "%s: Could not get procct resource definition. Cannot proceed", id);
                log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
                pbs_errno = PBSE_INTERNAL;
                return(ROUTE_PERM_FAILURE);
            }
            procctp = find_resc_entry(pattr, procct_def);
            if(procctp == NULL)
            {
                sprintf(log_buffer, "%s: Could not get nodes nor procs entry from Resource_List. Cannot proceed", id);
                log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
                pbs_errno = PBSE_INTERNAL;
                return(ROUTE_PERM_FAILURE);
            }
        }

        /* we now set pjob->procct and we also set the resource attribute procct */
        procct_def = find_resc_def(svr_resc_def, "procct", svr_resc_size);
        if(procct_def == NULL)
        {
            sprintf(log_buffer, "%s: Could not get procct resource definition. Cannot proceed", id);
            log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
            pbs_errno = PBSE_INTERNAL;
            return(ROUTE_PERM_FAILURE);
        }
        procctp = find_resc_entry(pattr, procct_def);
        if(procctp == NULL)
        {
            procctp = add_resource_entry(pattr, procct_def);
            if(procctp == NULL)
            {
                sprintf(log_buffer, "%s: Could not add procct resource. Cannot proceed", id);
                log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
                pbs_errno = PBSE_INTERNAL;
                return(ROUTE_PERM_FAILURE);
            }
        }

        /* Finally the moment of truth. We have the nodes and procs resources. Add them
           to the procct resoruce*/
        procctp->rs_value.at_val.at_long = 0;
        if(pnodesp != NULL)
        {
            procctp->rs_value.at_val.at_long = count_proc(pnodesp->rs_value.at_val.at_str);
        }

        if(pprocsp != NULL)
        {
            procctp->rs_value.at_val.at_long += pprocsp->rs_value.at_val.at_long;
        }
        procctp->rs_value.at_flags |= ATR_VFLAG_SET;
    }
    else
    {
        /* Something is really wrong. ji_wattr[JOB_ATR_resource] should always be set
           by the time this function is called */
        sprintf(log_buffer, "%s: Resource_List not set. Cannot proceed", id);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer);
        pbs_errno = PBSE_INTERNAL;
        return(ROUTE_PERM_FAILURE);
    }

    return(PBSE_NONE);
} /* END initialize_procct */
Exemplo n.º 3
0
int set_node_ct(

  resource      *pnodesp,  /* I */
  pbs_attribute *pattr,    /* I */
  int            actmode)  /* I */

  {
  resource *pnct;
  resource_def *pndef;
  resource *ppct = NULL;
  resource_def *ppdef;
  resource *pprocsp;
  resource_def *pprocsdef;

  if (actmode == ATR_ACTION_RECOV)
    {
    /* SUCCESS */

    return(0);
    }

  /* Set "nodect" to count of nodes in "nodes" */

  pndef = find_resc_def(svr_resc_def, "nodect", svr_resc_size);

  if (pndef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pnct = find_resc_entry(pattr, pndef)) == NULL)
    {
    if ((pnct = add_resource_entry(pattr, pndef)) == NULL)
      {
      return(PBSE_SYSTEM);
      }
    }

  pnct->rs_value.at_val.at_long = ctnodes(pnodesp->rs_value.at_val.at_str);

  pnct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* Set "neednodes" to "nodes", may be altered by scheduler */

  pndef = find_resc_def(svr_resc_def, "neednodes", svr_resc_size);

  if (pndef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pnct = find_resc_entry(pattr, pndef)) == NULL)
    {
    if ((pnct = add_resource_entry(pattr, pndef)) == NULL)
      {
      return(PBSE_SYSTEM);
      }
    }
  else
    {
    pndef->rs_free(&pnct->rs_value);
    }

  pndef->rs_decode(&pnct->rs_value, NULL, NULL, pnodesp->rs_value.at_val.at_str, ATR_DFLAG_ACCESS);

  pnct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* SUCCESS nodect */

  /* set "procct" to count of processors in "nodes" plus "procs" */

  ppdef = find_resc_def(svr_resc_def, "procct", svr_resc_size);

  if (ppdef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((ppct = find_resc_entry(pattr, ppdef)) == NULL)
    {
    if ((ppct = add_resource_entry(pattr, ppdef)) == 0)
      {
      return(PBSE_SYSTEM);
      }
    }

  pprocsdef = find_resc_def(svr_resc_def, "procs", svr_resc_size);
  if (pprocsdef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pprocsp = find_resc_entry(pattr, pprocsdef)) == NULL)
    {
    ppct->rs_value.at_val.at_long = count_proc(pnodesp->rs_value.at_val.at_str);
    }
  else
    { 
    ppct->rs_value.at_val.at_long = pprocsp->rs_value.at_val.at_long;
    ppct->rs_value.at_val.at_long += count_proc(pnodesp->rs_value.at_val.at_str);
    }

  ppct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* SUCCESS procct */

  return(0);
  }  /* END set_node_ct() */
Exemplo n.º 4
0
int set_node_ct(

  resource      *pnodesp,  /* I */
  pbs_attribute *pattr,    /* I */
  int            actmode)  /* I */

  {
  resource *pnct;
  resource_def *pndef;
  resource *ppct = NULL;
  resource_def *ppdef;
  resource *pprocsp;
  resource_def *pprocsdef;

  if (actmode == ATR_ACTION_RECOV)
    {
    /* SUCCESS */

    return(0);
    }
  
  // WARNING: we are potentially re-sizing the vector in the calls to add_resource_entry()
  // below. All attempts to use pnodesp after the calls to add_resource_entry may be using an
  // invalid pointer, so copy data here
  std::string nodes_val(pnodesp->rs_value.at_val.at_str);

  /* Set "nodect" to count of nodes in "nodes" */

  pndef = find_resc_def(svr_resc_def, "nodect", svr_resc_size);

  if (pndef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pnct = find_resc_entry(pattr, pndef)) == NULL)
    {
    if ((pnct = add_resource_entry(pattr, pndef)) == NULL)
      {
      return(PBSE_SYSTEM);
      }
    }

  pnct->rs_value.at_val.at_long = ctnodes(nodes_val.c_str());

  pnct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* Set "neednodes" to "nodes", may be altered by scheduler */

  pndef = find_resc_def(svr_resc_def, "neednodes", svr_resc_size);

  if (pndef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pnct = find_resc_entry(pattr, pndef)) == NULL)
    {
    if ((pnct = add_resource_entry(pattr, pndef)) == NULL)
      {
      return(PBSE_SYSTEM);
      }
    }
  else
    {
    pndef->rs_free(&pnct->rs_value);
    }

  pndef->rs_decode(&pnct->rs_value, NULL, NULL, nodes_val.c_str(), ATR_DFLAG_ACCESS);

  pnct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* SUCCESS nodect */

  /* set "procct" to count of processors in "nodes" plus "procs" */

  ppdef = find_resc_def(svr_resc_def, "procct", svr_resc_size);

  if (ppdef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((ppct = find_resc_entry(pattr, ppdef)) == NULL)
    {
    if ((ppct = add_resource_entry(pattr, ppdef)) == 0)
      {
      return(PBSE_SYSTEM);
      }
    }

  pprocsdef = find_resc_def(svr_resc_def, "procs", svr_resc_size);
  if (pprocsdef == NULL)
    {
    return(PBSE_SYSTEM);
    }

  if ((pprocsp = find_resc_entry(pattr, pprocsdef)) == NULL)
    {
    ppct->rs_value.at_val.at_long = count_proc(nodes_val.c_str());
    }
  else
    { 
    ppct->rs_value.at_val.at_long = pprocsp->rs_value.at_val.at_long;
    ppct->rs_value.at_val.at_long += count_proc(nodes_val.c_str());
    }

  ppct->rs_value.at_flags |= ATR_VFLAG_SET;

  /* SUCCESS procct */

  return(0);
  }  /* END set_node_ct() */