Version: v0.0.0-...-b0cd610 Latest Latest

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

Go to latest
Published: Jan 25, 2017 License: Apache-2.0 Imports: 12 Imported by: 0




This section is empty.


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


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 ProgressTableString

func ProgressTableString(maxNodeLen, maxPIndexLen int,
	seenNodes map[string]bool,
	seenNodesSorted []string,
	seenPIndexes map[string]bool,
	seenPIndexesSorted []string,
	progressEntries map[string]map[string]map[string]*ProgressEntry) string

ProgressTableString implements the ProgressToString func signature by generating a tabular representation of the progress.

func ReportProgress

func ReportProgress(r *Rebalancer,
	progressToString ProgressToString) error

ReportProgress tracks progress in progress entries and invokes the progressToString handler, whose output will be logged.

func RunRebalance

func RunRebalance(cfg cbgt.Cfg, server string, options map[string]string,
	nodesToRemove []string, favorMinNodes bool, dryRun bool, verbose int,
	progressToString ProgressToString) error

RunRebalance synchronously runs a rebalance and reports progress until the rebalance is done or has errored.

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.

func UpdateProgressEntries

func UpdateProgressEntries(
	r *Rebalancer,
	updateProgressEntry func(pindex, sourcePartition, node string,
		cb func(*ProgressEntry)),

UpdateProgressEntries invokes the updateProgressEntry callback to help maintain progress entries information.

func WriteProgressCell

func WriteProgressCell(b *bytes.Buffer,
	pe *ProgressEntry,
	sourcePartitions map[string]map[string]*ProgressEntry,
	maxNodeLen int)

WriteProgressCell writes a cell in a progress table to a buffer.

func WriteProgressTable

func WriteProgressTable(b *bytes.Buffer,
	maxNodeLen, maxPIndexLen int,
	seenNodes map[string]bool,
	seenNodesSorted []string,
	seenPIndexes map[string]bool,
	seenPIndexesSorted []string,
	progressEntries map[string]map[string]map[string]*ProgressEntry,

WriteProgressTable writes progress entries in tabular format to a bytes buffer.


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 ProgressEntry

type ProgressEntry struct {
	PIndex, SourcePartition, Node string // Immutable.

	StateOp     StateOp
	InitUUIDSeq cbgt.UUIDSeq
	CurrUUIDSeq cbgt.UUIDSeq
	WantUUIDSeq cbgt.UUIDSeq

	Move int
	Done bool

ProgressEntry represents a record of rebalance progress for a given pindex, source partition and node.

type ProgressToString

type ProgressToString func(maxNodeLen, maxPIndexLen int,
	seenNodes map[string]bool,
	seenNodesSorted []string,
	seenPIndexes map[string]bool,
	seenPIndexesSorted []string,
	progressEntries map[string]map[string]map[string]*ProgressEntry) string

ProgressToString defines the callback when there's progress and a representative progress summary string needs to be generated for possible logging.

The progressEntries is a map of pindex -> (source) partition -> node -> *ProgressEntry.

type RebalanceLogFunc

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

type RebalanceOptions

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

	// AddPrimaryDirectly, when true, means the rebalancer should
	// assign a pindex as primary to a node directly, and not use a
	// replica-promotion maneuver (e.g., assign replica first, wait
	// until replica is caught up, then promote replica to primary).
	AddPrimaryDirectly 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)

	SkipSeqChecks bool // For unit-testing.

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,
	optionsMgr map[string]string,
	nodesToRemoveParam []string,
	optionsReb 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) GetEndPlanPIndexes

func (r *Rebalancer) GetEndPlanPIndexes() *cbgt.PlanPIndexes

GetEndPlanPIndexes return value should be treated as immutable.

func (*Rebalancer) Logf

func (r *Rebalancer) Logf(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., "primary") with an op (e.g., "add", "del").

type VisitFunc

type VisitFunc func(CurrStates, CurrSeqs, WantSeqs,

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL