/* * _query_server - download the current server state * part_pptr IN/OUT - partition information message * node_pptr IN/OUT - node information message * block_pptr IN/OUT - BlueGene block data * reserv_pptr IN/OUT - reservation information message * clear_old IN - If set, then always replace old data, needed when going * between clusters. * RET zero or error code */ static int _query_server(partition_info_msg_t ** part_pptr, node_info_msg_t ** node_pptr, block_info_msg_t ** block_pptr, reserve_info_msg_t ** reserv_pptr, bool clear_old) { static partition_info_msg_t *old_part_ptr = NULL, *new_part_ptr; static node_info_msg_t *old_node_ptr = NULL, *new_node_ptr; static block_info_msg_t *old_bg_ptr = NULL, *new_bg_ptr; static reserve_info_msg_t *old_resv_ptr = NULL, *new_resv_ptr; int error_code; uint16_t show_flags = 0; int cc; node_info_t *node_ptr; if (params.all_flag) show_flags |= SHOW_ALL; if (old_part_ptr) { if (clear_old) old_part_ptr->last_update = 0; error_code = slurm_load_partitions(old_part_ptr->last_update, &new_part_ptr, show_flags); if (error_code == SLURM_SUCCESS) slurm_free_partition_info_msg(old_part_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_part_ptr = old_part_ptr; } } else { error_code = slurm_load_partitions((time_t) NULL, &new_part_ptr, show_flags); } if (error_code) { slurm_perror("slurm_load_partitions"); return error_code; } old_part_ptr = new_part_ptr; *part_pptr = new_part_ptr; if (old_node_ptr) { if (clear_old) old_node_ptr->last_update = 0; if (params.node_name_single) { error_code = slurm_load_node_single(&new_node_ptr, params.nodes, show_flags); } else { error_code = slurm_load_node(old_node_ptr->last_update, &new_node_ptr, show_flags); } if (error_code == SLURM_SUCCESS) slurm_free_node_info_msg(old_node_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_node_ptr = old_node_ptr; } } else if (params.node_name_single) { error_code = slurm_load_node_single(&new_node_ptr, params.nodes, show_flags); } else { error_code = slurm_load_node((time_t) NULL, &new_node_ptr, show_flags); } if (error_code) { slurm_perror("slurm_load_node"); return error_code; } old_node_ptr = new_node_ptr; *node_pptr = new_node_ptr; /* Set the node state as NODE_STATE_MIXED. */ for (cc = 0; cc < new_node_ptr->record_count; cc++) { node_ptr = &(new_node_ptr->node_array[cc]); if (IS_NODE_DRAIN(node_ptr)) { /* don't worry about mixed since the * whole node is being drained. */ } else { uint16_t alloc_cpus = 0, err_cpus = 0, idle_cpus; int single_node_cpus = (node_ptr->cpus / g_node_scaling); select_g_select_nodeinfo_get(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); if (params.cluster_flags & CLUSTER_FLAG_BG) { if (!alloc_cpus && (IS_NODE_ALLOCATED(node_ptr) || IS_NODE_COMPLETING(node_ptr))) alloc_cpus = node_ptr->cpus; else alloc_cpus *= single_node_cpus; } idle_cpus = node_ptr->cpus - alloc_cpus; select_g_select_nodeinfo_get(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); if (params.cluster_flags & CLUSTER_FLAG_BG) err_cpus *= single_node_cpus; idle_cpus -= err_cpus; if ((alloc_cpus && err_cpus) || (idle_cpus && (idle_cpus != node_ptr->cpus))) { node_ptr->node_state &= NODE_STATE_FLAGS; node_ptr->node_state |= NODE_STATE_MIXED; } } } if (old_resv_ptr) { if (clear_old) old_resv_ptr->last_update = 0; error_code = slurm_load_reservations(old_resv_ptr->last_update, &new_resv_ptr); if (error_code == SLURM_SUCCESS) slurm_free_reservation_info_msg(old_resv_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_resv_ptr = old_resv_ptr; } } else { error_code = slurm_load_reservations((time_t) NULL, &new_resv_ptr); } if (error_code) { slurm_perror("slurm_load_reservations"); return error_code; } old_resv_ptr = new_resv_ptr; *reserv_pptr = new_resv_ptr; if (!params.bg_flag) return SLURM_SUCCESS; if (params.cluster_flags & CLUSTER_FLAG_BG) { if (old_bg_ptr) { if (clear_old) old_bg_ptr->last_update = 0; error_code = slurm_load_block_info( old_bg_ptr->last_update, &new_bg_ptr, show_flags); if (error_code == SLURM_SUCCESS) slurm_free_block_info_msg(old_bg_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_bg_ptr = old_bg_ptr; } } else { error_code = slurm_load_block_info((time_t) NULL, &new_bg_ptr, show_flags); } } if (error_code) { slurm_perror("slurm_load_block"); return error_code; } old_bg_ptr = new_bg_ptr; *block_pptr = new_bg_ptr; return SLURM_SUCCESS; }
/* * _query_server - download the current server state * part_pptr IN/OUT - partition information message * node_pptr IN/OUT - node information message * block_pptr IN/OUT - BlueGene block data * reserv_pptr IN/OUT - reservation information message * clear_old IN - If set, then always replace old data, needed when going * between clusters. * RET zero or error code */ static int _query_server(partition_info_msg_t ** part_pptr, node_info_msg_t ** node_pptr, block_info_msg_t ** block_pptr, reserve_info_msg_t ** reserv_pptr, bool clear_old) { static partition_info_msg_t *old_part_ptr = NULL, *new_part_ptr; static node_info_msg_t *old_node_ptr = NULL, *new_node_ptr; static block_info_msg_t *old_bg_ptr = NULL, *new_bg_ptr; static reserve_info_msg_t *old_resv_ptr = NULL, *new_resv_ptr; int error_code; uint16_t show_flags = 0; if (params.all_flag) show_flags |= SHOW_ALL; if (old_part_ptr) { if (clear_old) old_part_ptr->last_update = 0; error_code = slurm_load_partitions(old_part_ptr->last_update, &new_part_ptr, show_flags); if (error_code == SLURM_SUCCESS) slurm_free_partition_info_msg(old_part_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_part_ptr = old_part_ptr; } } else { error_code = slurm_load_partitions((time_t) NULL, &new_part_ptr, show_flags); } if (error_code) { slurm_perror("slurm_load_partitions"); return error_code; } old_part_ptr = new_part_ptr; *part_pptr = new_part_ptr; if (old_node_ptr) { if (clear_old) old_node_ptr->last_update = 0; if (params.node_name_single) { error_code = slurm_load_node_single(&new_node_ptr, params.nodes, show_flags); } else { error_code = slurm_load_node(old_node_ptr->last_update, &new_node_ptr, show_flags); } if (error_code == SLURM_SUCCESS) slurm_free_node_info_msg(old_node_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_node_ptr = old_node_ptr; } } else if (params.node_name_single) { error_code = slurm_load_node_single(&new_node_ptr, params.nodes, show_flags); } else { error_code = slurm_load_node((time_t) NULL, &new_node_ptr, show_flags); } if (error_code) { slurm_perror("slurm_load_node"); return error_code; } old_node_ptr = new_node_ptr; *node_pptr = new_node_ptr; if (old_resv_ptr) { if (clear_old) old_resv_ptr->last_update = 0; error_code = slurm_load_reservations(old_resv_ptr->last_update, &new_resv_ptr); if (error_code == SLURM_SUCCESS) slurm_free_reservation_info_msg(old_resv_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_resv_ptr = old_resv_ptr; } } else { error_code = slurm_load_reservations((time_t) NULL, &new_resv_ptr); } if (error_code) { slurm_perror("slurm_load_reservations"); return error_code; } old_resv_ptr = new_resv_ptr; *reserv_pptr = new_resv_ptr; if (!params.bg_flag) return SLURM_SUCCESS; if (params.cluster_flags & CLUSTER_FLAG_BG) { if (old_bg_ptr) { if (clear_old) old_bg_ptr->last_update = 0; error_code = slurm_load_block_info( old_bg_ptr->last_update, &new_bg_ptr, show_flags); if (error_code == SLURM_SUCCESS) slurm_free_block_info_msg(old_bg_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_bg_ptr = old_bg_ptr; } } else { error_code = slurm_load_block_info((time_t) NULL, &new_bg_ptr, show_flags); } } if (error_code) { slurm_perror("slurm_load_block"); return error_code; } old_bg_ptr = new_bg_ptr; *block_pptr = new_bg_ptr; return SLURM_SUCCESS; }