Пример #1
0
void *modify_array_work(

  void *vp)

  {
  batch_request *preq = (batch_request *)vp;
  svrattrl      *plist;
  int            rc = 0;
  char          *pcnt = NULL;
  char          *array_spec = NULL;
  int            checkpoint_req = FALSE;
  job           *pjob = NULL;
  job_array     *pa;

  pa = get_array(preq->rq_ind.rq_modify.rq_objname);

  if (pa == NULL)
    {
    req_reject(PBSE_UNKARRAYID, 0, preq, NULL, "unable to find array");
    return(NULL);
    }

  mutex_mgr array_mutex(pa->ai_mutex, true);

  /* pbs_mom sets the extend string to trigger copying of checkpoint files */
  if (preq->rq_extend != NULL)
    {
    if (strcmp(preq->rq_extend,CHECKPOINTHOLD) == 0)
      {
      checkpoint_req = CHK_HOLD;
      }
    else if (strcmp(preq->rq_extend,CHECKPOINTCONT) == 0)
      {
      checkpoint_req = CHK_CONT;
      }
    }

  /* find if an array range was specified */
  if ((preq->rq_extend != NULL) && 
      ((array_spec = strstr(preq->rq_extend,ARRAY_RANGE)) != NULL))
    {
    /* move array spec past ARRAY_RANGE= */
    char *equals = strchr(array_spec,'=');
    if (equals != NULL)
      {
      array_spec = equals + 1;
      }

    if ((pcnt = strchr(array_spec,'%')) != NULL)
      {
      int slot_limit = atoi(pcnt+1);
      pa->ai_qs.slot_limit = slot_limit;
      }
    }
  
  plist = (svrattrl *)GET_NEXT(preq->rq_ind.rq_modify.rq_attr);

  if ((array_spec != NULL) &&
      (pcnt != array_spec))
    {
    if (pcnt != NULL)
      *pcnt = '\0';

    /* there is more than just a slot given, modify that range */
    rc = modify_array_range(pa,array_spec,plist,preq,checkpoint_req);

    if (pcnt != NULL)
      *pcnt = '%';

    if ((rc != 0) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      req_reject(PBSE_IVALREQ,0,preq,NULL,"Error reading array range");
      return(NULL);
      }
    else
      reply_ack(preq);

    return(NULL);
    }
  else 
    {
    rc = modify_whole_array(pa,plist,preq,checkpoint_req);

    if ((rc != 0) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      req_reject(PBSE_IVALREQ, 0, preq, NULL, "At least one array element did not modify successfully. Use qstat -f to verify changes");
      return(NULL);
      }

    /* we modified the job array. We now need to update the job */
    if ((pjob = chk_job_request(preq->rq_ind.rq_modify.rq_objname, preq)) == NULL)
      return(NULL);

    mutex_mgr job_mutex = mutex_mgr(pjob->ji_mutex, true);

    /* modify_job will reply to preq and free it */
    modify_job((void **)&pjob, plist, preq, checkpoint_req, NO_MOM_RELAY);
    }

  return(NULL);
  } /* END modify_array_work() */
Пример #2
0
void *req_modifyarray(

  void *vp) /* I */

  {
  char                  log_buf[LOCAL_LOG_BUF_SIZE];
  job_array            *pa;
  job                  *pjob = NULL;
  svrattrl             *plist;
  int                   checkpoint_req = FALSE;
  char                 *array_spec = NULL;
  char                 *pcnt = NULL;
  int                   rc = 0;
  int                   rc2 = 0;
  struct batch_request *preq = (struct batch_request *)vp;

  pa = get_array(preq->rq_ind.rq_modify.rq_objname);

  if (pa == NULL)
    {
    req_reject(PBSE_UNKARRAYID, 0, preq, NULL, "unable to find array");
    return(NULL);
    }

  plist = (svrattrl *)GET_NEXT(preq->rq_ind.rq_modify.rq_attr);

  /* If async modify, reply now; otherwise reply is handled later */
  if (preq->rq_type == PBS_BATCH_AsyModifyJob)
    {
    reply_ack(preq);

    preq->rq_noreply = TRUE; /* set for no more replies */
    }

  /* pbs_mom sets the extend string to trigger copying of checkpoint files */

  if (preq->rq_extend != NULL)
    {
    if (strcmp(preq->rq_extend,CHECKPOINTHOLD) == 0)
      {
      checkpoint_req = CHK_HOLD;
      }
    else if (strcmp(preq->rq_extend,CHECKPOINTCONT) == 0)
      {
      checkpoint_req = CHK_CONT;
      }
    }

  /* find if an array range was specified */
  if ((preq->rq_extend != NULL) && 
      ((array_spec = strstr(preq->rq_extend,ARRAY_RANGE)) != NULL))
    {
    /* move array spec past ARRAY_RANGE= */
    char *equals = strchr(array_spec,'=');
    if (equals != NULL)
      {
      array_spec = equals + 1;
      }

    if ((pcnt = strchr(array_spec,'%')) != NULL)
      {
      int slot_limit = atoi(pcnt+1);
      pa->ai_qs.slot_limit = slot_limit;
      }
    }

  if ((array_spec != NULL) &&
      (pcnt != array_spec))
    {
    if (pcnt != NULL)
      *pcnt = '\0';

    /* there is more than just a slot given, modify that range */
    rc = modify_array_range(pa,array_spec,plist,preq,checkpoint_req);

    if ((rc != 0) && 
       (rc != PBSE_RELAYED_TO_MOM))
      {
      pthread_mutex_unlock(pa->ai_mutex);
      if (LOGLEVEL >= 7)
        {
        sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf);
        }

      req_reject(PBSE_IVALREQ,0,preq,NULL,"Error reading array range");
  
      return(NULL);
      }

    if (pcnt != NULL)
      *pcnt = '%';

    if (rc == PBSE_RELAYED_TO_MOM)
      {
      pthread_mutex_unlock(pa->ai_mutex);
      if (LOGLEVEL >= 7)
        {
        sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf);
        }

      return(NULL);
      }
    }
  else 
    {
    rc = modify_whole_array(pa,plist,preq,checkpoint_req);

    if ((rc != 0) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      pthread_mutex_unlock(pa->ai_mutex);
      if (LOGLEVEL >= 7)
        {
        sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf);
        }

      req_reject(PBSE_IVALREQ,0,preq,NULL,"Error altering the array");
      return(NULL);
      }

    /* we modified the job array. We now need to update the job */
    pjob = chk_job_request(preq->rq_ind.rq_modify.rq_objname, preq);
    rc2 = modify_job((void **)&pjob, plist, preq, checkpoint_req, NO_MOM_RELAY);

    if ((rc2) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      /* there are two operations going on that give a return code:
         one from modify_whole_array and one from modify_job_for_array.
         If either of these fail, return the error. This makes it
         so some elements fo the array will be updated but others are
         not. But at least the user will know something went wrong.*/
      pthread_mutex_unlock(pa->ai_mutex);
      if (LOGLEVEL >= 7)
        {
        sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buf);
        }
      unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);

      req_reject(rc,0,preq,NULL,NULL);
      return(NULL);
      }

    if (rc == PBSE_RELAYED_TO_MOM)
      {
      pthread_mutex_unlock(pa->ai_mutex);
      if (LOGLEVEL >= 7)
        {
        sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
        log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buf);
        }
      unlock_ji_mutex(pjob, __func__, "2", LOGLEVEL);
      
      return(NULL);
      }

    unlock_ji_mutex(pjob, __func__, "3", LOGLEVEL);
    }

  /* SUCCESS */
  if (LOGLEVEL >= 7)
    {
    sprintf(log_buf, "%s: unlocked ai_mutex", __func__);
    log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pa->ai_qs.parent_id, log_buf);
    }
  pthread_mutex_unlock(pa->ai_mutex);

  reply_ack(preq);

  return(NULL);
  } /* END req_modifyarray() */
Пример #3
0
void req_modifyarray(

  struct batch_request *preq)  /* I */

  {
  job_array *pa;
  job *pjob;
  svrattrl *plist;
  int   checkpoint_req = FALSE;
  char *array_spec = NULL;
  char *pcnt = NULL;
  int rc = 0, rc2 = 0;

  pa = get_array(preq->rq_ind.rq_modify.rq_objname);

  if (pa == NULL)
    {
    req_reject(PBSE_IVALREQ,0,preq,NULL,"Cannot find array");

    return;
    }

  plist = (svrattrl *)GET_NEXT(preq->rq_ind.rq_modify.rq_attr);

  /* If async modify, reply now; otherwise reply is handled later */
  if (preq->rq_type == PBS_BATCH_AsyModifyJob)
    {
    reply_ack(preq);

    preq->rq_noreply = TRUE; /* set for no more replies */
    }

  /* pbs_mom sets the extend string to trigger copying of checkpoint files */

  if (preq->rq_extend != NULL)
    {
    if (strcmp(preq->rq_extend,CHECKPOINTHOLD) == 0)
      {
      checkpoint_req = CHK_HOLD;
      }
    else if (strcmp(preq->rq_extend,CHECKPOINTCONT) == 0)
      {
      checkpoint_req = CHK_CONT;
      }
    }

  /* find if an array range was specified */
  if ((preq->rq_extend != NULL) && 
      ((array_spec = strstr(preq->rq_extend,ARRAY_RANGE)) != NULL))
    {
    /* move array spec past ARRAY_RANGE= */
    char *equals = strchr(array_spec,'=');
    if (equals != NULL)
      {
      array_spec = equals + 1;
      }

    if ((pcnt = strchr(array_spec,'%')) != NULL)
      {
      int slot_limit = atoi(pcnt+1);
      pa->ai_qs.slot_limit = slot_limit;
      }
    }

  if ((array_spec != NULL) &&
      (pcnt != array_spec))
    {
    if (pcnt != NULL)
      *pcnt = '\0';

    /* there is more than just a slot given, modify that range */
    rc = modify_array_range(pa,array_spec,plist,preq,checkpoint_req);

    if((rc != 0) && 
       (rc != PBSE_RELAYED_TO_MOM))
      {
      req_reject(PBSE_IVALREQ,0,preq,NULL,"Error reading array range");
  
      return;
      }

    if (pcnt != NULL)
      *pcnt = '%';

    if(rc == PBSE_RELAYED_TO_MOM)
      {
      return;
      }
    }
  else 
    {
    rc = modify_whole_array(pa,plist,preq,checkpoint_req);

    if ((rc != 0) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      req_reject(PBSE_IVALREQ,0,preq,NULL,"Error altering the array");
      return;
      }

    /* we modified the job array. We now need to update the job */
    pjob = chk_job_request(preq->rq_ind.rq_modify.rq_objname, preq);
    rc2 = modify_job(pjob,plist,preq,checkpoint_req, NO_MOM_RELAY);

    if ((rc2) && 
        (rc != PBSE_RELAYED_TO_MOM))
      {
      /* there are two operations going on that give a return code:
         one from modify_whole_array and one from modify_job_for_array.
         If either of these fail, return the error. This makes it
         so some elements fo the array will be updated but others are
         not. But at least the user will know something went wrong.*/
      req_reject(rc,0,preq,NULL,NULL);
      return;
      }

    if(rc == PBSE_RELAYED_TO_MOM)
      {
      return;
      }

    }

  /* SUCCESS */

  reply_ack(preq);

  } /* END req_modifyarray() */