-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathapi.go
More file actions
111 lines (84 loc) · 3.27 KB
/
Copy pathapi.go
File metadata and controls
111 lines (84 loc) · 3.27 KB
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
package gossip
import (
"time"
"github.com/libopenstorage/gossip/proto"
"github.com/libopenstorage/gossip/types"
)
type GossipStore interface {
// types.NodeId of this Store
NodeId() types.NodeId
// Update updates the value for this node.
// Side-effects include updating the last update ts
// for this node.
UpdateSelf(types.StoreKey, interface{})
// GetSelfStatus returns the node's status
GetSelfStatus() types.NodeStatus
// GetStoreValue returns the StoreValue associated with
// the given key
GetStoreKeyValue(key types.StoreKey) types.NodeValueMap
// GetStoreKeys returns all the keys present in the store
GetStoreKeys() []types.StoreKey
// Used for gossiping
// Update updates the current state of the gossip data
// with the newly available data
Update(newData types.NodeInfoMap)
// UpdateSelfStatus
UpdateSelfStatus(types.NodeStatus)
// UpdateNodeStatus
UpdateNodeStatus(types.NodeId, types.NodeStatus) error
// MetaInfo returns meta information for the
// current available data
MetaInfo() types.NodeMetaInfo
// GetLocalState returns our nodeInfoMap
GetLocalState() types.NodeInfoMap
// GetLocalNodeInfo returns
GetLocalNodeInfo(types.NodeId) (types.NodeInfo, error)
// Add a new node in the database
AddNode(types.NodeId, types.NodeStatus, bool, string)
// Remove a node from the database
RemoveNode(types.NodeId) error
}
type Gossiper interface {
// Gossiper has a gossip store
GossipStore
// Start begins the gossip protocol using memberlist
// To join an existing cluster provide atleast one ip of the known node.
Start(startConfiguration types.GossipStartConfiguration) error
// GossipInterval gets the gossip interval
GossipInterval() time.Duration
// Stop stops the gossiping. Leave timeout indicates the minimum time
// required to successfully broadcast the leave message to all other nodes.
Stop(leaveTimeout time.Duration) error
// GetNodes returns a list of the connection addresses
GetNodes() []string
// UpdateCluster updates gossip with latest peer nodes info
UpdateCluster(map[types.NodeId]types.NodeUpdate)
// ExternalNodeLeave is used to indicate gossip that one of the nodes might be down.
// It checks quorum and appropriately marks either self down or the other node down.
// It returns the nodeId that was marked down
ExternalNodeLeave(nodeId types.NodeId) types.NodeId
// UpdateClusterDomainsActiveMap updates the cluster domain active map
// All the nodes in an inactive domain will shoot themselves down
// and will not participate in quorum decisions
UpdateClusterDomainsActiveMap(types.ClusterDomainsActiveMap) error
// UpdateSelfClusterDomain updates this node's cluster domain
UpdateSelfClusterDomain(selfFailureDomain string)
// Ping pings the given node's ip:port
// Note: This API is only supported with Gossip Version v2 and higher
Ping(nodeId types.NodeId, ipPort string) (time.Duration, error)
}
// New returns an initialized Gossip node
// which identifies itself with the given ip
func New(
ip string,
selfNodeId types.NodeId,
genNumber uint64,
gossipIntervals types.GossipIntervals,
gossipVersion string,
clusterId string,
selfFailureDomain string,
) Gossiper {
g := new(proto.GossiperImpl)
g.Init(ip, selfNodeId, genNumber, gossipIntervals, gossipVersion, clusterId, selfFailureDomain)
return g
}