1
1

lookup available nodes based on mapping data (if available)

This commit was SVN r7435.
Этот коммит содержится в:
Tim Woodall 2005-09-19 21:31:00 +00:00
родитель 9c334800ad
Коммит e1ec160858
2 изменённых файлов: 123 добавлений и 0 удалений

Просмотреть файл

@ -133,6 +133,122 @@ int orte_ras_base_node_query(opal_list_t* nodes)
return ORTE_SUCCESS;
}
/*
* Query the registry for all available nodes
*/
int orte_ras_base_node_query_context(opal_list_t* nodes, orte_app_context_t** context, size_t num_context)
{
size_t i, cnt;
orte_gpr_value_t** values;
int rc;
opal_list_t required;
opal_list_item_t* item;
/* expand the list of node/host specifications on the context structure into
* a list of node names
*/
OBJ_CONSTRUCT(&required, opal_list_t);
for(i=0; i<num_context; i++) {
orte_app_context_map_t** map = context[i]->map_data;
size_t m, num_map = context[i]->num_map;
for(m=0; m<num_map; m++) {
if(map[m]->map_type == ORTE_APP_CONTEXT_MAP_HOSTNAME) {
orte_ras_node_t* node = OBJ_NEW(orte_ras_node_t);
node->node_name = strdup(map[m]->map_data);
opal_list_append(&required, (opal_list_item_t*)node);
}
map++;
}
}
/* query all node entries */
rc = orte_gpr.get(
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
ORTE_NODE_SEGMENT,
NULL,
NULL,
&cnt,
&values);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* parse the response */
for(i=0; i<cnt; i++) {
orte_gpr_value_t* value = values[i];
orte_ras_node_t* node = OBJ_NEW(orte_ras_node_t);
size_t k;
bool found = false;
for(k=0; k<value->cnt; k++) {
orte_gpr_keyval_t* keyval = value->keyvals[k];
if(strcmp(keyval->key, ORTE_NODE_NAME_KEY) == 0) {
node->node_name = strdup(keyval->value.strptr);
continue;
}
if(strcmp(keyval->key, ORTE_NODE_ARCH_KEY) == 0) {
node->node_arch = strdup(keyval->value.strptr);
continue;
}
if(strcmp(keyval->key, ORTE_NODE_STATE_KEY) == 0) {
node->node_state = keyval->value.node_state;
continue;
}
if(strcmp(keyval->key, ORTE_NODE_SLOTS_KEY) == 0) {
node->node_slots = keyval->value.size;
continue;
}
if(strncmp(keyval->key, ORTE_NODE_SLOTS_ALLOC_KEY, strlen(ORTE_NODE_SLOTS_ALLOC_KEY)) == 0) {
node->node_slots_inuse += keyval->value.size;
continue;
}
if(strcmp(keyval->key, ORTE_NODE_SLOTS_MAX_KEY) == 0) {
node->node_slots_max = keyval->value.size;
continue;
}
if(strcmp(keyval->key, ORTE_NODE_USERNAME_KEY) == 0) {
node->node_username = strdup(keyval->value.strptr);
continue;
}
if(strcmp(keyval->key, ORTE_CELLID_KEY) == 0) {
node->node_cellid = keyval->value.cellid;
continue;
}
}
/* contained in app_context? */
for(item = opal_list_get_first(&required);
item != opal_list_get_end(&required);
item = opal_list_get_next(item)) {
if(strcmp(((orte_ras_node_t*)item)->node_name,node->node_name)) {
opal_list_remove_item(&required, item);
OBJ_RELEASE(item);
found = true;
break;
}
}
if(opal_list_get_size(&required) == 0 || found) {
opal_list_append(nodes, &node->super);
} else {
OBJ_RELEASE(node);
}
OBJ_RELEASE(value);
}
/* append any remaining specified nodes to the list with
* with default settings for slots,etc.
*/
while(NULL != (item = opal_list_remove_first(&required))) {
opal_list_append(&required, item);
}
OBJ_DESTRUCT(&required);
if (NULL != values) free(values);
return ORTE_SUCCESS;
}
/*
* Query the registry for all nodes allocated to a specified job
*/

Просмотреть файл

@ -22,6 +22,7 @@
#include "include/orte_types.h"
#include "mca/soh/soh_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "mca/ras/ras.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
@ -37,6 +38,12 @@ extern "C" {
*/
int orte_ras_base_node_query(opal_list_t*);
/*
* Query the registry for all available nodes that satisfy any
* constraints specified on the app_context(s)
*/
int orte_ras_base_node_query_context(opal_list_t*, orte_app_context_t**, size_t num_context);
/*
* Query the registry for all nodes allocated to a specific job
*/