Documentation ¶
Index ¶
- func RateOfL2Mx(onlineDuration int) float64
- type API
- type GeoMgr
- func (m *GeoMgr) AddCandidateNode(continent, country, province, city string, nodeInfo *types.NodeInfo)
- func (m *GeoMgr) AddEdgeNode(continent, country, province, city string, nodeInfo *types.NodeInfo)
- func (m *GeoMgr) AddNodeGeo(nodeInfo *types.NodeInfo, areaID string)
- func (m *GeoMgr) FindCandidateNodes(continent, country, province, city string) []*types.NodeInfo
- func (m *GeoMgr) FindEdgeNodes(continent, country, province, city string) []*types.NodeInfo
- func (m *GeoMgr) FindNodesFromGeo(continent, country, province, city string, nodeType types.NodeType) []*types.NodeInfo
- func (m *GeoMgr) GetEdgeGeoKey(continent, country, province string) map[string]int
- func (m *GeoMgr) GetGeoKey(continent, country, province string) map[string]int
- func (m *GeoMgr) RemoveCandidateNode(continent, country, province, city, nodeID string)
- func (m *GeoMgr) RemoveEdgeNode(continent, country, province, city, nodeID string)
- func (m *GeoMgr) RemoveNodeGeo(nodeID string, nodeType types.NodeType, areaID string)
- type IPMgr
- type Manager
- func (m *Manager) CalculateExitProfit(profit float64) (float64, float64)
- func (m *Manager) CalculatePenalty(nodeID string, profit float64, offlineDuration int) *types.ProfitDetails
- func (m *Manager) ComputeNodeOnlineRate(nodeID string, firstTime time.Time) float64
- func (m *Manager) DistributeNodeWeight(node *Node)
- func (m *Manager) GetAllCandidateNodes() ([]string, []*Node)
- func (m *Manager) GetAllEdgeNode() []*Node
- func (m *Manager) GetAllNodes() []*Node
- func (m *Manager) GetCandidateBaseProfitDetails(node *Node, minute int) *types.ProfitDetails
- func (m *Manager) GetCandidateNode(nodeID string) *Node
- func (m *Manager) GetCandidateNodes(num int) []*Node
- func (m *Manager) GetDownloadProfitDetails(node *Node, size float64, pid string) *types.ProfitDetails
- func (m *Manager) GetEdgeBaseProfitDetails(node *Node, minute int) (float64, *types.ProfitDetails)
- func (m *Manager) GetEdgeNode(nodeID string) *Node
- func (m *Manager) GetL5Node(nodeID string) *Node
- func (m *Manager) GetNode(nodeID string) *Node
- func (m *Manager) GetNodeBePullProfitDetails(node *Node, size float64, note string) *types.ProfitDetails
- func (m *Manager) GetNodeValidatableProfitDetails(node *Node, size float64) *types.ProfitDetails
- func (m *Manager) GetOnlineNodeCount(nodeType types.NodeType) int
- func (m *Manager) GetRandomCandidates(count int) map[string]int
- func (m *Manager) GetRandomEdges(count int) map[string]int
- func (m *Manager) GetReimburseProfitDetails(nodeID string, profit float64, note string) *types.ProfitDetails
- func (m *Manager) GetUploadProfitDetails(node *Node, size float64, pid string) *types.ProfitDetails
- func (m *Manager) NodeOnline(node *Node, info *types.NodeInfo) error
- func (m *Manager) RepayNodeWeight(node *Node)
- func (m *Manager) SetTunserverURL(edgeID, candidateID string) error
- func (m *Manager) UpdateNodeBandwidths(nodeID string, bandwidthDown, bandwidthUp int64)
- func (m *Manager) UpdateNodeDiskUsage(nodeID string, diskUsage float64)
- func (m *Manager) UpdateTunserverURL(edgeID string) (*Node, error)
- type Node
- func (n *Node) ConnectRPC(transport *quic.Transport, addr string, nodeType types.NodeType) error
- func (n *Node) DiskEnough(size float64) bool
- func (n *Node) DownloadAddr() string
- func (n *Node) EncryptToken(cid, clientID string, titanRsa *titanrsa.Rsa, privateKey *rsa.PrivateKey) (*types.Token, error)
- func (n *Node) GetNumberOfIPChanges() (int64, time.Time)
- func (n *Node) InitInfo(nodeInfo *types.NodeInfo)
- func (n *Node) IsAbnormal() bool
- func (n *Node) LastRequestTime() time.Time
- func (n *Node) NetFlowDownExcess(size float64) bool
- func (n *Node) NetFlowUpExcess(size float64) bool
- func (n *Node) RPCURL() string
- func (n *Node) SelectWeights() []int
- func (n *Node) SetCountOfIPChanges(count int64)
- func (n *Node) SetLastRequestTime(t time.Time)
- func (n *Node) TCPAddr() string
- func (n *Node) WsURL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct { // common api api.Common api.Device api.Validation api.DataSync api.Asset api.Workerd api.ProviderAPI 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 CreateTunnel func(ctx context.Context, req *types.CreateTunnelReq) 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 ¶
APIFromCandidate creates a new API from a Candidate API
func APIFromEdge ¶
APIFromEdge creates a new API from an Edge API
type GeoMgr ¶ added in v0.1.19
type GeoMgr struct {
// contains filtered or unexported fields
}
GeoMgr node geo info manager
func (*GeoMgr) AddCandidateNode ¶ added in v0.1.21
func (m *GeoMgr) AddCandidateNode(continent, country, province, city string, nodeInfo *types.NodeInfo)
AddCandidateNode add candidate to map
func (*GeoMgr) AddEdgeNode ¶ added in v0.1.21
AddEdgeNode add edge to map
func (*GeoMgr) AddNodeGeo ¶ added in v0.1.21
AddNodeGeo add node to map
func (*GeoMgr) FindCandidateNodes ¶ added in v0.1.21
FindCandidateNodes find candidate from map
func (*GeoMgr) FindEdgeNodes ¶ added in v0.1.21
FindEdgeNodes find edge from map
func (*GeoMgr) FindNodesFromGeo ¶ added in v0.1.21
func (m *GeoMgr) FindNodesFromGeo(continent, country, province, city string, nodeType types.NodeType) []*types.NodeInfo
FindNodesFromGeo find node from map
func (*GeoMgr) GetEdgeGeoKey ¶ added in v0.1.21
GetEdgeGeoKey get edge geo key
func (*GeoMgr) RemoveCandidateNode ¶ added in v0.1.21
RemoveCandidateNode remove candidate from map
func (*GeoMgr) RemoveEdgeNode ¶ added in v0.1.21
RemoveEdgeNode remove edge from map
type IPMgr ¶ added in v0.1.21
type IPMgr struct {
// contains filtered or unexported fields
}
IPMgr node ip info manager
func (*IPMgr) CheckIPExist ¶ added in v0.1.21
CheckIPExist check node
func (*IPMgr) GetNodeOfIP ¶ added in v0.1.21
GetNodeOfIP get node
func (*IPMgr) RemoveNodeIP ¶ added in v0.1.21
RemoveNodeIP remove node
func (*IPMgr) StoreNodeIP ¶ added in v0.1.21
StoreNodeIP store node
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 GeoMgr *GeoMgr IPMgr *IPMgr // 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) CalculateExitProfit ¶ added in v0.1.19
CalculateExitProfit Exit penalty calculation
func (*Manager) CalculatePenalty ¶ added in v0.1.19
func (m *Manager) CalculatePenalty(nodeID string, profit float64, offlineDuration int) *types.ProfitDetails
CalculatePenalty Penalty
func (*Manager) ComputeNodeOnlineRate ¶ added in v0.1.19
ComputeNodeOnlineRate Compute node online rate
func (*Manager) DistributeNodeWeight ¶ added in v0.1.11
DistributeNodeWeight Distribute Node Weight
func (*Manager) GetAllCandidateNodes ¶
GetAllCandidateNodes Get all valid candidate nodes
func (*Manager) GetAllEdgeNode ¶ added in v0.1.10
GetAllEdgeNode load all edge node
func (*Manager) GetAllNodes ¶ added in v0.1.18
GetAllNodes Get all valid candidate and edge nodes
func (*Manager) GetCandidateBaseProfitDetails ¶ added in v0.1.19
func (m *Manager) GetCandidateBaseProfitDetails(node *Node, minute int) *types.ProfitDetails
GetCandidateBaseProfitDetails Basic Rewards
func (*Manager) GetCandidateNode ¶
GetCandidateNode retrieves a candidate node with the given node ID
func (*Manager) GetCandidateNodes ¶
GetCandidateNodes return n candidate node
func (*Manager) GetDownloadProfitDetails ¶ added in v0.1.19
func (m *Manager) GetDownloadProfitDetails(node *Node, size float64, pid string) *types.ProfitDetails
GetDownloadProfitDetails Downstream traffic reward
func (*Manager) GetEdgeBaseProfitDetails ¶ added in v0.1.19
GetEdgeBaseProfitDetails Basic Rewards
func (*Manager) GetEdgeNode ¶
GetEdgeNode retrieves an edge node with the given node ID
func (*Manager) GetL5Node ¶ added in v0.1.21
GetCandidateNode retrieves a candidate 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
GetNodeBePullProfitDetails Provide download rewards
func (*Manager) GetNodeValidatableProfitDetails ¶ added in v0.1.18
func (m *Manager) GetNodeValidatableProfitDetails(node *Node, size float64) *types.ProfitDetails
GetNodeValidatableProfitDetails Rewards for random inspection
func (*Manager) GetOnlineNodeCount ¶
GetOnlineNodeCount returns online node count of the given type
func (*Manager) GetRandomCandidates ¶ added in v0.1.18
GetRandomCandidates returns a random candidate node
func (*Manager) GetRandomEdges ¶ added in v0.1.18
GetRandomEdges returns a random edge node
func (*Manager) GetReimburseProfitDetails ¶ added in v0.1.21
func (m *Manager) GetReimburseProfitDetails(nodeID string, profit float64, note string) *types.ProfitDetails
GetReimburseProfitDetails Reimburse
func (*Manager) GetUploadProfitDetails ¶ added in v0.1.19
GetUploadProfitDetails Upstream traffic reward
func (*Manager) NodeOnline ¶
NodeOnline registers a node as online
func (*Manager) RepayNodeWeight ¶ added in v0.1.11
RepayNodeWeight Repay Node Weight
func (*Manager) SetTunserverURL ¶ added in v0.1.21
SetTunserverURL set node Tunserver URL
func (*Manager) UpdateNodeBandwidths ¶ added in v0.1.11
UpdateNodeBandwidths update node bandwidthDown and bandwidthUp
func (*Manager) UpdateNodeDiskUsage ¶ added in v0.1.13
UpdateNodeDiskUsage update node disk usage
type Node ¶
type Node struct { // NodeID string *API jsonrpc.ClientCloser Token string // node info PublicKey *rsa.PublicKey TCPPort int ExternalURL string IsPrivateMinioOnly bool IsStorageNode bool OnlineRate float64 // Increase the count every 5 seconds // KeepaliveCount int LastValidateTime int64 types.NodeDynamicInfo IsTestNode bool Type types.NodeType ExternalIP string CPUUsage float64 MemoryUsage float64 NATType string ClientType types.NodeClientType BackProjectTime int64 RemoteAddr string Level int IncomeIncr float64 // Base points increase every half hour (30 minute) // GeoInfo *region.GeoInfo Mx float64 AreaID string NetFlowUp int64 NetFlowDown int64 DiskSpace float64 WSServerID string PortMapping string DeactivateTime int64 // contains filtered or unexported fields }
Node represents an Edge or Candidate node
func (*Node) ConnectRPC ¶
ConnectRPC connects to the node RPC
func (*Node) DiskEnough ¶ added in v0.1.14
DiskEnough Is there enough storage on the compute node
func (*Node) DownloadAddr ¶
DownloadAddr returns the download address of the node
func (*Node) EncryptToken ¶ added in v0.1.21
func (n *Node) EncryptToken(cid, clientID string, titanRsa *titanrsa.Rsa, privateKey *rsa.PrivateKey) (*types.Token, error)
EncryptToken returns the token of the node
func (*Node) GetNumberOfIPChanges ¶ added in v0.1.18
GetNumberOfIPChanges node change ip count
func (*Node) IsAbnormal ¶ added in v0.1.11
IsAbnormal is node abnormal
func (*Node) LastRequestTime ¶
LastRequestTime returns the last request time of the node
func (*Node) NetFlowDownExcess ¶ added in v0.1.19
NetFlowDownExcess Whether the downstream traffic exceeds the limit
func (*Node) NetFlowUpExcess ¶ added in v0.1.19
NetFlowUpExcess Whether the upstream traffic exceeds the limit
func (*Node) SelectWeights ¶ added in v0.1.10
SelectWeights get node select weights
func (*Node) SetCountOfIPChanges ¶ added in v0.1.21
SetCountOfIPChanges node change ip count
func (*Node) SetLastRequestTime ¶
SetLastRequestTime sets the last request time of the node