예제 #1
0
/*
 * updates which path we're looking at
 */
node_comm_t *force_path_update(

    mom_hierarchy_t *nt)

{
    int    path;
    int    level;
    int    node;
    int    attempts = 0;
    int    updated  = FALSE;
    time_t time_now = time(NULL);

    if (nt->paths.size() > 1)
    {
        path = nt->paths.size() - 1;

        while ((path >= 0) &&
                (updated == FALSE))
        {
            mom_levels &levels = nt->paths.at(nt->paths.size() - 1);

            for (level = levels.size() - 1; level >= 0 && updated == FALSE; level--)
            {
                mom_nodes &node_comm_entries = levels.at(level);

                for (node = 0; node < (int)node_comm_entries.size(); node++)
                {
                    node_comm_t &nc = node_comm_entries.at(node);

                    if ((nc.bad == TRUE) &&
                            (time_now - nc.mtime <= mom_hierarchy_retry_time))
                        continue;

                    if (rm_establish_connection(nc) == PBSE_NONE)
                    {
                        /* SUCCESS, return the new node */
                        return(&nc);
                    }
                    else
                        attempts++;
                } /* END for each node comm point */

                /* exit to examine alternate paths if we're above NODE_COMM_MAX_ATTEMPTS */
                if (attempts > NODE_COMM_MAX_ATTEMPTS)
                    break;
            } /* END for each level */

            path--;
        } /* END for each path */
    }
    else
    {
        mom_levels &levels = nt->paths.at(nt->paths.size()-1);

        for (level = levels.size() - 1; level >= 0 && updated == FALSE; level--)
        {
            mom_nodes &node_comm_entries = levels.at(level);

            for (node = 0; node < (int)node_comm_entries.size(); node++)
            {
                node_comm_t &nc = node_comm_entries.at(node);

                if ((nc.bad == TRUE) &&
                        (time_now - nc.mtime <= mom_hierarchy_retry_time))
                    continue;

                if (rm_establish_connection(nc) == PBSE_NONE)
                {
                    /* SUCCESS, return the new node */
                    return(&nc);
                }
            } /* END for each node comm point */
        } /* END for each level */
    }

    /* if this ever happens the mom will go to the server */
    return(NULL);
} /* END force_path_update() */
예제 #2
0
/* 
 * updates which path we're looking at 
 */
node_comm_t *force_path_update(

  mom_hierarchy_t *nt)

  {
  int                 path;
  int                 level;
  int                 node;
  int                 attempts = 0;
  int                 updated  = FALSE;
  time_t              time_now = time(NULL);
 
  resizable_array    *levels;
  resizable_array    *node_comm_entries;
  node_comm_t        *nc;


  if (nt->paths->num > 1)
    {
    path = nt->paths->num-1;

    while ((path >= 0) &&
           (updated == FALSE))
      {
      levels = (resizable_array *)nt->paths->slots[nt->paths->num].item;
     
      for (level = levels->num - 1; level >= 0 && updated == FALSE; level--) 
        {
        node_comm_entries = (resizable_array *)levels->slots[level+1].item;
        
        for (node = 0; node < node_comm_entries->num; node++)
          {
          nc = (node_comm_t *)node_comm_entries->slots[node+1].item;

          if ((nc->bad == TRUE) &&
              (time_now - nc->mtime <= mom_hierarchy_retry_time))
            continue;

          if (rm_establish_connection(nc) == PBSE_NONE)
            {
            /* SUCCESS, return the new node */
            return(nc);
            }
          else
            attempts++;
          } /* END for each node comm point */

        /* exit to examine alternate paths if we're above NODE_COMM_MAX_ATTEMPTS */
        if (attempts > NODE_COMM_MAX_ATTEMPTS)
          break;
        } /* END for each level */

      path--;
      } /* END for each path */
    }
  else
    {
    levels = (resizable_array *)nt->paths->slots[nt->paths->num].item;

    for (level = levels->num - 1; level >= 0 && updated == FALSE; level--)
      {
      node_comm_entries = (resizable_array *)levels->slots[level+1].item;

      for (node = 0; node < node_comm_entries->num; node++)
        {
        nc = (node_comm_t *)node_comm_entries->slots[node+1].item;

        if ((nc->bad == TRUE) &&
            (time_now - nc->mtime <= mom_hierarchy_retry_time))
          continue;

        if (rm_establish_connection(nc) == PBSE_NONE)
          {
          /* SUCCESS, return the new node */
          return(nc);
          }
        } /* END for each node comm point */
      } /* END for each level */
    }

  /* if this ever happens the mom will go to the server */
  return(NULL);
  } /* END force_path_update() */