1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
GlusterFS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef _GLUSTERD_SM_H_
#define _GLUSTERD_SM_H_
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif
#include <pthread.h>
#include "uuid.h"
#include "rpc-clnt.h"
#include "glusterfs.h"
#include "xlator.h"
#include "logging.h"
#include "call-stub.h"
#include "fd.h"
#include "byte-order.h"
//#include "glusterd.h"
#include "rpcsvc.h"
typedef enum glusterd_friend_sm_state_ {
GD_FRIEND_STATE_DEFAULT = 0,
GD_FRIEND_STATE_REQ_SENT,
GD_FRIEND_STATE_REQ_RCVD,
GD_FRIEND_STATE_BEFRIENDED,
GD_FRIEND_STATE_REQ_ACCEPTED,
GD_FRIEND_STATE_REQ_SENT_RCVD,
GD_FRIEND_STATE_REJECTED,
GD_FRIEND_STATE_UNFRIEND_SENT,
GD_FRIEND_STATE_MAX
} glusterd_friend_sm_state_t;
typedef struct glusterd_peer_state_info_ {
glusterd_friend_sm_state_t state;
struct timeval transition_time;
}glusterd_peer_state_info_t;
typedef struct glusterd_peer_hostname_ {
char *hostname;
struct list_head hostname_list;
}glusterd_peer_hostname_t;
struct glusterd_peerinfo_ {
uuid_t uuid;
char uuid_str[50];
glusterd_peer_state_info_t state;
char *hostname;
int port;
struct list_head uuid_list;
struct list_head op_peers_list;
struct list_head hostnames;
struct rpc_clnt *rpc;
};
typedef struct glusterd_peerinfo_ glusterd_peerinfo_t;
typedef enum glusterd_friend_sm_event_type_ {
GD_FRIEND_EVENT_NONE = 0,
GD_FRIEND_EVENT_PROBE,
GD_FRIEND_EVENT_INIT_FRIEND_REQ,
GD_FRIEND_EVENT_RCVD_ACC,
GD_FRIEND_EVENT_LOCAL_ACC,
GD_FRIEND_EVENT_RCVD_RJT,
GD_FRIEND_EVENT_LOCAL_RJT,
GD_FRIEND_EVENT_RCVD_FRIEND_REQ,
GD_FRIEND_EVENT_INIT_REMOVE_FRIEND,
GD_FRIEND_EVENT_REMOVE_FRIEND,
GD_FRIEND_EVENT_MAX
} glusterd_friend_sm_event_type_t;
struct glusterd_friend_sm_event_ {
struct list_head list;
glusterd_peerinfo_t *peerinfo;
void *ctx;
glusterd_friend_sm_event_type_t event;
};
typedef struct glusterd_friend_sm_event_ glusterd_friend_sm_event_t;
typedef int (*glusterd_friend_sm_ac_fn) (glusterd_friend_sm_event_t *, void *);
typedef struct glusterd_sm_ {
glusterd_friend_sm_state_t next_state;
glusterd_friend_sm_ac_fn handler;
} glusterd_sm_t;
typedef struct glusterd_friend_req_ctx_ {
uuid_t uuid;
char *hostname;
rpcsvc_request_t *req;
} glusterd_friend_req_ctx_t;
typedef glusterd_friend_req_ctx_t glusterd_friend_update_ctx_t;
typedef struct glusterd_probe_ctx_ {
char *hostname;
rpcsvc_request_t *req;
} glusterd_probe_ctx_t;
int
glusterd_friend_sm_new_event (glusterd_friend_sm_event_type_t event_type,
glusterd_friend_sm_event_t **new_event);
int
glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event);
int
glusterd_friend_sm_init ();
int
glusterd_friend_sm ();
#endif
|