ctl

package
v0.0.0-...-14425eb Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCtlCanceled = service.ErrCanceled
View Source
var ErrCtlWrongRev = service.ErrConflict

Functions

func DecodeRev

func DecodeRev(b service.Revision) (uint64, error)

func EncodeRev

func EncodeRev(revNum uint64) service.Revision

func WaitForWantedNodes

func WaitForWantedNodes(cfg cbgt.Cfg, wantedNodes []string,
	cancelCh <-chan struct{}, secs int) (
	[]string, error)

WaitForWantedNodes blocks until the nodeDefsWanted in the cfg is equal to or a superset of the provided wantedNodes, and returns the "nodes to remove" (actualWantedNodes SET-DIFFERENCE wantedNodes).

Types

type Ctl

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

An Ctl might be in the midst of controlling a replan/rebalance, where ctl.ctlDoneCh will be non-nil.

If we're in the midst of a replan/rebalance, and another topology change request comes in, we stop any existing work and then start off a new replan/rebalance, because the new topology change request will have the latest, wanted topology. This might happen if some stopChangeTopology request or signal got lost somewhere.

func StartCtl

func StartCtl(cfg cbgt.Cfg, server string,
	optionsMgr map[string]string, optionsCtl CtlOptions) (
	*Ctl, error)

func (*Ctl) ChangeTopology

func (ctl *Ctl) ChangeTopology(changeTopology *CtlChangeTopology,
	cb CtlOnProgressFunc) (topology *CtlTopology, err error)

ChangeTopology starts an asynchonous change topology operation, if there's no input error. ChangeTopology also synchronously stops any previous, inflight change topology operation, if any, before kicking off the new change topology operation.

func (*Ctl) GetTopology

func (ctl *Ctl) GetTopology() *CtlTopology

GetTopology retrieves the current topology.

func (*Ctl) IndexDefsChanged

func (ctl *Ctl) IndexDefsChanged() (err error)

When the index definitions have changed, our approach is to run the planner, but only for brand new indexes that don't have any pindexes yet.

func (*Ctl) Stop

func (ctl *Ctl) Stop() error

func (*Ctl) StopChangeTopology

func (ctl *Ctl) StopChangeTopology(rev string)

StopChangeTopology synchronously stops a current change topology operation.

func (*Ctl) WaitGetTopology

func (ctl *Ctl) WaitGetTopology(haveRev string, cancelCh <-chan struct{}) (
	*CtlTopology, error)

WaitGetTopology is like GetTopology() but will synchronously block until there's a rev change.

type CtlChangeTopology

type CtlChangeTopology struct {
	Rev string // Works as CAS, so use the last Topology response’s Rev.

	// Use Mode of "failover-hard" for hard failover.
	// Use Mode of "failover-graceful" for graceful failover.
	// Use Mode of "rebalance" for rebalance-style, clean and safe topology change.
	Mode string

	// The MemberNodeUUIDs are the service nodes that should remain in
	// the service cluster after the topology change is finished.
	// When Mode is a variant of failover, then there should not be
	// any new nodes added to the MemberNodes (only service node
	// removal is allowed on failover).
	MemberNodeUUIDs []string
}

type CtlMgr

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

CtlMgr implements the cbauth/service.Manager interface and provides the adapter or glue between ns-server's service API and cbgt's Ctl implementation.

func NewCtlMgr

func NewCtlMgr(nodeInfo *service.NodeInfo, ctl *Ctl) *CtlMgr

func (*CtlMgr) CancelTask

func (m *CtlMgr) CancelTask(
	taskId string, taskRev service.Revision) error

func (*CtlMgr) GetCurrentTopology

func (m *CtlMgr) GetCurrentTopology(haveTopologyRev service.Revision,
	cancelCh service.Cancel) (*service.Topology, error)

func (*CtlMgr) GetNodeInfo

func (m *CtlMgr) GetNodeInfo() (*service.NodeInfo, error)

func (*CtlMgr) GetTaskList

func (m *CtlMgr) GetTaskList(haveTasksRev service.Revision,
	cancelCh service.Cancel) (*service.TaskList, error)

func (*CtlMgr) PrepareTopologyChange

func (m *CtlMgr) PrepareTopologyChange(
	change service.TopologyChange) error

func (*CtlMgr) Shutdown

func (m *CtlMgr) Shutdown() error

func (*CtlMgr) StartTopologyChange

func (m *CtlMgr) StartTopologyChange(change service.TopologyChange) error

type CtlNode

type CtlNode struct {
	UUID string // Cluster manager assigned opaque UUID for a service on a node.

	// URL of the node’s service manager (i.e., cbft's REST endpoint).
	ServiceURL string

	// URL of the node’s cluster manager (i.e., ns-server’s REST endpoint).
	ManagerURL string
}

func CurrentMemberNodes

func CurrentMemberNodes(cfg cbgt.Cfg) ([]CtlNode, error)

type CtlOnProgressFunc

type CtlOnProgressFunc func(
	maxNodeLen, maxPIndexLen int,
	seenNodes map[string]bool,
	seenNodesSorted []string,
	seenPIndexes map[string]bool,
	seenPIndexesSorted []string,
	progressEntries map[string]map[string]map[string]*rebalance.ProgressEntry,
	errs []error,
) string

CtlOnProgressFunc defines the callback func signature that's invoked during change topology operations.

type CtlOptions

type CtlOptions struct {
	DryRun             bool
	Verbose            int
	FavorMinNodes      bool
	WaitForMemberNodes int // Seconds to wait for wanted member nodes to appear.
}

type CtlTopology

type CtlTopology struct {
	// Rev is a CAS opaque identifier.  Any change to any CtlTopology
	// field will mean a Rev change.
	Rev string

	// MemberNodes lists what the service thinks are the currently
	// "confirmed in" service nodes in the system.  MemberNodes field
	// can change during the midst of a topology change, but it is
	// service specific on when and how MemberNodes will change and
	// stabilize.
	MemberNodes []CtlNode

	// PrevWarnings holds the warnings from the previous operations
	// and topology changes.  NOTE: If the service manager (i.e., Ctl)
	// restarts, it may "forget" its previous PrevWarnings
	// field value (as perhaps it was only tracked in memory).
	PrevWarnings map[string][]string

	// PrevErrs holds the errors from the previous operations and
	// topology changes.  NOTE: If the service manager (i.e., Ctl)
	// restarts, it may "forget" its previous PrevErrs field value
	// (as perhaps it was only tracked in memory).
	PrevErrs []error

	// ChangeTopology will be non-nil when a service topology change
	// is in progress.
	ChangeTopology *CtlChangeTopology
}

Jump to

Keyboard shortcuts

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