2005-03-14 20:57:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 20:57:21 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
|
|
|
|
2005-03-29 13:50:15 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "include/orte_constants.h"
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2005-05-25 16:23:13 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "mca/errmgr/errmgr.h"
|
|
|
|
#include "mca/soh/soh_types.h"
|
|
|
|
#include "mca/gpr/gpr.h"
|
|
|
|
#include "mca/ns/ns.h"
|
2005-06-21 22:48:57 +00:00
|
|
|
#include "mca/ras/base/ras_base_node.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
static void orte_ras_base_node_construct(orte_ras_node_t* node)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
node->node_name = NULL;
|
|
|
|
node->node_arch = NULL;
|
|
|
|
node->node_cellid = 0;
|
|
|
|
node->node_state = ORTE_NODE_STATE_UNKNOWN;
|
|
|
|
node->node_slots = 0;
|
|
|
|
node->node_slots_inuse = 0;
|
2005-08-31 07:09:47 +00:00
|
|
|
node->node_slots_alloc = 0;
|
2005-03-14 20:57:21 +00:00
|
|
|
node->node_slots_max = 0;
|
2005-09-10 07:57:50 +00:00
|
|
|
node->node_username = NULL;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
static void orte_ras_base_node_destruct(orte_ras_node_t* node)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
if (NULL != node->node_name) {
|
|
|
|
free(node->node_name);
|
|
|
|
}
|
|
|
|
if (NULL != node->node_arch) {
|
|
|
|
free(node->node_arch);
|
|
|
|
}
|
2005-09-10 07:57:50 +00:00
|
|
|
if (NULL != node->node_username) {
|
|
|
|
free(node->node_username);
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t,
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_ras_base_node_construct,
|
|
|
|
orte_ras_base_node_destruct);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-09-10 08:01:47 +00:00
|
|
|
* Query the registry for all available nodes
|
2005-03-14 20:57:21 +00:00
|
|
|
*/
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
int orte_ras_base_node_query(opal_list_t* nodes)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-05-01 00:47:35 +00:00
|
|
|
size_t i, cnt;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_value_t** values;
|
|
|
|
int rc;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/* query all node entries */
|
|
|
|
rc = orte_gpr.get(
|
|
|
|
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
|
|
|
|
ORTE_NODE_SEGMENT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&cnt,
|
|
|
|
&values);
|
2005-06-24 16:59:37 +00:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
/* parse the response */
|
|
|
|
for(i=0; i<cnt; i++) {
|
|
|
|
orte_gpr_value_t* value = values[i];
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node = OBJ_NEW(orte_ras_node_t);
|
2005-05-01 00:47:35 +00:00
|
|
|
size_t k;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
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) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots = keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strncmp(keyval->key, ORTE_NODE_SLOTS_ALLOC_KEY, strlen(ORTE_NODE_SLOTS_ALLOC_KEY)) == 0) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots_inuse += keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_NODE_SLOTS_MAX_KEY) == 0) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots_max = keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-09-10 07:57:50 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_NODE_USERNAME_KEY) == 0) {
|
|
|
|
node->node_username = strdup(keyval->value.strptr);
|
|
|
|
continue;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_CELLID_KEY) == 0) {
|
|
|
|
node->node_cellid = keyval->value.cellid;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_append(nodes, &node->super);
|
2005-09-02 20:41:24 +00:00
|
|
|
OBJ_RELEASE(value);
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-09-02 20:41:24 +00:00
|
|
|
if (NULL != values) free(values);
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Query the registry for all nodes allocated to a specified job
|
|
|
|
*/
|
2005-07-03 16:22:16 +00:00
|
|
|
int orte_ras_base_node_query_alloc(opal_list_t* nodes, orte_jobid_t jobid)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-08-31 07:09:47 +00:00
|
|
|
char* keys[] = {
|
|
|
|
ORTE_NODE_NAME_KEY,
|
|
|
|
ORTE_NODE_ARCH_KEY,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_NODE_STATE_KEY,
|
|
|
|
ORTE_NODE_SLOTS_KEY,
|
|
|
|
ORTE_NODE_SLOTS_ALLOC_KEY,
|
|
|
|
ORTE_NODE_SLOTS_MAX_KEY,
|
2005-09-10 07:57:50 +00:00
|
|
|
ORTE_NODE_USERNAME_KEY,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_CELLID_KEY,
|
|
|
|
NULL
|
|
|
|
};
|
2005-08-31 07:09:47 +00:00
|
|
|
size_t i, cnt, keys_len;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_value_t** values;
|
|
|
|
char* jobid_str;
|
|
|
|
int rc;
|
|
|
|
|
2005-06-24 16:59:37 +00:00
|
|
|
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-08-31 07:09:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
asprintf(&keys[4], "%s-%s", ORTE_NODE_SLOTS_ALLOC_KEY, jobid_str);
|
2005-08-31 07:09:47 +00:00
|
|
|
keys_len = strlen(keys[4]);
|
2005-03-14 20:57:21 +00:00
|
|
|
free(jobid_str);
|
|
|
|
|
|
|
|
/* query selected node entries */
|
|
|
|
rc = orte_gpr.get(
|
|
|
|
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
|
|
|
|
ORTE_NODE_SEGMENT,
|
|
|
|
NULL,
|
|
|
|
keys,
|
|
|
|
&cnt,
|
|
|
|
&values);
|
2005-06-24 16:59:37 +00:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
/* parse the response */
|
|
|
|
for(i=0; i<cnt; i++) {
|
|
|
|
orte_gpr_value_t* value = values[i];
|
2005-08-31 07:09:47 +00:00
|
|
|
orte_ras_node_t* node;
|
2005-05-01 00:47:35 +00:00
|
|
|
size_t k;
|
2005-08-31 07:09:47 +00:00
|
|
|
bool found;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-08-31 07:09:47 +00:00
|
|
|
found = false;
|
|
|
|
for (k = 0; k < value->cnt; k++) {
|
|
|
|
orte_gpr_keyval_t* keyval = value->keyvals[k];
|
|
|
|
|
|
|
|
if(0 == strcmp(keyval->key, keys[4])) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
node = OBJ_NEW(orte_ras_node_t);
|
|
|
|
|
|
|
|
for(k=0; k < value->cnt; k++) {
|
2005-03-14 20:57:21 +00:00
|
|
|
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) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots = keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-08-31 07:09:47 +00:00
|
|
|
if(strncmp(keyval->key, keys[4], keys_len) == 0) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots_inuse += keyval->value.size;
|
|
|
|
node->node_slots_alloc += keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_NODE_SLOTS_MAX_KEY) == 0) {
|
2005-06-24 18:54:54 +00:00
|
|
|
node->node_slots_max = keyval->value.size;
|
2005-03-14 20:57:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-09-10 07:57:50 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_NODE_USERNAME_KEY) == 0) {
|
|
|
|
node->node_username = strdup(keyval->value.strptr);
|
|
|
|
continue;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_CELLID_KEY) == 0) {
|
|
|
|
node->node_cellid = keyval->value.cellid;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* in case we get back more than we asked for */
|
|
|
|
if(node->node_slots_inuse == 0) {
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_append(nodes, &node->super);
|
2005-09-02 20:41:24 +00:00
|
|
|
OBJ_RELEASE(value);
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-08-31 07:09:47 +00:00
|
|
|
|
|
|
|
free (keys[4]);
|
2005-09-02 20:41:24 +00:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 20:57:21 +00:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the specified node definitions to the registry
|
|
|
|
*/
|
2005-07-03 16:22:16 +00:00
|
|
|
int orte_ras_base_node_insert(opal_list_t* nodes)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t* item;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_value_t **values;
|
2005-05-01 00:47:35 +00:00
|
|
|
int rc;
|
|
|
|
size_t num_values, i, j;
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
num_values = opal_list_get_size(nodes);
|
2005-03-14 20:57:21 +00:00
|
|
|
if (0 >= num_values) {
|
2005-05-19 16:46:34 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
2005-03-14 20:57:21 +00:00
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
values = (orte_gpr_value_t**)malloc(num_values * sizeof(orte_gpr_value_t*));
|
|
|
|
if (NULL == values) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
for (i=0; i < num_values; i++) {
|
|
|
|
orte_gpr_value_t* value = values[i] = OBJ_NEW(orte_gpr_value_t);
|
|
|
|
if (NULL == value) {
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-05-25 16:23:13 +00:00
|
|
|
value->addr_mode = ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_AND;
|
2005-03-14 20:57:21 +00:00
|
|
|
value->segment = strdup(ORTE_NODE_SEGMENT);
|
2005-09-10 07:57:50 +00:00
|
|
|
value->cnt = 7; /* Seven, at max (including node_username) */
|
2005-03-14 20:57:21 +00:00
|
|
|
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt*sizeof(orte_gpr_keyval_t*));
|
|
|
|
if (NULL == value->keyvals) {
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
for (j=0; j < value->cnt; j++) {
|
|
|
|
value->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
|
|
|
|
if (NULL == value->keyvals[j]) {
|
|
|
|
for (j=0; j <= i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
for(i=0, item = opal_list_get_first(nodes);
|
|
|
|
i < num_values && item != opal_list_get_end(nodes);
|
|
|
|
i++, item = opal_list_get_next(item)) {
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_value_t* value = values[i];
|
2005-08-11 19:51:50 +00:00
|
|
|
node = (orte_ras_node_t*)item;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
j = 0;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_NAME_KEY);
|
|
|
|
(value->keyvals[j])->type = ORTE_STRING;
|
|
|
|
(value->keyvals[j])->value.strptr = strdup(node->node_name);
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_ARCH_KEY);
|
|
|
|
(value->keyvals[j])->type = ORTE_STRING;
|
|
|
|
if (NULL != node->node_arch) {
|
|
|
|
(value->keyvals[j])->value.strptr = strdup(node->node_arch);
|
|
|
|
} else {
|
|
|
|
(value->keyvals[j])->value.strptr = strdup("");
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_STATE_KEY);
|
|
|
|
(value->keyvals[j])->type = ORTE_NODE_STATE;
|
|
|
|
(value->keyvals[j])->value.node_state = node->node_state;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_CELLID_KEY);
|
|
|
|
(value->keyvals[j])->type = ORTE_CELLID;
|
|
|
|
(value->keyvals[j])->value.cellid = node->node_cellid;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_SLOTS_KEY);
|
2005-06-24 18:54:54 +00:00
|
|
|
(value->keyvals[j])->type = ORTE_SIZE;
|
|
|
|
(value->keyvals[j])->value.size = node->node_slots;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_SLOTS_MAX_KEY);
|
2005-06-24 18:54:54 +00:00
|
|
|
(value->keyvals[j])->type = ORTE_SIZE;
|
|
|
|
(value->keyvals[j])->value.size = node->node_slots_max;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
++j;
|
|
|
|
(value->keyvals[j])->key = strdup(ORTE_NODE_USERNAME_KEY);
|
|
|
|
(value->keyvals[j])->type = ORTE_STRING;
|
|
|
|
if (NULL != node->node_username) {
|
|
|
|
(value->keyvals[j])->value.strptr = strdup(node->node_username);
|
|
|
|
} else {
|
|
|
|
(value->keyvals[j])->value.strptr = strdup("");
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/* setup index/keys for this node */
|
|
|
|
rc = orte_schema.get_node_tokens(&value->tokens, &value->num_tokens, node->node_cellid, node->node_name);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
2005-06-24 16:59:37 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
for (j=0; j <= i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/* try the insert */
|
2005-06-24 16:59:37 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.put(num_values, values))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
for (j=0; j < num_values; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
2005-09-02 20:41:24 +00:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete the specified nodes from the registry
|
|
|
|
*/
|
2005-07-03 16:22:16 +00:00
|
|
|
int orte_ras_base_node_delete(opal_list_t* nodes)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t* item;
|
2005-03-14 20:57:21 +00:00
|
|
|
int rc;
|
2005-09-02 20:41:24 +00:00
|
|
|
size_t i, num_values, num_tokens;
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node;
|
2005-08-05 23:37:39 +00:00
|
|
|
char** tokens;
|
|
|
|
|
|
|
|
num_values = opal_list_get_size(nodes);
|
|
|
|
if (0 >= num_values) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
for(item = opal_list_get_first(nodes);
|
|
|
|
item != opal_list_get_end(nodes);
|
2005-08-05 23:37:39 +00:00
|
|
|
item = opal_list_get_next(item)) {
|
2005-08-11 19:51:50 +00:00
|
|
|
node = (orte_ras_node_t*)item;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-08-05 23:37:39 +00:00
|
|
|
/* setup index/keys for this node */
|
|
|
|
rc = orte_schema.get_node_tokens(&tokens, &num_tokens, node->node_cellid, node->node_name);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
2005-06-24 16:59:37 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
rc = orte_gpr.delete_entries(
|
|
|
|
ORTE_GPR_TOKENS_AND,
|
|
|
|
ORTE_NODE_SEGMENT,
|
|
|
|
tokens,
|
|
|
|
NULL);
|
2005-06-24 16:59:37 +00:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-09-02 20:41:24 +00:00
|
|
|
for (i=0; i < num_tokens; i++) {
|
|
|
|
free(tokens[i]);
|
|
|
|
tokens[i] = NULL;
|
|
|
|
}
|
|
|
|
if (NULL != tokens) free(tokens);
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-09-10 08:01:47 +00:00
|
|
|
* Assign the allocated slots on the specified nodes to the
|
2005-03-14 20:57:21 +00:00
|
|
|
* indicated jobid.
|
|
|
|
*/
|
2005-07-03 16:22:16 +00:00
|
|
|
int orte_ras_base_node_assign(opal_list_t* nodes, orte_jobid_t jobid)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t* item;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_value_t **values;
|
2005-05-01 00:47:35 +00:00
|
|
|
int rc;
|
|
|
|
size_t num_values, i, j;
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node;
|
2005-03-14 20:57:21 +00:00
|
|
|
char* jobid_str;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
num_values = opal_list_get_size(nodes);
|
2005-03-14 20:57:21 +00:00
|
|
|
if (0 >= num_values) {
|
2005-06-24 16:59:37 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
2005-03-14 20:57:21 +00:00
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
values = (orte_gpr_value_t**)malloc(num_values * sizeof(orte_gpr_value_t*));
|
|
|
|
if (NULL == values) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
for (i=0; i < num_values; i++) {
|
|
|
|
values[i] = OBJ_NEW(orte_gpr_value_t);
|
|
|
|
if (NULL == values[i]) {
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-05-25 16:23:13 +00:00
|
|
|
values[i]->addr_mode = ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_AND;
|
2005-03-14 20:57:21 +00:00
|
|
|
values[i]->segment = strdup(ORTE_NODE_SEGMENT);
|
|
|
|
values[i]->cnt = 1;
|
|
|
|
values[i]->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
|
|
|
|
if (NULL == values[i]->keyvals) {
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
values[i]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
|
|
|
|
if (NULL == values[i]->keyvals[0]) {
|
|
|
|
for (j=0; j < i; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
for(i=0, item = opal_list_get_first(nodes);
|
|
|
|
i < num_values && item != opal_list_get_end(nodes);
|
|
|
|
i++, item = opal_list_get_next(item)) {
|
2005-03-14 20:57:21 +00:00
|
|
|
int rc;
|
2005-08-11 19:51:50 +00:00
|
|
|
node = (orte_ras_node_t*)item;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
if(node->node_slots_alloc == 0)
|
|
|
|
continue;
|
2005-06-24 16:59:37 +00:00
|
|
|
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
2005-06-24 16:59:37 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
/* setup index/keys for this node */
|
|
|
|
rc = orte_schema.get_node_tokens(&values[i]->tokens, &values[i]->num_tokens, node->node_cellid, node->node_name);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
2005-06-24 16:59:37 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
for (j=0; j < num_values; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
|
|
|
free(values);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup node key/value pairs */
|
|
|
|
asprintf(&((values[i]->keyvals[0])->key), "%s-%s", ORTE_NODE_SLOTS_ALLOC_KEY, jobid_str);
|
|
|
|
free(jobid_str);
|
2005-09-10 08:01:47 +00:00
|
|
|
|
|
|
|
(values[i]->keyvals[0])->type = ORTE_SIZE;
|
2005-06-24 18:54:54 +00:00
|
|
|
(values[i]->keyvals[0])->value.size = node->node_slots_alloc;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/* try the insert */
|
2005-06-24 16:59:37 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.put(num_values, values))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
for (j=0; j < num_values; j++) {
|
|
|
|
OBJ_RELEASE(values[j]);
|
|
|
|
}
|
2005-09-02 20:41:24 +00:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|