overlay

package
v0.8.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OverlayBucket is the string representing the bucket used for a bolt-backed overlay dht cache
	OverlayBucket = "overlay"
)

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 ErrIncorrectVersion = errs.New("incorrect version")

ErrIncorrectVersion is returned when the version is empty or not properly formatted

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

func (cache *Cache) Delete(ctx context.Context, id storj.NodeID) (err error)

Delete will remove the node from the cache. Used when a node hard disconnects or fails to pass a PING multiple times.

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

GetAll looks up the provided ids from the overlay cache

func (*Cache) GetStats

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

GetStats returns node stats.

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

func (cache *Cache) UpdateOperator(ctx context.Context, node storj.NodeID, updatedOperator pb.NodeOperator) (stats *NodeStats, err error)

UpdateOperator updates the email and wallet for a given node ID for satellite payments.

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) (*pb.Node, error)
	// GetAll looks up nodes based on the ids from the overlay cache
	GetAll(ctx context.Context, nodeIDs storj.NodeIDList) ([]*pb.Node, error)
	// List lists nodes starting from cursor
	List(ctx context.Context, cursor storj.NodeID, limit int) ([]*pb.Node, error)
	// Paginate will page through the database nodes
	Paginate(ctx context.Context, offset int64, limit int) ([]*pb.Node, bool, error)
	// Update updates node information
	Update(ctx context.Context, value *pb.Node) error
	// Delete deletes node based on id
	Delete(ctx context.Context, id storj.NodeID) error

	// CreateStats initializes the stats for node.
	CreateStats(ctx context.Context, nodeID storj.NodeID, initial *NodeStats) (stats *NodeStats, err error)
	// GetStats returns node stats.
	GetStats(ctx context.Context, nodeID storj.NodeID) (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)
	// UpdateOperator updates the email and wallet for a given node ID for satellite payments.
	UpdateOperator(ctx context.Context, node storj.NodeID, updatedOperator pb.NodeOperator) (stats *NodeStats, err error)
	// UpdateUptime updates a single storagenode's uptime stats.
	UpdateUptime(ctx context.Context, nodeID storj.NodeID, isUp bool) (stats *NodeStats, err error)
	// UpdateBatch for updating multiple storage nodes' stats.
	UpdateBatch(ctx context.Context, requests []*UpdateRequest) (statslist []*NodeStats, failed []*UpdateRequest, err error)
	// CreateEntryIfNotExists creates a node stats entry if it didn't already exist.
	CreateEntryIfNotExists(ctx context.Context, value *pb.Node) (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 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:"set to minimum node software version" default:""`
}

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

type NodeStats

type NodeStats struct {
	NodeID             storj.NodeID
	AuditSuccessRatio  float64
	AuditSuccessCount  int64
	AuditCount         int64
	UptimeRatio        float64
	UptimeSuccessCount int64
	UptimeCount        int64
	Operator           pb.NodeOperator
	Version            pb.NodeVersion
}

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