rebalance

package
v0.0.0-...-a1de707 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotPausable = errors.New("not pausable")
View Source
var ErrorNotResumable = errors.New("not resumable")

Functions

func GetUUIDSeq

func GetUUIDSeq(
	m map[string]map[string]map[string]cbgt.UUIDSeq,
	pindex, sourcePartition, node string) (
	uuidSeq cbgt.UUIDSeq, uuidSeqExists bool)

GetUUIDSeq returns the cbgt.UUIDSeq for a pindex/sourcePartition/node.

func SetUUIDSeq

func SetUUIDSeq(
	m map[string]map[string]map[string]cbgt.UUIDSeq,
	pindex, sourcePartition, node string,
	uuid string, seq uint64) (
	uuidSeqPrev cbgt.UUIDSeq, uuidSeqPrevExists bool)

SetUUIDSeq updates the cbgt.UUIDSeq for a pindex/sourcePartition/node, and returns the previous cbgt.UUIDSeq.

Types

type CurrSeqs

type CurrSeqs map[string]map[string]map[string]cbgt.UUIDSeq

Map of pindex -> (source) partition -> node -> cbgt.UUIDSeq.

type CurrStates

type CurrStates map[string]map[string]map[string]StateOp

Map of index -> pindex -> node -> StateOp.

type RebalanceLogFunc

type RebalanceLogFunc func(format string, v ...interface{})

type RebalanceOptions

type RebalanceOptions struct {
	// See blance.CalcPartitionMoves(favorMinNodes).
	FavorMinNodes bool

	DryRun bool // When true, no changes, for analysis/planning.

	Log     RebalanceLogFunc
	Verbose int

	// Optional, defaults to http.Get(); this is used, for example,
	// for unit testing.
	HttpGet func(url string) (resp *http.Response, err error)
}

type RebalanceProgress

type RebalanceProgress struct {
	Error error
	Index string

	OrchestratorProgress blance.OrchestratorProgress
}

RebalanceProgress represents progress status information as the Rebalance() operation proceeds.

type Rebalancer

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

A Rebalancer struct holds all the tracking information for the Rebalance operation.

func StartRebalance

func StartRebalance(version string, cfg cbgt.Cfg, server string,
	nodesToRemoveParam []string,
	options RebalanceOptions) (
	*Rebalancer, error)

StartRebalance begins a concurrent, cluster-wide rebalancing of all the indexes (and their index partitions) on a cluster of cbgt nodes. StartRebalance utilizes the blance library for calculating and orchestrating partition reassignments and the cbgt/rest/monitor library to watch for progress and errors.

func (*Rebalancer) Log

func (r *Rebalancer) Log(fmt string, v ...interface{})

func (*Rebalancer) PauseNewAssignments

func (r *Rebalancer) PauseNewAssignments() (err error)

PauseNewAssignments pauses any new assignments. Any inflight assignments, however, will continue to completion or error.

func (*Rebalancer) ProgressCh

func (r *Rebalancer) ProgressCh() chan RebalanceProgress

ProgressCh() returns a channel that is updated occassionally when the rebalance has made some progress on one or more partition reassignments, or has reached an error. The channel is closed when the rebalance operation is finished, either naturally, or due to an error, or via a Stop(), and all the rebalance-related resources have been released.

func (*Rebalancer) ResumeNewAssignments

func (r *Rebalancer) ResumeNewAssignments() (err error)

ResumeNewAssignments resumes new assignments.

func (*Rebalancer) Stop

func (r *Rebalancer) Stop()

Stop asynchronously requests a stop to the rebalance operation. Callers can look for the closing of the ProgressCh() to see when the rebalance operation has actually stopped.

func (*Rebalancer) Visit

func (r *Rebalancer) Visit(visitor VisitFunc)

Visit invokes the visitor callback with the current, read-only CurrStates, CurrSeqs and WantSeqs.

type StateOp

type StateOp struct {
	State string
	Op    string // May be "" for unknown or no in-flight op.
}

A StateOp is used to track state transitions and associates a state (i.e., "master") with an op (e.g., "add", "del").

type VisitFunc

type VisitFunc func(CurrStates, CurrSeqs, WantSeqs,
	map[string]*blance.NextMoves)

type WantSeqs

type WantSeqs map[string]map[string]map[string]cbgt.UUIDSeq

Map of pindex -> (source) partition -> node -> cbgt.UUIDSeq.

Jump to

Keyboard shortcuts

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