Commit c6dd1a84 authored by Shane Snyder's avatar Shane Snyder

more changes to swim api

parent 4a25aed1
...@@ -130,6 +130,7 @@ static int ssg_get_swim_dping_target( ...@@ -130,6 +130,7 @@ static int ssg_get_swim_dping_target(
hg_addr_t *target_addr); hg_addr_t *target_addr);
static int ssg_get_swim_iping_targets( static int ssg_get_swim_iping_targets(
void *group_data, void *group_data,
int *num_targets,
swim_member_id_t *target_ids, swim_member_id_t *target_ids,
hg_addr_t *target_addrs); hg_addr_t *target_addrs);
static void ssg_get_swim_member_addr( static void ssg_get_swim_member_addr(
...@@ -160,7 +161,11 @@ static int ssg_get_swim_dping_target( ...@@ -160,7 +161,11 @@ static int ssg_get_swim_dping_target(
/* if current member list is empty, generate a new random one */ /* if current member list is empty, generate a new random one */
if (g->member_list == NULL) if (g->member_list == NULL)
{
ssg_gen_rand_member_list(g); ssg_gen_rand_member_list(g);
if(g->member_list == NULL)
return -1;
}
/* pull random member off head of list and return addr */ /* pull random member off head of list and return addr */
target_ms = g->member_list; target_ms = g->member_list;
...@@ -171,19 +176,6 @@ static int ssg_get_swim_dping_target( ...@@ -171,19 +176,6 @@ static int ssg_get_swim_dping_target(
return 0; return 0;
} }
static int ssg_get_swim_iping_targets(
void *group_data,
swim_member_id_t *target_id,
hg_addr_t *target_addrs)
{
ssg_group_t *g = (ssg_group_t *)group_data;
assert(g != NULL);
return 0;
}
static void ssg_gen_rand_member_list(ssg_group_t *g) static void ssg_gen_rand_member_list(ssg_group_t *g)
{ {
ssg_member_state_t *ms, *tmp; ssg_member_state_t *ms, *tmp;
...@@ -197,6 +189,22 @@ static void ssg_gen_rand_member_list(ssg_group_t *g) ...@@ -197,6 +189,22 @@ static void ssg_gen_rand_member_list(ssg_group_t *g)
return; return;
} }
static int ssg_get_swim_iping_targets(
void *group_data,
int *num_targets,
swim_member_id_t *target_id,
hg_addr_t *target_addrs)
{
ssg_group_t *g = (ssg_group_t *)group_data;
int max_targets = *num_targets;
assert(g != NULL);
*num_targets = 0;
return 0;
}
static void ssg_get_swim_member_addr( static void ssg_get_swim_member_addr(
void *group_data, void *group_data,
swim_member_id_t id, swim_member_id_t id,
...@@ -209,7 +217,7 @@ static void ssg_get_swim_member_addr( ...@@ -209,7 +217,7 @@ static void ssg_get_swim_member_addr(
assert(g != NULL); assert(g != NULL);
HASH_FIND(hh, g->view.member_map, &ssg_id, sizeof(ssg_member_id_t), ms); HASH_FIND(hh, g->view.member_map, &ssg_id, sizeof(ssg_member_id_t), ms);
/* XXX ASSERT */ assert(ms != NULL);
*addr = ms->addr; *addr = ms->addr;
...@@ -228,7 +236,7 @@ static void ssg_get_swim_member_state( ...@@ -228,7 +236,7 @@ static void ssg_get_swim_member_state(
assert(g != NULL); assert(g != NULL);
HASH_FIND(hh, g->view.member_map, &ssg_id, sizeof(ssg_member_id_t), ms); HASH_FIND(hh, g->view.member_map, &ssg_id, sizeof(ssg_member_id_t), ms);
/* XXX ASSERT */ assert(ms != NULL);
*state = &ms->swim_state; *state = &ms->swim_state;
...@@ -1201,21 +1209,12 @@ static int ssg_group_view_create( ...@@ -1201,21 +1209,12 @@ static int ssg_group_view_create(
if (strcmp(self_addr_substr, addr_substr) == 0) if (strcmp(self_addr_substr, addr_substr) == 0)
{ {
hret = margo_addr_dup(ssg_inst->mid, self_addr, &tmp_ms->addr);
if (hret != HG_SUCCESS)
{
free(tmp_ms->addr_str);
free(tmp_ms);
goto fini;
}
if (self_id) if (self_id)
*self_id = tmp_ms->id; *self_id = tmp_ms->id;
/* XXX: add self state to membership view? or somewhere static? */
//HASH_ADD(hh, view->member_map, id, sizeof(ssg_member_id_t), tmp_ms);
/* don't look up our own address, we already know it */ /* don't look up our own address, we already know it */
free(tmp_ms->addr_str);
free(tmp_ms);
continue; continue;
} }
} }
......
...@@ -192,8 +192,10 @@ static void swim_tick_ult( ...@@ -192,8 +192,10 @@ static void swim_tick_ult(
if(!(swim_ctx->ping_target_acked) && (swim_ctx->prot_subgroup_sz > 0)) if(!(swim_ctx->ping_target_acked) && (swim_ctx->prot_subgroup_sz > 0))
{ {
/* get a random subgroup of members to send indirect pings to */ /* get a random subgroup of members to send indirect pings to */
int iping_target_count = swim_ctx->swim_callbacks.get_iping_targets( int iping_target_count = swim_ctx->prot_subgroup_sz;
swim_ctx->group_data, swim_ctx->iping_target_ids, swim_ctx->iping_target_addrs); swim_ctx->swim_callbacks.get_iping_targets(
swim_ctx->group_data, &iping_target_count, swim_ctx->iping_target_ids,
swim_ctx->iping_target_addrs);
if(iping_target_count == 0) if(iping_target_count == 0)
{ {
/* no available subgroup members, back out */ /* no available subgroup members, back out */
......
...@@ -58,7 +58,7 @@ typedef struct swim_group_mgmt_callbacks ...@@ -58,7 +58,7 @@ typedef struct swim_group_mgmt_callbacks
* @param[out] target_id ID of selected direct ping target * @param[out] target_id ID of selected direct ping target
* @param[out] inc_nr SWIM incarnation number of target * @param[out] inc_nr SWIM incarnation number of target
* @param[out] target_addr HG address of target * @param[out] target_addr HG address of target
* @returns 1 on successful selection of a target, 0 if no targets available * @returns 0 on successful selection of a target, -1 if no available targets
*/ */
int (*get_dping_target)( int (*get_dping_target)(
void *group_data, void *group_data,
...@@ -70,13 +70,17 @@ typedef struct swim_group_mgmt_callbacks ...@@ -70,13 +70,17 @@ typedef struct swim_group_mgmt_callbacks
* Retrieve a set of (non-dead) random group members from the group * Retrieve a set of (non-dead) random group members from the group
* management layer to send indirect ping requests to. * management layer to send indirect ping requests to.
* *
* @param[in] group_data void pointer to group managment data * @param[in] group_data void pointer to group managment data
* @param[out] target_ids IDs of selected indirect ping targets * @param[in/out] num_targets on input, maximum number of indirect ping
* @param[out] target_addrs HG addresses of targets * targets to select. on output, the actual
* @returns number of selected indirect ping targets, 0 if no targets available * number of selected targets
* @param[out] target_ids IDs of selected indirect ping targets
* @param[out] target_addrs HG addresses of targets
* @returns 0 on successful selection of targets, -1 if no available targets
*/ */
int (*get_iping_targets)( int (*get_iping_targets)(
void *group_data, void *group_data,
int *num_targets,
swim_member_id_t *target_ids, swim_member_id_t *target_ids,
hg_addr_t *target_addrs hg_addr_t *target_addrs
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment