registry

package
v4.0.0-...-1d6e2d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownTarget is the error returned when the target address of the node
	// is unknown.
	ErrUnknownTarget = errors.New("target address unknown")
)

Functions

This section is empty.

Types

type GossipRegistry

type GossipRegistry struct {
	// contains filtered or unexported fields
}

GossipRegistry is a node registry backed by gossip. It is capable of supporting NodeHosts with dynamic RaftAddress values.

func NewGossipRegistry

func NewGossipRegistry(nhid string, f getShardInfo,
	nhConfig config.NodeHostConfig, streamConnections uint64,
	v config.TargetValidator) (*GossipRegistry, error)

NewGossipRegistry creates a new GossipRegistry instance.

func (*GossipRegistry) Add

func (n *GossipRegistry) Add(shardID uint64,
	replicaID uint64, target string)

Add adds a new node with its known NodeHostID to the registry.

func (*GossipRegistry) AdvertiseAddress

func (n *GossipRegistry) AdvertiseAddress() string

AdvertiseAddress returns the advertise address of the gossip service.

func (*GossipRegistry) Close

func (n *GossipRegistry) Close() error

Close closes the GossipRegistry instance.

func (*GossipRegistry) GetNodeHostRegistry

func (n *GossipRegistry) GetNodeHostRegistry() *NodeHostRegistry

GetNodeHostRegistry returns the NodeHostRegistry backed by gossip.

func (*GossipRegistry) NumMembers

func (n *GossipRegistry) NumMembers() int

NumMembers returns the number of live nodes known by the gossip service.

func (*GossipRegistry) Remove

func (n *GossipRegistry) Remove(shardID uint64, replicaID uint64)

Remove removes the specified node from the registry.

func (*GossipRegistry) RemoveShard

func (n *GossipRegistry) RemoveShard(shardID uint64)

RemoveShard removes the specified shard from the registry.

func (*GossipRegistry) Resolve

func (n *GossipRegistry) Resolve(shardID uint64,
	replicaID uint64) (string, string, error)

Resolve returns the current RaftAddress and connection key of the specified node. It returns ErrUnknownTarget when the RaftAddress is unknown.

type IResolver

type IResolver interface {
	Resolve(uint64, uint64) (string, string, error)
	Add(uint64, uint64, string)
}

IResolver converts the (shard id, replica id) tuple to network address.

type NodeHostRegistry

type NodeHostRegistry struct {
	// contains filtered or unexported fields
}

NodeHostRegistry is a NodeHost info registry backed by gossip.

func (*NodeHostRegistry) GetMeta

func (r *NodeHostRegistry) GetMeta(nhID string) ([]byte, bool)

GetMeta returns gossip metadata associated with the specified NodeHost instance.

func (*NodeHostRegistry) GetShardInfo

func (r *NodeHostRegistry) GetShardInfo(shardID uint64) (ShardView, bool)

GetShardInfo returns the shard info for the specified shard if it is available in the gossip view.

func (*NodeHostRegistry) NumOfShards

func (r *NodeHostRegistry) NumOfShards() int

NumOfShards returns the number of shards known to the current NodeHost instance.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is used to manage all known node addresses in the multi raft system. The transport layer uses this address registry to locate nodes.

func NewNodeRegistry

func NewNodeRegistry(streamConnections uint64, v config.TargetValidator) *Registry

NewNodeRegistry returns a new Registry object.

func (*Registry) Add

func (n *Registry) Add(shardID uint64, replicaID uint64, target string)

Add adds the specified replica and its target info to the registry.

func (*Registry) Close

func (n *Registry) Close() error

Close closes the registry.

func (*Registry) Remove

func (n *Registry) Remove(shardID uint64, replicaID uint64)

Remove removes a remote from the node registry.

func (*Registry) RemoveShard

func (n *Registry) RemoveShard(shardID uint64)

RemoveShard removes info associated with the specified shard.

func (*Registry) Resolve

func (n *Registry) Resolve(shardID uint64, replicaID uint64) (string, string, error)

Resolve looks up the address of the specified node.

type ShardInfo

type ShardInfo struct {
	// Replicas is a map of member replica IDs to their Raft addresses.
	Replicas map[uint64]string
	// ShardID is the shard ID of the Raft shard.
	ShardID uint64
	// ReplicaID is the replica ID of the Raft replica.
	ReplicaID uint64
	// ConfigChangeIndex is the current config change index of the Raft node.
	// ConfigChangeIndex is Raft Log index of the last applied membership
	// change entry.
	ConfigChangeIndex uint64
	// StateMachineType is the type of the state machine.
	StateMachineType sm.Type
	// IsLeader indicates whether this is a leader node.
	// Deprecated: Use LeaderID and Term instead.
	IsLeader bool
	// LeaderID is the replica ID of the current leader
	LeaderID uint64
	// Term is the term of the current leader
	Term uint64
	// IsNonVoting indicates whether this is a non-voting nonVoting node.
	IsNonVoting bool
	// IsWitness indicates whether this is a witness node without actual log.
	IsWitness bool
	// Pending is a boolean flag indicating whether details of the shard node
	// is not available. The Pending flag is set to true usually because the node
	// has not had anything applied yet.
	Pending bool
}

ShardInfo is a record for representing the state of a Raft shard based on the knowledge of the local NodeHost instance.

type ShardView

type ShardView struct {
	ShardID           uint64
	Replicas          map[uint64]string
	ConfigChangeIndex uint64
	LeaderID          uint64
	Term              uint64
}

ShardView is the view of a shard from gossip's point of view at a certain point in time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL