2004-07-09 01:59:50 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-09-01 01:07:30 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 20:09:25 +00:00
|
|
|
* 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.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
2005-09-01 01:07:30 +00:00
|
|
|
*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Additional copyrights may follow
|
2005-09-01 01:07:30 +00:00
|
|
|
*
|
2004-07-09 01:59:50 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/** @file:
|
|
|
|
*
|
|
|
|
*/
|
2005-05-01 00:54:12 +00:00
|
|
|
#include "orte_config.h"
|
2005-03-29 13:50:15 +00:00
|
|
|
|
2004-07-12 02:44:25 +00:00
|
|
|
#include <stdio.h>
|
2005-03-29 13:50:15 +00:00
|
|
|
#include <string.h>
|
2004-07-09 01:59:50 +00:00
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
#include "opal/threads/mutex.h"
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2006-10-02 19:44:35 +00:00
|
|
|
#include "opal/util/trace.h"
|
|
|
|
|
|
|
|
#include "orte/dss/dss.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2006-10-02 19:44:35 +00:00
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/mca/ns/base/base.h"
|
2007-01-08 22:00:01 +00:00
|
|
|
#include "orte/mca/ns/base/ns_private.h"
|
2004-07-09 01:59:50 +00:00
|
|
|
#include "ns_replica.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* globals
|
|
|
|
*/
|
2005-08-07 13:21:52 +00:00
|
|
|
#define NS_REPLICA_MAX_STRING_SIZE 256
|
2004-07-09 01:59:50 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/*
|
|
|
|
* DIAGNOSTIC functions
|
|
|
|
*/
|
2006-04-04 11:05:52 +00:00
|
|
|
int orte_ns_replica_dump_cells(void)
|
2005-08-07 13:21:52 +00:00
|
|
|
{
|
|
|
|
orte_buffer_t buffer;
|
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_cells_fn(&buffer))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int orte_ns_replica_dump_cells_fn(orte_buffer_t *buffer)
|
|
|
|
{
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i;
|
2006-03-30 14:59:41 +00:00
|
|
|
orte_cellid_t j;
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_cell_tracker_t **cell;
|
|
|
|
char tmp_out[NS_REPLICA_MAX_STRING_SIZE], *tmp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
tmp = tmp_out;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Dump of Name Service Cell Tracker\n");
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
cell = (orte_ns_replica_cell_tracker_t**)(orte_ns_replica.cells)->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_cells &&
|
|
|
|
i < (orte_ns_replica.cells)->size; i++) {
|
|
|
|
if (NULL != cell[i]) {
|
|
|
|
j++;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Num: %lu\tCell: %lu\n",
|
|
|
|
(unsigned long)j, (unsigned long)cell[i]->cell);
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "\tSite: %s\n\tResource: %s\n",
|
|
|
|
cell[i]->site, cell[i]->resource);
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
int orte_ns_replica_dump_jobs(void)
|
2005-08-07 13:21:52 +00:00
|
|
|
{
|
|
|
|
orte_buffer_t buffer;
|
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_jobs_fn(&buffer))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int orte_ns_replica_dump_jobs_fn(orte_buffer_t *buffer)
|
|
|
|
{
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i;
|
2006-03-30 14:59:41 +00:00
|
|
|
orte_cellid_t j;
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_jobid_tracker_t **ptr;
|
|
|
|
char tmp_out[NS_REPLICA_MAX_STRING_SIZE], *tmp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
tmp = tmp_out;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Dump of Name Service Jobid Tracker\n");
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
ptr = (orte_ns_replica_jobid_tracker_t**)(orte_ns_replica.jobids)->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_jobids &&
|
|
|
|
i < (orte_ns_replica.jobids)->size; i++) {
|
|
|
|
if (NULL != ptr[i]) {
|
|
|
|
j++;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Num: %lu\tJobid: %lu\tNext vpid: %lu\n",
|
|
|
|
(unsigned long)j, (unsigned long)ptr[i]->jobid,
|
|
|
|
(unsigned long)ptr[i]->next_vpid);
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
2004-07-09 01:59:50 +00:00
|
|
|
}
|
2005-01-07 16:03:55 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
int orte_ns_replica_dump_tags(void)
|
2005-08-07 13:21:52 +00:00
|
|
|
{
|
|
|
|
orte_buffer_t buffer;
|
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_tags_fn(&buffer))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int orte_ns_replica_dump_tags_fn(orte_buffer_t *buffer)
|
|
|
|
{
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i;
|
|
|
|
orte_rml_tag_t j;
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_tagitem_t **ptr;
|
|
|
|
char tmp_out[NS_REPLICA_MAX_STRING_SIZE], *tmp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
tmp = tmp_out;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Dump of Name Service RML Tag Tracker\n");
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
ptr = (orte_ns_replica_tagitem_t**)(orte_ns_replica.tags)->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_tags &&
|
|
|
|
i < (orte_ns_replica.tags)->size; i++) {
|
|
|
|
if (NULL != ptr[i]) {
|
|
|
|
j++;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Num: %lu\tTag id: %lu\tName: %s\n",
|
|
|
|
(unsigned long)j, (unsigned long)ptr[i]->tag, ptr[i]->name);
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
int orte_ns_replica_dump_datatypes(void)
|
2005-08-07 13:21:52 +00:00
|
|
|
{
|
|
|
|
orte_buffer_t buffer;
|
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_datatypes_fn(&buffer))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2006-04-04 11:05:52 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OBJ_DESTRUCT(&buffer);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int orte_ns_replica_dump_datatypes_fn(orte_buffer_t *buffer)
|
|
|
|
{
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i, j;
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_dti_t **ptr;
|
|
|
|
char tmp_out[NS_REPLICA_MAX_STRING_SIZE], *tmp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
tmp = tmp_out;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Dump of Name Service Datatype Tracker\n");
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
ptr = (orte_ns_replica_dti_t**)(orte_ns_replica.dts)->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_dts &&
|
|
|
|
i < (orte_ns_replica.dts)->size; i++) {
|
|
|
|
if (NULL != ptr[i]) {
|
|
|
|
j++;
|
|
|
|
snprintf(tmp, NS_REPLICA_MAX_STRING_SIZE, "Num: %lu\tDatatype id: %lu\tName: %s\n",
|
|
|
|
(unsigned long)j, (unsigned long)ptr[i]->id, ptr[i]->name);
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.pack(buffer, &tmp, 1, ORTE_STRING))) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TAG SERVER functions
|
|
|
|
*/
|
2005-03-14 20:57:21 +00:00
|
|
|
int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag,
|
|
|
|
char *name)
|
2005-01-07 16:03:55 +00:00
|
|
|
{
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_tagitem_t *tagitem, **tags;
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i;
|
|
|
|
orte_rml_tag_t j;
|
2005-08-07 13:21:52 +00:00
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
if (NULL != name) {
|
|
|
|
/* see if this name is already in list - if so, return tag */
|
2005-08-07 13:21:52 +00:00
|
|
|
tags = (orte_ns_replica_tagitem_t**)orte_ns_replica.tags->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_tags &&
|
|
|
|
i < (orte_ns_replica.tags)->size; i++) {
|
|
|
|
if (NULL != tags[i]) {
|
|
|
|
j++;
|
|
|
|
if (tags[i]->name != NULL &&
|
|
|
|
0 == strcmp(name, tags[i]->name)) { /* found name on list */
|
|
|
|
*tag = tags[i]->tag;
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/* not in list or not provided, so allocate next tag */
|
|
|
|
*tag = ORTE_RML_TAG_MAX;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/* check if tag is available - need to do this since the tag type
|
2006-08-15 19:54:10 +00:00
|
|
|
* is probably not going to be a orte_std_cntr_t, so we cannot just rely
|
2005-08-07 13:21:52 +00:00
|
|
|
* on the pointer_array's size limits to protect us. NOTE: need to
|
|
|
|
* reserve ORTE_RML_TAG_MAX as an invalid value, so can't let
|
|
|
|
* num_tags get there
|
|
|
|
*/
|
|
|
|
if (ORTE_RML_TAG_MAX-2 < orte_ns_replica.num_tags) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
tagitem = OBJ_NEW(orte_ns_replica_tagitem_t);
|
|
|
|
if (NULL == tagitem) { /* out of memory */
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_pointer_array_add(&i,
|
|
|
|
orte_ns_replica.tags, tagitem))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-28 03:20:43 +00:00
|
|
|
tagitem->tag = orte_ns_replica.num_tags + ORTE_RML_TAG_DYNAMIC;
|
2005-08-07 13:21:52 +00:00
|
|
|
(orte_ns_replica.num_tags)++;
|
|
|
|
if (NULL != name) { /* provided - can look it up later */
|
|
|
|
tagitem->name = strdup(name);
|
|
|
|
} else {
|
|
|
|
tagitem->name = NULL;
|
|
|
|
}
|
2005-05-01 00:54:12 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
*tag = tagitem->tag;
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_SUCCESS;
|
2005-05-01 00:54:12 +00:00
|
|
|
}
|
|
|
|
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/*
|
|
|
|
* DATA TYPE SERVER functions
|
|
|
|
*/
|
2005-05-01 00:58:06 +00:00
|
|
|
int orte_ns_replica_define_data_type(const char *name,
|
2005-05-01 00:54:12 +00:00
|
|
|
orte_data_type_t *type)
|
|
|
|
{
|
2005-08-07 13:21:52 +00:00
|
|
|
orte_ns_replica_dti_t **dti, *dtip;
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i, j;
|
2005-08-07 13:21:52 +00:00
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-05-01 00:58:06 +00:00
|
|
|
if (NULL == name || 0 < *type) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
|
|
|
|
|
|
|
|
dti = (orte_ns_replica_dti_t**)orte_ns_replica.dts->addr;
|
|
|
|
for (i=0, j=0; j < orte_ns_replica.num_dts &&
|
|
|
|
i < orte_ns_replica.dts->size; i++) {
|
|
|
|
if (NULL != dti[i]) {
|
|
|
|
j++;
|
|
|
|
if (dti[i]->name != NULL &&
|
|
|
|
0 == strcmp(name, dti[i]->name)) { /* found name on list */
|
|
|
|
*type = dti[i]->id;
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
2005-05-01 00:54:12 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/* not in list or not provided, so allocate next id */
|
2006-02-07 03:32:36 +00:00
|
|
|
*type = ORTE_DSS_ID_MAX;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
/* check if id is available - need to do this since the data type
|
2006-08-15 19:54:10 +00:00
|
|
|
* is probably not going to be a orte_std_cntr_t, so we cannot just rely
|
2005-08-07 13:21:52 +00:00
|
|
|
* on the pointer_array's size limits to protect us.
|
|
|
|
*/
|
2006-02-07 03:32:36 +00:00
|
|
|
if (ORTE_DSS_ID_MAX-2 < orte_ns_replica.num_dts) {
|
2005-08-07 13:21:52 +00:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dtip = OBJ_NEW(orte_ns_replica_dti_t);
|
|
|
|
if (NULL == dtip) { /* out of memory */
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2005-05-01 00:54:12 +00:00
|
|
|
}
|
2005-08-07 13:21:52 +00:00
|
|
|
dtip->name = strdup(name);
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_pointer_array_add(&i,
|
|
|
|
orte_ns_replica.dts, dtip))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
dtip->id = orte_ns_replica.num_dts;
|
|
|
|
(orte_ns_replica.num_dts)++;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
*type = dtip->id;
|
|
|
|
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
|
|
|
|
return ORTE_SUCCESS;
|
2005-01-07 16:03:55 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-05-24 13:39:15 +00:00
|
|
|
|
2005-08-07 13:21:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME functions
|
|
|
|
*/
|
2005-05-24 13:39:15 +00:00
|
|
|
int orte_ns_replica_create_my_name(void)
|
|
|
|
{
|
|
|
|
orte_jobid_t jobid;
|
|
|
|
orte_vpid_t vpid;
|
|
|
|
int rc;
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-05-24 13:39:15 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.create_jobid(&jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.reserve_range(jobid, 1, &vpid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.create_process_name(&(orte_process_info.my_name),
|
|
|
|
0, jobid, vpid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-01 01:07:30 +00:00
|
|
|
|
2005-05-24 13:39:15 +00:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|