supervisor

package
v2.0.1-a-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TinyFileSize = 128

Variables

This section is empty.

Functions

func GetDiffPieceNum

func GetDiffPieceNum(dst *Peer, src *Peer) int32

Types

type CDNMgr

type CDNMgr interface {

	// StartSeedTask start seed cdn task
	StartSeedTask(ctx context.Context, task *Task) (*Peer, error)
}

type Channel

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

func (*Channel) Close

func (c *Channel) Close()

func (*Channel) CloseWithError

func (c *Channel) CloseWithError(err error)

func (*Channel) Done

func (c *Channel) Done() <-chan struct{}

func (*Channel) Err

func (c *Channel) Err() error

func (*Channel) IsClosed

func (c *Channel) IsClosed() bool

func (*Channel) Receiver

func (c *Channel) Receiver() <-chan *scheduler.PieceResult

func (*Channel) Send

func (c *Channel) Send(packet *scheduler.PeerPacket) error

type HostMgr

type HostMgr interface {
	Add(host *PeerHost)

	Delete(uuid string)

	Get(uuid string) (*PeerHost, bool)
}

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 NewPeer

func NewPeer(peerID string, task *Task, host *PeerHost) *Peer

func (*Peer) BindNewConn

func (peer *Peer) BindNewConn(stream scheduler.Scheduler_ReportPieceResultServer) *Channel

func (*Peer) CloseChannel

func (peer *Peer) CloseChannel(err error) error

func (*Peer) GetChildren

func (peer *Peer) GetChildren() *sync.Map

func (*Peer) GetCost

func (peer *Peer) GetCost() int

func (*Peer) GetCostHistory

func (peer *Peer) GetCostHistory() []int

func (*Peer) GetDepth

func (peer *Peer) GetDepth() int

func (*Peer) GetFinishedNum

func (peer *Peer) GetFinishedNum() int32

func (*Peer) GetLastAccessTime

func (peer *Peer) GetLastAccessTime() time.Time

func (*Peer) GetParent

func (peer *Peer) GetParent() *Peer

func (*Peer) GetSortKeys

func (peer *Peer) GetSortKeys() (key1, key2 int)

func (*Peer) GetStatus

func (peer *Peer) GetStatus() PeerStatus

func (*Peer) GetTreeRoot

func (peer *Peer) GetTreeRoot() *Peer

func (*Peer) GetWholeTreeNode

func (peer *Peer) GetWholeTreeNode() int

TODO: remove

func (*Peer) IsAncestorOf

func (peer *Peer) IsAncestorOf(offspring *Peer) bool

IsAncestorOf if offspring is offspring of peer

func (*Peer) IsBad

func (peer *Peer) IsBad() bool

func (*Peer) IsConnected

func (peer *Peer) IsConnected() bool

func (*Peer) IsDescendantOf

func (peer *Peer) IsDescendantOf(ancestor *Peer) bool

IsDescendantOf if peer is offspring of ancestor

func (*Peer) IsDone

func (peer *Peer) IsDone() bool

func (*Peer) IsFail

func (peer *Peer) IsFail() bool

func (*Peer) IsLeave

func (peer *Peer) IsLeave() bool

func (*Peer) IsRunning

func (peer *Peer) IsRunning() bool

func (*Peer) IsSuccess

func (peer *Peer) IsSuccess() bool

func (*Peer) IsWaiting

func (peer *Peer) IsWaiting() bool

func (*Peer) Log

func (peer *Peer) Log() *logger.SugaredLoggerOnWith

func (*Peer) MarkLeave

func (peer *Peer) MarkLeave()

func (*Peer) ReplaceParent

func (peer *Peer) ReplaceParent(parent *Peer)

func (*Peer) SendSchedulePacket

func (peer *Peer) SendSchedulePacket(packet *scheduler.PeerPacket) error

func (*Peer) SetStatus

func (peer *Peer) SetStatus(status PeerStatus)

func (*Peer) Touch

func (peer *Peer) Touch()

func (*Peer) UpdateProgress

func (peer *Peer) UpdateProgress(finishedCount int32, cost int)

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 NewCDNPeerHost(uuid, ip, hostname string, rpcPort, downloadPort int32, securityDomain, location, idc, netTopology string,
	totalUploadLoad int32) *PeerHost

func NewClientPeerHost

func NewClientPeerHost(uuid, ip, hostname string, rpcPort, downloadPort int32, securityDomain, location, idc, netTopology string,
	totalUploadLoad int32) *PeerHost

func (*PeerHost) AddPeer

func (h *PeerHost) AddPeer(peer *Peer)

func (*PeerHost) DecUploadLoad

func (h *PeerHost) DecUploadLoad() int32

func (*PeerHost) DeletePeer

func (h *PeerHost) DeletePeer(peerID string)

func (*PeerHost) GetCurrentUpload

func (h *PeerHost) GetCurrentUpload() int32

func (*PeerHost) GetFreeUploadLoad

func (h *PeerHost) GetFreeUploadLoad() int

func (*PeerHost) GetPeer

func (h *PeerHost) GetPeer(peerID string) (*Peer, bool)

func (*PeerHost) GetPeerTaskNum

func (h *PeerHost) GetPeerTaskNum() int

func (*PeerHost) GetUploadLoadPercent

func (h *PeerHost) GetUploadLoadPercent() float64

func (*PeerHost) IncUploadLoad

func (h *PeerHost) IncUploadLoad() int32

func (*PeerHost) Log

type PeerMgr

type PeerMgr interface {
	Add(peer *Peer)

	Get(peerID string) (*Peer, bool)

	Delete(peerID string)

	ListPeersByTask(taskID string) []*Peer

	ListPeers() *sync.Map
}

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 NewTask

func NewTask(taskID, url string, meta *base.UrlMeta) *Task

func (*Task) AddPeer

func (task *Task) AddPeer(peer *Peer)

func (*Task) AddPiece

func (task *Task) AddPiece(p *base.PieceInfo)

func (*Task) CanSchedule

func (task *Task) CanSchedule() bool

CanSchedule determines whether task can be scheduled only task status is seeding or success can be scheduled

func (*Task) DeletePeer

func (task *Task) DeletePeer(peer *Peer)

func (*Task) GetBackSourcePeers

func (task *Task) GetBackSourcePeers() []string

func (*Task) GetLastAccessTime

func (task *Task) GetLastAccessTime() time.Time

func (*Task) GetLastTriggerTime

func (task *Task) GetLastTriggerTime() time.Time

func (*Task) GetPiece

func (task *Task) GetPiece(pieceNum int32) *base.PieceInfo

func (*Task) GetStatus

func (task *Task) GetStatus() TaskStatus

func (*Task) IncreaseBackSourcePeer

func (task *Task) IncreaseBackSourcePeer(peerID string)

func (*Task) IsBackSourcePeer

func (task *Task) IsBackSourcePeer(peerID string) bool

func (*Task) IsFail

func (task *Task) IsFail() bool

IsFail determines whether task is fail

func (*Task) IsHealth

func (task *Task) IsHealth() bool

IsHealth determines whether task is health

func (*Task) IsSuccess

func (task *Task) IsSuccess() bool

IsSuccess determines that whether cdn status is success.

func (*Task) IsWaiting

func (task *Task) IsWaiting() bool

IsWaiting determines whether task is waiting

func (*Task) ListPeers

func (task *Task) ListPeers() *sortedlist.SortedList

func (*Task) Lock

func (task *Task) Lock()

func (*Task) Log

func (task *Task) Log() *logger.SugaredLoggerOnWith

func (*Task) NeedClientBackSource

func (task *Task) NeedClientBackSource() bool

func (*Task) Pick

func (task *Task) Pick(limit int, pickFn func(peer *Peer) bool) (pickedPeers []*Peer)

func (*Task) PickReverse

func (task *Task) PickReverse(limit int, pickFn func(peer *Peer) bool) (pickedPeers []*Peer)

func (*Task) RLock

func (task *Task) RLock()

func (*Task) RUnlock

func (task *Task) RUnlock()

func (*Task) SetClientBackSourceStatusAndLimit

func (task *Task) SetClientBackSourceStatusAndLimit(backSourceLimit int32)

func (*Task) SetStatus

func (task *Task) SetStatus(status TaskStatus)

func (*Task) Touch

func (task *Task) Touch()

func (*Task) UnLock

func (task *Task) UnLock()

func (*Task) UpdateLastTriggerTime

func (task *Task) UpdateLastTriggerTime(lastTriggerTime time.Time)

func (*Task) UpdatePeer

func (task *Task) UpdatePeer(peer *Peer)

func (*Task) UpdateTaskSuccessResult

func (task *Task) UpdateTaskSuccessResult(pieceTotal int32, contentLength int64)

type TaskMgr

type TaskMgr interface {
	Add(task *Task)

	Get(taskID string) (task *Task, ok bool)

	Delete(taskID string)

	GetOrAdd(task *Task) (actual *Task, loaded bool)
}

type TaskStatus

type TaskStatus uint8
const (
	TaskStatusWaiting TaskStatus = iota
	TaskStatusRunning
	TaskStatusSeeding
	TaskStatusSuccess
	TaskStatusZombie
	TaskStatusFail
)

func (TaskStatus) String

func (status TaskStatus) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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