overlay

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketNotFound = errs.New("bucket not found")

ErrBucketNotFound is returned if a bucket is unable to be found in the routing table

View Source
var ErrEmptyNode = errs.New("empty node ID")

ErrEmptyNode is returned when the nodeID is empty

View Source
var ErrNodeNotFound = errs.Class("node not found")

ErrNodeNotFound is returned if a node does not exist in database

View Source
var ErrNotEnoughNodes = errs.Class("not enough nodes")

ErrNotEnoughNodes is when selecting nodes failed with the given parameters

View Source
var (

	// Error represents an overlay error
	Error = errs.Class("overlay error")
)
View Source
var OverlayError = errs.Class("overlay error")

OverlayError creates class of errors for stack traces

Functions

This section is empty.

Types

type Cache

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

Cache is used to store and handle node information

func NewCache

func NewCache(log *zap.Logger, db DB, preferences NodeSelectionConfig) *Cache

NewCache returns a new Cache

func (*Cache) Close

func (cache *Cache) Close() error

Close closes resources

func (*Cache) ConnFailure

func (cache *Cache) ConnFailure(ctx context.Context, node *pb.Node, failureError error)

ConnFailure implements the Transport Observer `ConnFailure` function

func (*Cache) ConnSuccess

func (cache *Cache) ConnSuccess(ctx context.Context, node *pb.Node)

ConnSuccess implements the Transport Observer `ConnSuccess` function

func (*Cache) Create

func (cache *Cache) Create(ctx context.Context, nodeID storj.NodeID, initial *NodeStats) (stats *NodeStats, err error)

Create adds a new stats entry for node.

func (*Cache) FindStorageNodes

func (cache *Cache) FindStorageNodes(ctx context.Context, req FindStorageNodesRequest) ([]*pb.Node, error)

FindStorageNodes searches the overlay network for nodes that meet the provided requirements

func (*Cache) FindStorageNodesWithPreferences

func (cache *Cache) FindStorageNodesWithPreferences(ctx context.Context, req FindStorageNodesRequest, preferences *NodeSelectionConfig) (nodes []*pb.Node, err error)

FindStorageNodesWithPreferences searches the overlay network for nodes that meet the provided criteria

func (*Cache) Get

func (cache *Cache) Get(ctx context.Context, nodeID storj.NodeID) (_ *NodeDossier, err error)

Get looks up the provided nodeID from the overlay cache

func (*Cache) GetMissingPieces added in v0.11.4

func (cache *Cache) GetMissingPieces(ctx context.Context, pieces []*pb.RemotePiece) (missingPieces []int32, err error)

GetMissingPieces returns the list of offline nodes

func (*Cache) Inspect

func (cache *Cache) Inspect(ctx context.Context) (storage.Keys, error)

Inspect lists limited number of items in the cache

func (*Cache) IsOnline added in v0.10.0

func (cache *Cache) IsOnline(node *NodeDossier) bool

IsOnline checks if a node is 'online' based on the collected statistics.

func (*Cache) KnownUnreliableOrOffline added in v0.11.0

func (cache *Cache) KnownUnreliableOrOffline(ctx context.Context, nodeIds storj.NodeIDList) (badNodes storj.NodeIDList, err error)

KnownUnreliableOrOffline filters a set of nodes to unhealth or offlines node, independent of new.

func (*Cache) Paginate

func (cache *Cache) Paginate(ctx context.Context, offset int64, limit int) (_ []*NodeDossier, _ bool, err error)

Paginate returns a list of `limit` nodes starting from `start` offset.

func (*Cache) Put

func (cache *Cache) Put(ctx context.Context, nodeID storj.NodeID, value pb.Node) (err error)

Put adds a node id and proto definition into the overlay cache

func (*Cache) UpdateNodeInfo added in v0.9.0

func (cache *Cache) UpdateNodeInfo(ctx context.Context, node storj.NodeID, nodeInfo *pb.InfoResponse) (stats *NodeDossier, err error)

UpdateNodeInfo updates node dossier with info requested from the node itself like node type, email, wallet, capacity, and version.

func (*Cache) UpdateStats

func (cache *Cache) UpdateStats(ctx context.Context, request *UpdateRequest) (stats *NodeStats, err error)

UpdateStats all parts of single storagenode's stats.

func (*Cache) UpdateUptime

func (cache *Cache) UpdateUptime(ctx context.Context, nodeID storj.NodeID, isUp bool) (stats *NodeStats, err error)

UpdateUptime updates a single storagenode's uptime stats.

type Config

type Config struct {
	Node NodeSelectionConfig
}

Config is a configuration struct for everything you need to start the Overlay cache responsibility.

type DB

type DB interface {
	// SelectStorageNodes looks up nodes based on criteria
	SelectStorageNodes(ctx context.Context, count int, criteria *NodeCriteria) ([]*pb.Node, error)
	// SelectNewStorageNodes looks up nodes based on new node criteria
	SelectNewStorageNodes(ctx context.Context, count int, criteria *NodeCriteria) ([]*pb.Node, error)

	// Get looks up the node by nodeID
	Get(ctx context.Context, nodeID storj.NodeID) (*NodeDossier, error)
	// KnownUnreliableOrOffline filters a set of nodes to unhealth or offlines node, independent of new
	KnownUnreliableOrOffline(context.Context, *NodeCriteria, storj.NodeIDList) (storj.NodeIDList, error)
	// Paginate will page through the database nodes
	Paginate(ctx context.Context, offset int64, limit int) ([]*NodeDossier, bool, error)

	// CreateStats initializes the stats for node.
	CreateStats(ctx context.Context, nodeID storj.NodeID, initial *NodeStats) (stats *NodeStats, err error)
	// Update updates node address
	UpdateAddress(ctx context.Context, value *pb.Node) error
	// UpdateStats all parts of single storagenode's stats.
	UpdateStats(ctx context.Context, request *UpdateRequest) (stats *NodeStats, err error)
	// UpdateNodeInfo updates node dossier with info requested from the node itself like node type, email, wallet, capacity, and version.
	UpdateNodeInfo(ctx context.Context, node storj.NodeID, nodeInfo *pb.InfoResponse) (stats *NodeDossier, err error)
	// UpdateUptime updates a single storagenode's uptime stats.
	UpdateUptime(ctx context.Context, nodeID storj.NodeID, isUp bool) (stats *NodeStats, err error)
}

DB implements the database for overlay.Cache

type FindStorageNodesRequest

type FindStorageNodesRequest struct {
	MinimumRequiredNodes int
	RequestedCount       int
	FreeBandwidth        int64
	FreeDisk             int64
	ExcludedNodes        []storj.NodeID
	MinimumVersion       string // semver or empty
}

FindStorageNodesRequest defines easy request parameters.

type Inspector

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

Inspector is a gRPC service for inspecting overlay cache internals

func NewInspector

func NewInspector(cache *Cache) *Inspector

NewInspector creates an Inspector

func (*Inspector) CountNodes

func (srv *Inspector) CountNodes(ctx context.Context, req *pb.CountNodesRequest) (*pb.CountNodesResponse, error)

CountNodes returns the number of nodes in the cache

func (*Inspector) CreateStats

func (srv *Inspector) CreateStats(ctx context.Context, req *pb.CreateStatsRequest) (*pb.CreateStatsResponse, error)

CreateStats creates a node with specified stats

func (*Inspector) DumpNodes

func (srv *Inspector) DumpNodes(ctx context.Context, req *pb.DumpNodesRequest) (*pb.DumpNodesResponse, error)

DumpNodes returns all of the nodes in the overlay cachea

func (*Inspector) GetStats

func (srv *Inspector) GetStats(ctx context.Context, req *pb.GetStatsRequest) (*pb.GetStatsResponse, error)

GetStats returns the stats for a particular node ID

type LookupConfig

type LookupConfig struct {
	NodeIDsString string `help:"one or more string-encoded node IDs, delimited by Delimiter"`
	Delimiter     string `help:"delimiter used for parsing node IDs" default:","`
}

LookupConfig is a configuration struct for querying the overlay cache with one or more node IDs

func (LookupConfig) ParseIDs

func (c LookupConfig) ParseIDs() (ids storj.NodeIDList, err error)

ParseIDs converts the base58check encoded node ID strings from the config into node IDs

type NodeCriteria

type NodeCriteria struct {
	FreeBandwidth      int64
	FreeDisk           int64
	AuditCount         int64
	AuditSuccessRatio  float64
	UptimeCount        int64
	UptimeSuccessRatio float64
	ExcludedNodes      []storj.NodeID
	ExcludedIPs        []string
	MinimumVersion     string // semver or empty
	OnlineWindow       time.Duration
	DistinctIP         bool
}

NodeCriteria are the requirements for selecting nodes

type NodeDossier added in v0.9.0

type NodeDossier struct {
	pb.Node
	Type       pb.NodeType
	Operator   pb.NodeOperator
	Capacity   pb.NodeCapacity
	Reputation NodeStats
	Version    pb.NodeVersion
	Contained  bool
}

NodeDossier is the complete info that the satellite tracks for a storage node

type NodeSelectionConfig

type NodeSelectionConfig struct {
	UptimeRatio       float64       `help:"a node's ratio of being up/online vs. down/offline" releaseDefault:"0.9" devDefault:"0"`
	UptimeCount       int64         ``                                                                               /* 127-byte string literal not displayed */
	AuditSuccessRatio float64       `help:"a node's ratio of successful audits" releaseDefault:"0.4" devDefault:"0"` // TODO: update after beta
	AuditCount        int64         `help:"the number of times a node has been audited to not be considered a New Node" releaseDefault:"500" devDefault:"0"`
	NewNodePercentage float64       `help:"the percentage of new nodes allowed per request" default:"0.05"` // TODO: fix, this is not percentage, it's ratio
	MinimumVersion    string        `help:"the minimum node software version for node selection queries" default:""`
	OnlineWindow      time.Duration `help:"the amount of time without seeing a node before its considered offline" default:"1h"`
	DistinctIP        bool          `help:"require distinct IPs when choosing nodes for upload" releaseDefault:"true" devDefault:"false"`
}

NodeSelectionConfig is a configuration struct to determine the minimum values for nodes to select

type NodeStats

type NodeStats struct {
	Latency90          int64
	AuditSuccessRatio  float64
	AuditSuccessCount  int64
	AuditCount         int64
	UptimeRatio        float64
	UptimeSuccessCount int64
	UptimeCount        int64
	LastContactSuccess time.Time
	LastContactFailure time.Time
}

NodeStats contains statistics about a node.

type UpdateRequest

type UpdateRequest struct {
	NodeID       storj.NodeID
	AuditSuccess bool
	IsUp         bool
}

UpdateRequest is used to update a node status.

Jump to

Keyboard shortcuts

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