Commit 5372d4df authored by Shane Snyder's avatar Shane Snyder

get SWIM to use SSG dping fn

parent f6d7f3fb
......@@ -65,7 +65,6 @@ typedef struct ssg_group_descriptor
typedef struct ssg_group_view
{
unsigned int size;
ssg_member_state_t *member_list;
ssg_member_state_t *member_map;
} ssg_group_view_t;
......@@ -76,6 +75,7 @@ typedef struct ssg_group
ssg_group_view_t view;
ssg_group_descriptor_t *descriptor;
swim_context_t *swim_ctx;
ssg_member_state_t *member_list;
ssg_membership_update_cb update_cb;
void *update_cb_dat;
UT_hash_handle hh;
......
......@@ -248,7 +248,7 @@ DEFINE_MARGO_RPC_HANDLER(ssg_group_attach_recv_ult)
static int ssg_group_view_serialize(
ssg_group_view_t *view, void **buf, hg_size_t *buf_size)
{
ssg_member_state_t *member_state;
ssg_member_state_t *member_state, *tmp;
hg_size_t view_buf_size = 0;
void *view_buf;
void *buf_p, *str_p;
......@@ -257,7 +257,7 @@ static int ssg_group_view_serialize(
*buf_size = 0;
/* first determine view size */
LL_FOREACH(view->member_list, member_state)
HASH_ITER(hh, view->member_map, member_state, tmp)
{
view_buf_size += strlen(member_state->addr_str) + 1;
}
......@@ -267,7 +267,7 @@ static int ssg_group_view_serialize(
return SSG_FAILURE;
buf_p = view_buf;
LL_FOREACH(view->member_list, member_state)
HASH_ITER(hh, view->member_map, member_state, tmp)
{
str_p = member_state->addr_str;
strcpy(buf_p, str_p);
......
......@@ -123,21 +123,51 @@ int ssg_finalize()
*** SSG group management routines ***
*************************************/
/* XXX */
static int ssg_get_swim_dping_target(
void *group_data,
hg_addr_t *target_addr,
swim_member_state_t *target_ms)
swim_member_state_t *target_swim_ms);
static void ssg_gen_rand_member_list(
ssg_group_t *g);
static int ssg_get_swim_dping_target(
void *group_data,
hg_addr_t *target_addr,
swim_member_state_t *target_swim_ms)
{
ssg_group_t *g = (ssg_group_t *)group_data;
ssg_member_state_t *target_ms;
assert(g != NULL);
/* get a random group member, return addr and state */
/* if current member list is empty, generate a new random one */
if (g->member_list == NULL)
ssg_gen_rand_member_list(g);
/* pull random member off head of list and return addr */
target_ms = g->member_list;
LL_DELETE(g->member_list, target_ms);
*target_addr = target_ms->addr;
*target_swim_ms = target_ms->swim_state;
printf("%lu: pinging %lu\n", g->self_id, target_ms->id);
return 0;
}
static void ssg_gen_rand_member_list(ssg_group_t *g)
{
ssg_member_state_t *ms, *tmp;
/* XXX generate random LL permutation from membership map */
HASH_ITER(hh, g->view.member_map, ms, tmp)
{
LL_APPEND(g->member_list, ms);
}
return;
}
ssg_group_id_t ssg_group_create(
const char * group_name,
const char * const group_addr_strs[],
......@@ -197,6 +227,9 @@ ssg_group_id_t ssg_group_create(
goto fini;
}
/* generate random list permutation of the member map */
ssg_gen_rand_member_list(g);
/* initialize swim failure detector */
// TODO: we should probably barrier or sync somehow to avoid rpc failures
// due to timing skew of different ranks initializing swim
......@@ -942,7 +975,6 @@ void ssg_apply_membership_update(
member_state);
if (member_state)
{
LL_DELETE(g->view.member_list, member_state);
HASH_DELETE(hh, g->view.member_map, member_state);
margo_addr_free(ssg_inst->mid, member_state->addr);
free(member_state->addr_str);
......@@ -1105,9 +1137,8 @@ static int ssg_group_view_create(
if (self_id)
*self_id = tmp_ms->id;
/* add self state to membership view */
LL_PREPEND(view->member_list, tmp_ms);
HASH_ADD(hh, view->member_map, id, sizeof(ssg_member_id_t), tmp_ms);
/* 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 */
continue;
......@@ -1196,7 +1227,6 @@ static void ssg_group_lookup_ult(
&l->member_state->addr);
if (l->out == HG_SUCCESS)
{
LL_APPEND(l->view->member_list, l->member_state);
HASH_ADD(hh, l->view->member_map, id, sizeof(ssg_member_id_t),
l->member_state);
}
......@@ -1214,15 +1244,13 @@ static void ssg_group_view_destroy(
ssg_member_state_t *state, *tmp;
/* destroy state for all group members */
LL_FOREACH_SAFE(view->member_list, state, tmp)
HASH_ITER(hh, view->member_map, state, tmp)
{
LL_DELETE(view->member_list, state);
HASH_DEL(view->member_map, state);
free(state->addr_str);
margo_addr_free(ssg_inst->mid, state->addr);
free(state);
}
view->member_list = NULL;
view->member_map = NULL;
return;
......
......@@ -18,6 +18,8 @@
#include "swim-fd.h"
#include "swim-fd-internal.h"
#if 0
/* NOTE these defines must be kept in sync with defs in
* ssg.h & swim-internal.h
*/
......@@ -443,3 +445,4 @@ static hg_return_t hg_proc_swim_message_t(hg_proc_t proc, void *data)
return(hret);
}
#endif
......@@ -4,8 +4,6 @@
* See COPYRIGHT in top-level directory.
*/
#include <ssg-config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......@@ -50,11 +48,6 @@ static void swim_update_suspected_members(
ssg_group_t *g, double susp_timeout);
static void swim_add_recent_member_update(
ssg_group_t *g, swim_member_update_t update);
static int swim_get_rand_group_member(
ssg_group_t *g, ssg_member_id_t *member_id);
static int swim_get_rand_group_member_set(
ssg_group_t *g, ssg_member_id_t *member_ids, int num_members,
ssg_member_id_t excluded_id);
#endif
/******************************************************
......@@ -604,52 +597,4 @@ static void swim_add_recent_member_update(
return;
}
static int swim_get_rand_group_member(
ssg_group_t *g, ssg_member_id_t *member_id)
{
int ret = swim_get_rand_group_member_set(g, member_id, 1,
SSG_MEMBER_ID_INVALID);
return(ret);
}
static int swim_get_rand_group_member_set(
ssg_group_t *g, ssg_member_id_t *member_ids, int num_members,
ssg_member_id_t excluded_id)
{
unsigned int i, j, rand_ndx = 0;
ssg_member_id_t r, rand_member;
if(num_members == 0)
return(0);
/* TODO: what data structure could we use to avoid looping to look
* for a set of random ranks
*/
do
{
r = rand() % g->view.size;
for(i = 0; i < g->view.size; i++)
{
rand_member = (r + i) % g->view.size;
if(rand_member == g->self_id || rand_member == excluded_id ||
!(g->view.member_states[rand_member].is_member))
continue;
for(j = 0; j < rand_ndx; j++)
{
if(rand_member == member_ids[j])
break;
}
if(j == rand_ndx)
break;
}
if(i == g->view.size)
break;
member_ids[rand_ndx++] = rand_member;
} while((int)rand_ndx < num_members);
return(rand_ndx);
}
#endif
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