1
1
openmpi/orte/util/univ_info.c

195 строки
6.2 KiB
C
Исходник Обычный вид История

/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <stdlib.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif /* HAVE_PWD_H */
#include <sys/stat.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_param.h"
#include "orte/mca/ns/ns_types.h"
#include "orte/mca/schema/schema_types.h"
#include "opal/util/output.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/util/univ_info.h"
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
static bool universe_info_has_been_created = false;
orte_universe_t orte_universe_info;
void orte_universe_construct(orte_universe_t *obj);
void orte_universe_destruct( orte_universe_t *obj);
OBJ_CLASS_INSTANCE(orte_universe_t,
opal_list_item_t,
orte_universe_construct,
orte_universe_destruct);
void orte_universe_construct(orte_universe_t *obj) {
obj->state = ORTE_UNIVERSE_STATE_PRE_INIT;
obj->persistence = false;
obj->console = false;
obj->console_connected = false;
obj->name = NULL;
obj->default_name = false;
obj->host = NULL;
obj->uid = NULL;
obj->scope = NULL;
obj->seed_uri = NULL;
obj->scriptfile = NULL;
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
}
void orte_universe_destruct( orte_universe_t *obj) {
if (NULL != obj->name) {
free(obj->name);
obj->name = NULL;
}
if (NULL != obj->host) {
free(obj->host);
obj->host = NULL;
}
if (NULL != obj->uid) {
free(obj->uid);
obj->uid = NULL;
}
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
if (NULL != obj->scope) {
free(obj->scope);
obj->scope = NULL;
}
if (NULL != obj->seed_uri) {
free(obj->seed_uri);
obj->seed_uri = NULL;
}
if (NULL != obj->scriptfile) {
free(obj->scriptfile);
obj->scriptfile = NULL;
}
obj->state = ORTE_UNIVERSE_STATE_PRE_INIT;
obj->persistence = false;
obj->console = false;
obj->console_connected = false;
}
int orte_univ_info(void)
{
int id, tmp;
char *tmpname=NULL, *tptr, *ptr;
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
if(!universe_info_has_been_created) {
OBJ_CONSTRUCT(&orte_universe_info, orte_universe_t);
universe_info_has_been_created = true;
}
if (ORTE_UNIVERSE_STATE_PRE_INIT == orte_universe_info.state) {
id = mca_base_param_register_string("universe", NULL, NULL, NULL, NULL);
mca_base_param_lookup_string(id, &tmpname);
if (NULL != tmpname) {
/* Universe name info is passed as userid@hostname:univ_name */
/* extract the userid from the universe option, if provided */
tptr = tmpname;
if (NULL != (ptr = strchr(tptr, '@'))) {
*ptr = '\0';
orte_universe_info.uid = strdup(tptr);
ptr++;
tptr = ptr;
} else {
if (NULL == orte_system_info.user) {
orte_sys_info();
}
orte_universe_info.uid = strdup(orte_system_info.user);
}
/* extract the hostname, if provided */
if (NULL != (ptr = strchr(tptr, ':'))) {
*ptr = '\0';
orte_universe_info.host = strdup(tptr);
ptr++;
tptr = ptr;
} else {
orte_universe_info.host = strdup(orte_system_info.nodename);
}
/* now copy the universe name into the universe_info structure */
orte_universe_info.name = strdup(tptr);
/* indicate that the universe name was provided */
orte_universe_info.default_name = false;
} else {
/* if nothing was provided, then initialize the user and nodename
* to the local values
*/
orte_universe_info.uid = strdup(orte_system_info.user);
orte_universe_info.host = strdup(orte_system_info.nodename);
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
/* and the universe name to default-universe-PID */
asprintf(&orte_universe_info.name, "%s-%d", ORTE_DEFAULT_UNIVERSE, getpid());
/* indicate that the universe name is a default one */
orte_universe_info.default_name = true;
}
id = mca_base_param_register_int("universe", "persistence", NULL, NULL, orte_universe_info.persistence);
mca_base_param_lookup_int(id, &tmp);
orte_universe_info.persistence = OPAL_INT_TO_BOOL(tmp);
id = mca_base_param_register_string("universe", "scope", NULL, NULL, orte_universe_info.scope);
mca_base_param_lookup_string(id, &(orte_universe_info.scope));
id = mca_base_param_register_int("universe", "console", NULL, NULL, orte_universe_info.console);
mca_base_param_lookup_int(id, &tmp);
orte_universe_info.console = OPAL_INT_TO_BOOL(tmp);
id = mca_base_param_register_string("universe", "uri", NULL, NULL, orte_universe_info.seed_uri);
mca_base_param_lookup_string(id, &(orte_universe_info.seed_uri));
/* console connected is set elsewhere */
id = mca_base_param_register_string("universe", "script", NULL, NULL, orte_universe_info.scriptfile);
mca_base_param_lookup_string(id, &(orte_universe_info.scriptfile));
orte_universe_info.state = ORTE_UNIVERSE_STATE_INIT;
}
return(ORTE_SUCCESS);
}
int orte_univ_info_finalize(void)
{
Brining over the session directory and universe changes from the tmp/jjhursey-ft-cr branch. In this commit we change the way universe names are created. Before we by default first created "default-universe" then if there was a conflict we created "default-universe-PID" where PID is the PID of the HNP. Now we create "default-universe-PID" all the time (when a default universe name is used). This makes it much easier when trying to find a HNP from an outside app (e.g. orte-ps, orteconsole, ...) This also adds a "search" function to find all of the universes on the machine. This is useful in many contexts when trying to find a persistent daemon or when trying to connect to a HNP. This commit also makes orte_universe_t an opal_object_t, which is something that needed to happen, and only effected the SDS in one of it's base functions. I was asked to bring this over to aid in fixing orteconsole and orteprobe. Due to the change of orte_universe_t to an object orteprobe may need to be updated to reflect this change. Since orteprobe needs to be looked at anyway I'll leave this to Ralph to take care of. *Note*: These changes do not depend upon any of the FT work (but the FT work does depend upon them). These were brought over to help in fixing some of the ORTE tool set that require the functionality layed out in this patch. Testing: Ran the 'ibm' tests before and after this change, and all was as well as before the change. If anyone notices additional irregularities in the system let me know. But none are expected. This commit was SVN r10550.
2006-06-29 01:03:31 +04:00
OBJ_DESTRUCT(&orte_universe_info);
return ORTE_SUCCESS;
}