예제 #1
0
job *find_array_template(
    
  char *arrayid)

  {
  char *at;
  char *comp;
  int   different = FALSE;
  int   iter = -1;

  job  *pj;

  if ((at = strchr(arrayid, (int)'@')) != NULL)
    * at = '\0'; /* strip off @server_name */

  if ((is_svr_attr_set(SRV_ATR_display_job_server_suffix) == TRUE) ||
      (is_svr_attr_set(SRV_ATR_job_suffix_alias) == TRUE))
    {
    comp = get_correct_jobname(arrayid);
    different = TRUE;

    if (comp == NULL)
      return NULL;
    }
  else
    {
    comp = arrayid;
    }

  while ((pj = next_job(&array_summary,&iter)) != NULL)
    {
    if (!strcmp(comp, pj->ji_qs.ji_jobid))
      break;

    unlock_ji_mutex(pj, __func__, NULL, LOGLEVEL);
    }

  if (at)
    *at = '@'; /* restore @server_name */

  if (different)
    free(comp);

  return(pj);  /* may be NULL */
  }   /* END find_array_template() */
예제 #2
0
job *find_array_template(char *arrayid)
  {
  char *at;
  char *comp;
  int   different = FALSE;

  job  *pj;

  if ((at = strchr(arrayid, (int)'@')) != NULL)
    * at = '\0'; /* strip off @server_name */

  pj = (job *)GET_NEXT(svr_jobs_array_sum);

  if ((server.sv_attr[SRV_ATR_display_job_server_suffix].at_flags & ATR_VFLAG_SET) ||
      (server.sv_attr[SRV_ATR_job_suffix_alias].at_flags & ATR_VFLAG_SET))
    {
    comp = get_correct_jobname(arrayid);
    different = TRUE;

    if (comp == NULL)
      return NULL;
    }
  else
    {
    comp = arrayid;
    }

  while (pj != NULL)
    {
    if (!strcmp(comp, pj->ji_qs.ji_jobid))
      break;

    pj = (job *)GET_NEXT(pj->ji_jobs_array_sum);
    }

  if (at)
    *at = '@'; /* restore @server_name */

  if (different)
    free(comp);

  return(pj);  /* may be NULL */
  }   /* END find_job() */
예제 #3
0
job *svr_find_job(

  const char *jobid,      /* I */
  int         get_subjob) /* I */

  {
  char *at;
  char *comp = NULL;
  int   different = FALSE;
  char *dash = NULL;
  char *dot = NULL;
  char  without_dash[PBS_MAXSVRJOBID + 1];
  char  work_jobid[PBS_MAXSVRJOBID + 1];
  char *jid_ptr = NULL;

  job  *pj = NULL;

  if (NULL == jobid)
    {
    log_err(-1,__func__,"jobid is null");
    return NULL;
    }

  if (LOGLEVEL >= 10)
    LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, jobid);

  snprintf(work_jobid, sizeof(work_jobid), "%s", jobid);

  if ((at = strchr(work_jobid, '@')) != NULL)
    *at = '\0'; /* strip off @server_name */

  /* jobid-0.server indicates the external sub-job of a heterogeneous
   * job. For this case we want to get jobid.server, find that, and 
   * the get the external sub-job */
  if (get_subjob == TRUE)
    {
    dot = strchr(work_jobid, '.');

    if (((dash = strchr(work_jobid, '-')) != NULL) &&
        (dot != NULL) &&
        (dash < dot))
      {
      *dash = '\0';
      snprintf(without_dash, sizeof(without_dash), "%s%s", work_jobid, dash + 2);
      jid_ptr = without_dash;
      }
    else
      {
      dash = NULL;
      jid_ptr = work_jobid;
      }
    }
  else
    jid_ptr = work_jobid;

  if ((is_svr_attr_set(SRV_ATR_display_job_server_suffix)) ||
      (is_svr_attr_set(SRV_ATR_job_suffix_alias)))
    {
    comp = get_correct_jobname(jid_ptr);
    different = TRUE;

    if (comp == NULL)
      return(NULL);
    }
  else
    {
    comp = jid_ptr;
    }

  if (strstr(jid_ptr,"[]") == NULL)
    {
    /* if we're searching for the external we want find_job_by_array to 
     * return the parent, but if we're searching for the cray subjob then
     * we want find_job_by_array to return the sub job */
    pj = find_job_by_array(&alljobs, comp, (dash != NULL) ? FALSE : get_subjob, false);
    }

  /* when remotely routing jobs, they are removed from the 
   * regular job list first and the array summary after. 
   * Attempt to find them there if NULL
   * OR it's an array, try to find the job */
  if (pj == NULL)
    {
    /* see the comment on the above call to find_job_by_array() */
    pj = find_job_by_array(&array_summary, comp, (dash != NULL) ? FALSE : get_subjob, false);
    }

  if (at)
    *at = '@'; /* restore @server_name */

  if ((get_subjob == TRUE) &&
      (pj != NULL))
    {
    if (dash != NULL)
      {
      *dash = '-';
      
      if (pj->ji_external_clone != NULL)
        {
        pj = pj->ji_external_clone;
        
        lock_ji_mutex(pj, __func__, NULL, LOGLEVEL);
        unlock_ji_mutex(pj->ji_parent_job, __func__, NULL, LOGLEVEL);

        if (pj->ji_being_recycled == TRUE)
          {
          unlock_ji_mutex(pj, __func__, NULL, LOGLEVEL);
          pj = NULL;
          }
        }
      else
        {
        unlock_ji_mutex(pj, __func__, NULL, LOGLEVEL);
        pj = NULL;
        }
      }
    }

  if (different)
    free(comp);

  return(pj);  /* may be NULL */
  }   /* END svr_find_job() */