node

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// common api
	api.Common
	api.Device
	api.Validation
	api.DataSync
	api.Asset
	api.Workerd
	WaitQuiet func(ctx context.Context) error
	// edge api
	// ExternalServiceAddress func(ctx context.Context, candidateURL string) (string, error)
	UserNATPunch func(ctx context.Context, sourceURL string, req *types.NatPunchReq) error
	// candidate api
	GetBlocksOfAsset        func(ctx context.Context, assetCID string, randomSeed int64, randomCount int) ([]string, error)
	CheckNetworkConnectable func(ctx context.Context, network, targetURL string) (bool, error)
	GetMinioConfig          func(ctx context.Context) (*types.MinioConfig, error)
}

API represents the node API

func APIFromCandidate

func APIFromCandidate(api api.Candidate) *API

APIFromCandidate creates a new API from a Candidate API

func APIFromEdge

func APIFromEdge(api api.Edge) *API

APIFromEdge creates a new API from an Edge API

type GeoMgr added in v0.1.19

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

func (*GeoMgr) AddNode added in v0.1.19

func (g *GeoMgr) AddNode(continent, country, province, city string, nodeInfo *types.NodeInfo)

func (*GeoMgr) FindNodes added in v0.1.19

func (g *GeoMgr) FindNodes(continent, country, province, city string) []*types.NodeInfo

func (*GeoMgr) GetGeoKey added in v0.1.19

func (g *GeoMgr) GetGeoKey(continent, country, province string) map[string]int

func (*GeoMgr) RemoveNode added in v0.1.19

func (g *GeoMgr) RemoveNode(continent, country, province, city, nodeID string)

type Manager

type Manager struct {
	Edges      int // online edge node count
	Candidates int // online candidate node count

	*db.SQLDB
	*rsa.PrivateKey // scheduler privateKey
	dtypes.ServerID // scheduler server id
	// contains filtered or unexported fields
}

Manager is the node manager responsible for managing the online nodes

func NewManager

func NewManager(sdb *db.SQLDB, serverID dtypes.ServerID, pk *rsa.PrivateKey, pb *pubsub.PubSub, config dtypes.GetSchedulerConfigFunc, ec *etcdcli.Client) *Manager

NewManager creates a new instance of the node manager

func (*Manager) AddNodeGeo added in v0.1.19

func (m *Manager) AddNodeGeo(nodeInfo *types.NodeInfo, geo *region.GeoInfo)

func (*Manager) CalculateExitProfit added in v0.1.19

func (m *Manager) CalculateExitProfit(profit float64) (float64, float64)

func (*Manager) CalculatePenalty added in v0.1.19

func (m *Manager) CalculatePenalty(nodeID string, profit float64, offlineDuration int) float64

func (*Manager) CheckIPExist added in v0.1.14

func (m *Manager) CheckIPExist(ip string) bool

func (*Manager) ComputeNodeOnlineRate added in v0.1.19

func (m *Manager) ComputeNodeOnlineRate(nodeID string, firstTime time.Time) float64

func (*Manager) DistributeNodeWeight added in v0.1.11

func (m *Manager) DistributeNodeWeight(node *Node)

DistributeNodeWeight Distribute Node Weight

func (*Manager) FindNodesFromGeo added in v0.1.19

func (m *Manager) FindNodesFromGeo(continent, country, province, city string) []*types.NodeInfo

func (*Manager) GetAllCandidateNodes

func (m *Manager) GetAllCandidateNodes() ([]string, []*Node)

GetAllCandidateNodes Get all valid candidate nodes

func (*Manager) GetAllEdgeNode added in v0.1.10

func (m *Manager) GetAllEdgeNode() []*Node

GetAllEdgeNode load all edge node

func (*Manager) GetAllNodes added in v0.1.18

func (m *Manager) GetAllNodes() []*Node

GetAllNodes Get all valid candidate and edge nodes

func (*Manager) GetCandidateBaseProfitDetails added in v0.1.19

func (m *Manager) GetCandidateBaseProfitDetails(node *Node) *types.ProfitDetails

func (*Manager) GetCandidateNode

func (m *Manager) GetCandidateNode(nodeID string) *Node

GetCandidateNode retrieves a candidate node with the given node ID

func (*Manager) GetCandidateNodes

func (m *Manager) GetCandidateNodes(num int) []*Node

GetCandidateNodes return n candidate node

func (*Manager) GetDownloadProfitDetails added in v0.1.19

func (m *Manager) GetDownloadProfitDetails(node *Node, size float64) *types.ProfitDetails

func (*Manager) GetEdgeBaseProfitDetails added in v0.1.19

func (m *Manager) GetEdgeBaseProfitDetails(node *Node) (float64, *types.ProfitDetails)

func (*Manager) GetEdgeNode

func (m *Manager) GetEdgeNode(nodeID string) *Node

GetEdgeNode retrieves an edge node with the given node ID

func (*Manager) GetGeoKey added in v0.1.19

func (m *Manager) GetGeoKey(continent, country, province string) map[string]int

func (*Manager) GetNode

func (m *Manager) GetNode(nodeID string) *Node

GetNode retrieves a node with the given node ID

func (*Manager) GetNodeBePullProfitDetails added in v0.1.18

func (m *Manager) GetNodeBePullProfitDetails(node *Node, size float64, note string) *types.ProfitDetails

func (*Manager) GetNodeOfIP added in v0.1.15

func (m *Manager) GetNodeOfIP(ip string) []string

func (*Manager) GetNodeValidatableProfitDetails added in v0.1.18

func (m *Manager) GetNodeValidatableProfitDetails(node *Node, size float64) *types.ProfitDetails

func (*Manager) GetOnlineNodeCount

func (m *Manager) GetOnlineNodeCount(nodeType types.NodeType) int

GetOnlineNodeCount returns online node count of the given type

func (*Manager) GetRandomCandidates added in v0.1.18

func (m *Manager) GetRandomCandidates(count int) map[string]int

GetRandomCandidates returns a random candidate node

func (*Manager) GetRandomEdges added in v0.1.18

func (m *Manager) GetRandomEdges(count int) map[string]int

GetRandomEdges returns a random edge node

func (*Manager) GetUploadProfitDetails added in v0.1.19

func (m *Manager) GetUploadProfitDetails(node *Node, size float64) *types.ProfitDetails

func (*Manager) NodeOnline

func (m *Manager) NodeOnline(node *Node, info *types.NodeInfo) error

NodeOnline registers a node as online

func (*Manager) RemoveNodeGeo added in v0.1.19

func (m *Manager) RemoveNodeGeo(nodeID string, geo *region.GeoInfo)

func (*Manager) RemoveNodeIP added in v0.1.13

func (m *Manager) RemoveNodeIP(nodeID, ip string)

func (*Manager) RepayNodeWeight added in v0.1.11

func (m *Manager) RepayNodeWeight(node *Node)

RepayNodeWeight Repay Node Weight

func (*Manager) StoreNodeIP added in v0.1.18

func (m *Manager) StoreNodeIP(nodeID, ip string) bool

func (*Manager) UpdateNodeBandwidths added in v0.1.11

func (m *Manager) UpdateNodeBandwidths(nodeID string, bandwidthDown, bandwidthUp int64)

UpdateNodeBandwidths update node bandwidthDown and bandwidthUp

func (*Manager) UpdateNodeDiskUsage added in v0.1.13

func (m *Manager) UpdateNodeDiskUsage(nodeID string, diskUsage float64)

type Node

type Node struct {
	// NodeID string
	*API
	jsonrpc.ClientCloser
	*types.NodeInfo

	// node info
	PublicKey          *rsa.PublicKey
	TCPPort            int
	ExternalURL        string
	IsPrivateMinioOnly bool
	IsStorageOnly      bool

	OnlineRate float64

	KeepaliveCount   int
	LastValidateTime int64
	// contains filtered or unexported fields
}

Node represents an Edge or Candidate node

func New

func New() *Node

New creates a new node

func (*Node) ConnectRPC

func (n *Node) ConnectRPC(transport *quic.Transport, addr string, nodeType types.NodeType) error

ConnectRPC connects to the node RPC

func (*Node) DiskEnough added in v0.1.14

func (n *Node) DiskEnough(size float64) bool

func (*Node) DownloadAddr

func (n *Node) DownloadAddr() string

DownloadAddr returns the download address of the node

func (*Node) GetNumberOfIPChanges added in v0.1.18

func (n *Node) GetNumberOfIPChanges() (int64, time.Time)

func (*Node) GetToken added in v0.1.13

func (n *Node) GetToken() string

GetToken get the token of the node

func (*Node) IsAbnormal added in v0.1.11

func (n *Node) IsAbnormal() bool

IsAbnormal is node abnormal

func (*Node) LastRequestTime

func (n *Node) LastRequestTime() time.Time

LastRequestTime returns the last request time of the node

func (*Node) NetFlowDownExcess added in v0.1.19

func (n *Node) NetFlowDownExcess(size float64) bool

func (*Node) NetFlowUpExcess added in v0.1.19

func (n *Node) NetFlowUpExcess(size float64) bool

func (*Node) RPCURL

func (n *Node) RPCURL() string

RPCURL returns the rpc url of the node

func (*Node) SelectWeights added in v0.1.10

func (n *Node) SelectWeights() []int

SelectWeights get node select weights

func (*Node) SetLastRequestTime

func (n *Node) SetLastRequestTime(t time.Time)

SetLastRequestTime sets the last request time of the node

func (*Node) SetNumberOfIPChanges added in v0.1.18

func (n *Node) SetNumberOfIPChanges(count int64)

func (*Node) SetToken

func (n *Node) SetToken(t string)

SetToken sets the token of the node

func (*Node) TCPAddr

func (n *Node) TCPAddr() string

TCPAddr returns the tcp address of the node

func (*Node) Token

func (n *Node) Token(cid, clientID string, titanRsa *titanrsa.Rsa, privateKey *rsa.PrivateKey) (*types.Token, *types.TokenPayload, error)

Token returns the token of the node

func (*Node) WsURL added in v0.1.19

func (n *Node) WsURL() string

Jump to

Keyboard shortcuts

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