swim-fd.h 2.01 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
typedef struct swim_member_update
{
    swim_member_id_t id;
    swim_member_state_t state;
} swim_member_update_t;

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

46 47 48
/* XXX rename once more clear what all is here */
typedef struct swim_group_mgmt_callbacks
{
Shane Snyder's avatar
Shane Snyder committed
49
    /* XXX RET VALS */
50 51
    int (*get_dping_target)(
            void *group_data,
Shane Snyder's avatar
Shane Snyder committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
            swim_member_id_t *target_id,
            swim_member_inc_nr_t *inc_nr,
            hg_addr_t *target_addr
            );
    int (*get_iping_targets)(
            void *group_data,
            swim_member_id_t *target_ids,
            hg_addr_t *target_addrs
            );
    void (*get_member_addr)(
            void *group_data,
            swim_member_id_t id,
            hg_addr_t *addr
            );
    void (*get_member_state)(
            void *group_data,
            swim_member_id_t id,
            swim_member_state_t **state
70
            );
71 72 73 74
    void (*apply_member_update)(
            void *group_data,
            swim_member_update_t update
            );
75 76
} swim_group_mgmt_callbacks_t;

Shane Snyder's avatar
Shane Snyder committed
77
/* Initialize SWIM */
78
swim_context_t * swim_init(
79
    margo_instance_id mid,
Shane Snyder's avatar
Shane Snyder committed
80
    void * group_data,
81
    swim_member_id_t self_id,
82
    swim_group_mgmt_callbacks_t swim_callbacks,
83 84
    int active);

Shane Snyder's avatar
Shane Snyder committed
85
/* Finalize SWIM */
86
void swim_finalize(
87
    swim_context_t * swim_ctx);
88 89 90 91

#ifdef __cplusplus
}
#endif