durability

package
v1.90.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package durability helps us to keep segments in healthy state with reporting risks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthStat

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

HealthStat collects the availability conditions for one class (for example: nodes with the same owner).

func (*HealthStat) Merge

func (h *HealthStat) Merge(stat *HealthStat)

Merge can merge two stat to one, without losing information.

func (*HealthStat) Min

func (h *HealthStat) Min() int

Min returns the minimal number.

func (*HealthStat) Unused

func (h *HealthStat) Unused() bool

Unused returns true when stat is uninitialized (-1) and was not updated with any number.

func (*HealthStat) Update

func (h *HealthStat) Update(num int)

Update updates the stat with one measurement: number of pieces which are available even without the nodes of the selected class.

type NodeClassifier

type NodeClassifier func(node *nodeselection.SelectedNode) string

NodeClassifier identifies a risk class (for example an owner, or country) of the SelectedNode.

type ObserverFork

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

ObserverFork is the durability calculator for each segment range.

func (*ObserverFork) Process

func (c *ObserverFork) Process(ctx context.Context, segments []rangedloop.Segment) (err error)

Process implements rangedloop.Partial.

type Report

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

Report is a calculator (rangloop.Observer) which checks the availability of pieces without certain nodes. It can answer the following question:

  1. loosing a given group of nodes (all nodes of one country or all nodes of one owner)...
  2. what will be the lowest humber of healhty pieces, checking all the segments.

Example: we have one segment where 80 pieces are stored, but 42 of them are in Germany.

in this case this reporter will return 38 for the class "country:DE" (assuming all the other segments are more lucky).

func NewDurability

func NewDurability(db overlay.DB, metabaseDB *metabase.DB, classifiers []NodeClassifier, reportThreshold int, asOfSystemInterval time.Duration) *Report

NewDurability creates the new instance.

func (*Report) Finish

func (c *Report) Finish(ctx context.Context) error

Finish implements rangedloop.Observer.

func (*Report) Fork

func (c *Report) Fork(ctx context.Context) (rangedloop.Partial, error)

Fork implements rangedloop.Observer.

func (*Report) Join

func (c *Report) Join(ctx context.Context, partial rangedloop.Partial) (err error)

Join implements rangedloop.Observer.

func (*Report) Start

func (c *Report) Start(ctx context.Context, startTime time.Time) error

Start implements rangedloop.Observer.

func (*Report) TestChangeReporter

func (c *Report) TestChangeReporter(r func(name string, stat *HealthStat))

TestChangeReporter modifies the reporter for unit tests.

type ReportConfig

type ReportConfig struct {
	Enabled bool `help:"whether to enable durability report (rangedloop observer)" default:"true"`
}

ReportConfig configures durability report.

Jump to

Keyboard shortcuts

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