Documentation ¶
Index ¶
- Constants
- func GetDiffPieceNum(dst *Peer, src *Peer) int32
- type CDNMgr
- type Channel
- type HostMgr
- type Peer
- func (peer *Peer) BindNewConn(stream scheduler.Scheduler_ReportPieceResultServer) *Channel
- func (peer *Peer) CloseChannel(err error) error
- func (peer *Peer) GetChildren() *sync.Map
- func (peer *Peer) GetCost() int
- func (peer *Peer) GetCostHistory() []int
- func (peer *Peer) GetDepth() int
- func (peer *Peer) GetFinishedNum() int32
- func (peer *Peer) GetLastAccessTime() time.Time
- func (peer *Peer) GetParent() *Peer
- func (peer *Peer) GetSortKeys() (key1, key2 int)
- func (peer *Peer) GetStatus() PeerStatus
- func (peer *Peer) GetTreeRoot() *Peer
- func (peer *Peer) GetWholeTreeNode() int
- func (peer *Peer) IsAncestorOf(offspring *Peer) bool
- func (peer *Peer) IsBad() bool
- func (peer *Peer) IsConnected() bool
- func (peer *Peer) IsDescendantOf(ancestor *Peer) bool
- func (peer *Peer) IsDone() bool
- func (peer *Peer) IsFail() bool
- func (peer *Peer) IsLeave() bool
- func (peer *Peer) IsRunning() bool
- func (peer *Peer) IsSuccess() bool
- func (peer *Peer) IsWaiting() bool
- func (peer *Peer) Log() *logger.SugaredLoggerOnWith
- func (peer *Peer) MarkLeave()
- func (peer *Peer) ReplaceParent(parent *Peer)
- func (peer *Peer) SendSchedulePacket(packet *scheduler.PeerPacket) error
- func (peer *Peer) SetStatus(status PeerStatus)
- func (peer *Peer) Touch()
- func (peer *Peer) UpdateProgress(finishedCount int32, cost int)
- type PeerHost
- func (h *PeerHost) AddPeer(peer *Peer)
- func (h *PeerHost) DecUploadLoad() int32
- func (h *PeerHost) DeletePeer(peerID string)
- func (h *PeerHost) GetCurrentUpload() int32
- func (h *PeerHost) GetFreeUploadLoad() int
- func (h *PeerHost) GetPeer(peerID string) (*Peer, bool)
- func (h *PeerHost) GetPeerTaskNum() int
- func (h *PeerHost) GetUploadLoadPercent() float64
- func (h *PeerHost) IncUploadLoad() int32
- func (h *PeerHost) Log() *logger.SugaredLoggerOnWith
- type PeerMgr
- type PeerStatus
- type Task
- func (task *Task) AddPeer(peer *Peer)
- func (task *Task) AddPiece(p *base.PieceInfo)
- func (task *Task) CanSchedule() bool
- func (task *Task) DeletePeer(peer *Peer)
- func (task *Task) GetBackSourcePeers() []string
- func (task *Task) GetLastAccessTime() time.Time
- func (task *Task) GetLastTriggerTime() time.Time
- func (task *Task) GetPiece(pieceNum int32) *base.PieceInfo
- func (task *Task) GetStatus() TaskStatus
- func (task *Task) IncreaseBackSourcePeer(peerID string)
- func (task *Task) IsBackSourcePeer(peerID string) bool
- func (task *Task) IsFail() bool
- func (task *Task) IsHealth() bool
- func (task *Task) IsSuccess() bool
- func (task *Task) IsWaiting() bool
- func (task *Task) ListPeers() *sortedlist.SortedList
- func (task *Task) Lock()
- func (task *Task) Log() *logger.SugaredLoggerOnWith
- func (task *Task) NeedClientBackSource() bool
- func (task *Task) Pick(limit int, pickFn func(peer *Peer) bool) (pickedPeers []*Peer)
- func (task *Task) PickReverse(limit int, pickFn func(peer *Peer) bool) (pickedPeers []*Peer)
- func (task *Task) RLock()
- func (task *Task) RUnlock()
- func (task *Task) SetClientBackSourceStatusAndLimit(backSourceLimit int32)
- func (task *Task) SetStatus(status TaskStatus)
- func (task *Task) Touch()
- func (task *Task) UnLock()
- func (task *Task) UpdateLastTriggerTime(lastTriggerTime time.Time)
- func (task *Task) UpdatePeer(peer *Peer)
- func (task *Task) UpdateTaskSuccessResult(pieceTotal int32, contentLength int64)
- type TaskMgr
- type TaskStatus
Constants ¶
View Source
const TinyFileSize = 128
Variables ¶
This section is empty.
Functions ¶
func GetDiffPieceNum ¶
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func (*Channel) CloseWithError ¶
func (*Channel) Receiver ¶
func (c *Channel) Receiver() <-chan *scheduler.PieceResult
type Peer ¶
type Peer struct { // PeerID specifies ID of peer PeerID string // Task specifies Task *Task // Host specifies Host *PeerHost // createTime CreateTime time.Time // contains filtered or unexported fields }
func (*Peer) BindNewConn ¶
func (peer *Peer) BindNewConn(stream scheduler.Scheduler_ReportPieceResultServer) *Channel
func (*Peer) CloseChannel ¶
func (*Peer) GetChildren ¶
func (*Peer) GetCostHistory ¶
func (*Peer) GetFinishedNum ¶
func (*Peer) GetLastAccessTime ¶
func (*Peer) GetSortKeys ¶
func (*Peer) GetStatus ¶
func (peer *Peer) GetStatus() PeerStatus
func (*Peer) GetTreeRoot ¶
func (*Peer) IsAncestorOf ¶
IsAncestorOf if offspring is offspring of peer
func (*Peer) IsConnected ¶
func (*Peer) IsDescendantOf ¶
IsDescendantOf if peer is offspring of ancestor
func (*Peer) Log ¶
func (peer *Peer) Log() *logger.SugaredLoggerOnWith
func (*Peer) ReplaceParent ¶
func (*Peer) SendSchedulePacket ¶
func (peer *Peer) SendSchedulePacket(packet *scheduler.PeerPacket) error
func (*Peer) SetStatus ¶
func (peer *Peer) SetStatus(status PeerStatus)
func (*Peer) UpdateProgress ¶
type PeerHost ¶
type PeerHost struct { // uuid each time the daemon starts, it will generate a different uuid UUID string // IP peer host ip IP string // HostName peer host name HostName string // RPCPort rpc service port for peer RPCPort int32 // DownloadPort piece downloading port for peer DownloadPort int32 // CDN if host type is cdn CDN bool // SecurityDomain security isolation domain for network SecurityDomain string // Location location path: area|country|province|city|... Location string // IDC idc where the peer host is located IDC string // NetTopology network device path: switch|router|... NetTopology string // TODO TotalUploadLoad currentUploadLoad decided by real time client report host info TotalUploadLoad int32 // contains filtered or unexported fields }
func NewCDNPeerHost ¶
func NewClientPeerHost ¶
func (*PeerHost) DecUploadLoad ¶
func (*PeerHost) DeletePeer ¶
func (*PeerHost) GetCurrentUpload ¶
func (*PeerHost) GetFreeUploadLoad ¶
func (*PeerHost) GetPeerTaskNum ¶
func (*PeerHost) GetUploadLoadPercent ¶
func (*PeerHost) IncUploadLoad ¶
func (*PeerHost) Log ¶
func (h *PeerHost) Log() *logger.SugaredLoggerOnWith
type PeerStatus ¶
type PeerStatus uint8
const ( PeerStatusWaiting PeerStatus = iota PeerStatusRunning // TODO add Seeding status PeerStatusZombie PeerStatusFail PeerStatusSuccess )
func (PeerStatus) String ¶
func (status PeerStatus) String() string
type Task ¶
type Task struct { TaskID string URL string URLMeta *base.UrlMeta DirectPiece []byte CreateTime time.Time PieceTotal int32 ContentLength int64 // contains filtered or unexported fields }
func (*Task) CanSchedule ¶
CanSchedule determines whether task can be scheduled only task status is seeding or success can be scheduled
func (*Task) DeletePeer ¶
func (*Task) GetBackSourcePeers ¶
func (*Task) GetLastAccessTime ¶
func (*Task) GetLastTriggerTime ¶
func (*Task) GetStatus ¶
func (task *Task) GetStatus() TaskStatus
func (*Task) IncreaseBackSourcePeer ¶
func (*Task) IsBackSourcePeer ¶
func (*Task) ListPeers ¶
func (task *Task) ListPeers() *sortedlist.SortedList
func (*Task) Log ¶
func (task *Task) Log() *logger.SugaredLoggerOnWith
func (*Task) NeedClientBackSource ¶
func (*Task) PickReverse ¶
func (*Task) SetClientBackSourceStatusAndLimit ¶
func (*Task) SetStatus ¶
func (task *Task) SetStatus(status TaskStatus)
func (*Task) UpdateLastTriggerTime ¶
func (*Task) UpdatePeer ¶
func (*Task) UpdateTaskSuccessResult ¶
type TaskStatus ¶
type TaskStatus uint8
const ( TaskStatusWaiting TaskStatus = iota TaskStatusRunning TaskStatusSeeding TaskStatusSuccess TaskStatusZombie TaskStatusFail )
func (TaskStatus) String ¶
func (status TaskStatus) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.