swim-fd.h 1.45 KB
Newer Older
1
/*
Shane Snyder's avatar
Shane Snyder committed
2 3
 * Copyright (c) 2016 UChicago Argonne, LLC
 *
4 5 6
 * See COPYRIGHT in top-level directory.
 */

Shane Snyder's avatar
Shane Snyder committed
7
#pragma once
8

Shane Snyder's avatar
Shane Snyder committed
9 10
#include <stdint.h>
#include <inttypes.h>
11

12 13 14 15 16 17 18
#ifdef __cplusplus
extern "C" {
#endif

/* opaque swim context type */
typedef struct swim_context swim_context_t;

Shane Snyder's avatar
Shane Snyder committed
19
/* swim member specific types */
20
typedef uint64_t swim_member_id_t;
Shane Snyder's avatar
Shane Snyder committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
typedef uint32_t swim_member_inc_nr_t;
typedef enum swim_member_status
{
    SWIM_MEMBER_ALIVE = 0,
    SWIM_MEMBER_SUSPECT,
    SWIM_MEMBER_DEAD
} swim_member_status_t;

typedef struct swim_member_state
{
    swim_member_inc_nr_t inc_nr;
    swim_member_status_t status;
} swim_member_state_t;

35 36 37 38 39 40 41
typedef struct swim_dping_target_info
{
    swim_member_id_t id;
    hg_addr_t addr;
    swim_member_state_t swim_state;
} swim_dping_target_info_t;

42 43 44 45 46
#define SWIM_MEMBER_STATE_INIT(__ms) do { \
    __ms.inc_nr = 0; \
    __ms.status = SWIM_MEMBER_ALIVE; \
} while(0)

47 48 49 50 51
/* XXX rename once more clear what all is here */
typedef struct swim_group_mgmt_callbacks
{
    int (*get_dping_target)(
            void *group_data,
52
            swim_dping_target_info_t *target_info
53 54 55 56
            );
    /* get_rand_iping_subgroup */
} swim_group_mgmt_callbacks_t;

Shane Snyder's avatar
Shane Snyder committed
57
/* Initialize SWIM */
58
swim_context_t * swim_init(
59
    margo_instance_id mid,
Shane Snyder's avatar
Shane Snyder committed
60
    void * group_data,
61
    swim_member_id_t self_id,
62
    swim_group_mgmt_callbacks_t swim_callbacks,
63 64
    int active);

Shane Snyder's avatar
Shane Snyder committed
65
/* Finalize SWIM */
66
void swim_finalize(
67
    swim_context_t * swim_ctx);
68 69 70 71

#ifdef __cplusplus
}
#endif