roster

package
v0.0.0-...-ba27772 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrNodeNotFound

type ErrNodeNotFound struct {
	NodeID api.NodeID
}

ErrNodeNotFound is returned by NodeGetter implementations when NodeByIdent is called with a node which does not exist.

func (ErrNodeNotFound) Error

func (e ErrNodeNotFound) Error() string

type Location

type Location struct {
	Node api.NodeID
	Info api.RangeInfo
}

Location is returned by the Locate method. Don't use it for anything else.

type Node

type Node struct {
	Remote api.Remote

	Client pb.NodeClient
	// contains filtered or unexported fields
}

func NewNode

func NewNode(remote api.Remote, conn *grpc.ClientConn) *Node

func (*Node) Addr

func (n *Node) Addr() string

func (*Node) Get

func (n *Node) Get(rangeID api.RangeID) (api.RangeInfo, bool)

func (*Node) HasRange

func (n *Node) HasRange(rID api.RangeID) bool

HasRange returns whether we think this node has the given range.

func (*Node) Ident

func (n *Node) Ident() api.NodeID

func (*Node) IsGoneFromServiceDiscovery

func (n *Node) IsGoneFromServiceDiscovery(now time.Time) bool

func (*Node) IsMissing

func (n *Node) IsMissing(expireDuration time.Duration, now time.Time) bool

IsMissing returns true if this node hasn't responded to a probe in long enough that we think it's dead, and should move its ranges elsewhere.

func (*Node) PlacementFailed

func (n *Node) PlacementFailed(rID api.RangeID, t time.Time)

func (*Node) PlacementFailures

func (n *Node) PlacementFailures(rID api.RangeID, after time.Time) int

func (*Node) String

func (n *Node) String() string

func (*Node) TestString

func (n *Node) TestString() string

TODO: This is only used by tests. Maybe move it there?

func (*Node) UpdateRangeInfo

func (n *Node) UpdateRangeInfo(ri *api.RangeInfo)

func (*Node) UpdateRangeState

func (n *Node) UpdateRangeState(rID api.RangeID, s api.RemoteState) error

func (*Node) Utilization

func (n *Node) Utilization() uint8

Utilization returns a uint in [0, 255], indicating how busy this node is. Ranges should generally be placed on nodes with lower utilization.

func (*Node) WantDrain

func (n *Node) WantDrain() bool

type NodeGetter

type NodeGetter interface {
	NodeByIdent(nID api.NodeID) (*Node, error)
}

NodeGetter allows callers to get a Node from its NodeIdent.

type NodeInfo

type NodeInfo struct {
	Time   time.Time
	NodeID api.NodeID
	Ranges []api.RangeInfo

	// Expired is true when the node was automatically expired because we
	// haven't been able to probe it in a while.
	Expired bool
}

type PlacementFailure

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

type Roster

type Roster struct {

	// How long should the controller wait for a node to respond to a probe
	// before expiring it? The default value (zero) means that nodes expire as
	// soon as they are discovered, which means that nothing every works. That
	// is non-ideal.
	NodeExpireDuration time.Duration

	// TODO: Can this be private now?
	Nodes map[api.NodeID]*Node
	sync.RWMutex

	// To be stubbed when testing.
	NodeConnFactory func(ctx context.Context, remote api.Remote) (*grpc.ClientConn, error)
	// contains filtered or unexported fields
}

func New

func New(disc discovery.Discoverer, add, remove func(rem *api.Remote), info chan NodeInfo) *Roster

func (*Roster) Candidate

func (r *Roster) Candidate(rng *ranje.Range, c ranje.Constraint) (api.NodeID, error)

Candidate returns the NodeIdent of a node which could accept the given range.

TODO: Instead of an actual range, this should take a "pseudo-range" which is either a single range (wanting to split) and split point, or two ranges (wanting to join). Or I guess just a wrapper around a single (moving) range. From these, we can estimate how much capacity the candidate node(s) will need, allowing us to find candidates before actually performing splits and joins.

func (*Roster) Discover

func (ros *Roster) Discover()

Caller must hold ros.RWMutex

func (*Roster) Locate

func (ros *Roster) Locate(k api.Key) []Location

Locate returns the list of node IDs that the given key can be found on, and the state of the range containing the key.

func (*Roster) LocateInState

func (ros *Roster) LocateInState(k api.Key, states []api.RemoteState) []Location

func (*Roster) NodeByIdent

func (ros *Roster) NodeByIdent(nID api.NodeID) (*Node, error)

func (*Roster) Run

func (r *Roster) Run(t *time.Ticker)

TODO: Need some way to gracefully stop! Have to close the info channel to stop the reconciler.

func (*Roster) TestString

func (ros *Roster) TestString() string

TODO: This is only used by tests. Maybe move it there?

func (*Roster) Tick

func (r *Roster) Tick()

Jump to

Keyboard shortcuts

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