1
1

Added the local support functions for the replica. Everything compiles fine on my machine - next step is to test these functions.

This commit was SVN r2154.
Этот коммит содержится в:
Ralph Castain 2004-08-15 22:37:01 +00:00
родитель 6bdf9c0cbc
Коммит b433fc3ad9
5 изменённых файлов: 197 добавлений и 192 удалений

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

@ -8,4 +8,6 @@ noinst_LTLIBRARIES = libmca_gpr_replica.la
libmca_gpr_replica_la_SOURCES = \
gpr_replica.h \
gpr_replica.c \
gpr_replica_internals.h \
gpr_replica_internals.c \
gpr_replica_component.c

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

@ -18,13 +18,13 @@
*/
typedef uint32_t mca_gpr_replica_key_t;
struct ompi_registry_t {
struct mca_gpr_registry_t {
ompi_list_t registry;
ompi_list_t segment_dict;
mca_gpr_replica_key_t lastkey;
ompi_list_t freekeys;
};
typedef struct ompi_registry_t ompi_registry_t;
typedef struct mca_gpr_registry_t mca_gpr_registry_t;
/** Dictionary of token-key pairs.
* This structure is used to create a linked list of token-key pairs. All calls to
@ -33,41 +33,41 @@ typedef struct ompi_registry_t ompi_registry_t;
* for faster searches of the registry. This structure is also used to return token-key pairs
* from the dictionary in response to an ompi_registry_index() call.
*/
struct ompi_keytable_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
char *token; /**< Char string that defines the key */
unsigned long int key; /**< Numerical value assigned by registry to represent token string */
struct mca_gpr_keytable_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
char *token; /**< Char string that defines the key */
mca_gpr_replica_key_t key; /**< Numerical value assigned by registry to represent token string */
};
typedef struct ompi_keytable_t ompi_keytable_t;
typedef struct mca_gpr_keytable_t mca_gpr_keytable_t;
OBJ_CLASS_DECLARATION(ompi_keytable_t);
OBJ_CLASS_DECLARATION(mca_gpr_keytable_t);
/** List of keys that describe a stored object.
* Each object stored in the registry may have as many keys describing it as the
* creator desires. This structure is used to create a linked list of keys
* associated with each object.
*/
struct ompi_keylist_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
unsigned long int key; /**< Numerical key that defines stored object */
struct mca_gpr_keylist_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
mca_gpr_replica_key_t key; /**< Numerical key that defines stored object */
};
typedef struct ompi_keylist_t ompi_keylist_t;
typedef struct mca_gpr_keylist_t mca_gpr_keylist_t;
OBJ_CLASS_DECLARATION(ompi_keylist_t);
OBJ_CLASS_DECLARATION(mca_gpr_keylist_t);
/** List of subscribers to a stored object.
* Each object can have an arbitrary number of subscribers desiring notification
* upon specified actions being performed against the object. This structure is
* used to create a linked list of subscribers for objects.
*/
struct ompi_subscribe_list_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
unsigned long int id; /**< ID of the subscriber */
uint8_t action; /**< Bit-mask of actions that trigger notification */
struct mca_gpr_subscriber_list_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
ompi_process_name_t *subscriber; /**< ID of the subscriber */
ompi_registry_notify_action_t action; /**< Bit-mask of actions that trigger notification */
};
typedef struct ompi_subscribe_list_t ompi_subscribe_list_t;
typedef struct mca_gpr_subscriber_list_t mca_gpr_subscriber_list_t;
OBJ_CLASS_DECLARATION(ompi_subscribe_list_t);
OBJ_CLASS_DECLARATION(mca_gpr_subscribe_list_t);
/** List of replicas that hold a stored object.
* Each object can have an arbitrary number of replicas that hold a copy
@ -75,13 +75,13 @@ OBJ_CLASS_DECLARATION(ompi_subscribe_list_t);
* two locations. This structure is used to create a linked list of
* replicas for the object.
*/
struct ompi_replica_list_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
char *name; /**< Name of the replica */
struct mca_gpr_replica_list_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
ompi_process_name_t *replica; /**< Name of the replica */
};
typedef struct ompi_replica_list_t ompi_replica_list_t;
typedef struct mca_gpr_replica_list_t mca_gpr_replica_list_t;
OBJ_CLASS_DECLARATION(ompi_replica_list_t);
OBJ_CLASS_DECLARATION(mca_gpr_replica_list_t);
/** Write invalidate structure.
* The structure used to indicate that an object has been updated somewhere else in the GPR.
@ -90,12 +90,12 @@ OBJ_CLASS_DECLARATION(ompi_replica_list_t);
* of the object within the global registry, and the replica holding the last known
* up-to-date version of the object.
*/
struct ompi_write_invalidate_t {
struct mca_gpr_write_invalidate_t {
bool invalidate;
time_t last_mod;
char *replica;
ompi_process_name_t *valid_replica;
};
typedef struct ompi_write_invalidate_t ompi_write_invalidate_t;
typedef struct mca_gpr_write_invalidate_t mca_gpr_write_invalidate_t;
/** The core registry structure.
@ -110,18 +110,18 @@ typedef struct ompi_write_invalidate_t ompi_write_invalidate_t;
* object are automatically granted. This may be changed at some future time by adding an
* "authorization" linked list of ID's and their access rights to this structure.
*/
struct ompi_registry_core_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
ompi_list_t keys; /**< Linked list of keys that define stored object */
int object_size; /**< Size of stored object, in bytes */
uint8_t *object; /**< Pointer to stored object */
ompi_list_t subscriber; /**< Linked list of subscribers to this object */
ompi_list_t replicas; /**< Linked list of replicas that also contain this object */
ompi_write_invalidate_t write_invalidate; /**< Structure containing write invalidate info */
struct mca_gpr_registry_core_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
ompi_list_t keys; /**< Linked list of keys that define stored object */
ompi_registry_object_size_t object_size; /**< Size of stored object, in bytes */
ompi_registry_object_t *object; /**< Pointer to stored object */
ompi_list_t subscriber; /**< Linked list of subscribers to this object */
ompi_list_t replicas; /**< Linked list of replicas that also contain this object */
mca_gpr_write_invalidate_t write_invalidate; /**< Structure containing write invalidate info */
};
typedef struct ompi_registry_core_t ompi_registry_core_t;
typedef struct mca_gpr_registry_core_t mca_gpr_registry_core_t;
OBJ_CLASS_DECLARATION(ompi_registry_core_t);
OBJ_CLASS_DECLARATION(mca_gpr_registry_core_t);
/** Registry segment definition.
* The registry is subdivided into segments, each defining a unique domain. The "universe" segment
@ -132,23 +132,23 @@ OBJ_CLASS_DECLARATION(ompi_registry_core_t);
* list of registry elements for that segment. Each segment also holds its own token-key dictionary
* to avoid naming conflicts between tokens from CommWorlds sharing a given universe.
*/
struct ompi_registry_segment_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
unsigned long int segment; /**< ID of registry segment */
unsigned long int lastkey; /**< Highest key value used */
ompi_list_t reg_list; /**< Linked list of stored objects within this segment */
ompi_list_t keytable; /**< Token-key dictionary for this segment */
ompi_list_t freekeys; /**< List of keys that have been made available */
struct mca_gpr_registry_segment_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
mca_gpr_replica_key_t segment; /**< Key corresponding to name of registry segment */
mca_gpr_replica_key_t lastkey; /**< Highest key value used */
ompi_list_t registry_entries; /**< Linked list of stored objects within this segment */
ompi_list_t keytable; /**< Token-key dictionary for this segment */
ompi_list_t freekeys; /**< List of keys that have been made available */
};
typedef struct ompi_registry_segment_t ompi_registry_segment_t;
typedef struct mca_gpr_registry_segment_t mca_gpr_registry_segment_t;
OBJ_CLASS_DECLARATION(ompi_registry_segment_t);
OBJ_CLASS_DECLARATION(mca_gpr_registry_segment_t);
/*
* globals needed within component
*/
extern ompi_registry_t mca_gpr_head;
extern mca_gpr_registry_t mca_gpr_replica_head;
/*
* Module open / close

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

@ -65,18 +65,18 @@ static bool initialized = false;
/*
* globals needed within replica component
*/
ompi_registry_t mca_gpr_head;
mca_gpr_registry_t mca_gpr_replica_head;
/* constructor - used to initialize state of keytable instance */
static void ompi_keytable_construct(ompi_keytable_t* keytable)
static void mca_gpr_keytable_construct(mca_gpr_keytable_t* keytable)
{
keytable->token = NULL;
keytable->key = 0;
}
/* destructor - used to free any resources held by instance */
static void ompi_keytable_destructor(ompi_keytable_t* keytable)
static void mca_gpr_keytable_destructor(mca_gpr_keytable_t* keytable)
{
if (NULL != keytable->token) {
free(keytable->token);
@ -85,125 +85,130 @@ static void ompi_keytable_destructor(ompi_keytable_t* keytable)
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_keytable_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_keytable_construct, /* constructor */
ompi_keytable_destructor); /* destructor */
mca_gpr_keytable_t, /* type name */
ompi_list_item_t, /* parent "class" name */
mca_gpr_keytable_construct, /* constructor */
mca_gpr_keytable_destructor); /* destructor */
/* constructor - used to initialize state of keytable instance */
static void ompi_keylist_construct(ompi_keylist_t* keylist)
static void mca_gpr_keylist_construct(mca_gpr_keylist_t* keylist)
{
keylist->key = 0;
}
/* destructor - used to free any resources held by instance */
static void ompi_keylist_destructor(ompi_keylist_t* keylist)
static void mca_gpr_keylist_destructor(mca_gpr_keylist_t* keylist)
{
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_keylist_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_keylist_construct, /* constructor */
ompi_keylist_destructor); /* destructor */
mca_gpr_keylist_t, /* type name */
ompi_list_item_t, /* parent "class" name */
mca_gpr_keylist_construct, /* constructor */
mca_gpr_keylist_destructor); /* destructor */
/* constructor - used to initialize state of keytable instance */
static void ompi_subscribe_list_construct(ompi_subscribe_list_t* subscriber)
static void mca_gpr_subscriber_list_construct(mca_gpr_subscriber_list_t* subscriber)
{
subscriber->id = 0;
subscriber->subscriber = NULL;
subscriber->action = 0x00;
}
/* destructor - used to free any resources held by instance */
static void ompi_subscribe_list_destructor(ompi_subscribe_list_t* subscriber)
static void mca_gpr_subscriber_list_destructor(mca_gpr_subscriber_list_t* subscriber)
{
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_subscribe_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_subscribe_list_construct, /* constructor */
ompi_subscribe_list_destructor); /* destructor */
/* constructor - used to initialize state of replica list instance */
static void ompi_replica_list_construct(ompi_replica_list_t* replica)
{
replica->name = NULL;
}
/* destructor - used to free any resources held by instance */
static void ompi_replica_list_destructor(ompi_replica_list_t* replica)
{
if (NULL != replica->name) {
free(replica->name);
if (NULL != subscriber->subscriber) {
free(subscriber->subscriber);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_replica_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_replica_list_construct, /* constructor */
ompi_replica_list_destructor); /* destructor */
mca_gpr_subscriber_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
mca_gpr_subscriber_list_construct, /* constructor */
mca_gpr_subscriber_list_destructor); /* destructor */
/* constructor - used to initialize state of replica list instance */
static void mca_gpr_replica_list_construct(mca_gpr_replica_list_t* replica)
{
replica->replica = NULL;
}
/* destructor - used to free any resources held by instance */
static void mca_gpr_replica_list_destructor(mca_gpr_replica_list_t* replica)
{
if (NULL != replica->replica) {
free(replica->replica);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
mca_gpr_replica_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
mca_gpr_replica_list_construct, /* constructor */
mca_gpr_replica_list_destructor); /* destructor */
/* constructor - used to initialize state of registry core instance */
static void ompi_registry_core_construct(ompi_registry_core_t* reg)
static void mca_gpr_registry_core_construct(mca_gpr_registry_core_t* reg)
{
reg->object = NULL;
reg->object_size = 0;
OBJ_CONSTRUCT(&reg->subscriber, ompi_list_t);
OBJ_CONSTRUCT(&reg->keys, ompi_list_t);
reg->object_size = 0;
reg->object = NULL;
OBJ_CONSTRUCT(&reg->subscriber, ompi_list_t);
OBJ_CONSTRUCT(&reg->replicas, ompi_list_t);
}
/* destructor - used to free any resources held by instance */
static void ompi_registry_core_destructor(ompi_registry_core_t* reg)
static void mca_gpr_registry_core_destructor(mca_gpr_registry_core_t* reg)
{
OBJ_DESTRUCT(&reg->keys);
if (NULL != reg->object) {
free(reg->object);
}
OBJ_DESTRUCT(&reg->subscriber);
OBJ_DESTRUCT(&reg->keys);
OBJ_DESTRUCT(&reg->replicas);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_registry_core_t, /* type name */
mca_gpr_registry_core_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_registry_core_construct, /* constructor */
ompi_registry_core_destructor); /* destructor */
mca_gpr_registry_core_construct, /* constructor */
mca_gpr_registry_core_destructor); /* destructor */
/* constructor - used to initialize state of segment instance */
static void ompi_registry_segment_construct(ompi_registry_segment_t* seg)
static void mca_gpr_registry_segment_construct(mca_gpr_registry_segment_t* seg)
{
seg->segment = 0;
seg->segment = NULL;
seg->lastkey = 0;
OBJ_CONSTRUCT(&seg->reg_list, ompi_list_t);
OBJ_CONSTRUCT(&seg->registry_entries, ompi_list_t);
OBJ_CONSTRUCT(&seg->keytable, ompi_list_t);
OBJ_CONSTRUCT(&seg->freekeys, ompi_list_t);
}
/* destructor - used to free any resources held by instance */
static void ompi_registry_segment_destructor(ompi_registry_segment_t* seg)
static void mca_gpr_registry_segment_destructor(mca_gpr_registry_segment_t* seg)
{
OBJ_DESTRUCT(&seg->reg_list);
OBJ_DESTRUCT(&seg->registry_entries);
OBJ_DESTRUCT(&seg->keytable);
OBJ_DESTRUCT(&seg->freekeys);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
ompi_registry_segment_t, /* type name */
mca_gpr_registry_segment_t, /* type name */
ompi_list_item_t, /* parent "class" name */
ompi_registry_segment_construct, /* constructor */
ompi_registry_segment_destructor); /* destructor */
mca_gpr_registry_segment_construct, /* constructor */
mca_gpr_registry_segment_destructor); /* destructor */
/*
@ -246,12 +251,12 @@ mca_gpr_base_module_t *mca_gpr_replica_init(bool *allow_multi_user_threads, bool
*have_hidden_threads = false;
/* initialize the registry head */
OBJ_CONSTRUCT(&mca_gpr_head.registry, ompi_list_t);
OBJ_CONSTRUCT(&mca_gpr_replica_head.registry, ompi_list_t);
/* initialize the global dictionary for segment id's */
OBJ_CONSTRUCT(&mca_gpr_head.segment_dict, ompi_list_t);
OBJ_CONSTRUCT(&mca_gpr_head.freekeys, ompi_list_t);
mca_gpr_head.lastkey = 0;
OBJ_CONSTRUCT(&mca_gpr_replica_head.segment_dict, ompi_list_t);
OBJ_CONSTRUCT(&mca_gpr_replica_head.freekeys, ompi_list_t);
mca_gpr_replica_head.lastkey = 0;
/* define the "universe" segment key */
/* if (0 == gpr_replica_definekey("universe", NULL)) {

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

@ -30,24 +30,24 @@
/*
*
*/
ompi_registry_segment_t *ompi_registry_findseg(char *segment)
mca_gpr_registry_segment_t *gpr_replica_find_seg(char *segment)
{
ompi_keytable_t *ptr_seg;
ompi_registry_segment_t *seg;
mca_gpr_keytable_t *ptr_seg;
mca_gpr_registry_segment_t *seg;
/* search the registry segments to find which one is being referenced */
for (ptr_seg = (ompi_keytable_t*)ompi_list_get_first(&ompi_registry.segment_dict);
ptr_seg != (ompi_keytable_t*)ompi_list_get_end(&ompi_registry.segment_dict);
ptr_seg = (ompi_keytable_t*)ompi_list_get_next(ptr_seg)) {
for (ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_first(&mca_gpr_replica_head.segment_dict);
ptr_seg != (mca_gpr_keytable_t*)ompi_list_get_end(&mca_gpr_replica_head.segment_dict);
ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_next(ptr_seg)) {
if (0 == strcmp(segment, ptr_seg->token)) {
fprintf(stderr, "findseg: found segment token %s key %ld\n", ptr_seg->token, ptr_seg->key);
/* search ompi_registry to find segment */
for (seg=(ompi_registry_segment_t*)ompi_list_get_first(&ompi_registry.registry);
seg != (ompi_registry_segment_t*)ompi_list_get_end(&ompi_registry.registry);
seg = (ompi_registry_segment_t*)ompi_list_get_next(seg)) {
fprintf(stderr, "findseg: found segment token %s key %d\n", ptr_seg->token, (int)ptr_seg->key);
/* search mca_gpr_replica_head to find segment */
for (seg=(mca_gpr_registry_segment_t*)ompi_list_get_first(&mca_gpr_replica_head.registry);
seg != (mca_gpr_registry_segment_t*)ompi_list_get_end(&mca_gpr_replica_head.registry);
seg = (mca_gpr_registry_segment_t*)ompi_list_get_next(seg)) {
fprintf(stderr, "findseg: checking seg\n");
if(seg->segment == ptr_seg->key) {
fprintf(stderr, "findseg: found segment key %ld\n", seg->segment);
fprintf(stderr, "findseg: found segment key %d\n", (int)seg->segment);
return(seg);
}
}
@ -56,29 +56,29 @@ ompi_registry_segment_t *ompi_registry_findseg(char *segment)
return(NULL); /* couldn't find the specified segment */
}
ompi_keytable_t *ompi_registry_finddictentry(char *segment, char *token)
mca_gpr_keytable_t *gpr_replica_find_dict_entry(char *segment, char *token)
{
ompi_keytable_t *ptr_seg;
ompi_keytable_t *ptr_key;
ompi_registry_segment_t *seg;
mca_gpr_keytable_t *ptr_seg;
mca_gpr_keytable_t *ptr_key;
mca_gpr_registry_segment_t *seg;
/* search the registry segments to find which one is being referenced */
for (ptr_seg = (ompi_keytable_t*)ompi_list_get_first(&ompi_registry.segment_dict);
ptr_seg != (ompi_keytable_t*)ompi_list_get_end(&ompi_registry.segment_dict);
ptr_seg = (ompi_keytable_t*)ompi_list_get_next(ptr_seg)) {
for (ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_first(&mca_gpr_replica_head.segment_dict);
ptr_seg != (mca_gpr_keytable_t*)ompi_list_get_end(&mca_gpr_replica_head.segment_dict);
ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_next(ptr_seg)) {
if (0 == strcmp(segment, ptr_seg->token)) {
if (NULL == token) { /* just want segment token-key pair */
return(ptr_seg);
}
/* search ompi_registry to find segment */
for (seg=(ompi_registry_segment_t*)ompi_list_get_first(&ompi_registry.registry);
seg != (ompi_registry_segment_t*)ompi_list_get_end(&ompi_registry.registry);
seg = (ompi_registry_segment_t*)ompi_list_get_next(seg)) {
/* search registry to find segment */
for (seg=(mca_gpr_registry_segment_t*)ompi_list_get_first(&mca_gpr_replica_head.registry);
seg != (mca_gpr_registry_segment_t*)ompi_list_get_end(&mca_gpr_replica_head.registry);
seg = (mca_gpr_registry_segment_t*)ompi_list_get_next(seg)) {
if(seg->segment == ptr_seg->key) {
/* got segment - now find specified token-key pair in that dictionary */
for (ptr_key = (ompi_keytable_t*)ompi_list_get_first(&seg->keytable);
ptr_key != (ompi_keytable_t*)ompi_list_get_end(&seg->keytable);
ptr_key = (ompi_keytable_t*)ompi_list_get_next(ptr_key)) {
for (ptr_key = (mca_gpr_keytable_t*)ompi_list_get_first(&seg->keytable);
ptr_key != (mca_gpr_keytable_t*)ompi_list_get_end(&seg->keytable);
ptr_key = (mca_gpr_keytable_t*)ompi_list_get_next(ptr_key)) {
if (0 == strcmp(token, ptr_key->token)) {
return(ptr_key);
}
@ -93,18 +93,18 @@ ompi_keytable_t *ompi_registry_finddictentry(char *segment, char *token)
}
mca_gpr_replica_key_t ompi_registry_getkey(char *segment, char *token)
mca_gpr_replica_key_t gpr_replica_get_key(char *segment, char *token)
{
ompi_keytable_t *ptr_key;
mca_gpr_keytable_t *ptr_key;
/* find registry segment */
ptr_key = ompi_registry_finddictentry(segment, NULL);
ptr_key = gpr_replica_find_dict_entry(segment, NULL);
if (NULL != ptr_key) {
if (NULL == token) { /* only want segment key */
return(ptr_key->key);
}
/* if token specified, find the dictionary entry that matches token */
ptr_key = ompi_registry_finddictentry(segment, token);
ptr_key = gpr_replica_find_dict_entry(segment, token);
if (NULL != ptr_key) {
return(ptr_key->key);
}
@ -114,10 +114,10 @@ mca_gpr_replica_key_t ompi_registry_getkey(char *segment, char *token)
}
mca_gpr_relica_key_t gpr_replica_definekey(char *segment, char *token)
mca_gpr_replica_key_t gpr_replica_define_key(char *segment, char *token)
{
ompi_registry_segment_t *seg;
ompi_keytable_t *ptr_seg, *ptr_key, *new;
mca_gpr_registry_segment_t *seg;
mca_gpr_keytable_t *ptr_seg, *ptr_key, *new;
/* protect against errors */
if (NULL == segment) {
@ -126,48 +126,48 @@ mca_gpr_relica_key_t gpr_replica_definekey(char *segment, char *token)
/* if token is NULL, then this is defining a segment name. Check dictionary to ensure uniqueness */
if (NULL == token) {
for (ptr_seg = (ompi_keytable_t*)ompi_list_get_first(&ompi_registry.segment_dict);
ptr_seg != (ompi_keytable_t*)ompi_list_get_end(&ompi_registry.segment_dict);
ptr_seg = (ompi_keytable_t*)ompi_list_get_next(ptr_seg)) {
for (ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_first(&mca_gpr_replica_head.segment_dict);
ptr_seg != (mca_gpr_keytable_t*)ompi_list_get_end(&mca_gpr_replica_head.segment_dict);
ptr_seg = (mca_gpr_keytable_t*)ompi_list_get_next(ptr_seg)) {
if (0 == strcmp(segment, ptr_seg->token)) {
return(0);
}
}
/* okay, name is not previously taken. Define a key value for it and return */
new = OBJ_NEW(ompi_keytable_t);
new = OBJ_NEW(mca_gpr_keytable_t);
new->token = strdup(segment);
if (0 == ompi_list_get_size(&ompi_registry.freekeys)) { /* no keys waiting for reuse */
ompi_registry.lastkey++;
new->key = ompi_registry.lastkey;
if (0 == ompi_list_get_size(&mca_gpr_replica_head.freekeys)) { /* no keys waiting for reuse */
mca_gpr_replica_head.lastkey++;
new->key = mca_gpr_replica_head.lastkey;
} else {
ptr_key = (ompi_keytable_t*)ompi_list_remove_first(&ompi_registry.freekeys);
ptr_key = (mca_gpr_keytable_t*)ompi_list_remove_first(&mca_gpr_replica_head.freekeys);
new->key = ptr_key->key;
}
ompi_list_append(&ompi_registry.segment_dict, &new->item);
ompi_list_append(&mca_gpr_replica_head.segment_dict, &new->item);
return(new->key);
}
/* okay, token is specified */
/* search the registry segments to find which one is being referenced */
seg = ompi_registry_findseg(segment);
seg = gpr_replica_find_seg(segment);
if (NULL != seg) {
/* using that segment, check dictionary to ensure uniqueness */
for (ptr_key = (ompi_keytable_t*)ompi_list_get_first(&seg->keytable);
ptr_key != (ompi_keytable_t*)ompi_list_get_end(&seg->keytable);
ptr_key = (ompi_keytable_t*)ompi_list_get_next(ptr_key)) {
for (ptr_key = (mca_gpr_keytable_t*)ompi_list_get_first(&seg->keytable);
ptr_key != (mca_gpr_keytable_t*)ompi_list_get_end(&seg->keytable);
ptr_key = (mca_gpr_keytable_t*)ompi_list_get_next(ptr_key)) {
if (0 == strcmp(token, ptr_key->token)) {
return(0); /* already taken, report error */
}
}
/* okay, token is unique - create dictionary entry */
new = OBJ_NEW(ompi_keytable_t);
new = OBJ_NEW(mca_gpr_keytable_t);
new->token = strdup(token);
if (0 == ompi_list_get_size(&seg->freekeys)) { /* no keys waiting for reuse */
seg->lastkey++;
new->key = seg->lastkey;
} else {
ptr_key = (ompi_keytable_t*)ompi_list_remove_first(&seg->freekeys);
ptr_key = (mca_gpr_keytable_t*)ompi_list_remove_first(&seg->freekeys);
new->key = ptr_key->key;
}
ompi_list_append(&seg->keytable, &new->item);
@ -177,12 +177,11 @@ mca_gpr_relica_key_t gpr_replica_definekey(char *segment, char *token)
return(0);
}
int ompi_registry_deletekey(char *segment, char *token)
int gpr_replica_delete_key(char *segment, char *token)
{
ompi_registry_segment_t *seg;
ompi_registry_core_t *reg, *prev;
ompi_keytable_t *ptr_seg, *ptr_key, *new, *regkey;
ompi_subscribe_list_t *subscriber;
mca_gpr_registry_segment_t *seg;
mca_gpr_registry_core_t *reg, *prev;
mca_gpr_keytable_t *ptr_seg, *ptr_key, *new, *regkey;
/* protect ourselves against errors */
if (NULL == segment) {
@ -190,13 +189,14 @@ int ompi_registry_deletekey(char *segment, char *token)
}
/* find the segment */
seg = ompi_registry_findseg(segment);
seg = gpr_replica_find_seg(segment);
if (NULL != seg) {
/* if specified token is NULL, then this is deleting a segment name.*/
if (NULL == token) {
/* empty the segment's registry */
while (0 < ompi_list_get_size(&seg->reg_list)) {
ompi_list_remove_last(&seg->reg_list);
while (0 < ompi_list_get_size(&seg->registry_entries)) {
ompi_list_remove_last(&seg->registry_entries);
}
/* empty the segment's dictionary */
while (0 < ompi_list_get_size(&seg->keytable)) {
@ -207,38 +207,32 @@ int ompi_registry_deletekey(char *segment, char *token)
ompi_list_remove_last(&seg->freekeys);
}
/* now remove segment from global registry */
ompi_list_remove_item(&ompi_registry.registry, &seg->item);
ompi_list_remove_item(&mca_gpr_replica_head.registry, &seg->item);
/* add key to global registry's freekey list */
new = OBJ_NEW(ompi_keytable_t);
new = OBJ_NEW(mca_gpr_keytable_t);
new->token = NULL;
new->key = ptr_seg->key;
ompi_list_append(&ompi_registry.freekeys, &new->item);
ompi_list_append(&mca_gpr_replica_head.freekeys, &new->item);
/* NEED TO RE-FIND PTR_SEG */
/* now remove the dictionary entry from the global registry dictionary*/
ompi_list_remove_item(&ompi_registry.segment_dict, &ptr_seg->item);
ompi_list_remove_item(&mca_gpr_replica_head.segment_dict, &ptr_seg->item);
return(OMPI_SUCCESS);
} else { /* token not null, so need to find dictionary element to delete */
ptr_key = ompi_registry_finddictentry(segment, token);
ptr_key = gpr_replica_find_dict_entry(segment, token);
if (NULL != ptr_key) {
/* found key in dictionary */
/* need to search this segment's registry to find all instances of key - then delete them */
for (reg = (ompi_registry_core_t*)ompi_list_get_first(&seg->reg_list);
reg != (ompi_registry_core_t*)ompi_list_get_end(&seg->reg_list);
reg = (ompi_registry_core_t*)ompi_list_get_next(reg)) {
/* check the subscriber list */
for (subscriber = (ompi_subscribe_list_t*)ompi_list_get_first(&reg->subscriber);
(subscriber != (ompi_subscribe_list_t*)ompi_list_get_end(&reg->subscriber)
&& (subscriber->id != ptr_key->key));
subscriber = (ompi_subscribe_list_t*)ompi_list_get_next(subscriber));
if (subscriber != (ompi_subscribe_list_t*)ompi_list_get_end(&reg->subscriber)) {
ompi_list_remove_item(&reg->subscriber, &subscriber->item);
}
for (reg = (mca_gpr_registry_core_t*)ompi_list_get_first(&seg->registry_entries);
reg != (mca_gpr_registry_core_t*)ompi_list_get_end(&seg->registry_entries);
reg = (mca_gpr_registry_core_t*)ompi_list_get_next(reg)) {
/* check the key list */
for (regkey = (ompi_keytable_t*)ompi_list_get_first(&reg->keys);
(regkey != (ompi_keytable_t*)ompi_list_get_end(&reg->keys))
for (regkey = (mca_gpr_keytable_t*)ompi_list_get_first(&reg->keys);
(regkey != (mca_gpr_keytable_t*)ompi_list_get_end(&reg->keys))
&& (regkey->key != ptr_key->key);
regkey = (ompi_keytable_t*)ompi_list_get_next(regkey));
if (regkey != (ompi_keytable_t*)ompi_list_get_end(&reg->keys)) {
regkey = (mca_gpr_keytable_t*)ompi_list_get_next(regkey));
if (regkey != (mca_gpr_keytable_t*)ompi_list_get_end(&reg->keys)) {
ompi_list_remove_item(&reg->keys, &regkey->item);
}
/* if this was the last key, then remove the registry entry itself */
@ -246,16 +240,18 @@ int ompi_registry_deletekey(char *segment, char *token)
while (0 < ompi_list_get_size(&reg->subscriber)) {
ompi_list_remove_last(&reg->subscriber);
}
prev = (ompi_registry_core_t*)ompi_list_get_prev(reg);
ompi_list_remove_item(&seg->reg_list, &reg->item);
prev = (mca_gpr_registry_core_t*)ompi_list_get_prev(reg);
ompi_list_remove_item(&seg->registry_entries, &reg->item);
reg = prev;
}
}
/* add key to this segment's freekey list */
new = OBJ_NEW(ompi_keytable_t);
new = OBJ_NEW(mca_gpr_keytable_t);
new->token = NULL;
new->key = ptr_key->key;
ompi_list_append(&seg->freekeys, &new->item);
/* now remove the dictionary entry from the segment's dictionary */
ompi_list_remove_item(&seg->keytable, &ptr_key->item);
return(OMPI_SUCCESS);

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

@ -18,7 +18,7 @@
* @retval key Unsigned long integer value corresponding to the specified token within the specified segment.
* @retval -1 Indicates that the segment and/or token could not be found.
*/
mca_gpr_replica_key_t gpr_replica_getkey(char *segment, char *token);
mca_gpr_replica_key_t gpr_replica_get_key(char *segment, char *token);
/** Add a token to a segment's dictionary.
* The gpr_replica_definekey() function allows the addition of a new definition to
@ -33,7 +33,7 @@ mca_gpr_replica_key_t gpr_replica_getkey(char *segment, char *token);
* @retval key Unsigned long integer value corresponding to the specified token within the specified segment.
* @retval -1 Indicates that the entry could not be created.
*/
mca_gpr_replica_key_t gpr_replica_definekey(char *segment, char *token);
mca_gpr_replica_key_t gpr_replica_define_key(char *segment, char *token);
/** Delete a token from a segment's dictionary.
* The gpr_replica_deletekey() function allows the removal of a definition from the
@ -51,7 +51,7 @@ mca_gpr_replica_key_t gpr_replica_definekey(char *segment, char *token);
* @retval OMPI_ERROR Indicates that the operation failed - most likely caused by specifying
* a token that did not exist within the specified segment, or a non-existent segment.
*/
int gpr_replica_deletekey(char *segment, char *token);
int gpr_replica_delete_key(char *segment, char *token);
/** Find a requested registry segment.
* The gpr_replica_findseq() function finds the registry segment corresponding to
@ -62,5 +62,7 @@ int gpr_replica_deletekey(char *segment, char *token);
* @retval *seg Pointer to the segment
* @retval NULL Indicates that the specified segment could not be found
*/
ompi_registry_segment_t *gpr_replica_findseg(char *segment);
mca_gpr_registry_segment_t *gpr_replica_find_seg(char *segment);
mca_gpr_keytable_t *gpr_replica_find_dict_entry(char *segment, char *token);