struct pbsnode *get_next_login_node( struct prop *needed) { struct pbsnode *pnode = NULL; login_node *ln; int node_fits = TRUE; pthread_mutex_lock(logins.ln_mutex); ln = (login_node *)logins.ra->slots[logins.next_node].item; if (ln != NULL) { pnode = ln->pnode; lock_node(pnode, __func__, NULL, LOGLEVEL); if (needed != NULL) { if (hasprop(pnode, needed) == FALSE) { node_fits = FALSE; } } /* must have at least one execution slot available */ if ((pnode->nd_nsn - pnode->nd_np_to_be_used < 1) || ((pnode->nd_state & INUSE_DOWN) != 0) || ((pnode->nd_state & INUSE_OFFLINE) != 0)) { node_fits = FALSE; } if (node_fits == FALSE) { unlock_node(pnode, __func__, NULL, LOGLEVEL); pnode = find_fitting_node(needed); } else { ln->times_used++; update_next_node_index(ln->times_used); } } pthread_mutex_unlock(logins.ln_mutex); return(pnode); } /* END get_next_login_node() */
struct pbsnode *get_next_login_node( struct prop *needed) { struct pbsnode *pnode = NULL; int node_fits = TRUE; pthread_mutex_lock(logins.ln_mutex); login_node &ln = logins.nodes[logins.next_node]; pnode = ln.pnode; lock_node(pnode, __func__, NULL, LOGLEVEL); if (needed != NULL) { if (hasprop(pnode, needed) == FALSE) { node_fits = FALSE; } } /* must have at least one execution slot available */ if ((pnode->nd_slots.get_total_execution_slots() - pnode->nd_np_to_be_used < 1) || ((pnode->nd_state & INUSE_NOT_READY) != 0) || ((pnode->nd_state & INUSE_OFFLINE) != 0) || (pnode->nd_power_state != POWER_STATE_RUNNING)) { node_fits = FALSE; } if (node_fits == FALSE) { unlock_node(pnode, __func__, NULL, LOGLEVEL); pnode = find_fitting_node(needed); } else { ln.times_used++; update_next_node_index(ln.times_used); } pthread_mutex_unlock(logins.ln_mutex); return(pnode); } /* END get_next_login_node() */
struct pbsnode *check_node( login_node *ln, struct prop *needed) { struct pbsnode *pnode = ln->pnode; lock_node(pnode, __func__, NULL, LOGLEVEL); if ((hasprop(pnode, needed) == TRUE) && (pnode->nd_nsn - pnode->nd_np_to_be_used >= 1) && ((pnode->nd_state & INUSE_DOWN) == 0) && ((pnode->nd_state & INUSE_OFFLINE) == 0)) return(pnode); else { unlock_node(pnode, __func__, NULL, LOGLEVEL); return(NULL); } } /* END check_node() */
/* * check_node() * * @return a pointer to the node if it is valid to be used * @param ln - a pointer to the login node struct containing the * node that should be checked * @pre-cond - ln must be a pointer to a valid login node struct * @param needed - an optional pointer to the required properties for * the login node to have. */ struct pbsnode *check_node( login_node *ln, struct prop *needed) { struct pbsnode *pnode = ln->pnode; lock_node(pnode, __func__, NULL, LOGLEVEL); if ((hasprop(pnode, needed) == TRUE) && (pnode->nd_slots.get_number_free() - pnode->nd_np_to_be_used >= 1) && ((pnode->nd_state & INUSE_NOT_READY) == 0) && ((pnode->nd_state & INUSE_OFFLINE) == 0) && (pnode->nd_power_state == POWER_STATE_RUNNING)) return(pnode); else { unlock_node(pnode, __func__, NULL, LOGLEVEL); return(NULL); } } /* END check_node() */
int req_stat_node( struct batch_request *preq) { char *name; int rc = PBSE_NONE; int type = 0; int bad = 0; struct pbsnode *pnode = NULL; struct batch_reply *preply; struct prop props; svrattrl *pal; /* * first, check that the server indeed has a list of nodes * and if it does, validate the name of the requested object-- * either name is that of a specific node, or name[0] is null/@ * meaning request is for all nodes in the server's jurisdiction */ if (LOGLEVEL >= 6) { log_record( PBSEVENT_SCHED, PBS_EVENTCLASS_REQUEST, __func__, "entered"); } if (svr_totnodes <= 0) { rc = PBSE_NONODES; req_reject(rc, 0, preq, NULL, "node list is empty - check 'server_priv/nodes' file"); return rc; } name = preq->rq_ind.rq_status.rq_id; if ((*name == '\0') || (*name == '@')) { type = 1; } else if ((*name == ':') && (*(name + 1) != '\0')) { if (!strcmp(name + 1, "ALL")) { type = 1; /* psuedo-group for all nodes */ } else { type = 2; props.name = name + 1; props.mark = 1; props.next = NULL; } } preply = &preq->rq_reply; preply->brp_choice = BATCH_REPLY_CHOICE_Status; CLEAR_HEAD(preply->brp_un.brp_status); if (type == 0) { /* get status of the named node */ pnode = find_nodebyname(name); if (pnode == NULL) { rc = PBSE_UNKNODE; req_reject(rc, 0, preq, NULL, "cannot locate specified node"); return(rc); } /* get the status on all of the numa nodes */ if (pnode->nd_is_alps_reporter == TRUE) rc = get_alps_statuses(pnode, preq, &bad, &preply->brp_un.brp_status); else rc = get_numa_statuses(pnode, preq, &bad, &preply->brp_un.brp_status); unlock_node(pnode, __func__, "type == 0", LOGLEVEL); } else { /* get status of all or several nodes */ all_nodes_iterator *iter = NULL; while ((pnode = next_host(&allnodes,&iter,NULL)) != NULL) { if ((type == 2) && (!hasprop(pnode, &props))) { unlock_node(pnode, __func__, "type != 0, next_host", LOGLEVEL); continue; } /* get the status on all of the numa nodes */ if (pnode->nd_is_alps_reporter == TRUE) rc = get_alps_statuses(pnode, preq, &bad, &preply->brp_un.brp_status); else rc = get_numa_statuses(pnode, preq, &bad, &preply->brp_un.brp_status); if (rc != PBSE_NONE) { unlock_node(pnode, __func__, "type != 0, rc != 0, get_numa_statuses", LOGLEVEL); break; } unlock_node(pnode, __func__, "type != 0, rc == 0, get_numa_statuses", LOGLEVEL); } if (iter != NULL) delete iter; } if (rc == PBSE_NONE) { /* SUCCESS */ reply_send_svr(preq); } else { if (rc != PBSE_UNKNODEATR) { req_reject(rc, 0, preq, NULL, NULL); } else { pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); reply_badattr(rc, bad, pal, preq); } } return(rc); } /* END req_stat_node() */
void req_stat_node( struct batch_request *preq) /* ptr to the decoded request */ { char *name; struct pbsnode *pnode = NULL; struct batch_reply *preply; svrattrl *pal; int rc = 0; int type = 0; int i; struct prop props; char *id = "req_stat_node"; /* * first, check that the server indeed has a list of nodes * and if it does, validate the name of the requested object-- * either name is that of a specific node, or name[0] is null/@ * meaning request is for all nodes in the server's jurisdiction */ if (LOGLEVEL >= 6) { log_record( PBSEVENT_SCHED, PBS_EVENTCLASS_REQUEST, id, "entered"); } if ((pbsndmast == NULL) || (svr_totnodes <= 0)) { req_reject(PBSE_NONODES, 0, preq, NULL, "node list is empty - check 'server_priv/nodes' file"); return; } name = preq->rq_ind.rq_status.rq_id; if ((*name == '\0') || (*name == '@')) { type = 1; } else if ((*name == ':') && (*(name + 1) != '\0')) { if (!strcmp(name + 1, "ALL")) { type = 1; /* psuedo-group for all nodes */ } else { type = 2; props.name = name + 1; props.mark = 1; props.next = NULL; } } else { pnode = find_nodebyname(name); if (pnode == NULL) { req_reject(PBSE_UNKNODE, 0, preq, NULL, "cannot locate specified node"); return; } } preply = &preq->rq_reply; preply->brp_choice = BATCH_REPLY_CHOICE_Status; CLEAR_HEAD(preply->brp_un.brp_status); if (type == 0) { /* get status of the named node */ rc = status_node(pnode, preq, &preply->brp_un.brp_status); } else { /* get status of all or several nodes */ for (i = 0;i < svr_totnodes;i++) { pnode = pbsndmast[i]; if ((type == 2) && !hasprop(pnode, &props)) continue; if ((rc = status_node(pnode, preq, &preply->brp_un.brp_status)) != 0) break; } } if (!rc) { /* SUCCESS */ reply_send(preq); } else { if (rc != PBSE_UNKNODEATR) { req_reject(rc, 0, preq, NULL, NULL); } else { pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); reply_badattr(rc, bad, pal, preq); } } return; } /* END req_stat_node() */