Documentation
¶
Index ¶
- Constants
- type ClusterDomainState
- type ClusterDomainsActiveMap
- type ClusterDomainsQuorumMembersMap
- type GossipIntervals
- type GossipNodeConfiguration
- type GossipStartConfiguration
- type MessageChannel
- type NodeId
- type NodeInfo
- type NodeInfoMap
- type NodeMetaInfo
- type NodeStatus
- type NodeUpdate
- type NodeValue
- type NodeValueMap
- type OnMessageRcv
- type QuorumProvider
- type StateEvent
- type StoreKey
- type StoreMap
- type StoreMetaInfo
- type StoreNodes
Constants ¶
const ( DEFAULT_GOSSIP_INTERVAL time.Duration = 2 * time.Second DEFAULT_PUSH_PULL_INTERVAL time.Duration = 2 * time.Second DEFAULT_PROBE_INTERVAL time.Duration = 5 * time.Second DEFAULT_PROBE_TIMEOUT time.Duration = 200 * time.Millisecond DEFAULT_QUORUM_TIMEOUT time.Duration = 1 * time.Minute DEFAULT_SUSPICION_MULTIPLIER int = 5 DEFAULT_GOSSIP_VERSION string = "v1" GOSSIP_VERSION_2 string = "v2" )
const ( CLUSTER_DOMAIN_STATE_ACTIVE = ClusterDomainState("Active") CLUSTER_DOMAIN_STATE_INACTIVE = ClusterDomainState("Inactive") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterDomainState ¶
type ClusterDomainState string
ClusterDomainState identifies the state of cluster domain
type ClusterDomainsActiveMap ¶
type ClusterDomainsActiveMap map[string]ClusterDomainState
ClusterDomainsActiveMap is a map of cluster domain to a boolean value indicating whether that domain is active or inactive
type ClusterDomainsQuorumMembersMap ¶
ClusterDomainsQuorumMembersMap is a map of cluster domains to the number of quorum members in that domain
type GossipIntervals ¶
type GossipIntervals struct {
// GossipInterval is the time interval within which the nodes gossip
GossipInterval time.Duration
// PushPullInterval is the time interval for full local state tcp sync amongst nodes
PushPullInterval time.Duration
// ProbeInterval is the time interval for probing other nodes.
// Used for failure detection amongst peers and reap dead nodes.
// It is also the interval for broadcasts (Broadcasts Not used currently)
ProbeInterval time.Duration
// ProbeTimeout used to determine if a node is down. Should be atleast twice the RTT of network
ProbeTimeout time.Duration
// QuorumTimeout is the timeout for which a node will stay in the SUSPECT_NOT_IN_QUORUM
// and then transition to NOT_IN_QUORUM (Not UP) if quorum is not satisfied
QuorumTimeout time.Duration
// SuspicionMult is the multiplier for determining the time an
// inaccessible node is considered suspect before declaring it dead.
SuspicionMult int
}
GossipIntervals object defines the different tuning parameters for gossip intervals and timeouts
type GossipNodeConfiguration ¶
type GossipNodeConfiguration struct {
// KnownUrl is the ip of this peer node
KnownUrl string
// ClusterDomain is the failure domain of this peer node
ClusterDomain string
}
GossipNodeConfiguration is the peer node configuration with which gossip on this node can start
type GossipStartConfiguration ¶
type GossipStartConfiguration struct {
// Nodes is a map of known nodes and their failure domains
Nodes map[NodeId]GossipNodeConfiguration
// ActiveMap is a map of failure domains to a boolean indicating whether they
// are active or inactive
ActiveMap ClusterDomainsActiveMap
// QuorumProviderType indicates which quorum calculation algorithm to use
QuorumProviderType QuorumProvider
}
GossipStartConfiguration object provides the configuration with which gossip should start.
type MessageChannel ¶
type MessageChannel interface {
// SendData serialized the the message and sends it
// to peer. The data must implement json.Marshal
SendData(obj interface{}) error
// RcvData recieves data from the peer and unmarshals
// it into the given obj. obj must be a pointer to
// effect change and must implement json.Unmarshal
RcvData(obj interface{}) error
// RunOnRcvData loops in continously and runs a handler
// which is activated on receiving any data
RunOnRcvData(time.Duration)
// Close terminates the message channel.
Close()
}
MessageChanne defines an interface for sending and receiving messages between peer nodes. It abstracts the underlying mechanism used to exchange messages.
type NodeInfo ¶
type NodeInfo struct {
// Id of the node
Id NodeId
// GenNumber of the object
GenNumber uint64
// LastUpdateTs is the last updated timestamp for this object
LastUpdateTs time.Time
// WaitForGenUpdateTs
WaitForGenUpdateTs time.Time
// Status of the node as seen by gossip on this node
Status NodeStatus
// Value is the opaque key value map provided by the callers of gossip
Value StoreMap
// QuorumMember indicates if this node participates in quorum calculations
QuorumMember bool
// ClusterDomain indicates the cluster domain in which this node lies
ClusterDomain string
// Addr is the connection address for this node
Addr string
}
NodeInfo is the node object that is stored for each node in gossip's in memory datastructures
type NodeInfoMap ¶
NodeInfoMap is a map of NodeId to NodeInfo object
type NodeMetaInfo ¶
type NodeMetaInfo struct {
// ClusterId of the gossip cluster
ClusterId string
// GossipVersion is the version of gossip protocol
GossipVersion string
// Id is the node id
Id NodeId
// GenNumber of the object
GenNumber uint64
// LastUpdateTs is the last updated timestamp for this object
LastUpdateTs time.Time
}
NodeMetaInfo object is the node metadata information that gets stored in memberlist's Node object. Any node update that gossip receives from memberlist will have this metadata.
type NodeStatus ¶
type NodeStatus uint8
NodeStatus indicates the status of the node
const ( NODE_STATUS_INVALID NodeStatus = iota NODE_STATUS_UP NODE_STATUS_DOWN NODE_STATUS_NEVER_GOSSIPED NODE_STATUS_NOT_IN_QUORUM NODE_STATUS_SUSPECT_NOT_IN_QUORUM NODE_STATUS_SUSPECT_DOWN )
type NodeUpdate ¶
type NodeUpdate struct {
// Addr is the contact address for the node
Addr string
// QuorumMember is true if node participates in quorum decisions
QuorumMember bool
// ClusterDomain of the node
ClusterDomain string
}
NodeUpdate object is used for externally updating a node in gossip
type NodeValue ¶
type NodeValue struct {
Id NodeId
GenNumber uint64
LastUpdateTs time.Time
Status NodeStatus
Value interface{}
}
NodeValue is the node object that is returned to the callers of gossip. It essentially is a subset of the NodeInfo object
type NodeValueMap ¶
NodeValueMap is a map of NodeId to NodeValue object
type OnMessageRcv ¶
type OnMessageRcv func(peerid string, c MessageChannel)
OnMessageRcv is a handler that is invoked when message arrives on the message channel.
type QuorumProvider ¶
type QuorumProvider uint8
QuorumProvider identifies the algorithm used to determine quorum of a cluster
const ( QUORUM_PROVIDER_DEFAULT QuorumProvider = iota QUORUM_PROVIDER_FAILURE_DOMAINS )
type StateEvent ¶
type StateEvent uint8
StateEvent is an event that triggeres a change in the state of the node which in turn could change the NodeStatus
const ( SELF_ALIVE StateEvent = iota NODE_ALIVE SELF_LEAVE NODE_LEAVE UPDATE_CLUSTER_SIZE TIMEOUT UPDATE_CLUSTER_DOMAINS_ACTIVE_MAP )
type StoreMap ¶
type StoreMap map[StoreKey]interface{}
StoreMap is an opaque map which the users of gossip can use to transer data between nodes.
type StoreNodes ¶
type StoreNodes []NodeId