overlay

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OnlineWindow is the maximum amount of time that can pass without seeing a node before that node is considered offline
	OnlineWindow = 1 * time.Hour
)

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) FindInvalidNodes

func (cache *Cache) FindInvalidNodes(ctx context.Context, nodeIDs storj.NodeIDList, maxStats *NodeStats) (invalid storj.NodeIDList, err error)

FindInvalidNodes finds a subset of storagenodes that have stats below provided reputation requirements.

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) (_ []*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) GetAll

func (cache *Cache) GetAll(ctx context.Context, ids storj.NodeIDList) (_ []*NodeDossier, err error)

GetAll looks up the provided ids from the overlay cache

func (*Cache) Inspect

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

Inspect lists limited number of items in the cache

func (*Cache) List

func (cache *Cache) List(ctx context.Context, cursor storj.NodeID, limit int) (_ []*NodeDossier, err error)

List returns a list of nodes from the cache DB

func (*Cache) OfflineNodes

func (cache *Cache) OfflineNodes(ctx context.Context, nodes []storj.NodeID) (offline []int, err error)

OfflineNodes returns indices of the nodes that are offline

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 and stat db

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 *NewNodeCriteria) ([]*pb.Node, error)

	// Get looks up the node by nodeID
	Get(ctx context.Context, nodeID storj.NodeID) (*NodeDossier, error)
	// GetAll looks up nodes based on the ids from the overlay cache
	GetAll(ctx context.Context, nodeIDs storj.NodeIDList) ([]*NodeDossier, error)
	// List lists nodes starting from cursor
	List(ctx context.Context, cursor storj.NodeID, limit int) ([]*NodeDossier, error)
	// Paginate will page through the database nodes
	Paginate(ctx context.Context, offset int64, limit int) ([]*NodeDossier, bool, error)
	// Update updates node information
	Update(ctx context.Context, value *pb.Node) error

	// CreateStats initializes the stats for node.
	CreateStats(ctx context.Context, nodeID storj.NodeID, initial *NodeStats) (stats *NodeStats, err error)
	// FindInvalidNodes finds a subset of storagenodes that have stats below provided reputation requirements.
	FindInvalidNodes(ctx context.Context, nodeIDs storj.NodeIDList, maxStats *NodeStats) (invalid storj.NodeIDList, err 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 NewNodeCriteria

type NewNodeCriteria struct {
	FreeBandwidth int64
	FreeDisk      int64

	AuditThreshold int64

	Excluded []storj.NodeID

	MinimumVersion string // semver or empty
}

NewNodeCriteria are the requirement for selecting new nodes

type NodeCriteria

type NodeCriteria struct {
	FreeBandwidth int64
	FreeDisk      int64

	AuditCount         int64
	AuditSuccessRatio  float64
	UptimeCount        int64
	UptimeSuccessRatio float64

	Excluded []storj.NodeID

	MinimumVersion string // semver or empty
}

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
}

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

func (*NodeDossier) Online added in v0.9.0

func (node *NodeDossier) Online() bool

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

A node is considered online if the last attempt for contact was successful and it was within the last hour.

type NodeSelectionConfig

type NodeSelectionConfig struct {
	UptimeRatio       float64 `help:"a node's ratio of being up/online vs. down/offline" default:"0"`
	UptimeCount       int64   `help:"the number of times a node's uptime has been checked" default:"0"`
	AuditSuccessRatio float64 `help:"a node's ratio of successful audits" default:"0"`
	AuditCount        int64   `help:"the number of times a node has been audited" default:"0"`

	NewNodeAuditThreshold int64   `help:"the number of audits a node must have to not be considered a New Node" default:"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:""`
}

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