Documentation ¶
Index ¶
- Constants
- Variables
- func GetUUIDSeq(m map[string]map[string]map[string]cbgt.UUIDSeq, ...) (uuidSeq cbgt.UUIDSeq, uuidSeqExists bool)
- func ProgressTableString(maxNodeLen, maxPIndexLen int, seenNodes map[string]bool, ...) string
- func ReportProgress(r *Rebalancer, progressToString ProgressToString) error
- func RunRebalance(cfg cbgt.Cfg, server string, options map[string]string, nodesToRemove []string, ...) error
- func SetUUIDSeq(m map[string]map[string]map[string]cbgt.UUIDSeq, ...) (uuidSeqPrev cbgt.UUIDSeq, uuidSeqPrevExists bool)
- func UpdateProgressEntries(r *Rebalancer, ...)
- func WriteProgressCell(b *bytes.Buffer, pe *ProgressEntry, ...)
- func WriteProgressTable(b *bytes.Buffer, maxNodeLen, maxPIndexLen int, seenNodes map[string]bool, ...)
- type CurrSeqs
- type CurrStates
- type MonitorNodes
- type MonitorNodesOptions
- type MonitorSample
- type ProgressEntry
- type ProgressToString
- type RebalanceLogFunc
- type RebalanceOptions
- type RebalanceProgress
- type Rebalancer
- func (r *Rebalancer) GetEndPlanPIndexes() *cbgt.PlanPIndexes
- func (r *Rebalancer) GetMovingPartitionsCount() int
- func (r *Rebalancer) PauseNewAssignments() (err error)
- func (r *Rebalancer) ProgressCh() chan RebalanceProgress
- func (r *Rebalancer) ResumeNewAssignments() (err error)
- func (r *Rebalancer) Stop()
- func (r *Rebalancer) Visit(visitor VisitFunc)
- type StateOp
- type UrlUUID
- type VisitFunc
- type WantSeqs
Constants ¶
const DEFAULT_CFG_SAMPLE_INTERVAL_SECS = 60
const DEFAULT_DIAG_SAMPLE_INTERVAL_SECS = 60
const DEFAULT_STATS_SAMPLE_INTERVAL_SECS = 1
Variables ¶
var ErrorNoIndexDefinitionFound = errors.New("no index definition found")
var ErrorNotPausable = errors.New("not pausable")
var ErrorNotResumable = errors.New("not resumable")
var StatsSampleErrorThreshold = uint8(3)
StatsSampleErrorThreshold defines the default upper limit for the ephemeral stats monitoring errors tolerated / ignored during a heavy rebalance scenario.
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 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, log cbgt.Log) 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.
Types ¶
type CurrStates ¶
Map of index -> pindex -> node -> StateOp.
type MonitorNodes ¶
type MonitorNodes struct {
// contains filtered or unexported fields
}
A MonitorNodes struct holds all the tracking information for the StartMonitorNodes operation.
func StartMonitorNodes ¶
func StartMonitorNodes( urlUUIDs []UrlUUID, sampleCh chan MonitorSample, options MonitorNodesOptions, ) (*MonitorNodes, error)
StartMonitorNodes begins REST stats and diag sampling from a fixed set of cbgt nodes. Higher level parts (like StartMonitorCluster) should handle situations of node membership changes by stopping and restarting StartMonitorNodes() as needed.
The cbgt REST URL endpoints that are monitored are [url]/api/stats and [url]/api/diag.
func (*MonitorNodes) Stop ¶
func (m *MonitorNodes) Stop()
type MonitorNodesOptions ¶
type MonitorNodesOptions struct { StatsSampleInterval time.Duration // Ex: 1 * time.Second. StatsSampleDisable bool DiagSampleInterval time.Duration DiagSampleDisable bool // Optional, defaults to http.Get(); this is used, for example, // for unit testing. HttpGet func(url string) (resp *http.Response, err error) }
type MonitorSample ¶
type MonitorSample struct { Kind string // Ex: "/api/cfg", "/api/stats", "/api/diag". Url string // Ex: "http://10.0.0.1:8095". UUID string Start time.Time // When we started to get this sample. Duration time.Duration // How long it took to get this sample. Error error Data []byte }
MonitorSample represents the information collected during monitoring and sampling a node.
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 MaxConcurrentPartitionMovesPerNode int // 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. Manager *cbgt.Manager StatsSampleErrorThreshold *int }
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, log cbgt.Log, 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) GetMovingPartitionsCount ¶
func (r *Rebalancer) GetMovingPartitionsCount() int
GetMovingPartitionsCount returns the total partitions to be moved as a part of the rebalance operation.
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 occasionally 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 ¶
A StateOp is used to track state transitions and associates a state (i.e., "primary") with an op (e.g., "add", "del").