Documentation ¶
Overview ¶
Package standard is a generated GoMock package.
Package standard is a generated GoMock package.
Package standard is a generated GoMock package.
Package standard is a generated GoMock package.
Package standard is a generated GoMock package.
Package standard is a generated GoMock package.
Index ¶
- Constants
- func IsPieceBackToSource(parentID string) bool
- type Build
- type CPU
- type CPUTimes
- type Disk
- type Host
- type HostManager
- type HostOption
- func WithAnnounceInterval(announceInterval time.Duration) HostOption
- func WithBuild(build Build) HostOption
- func WithCPU(cpu CPU) HostOption
- func WithConcurrentUploadLimit(limit int32) HostOption
- func WithDisableShared(disableShared bool) HostOption
- func WithDisk(disk Disk) HostOption
- func WithKernelVersion(kernelVersion string) HostOption
- func WithMemory(memory Memory) HostOption
- func WithNetwork(network Network) HostOption
- func WithOS(os string) HostOption
- func WithObjectStoragePort(port int32) HostOption
- func WithPlatform(platform string) HostOption
- func WithPlatformFamily(platformFamily string) HostOption
- func WithPlatformVersion(platformVersion string) HostOption
- func WithSchedulerClusterID(id uint64) HostOption
- type Memory
- type MockHostManager
- func (m *MockHostManager) Delete(arg0 string)
- func (m *MockHostManager) EXPECT() *MockHostManagerMockRecorder
- func (m *MockHostManager) Load(arg0 string) (*Host, bool)
- func (m *MockHostManager) LoadAll() []*Host
- func (m *MockHostManager) LoadOrStore(arg0 *Host) (*Host, bool)
- func (m *MockHostManager) LoadRandom(arg0 int, arg1 set.SafeSet[string]) []*Host
- func (m *MockHostManager) Range(f func(any, any) bool)
- func (m *MockHostManager) RunGC() error
- func (m *MockHostManager) Store(arg0 *Host)
- type MockHostManagerMockRecorder
- func (mr *MockHostManagerMockRecorder) Delete(arg0 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) Load(arg0 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) LoadAll() *gomock.Call
- func (mr *MockHostManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) LoadRandom(arg0, arg1 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) Range(f any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) RunGC() *gomock.Call
- func (mr *MockHostManagerMockRecorder) Store(arg0 any) *gomock.Call
- type MockPeerManager
- func (m *MockPeerManager) Delete(arg0 string)
- func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder
- func (m *MockPeerManager) Load(arg0 string) (*Peer, bool)
- func (m *MockPeerManager) LoadOrStore(arg0 *Peer) (*Peer, bool)
- func (m *MockPeerManager) Range(f func(any, any) bool)
- func (m *MockPeerManager) RunGC() error
- func (m *MockPeerManager) Store(arg0 *Peer)
- type MockPeerManagerMockRecorder
- func (mr *MockPeerManagerMockRecorder) Delete(arg0 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) Load(arg0 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) Range(f any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) RunGC() *gomock.Call
- func (mr *MockPeerManagerMockRecorder) Store(arg0 any) *gomock.Call
- type MockResource
- type MockResourceMockRecorder
- func (mr *MockResourceMockRecorder) HostManager() *gomock.Call
- func (mr *MockResourceMockRecorder) PeerManager() *gomock.Call
- func (mr *MockResourceMockRecorder) SeedPeer() *gomock.Call
- func (mr *MockResourceMockRecorder) Stop() *gomock.Call
- func (mr *MockResourceMockRecorder) TaskManager() *gomock.Call
- type MockSeedPeer
- func (m *MockSeedPeer) Client() SeedPeerClient
- func (m *MockSeedPeer) EXPECT() *MockSeedPeerMockRecorder
- func (m *MockSeedPeer) Stop() error
- func (m *MockSeedPeer) TriggerDownloadTask(arg0 context.Context, arg1 string, arg2 *dfdaemon.DownloadTaskRequest) error
- func (m *MockSeedPeer) TriggerTask(arg0 context.Context, arg1 *http.Range, arg2 *Task) (*Peer, *scheduler.PeerResult, error)
- type MockSeedPeerClient
- func (m *MockSeedPeerClient) Addrs() []string
- func (m *MockSeedPeerClient) Close() error
- func (m *MockSeedPeerClient) DeletePersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.DeletePersistentCacheTaskRequest, ...) error
- func (m *MockSeedPeerClient) DeleteTask(arg0 context.Context, arg1 *dfdaemon.DeleteTaskRequest, ...) error
- func (m *MockSeedPeerClient) DownloadPersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.DownloadPersistentCacheTaskRequest, ...) (dfdaemon.DfdaemonUpload_DownloadPersistentCacheTaskClient, error)
- func (m *MockSeedPeerClient) DownloadPiece(arg0 context.Context, arg1 *dfdaemon.DownloadPieceRequest, ...) (*dfdaemon.DownloadPieceResponse, error)
- func (m *MockSeedPeerClient) DownloadTask(arg0 context.Context, arg1 string, arg2 *dfdaemon.DownloadTaskRequest, ...) (dfdaemon.DfdaemonUpload_DownloadTaskClient, error)
- func (m *MockSeedPeerClient) EXPECT() *MockSeedPeerClientMockRecorder
- func (m *MockSeedPeerClient) GetPieceTasks(arg0 context.Context, arg1 *common.PieceTaskRequest, arg2 ...grpc.CallOption) (*common.PiecePacket, error)
- func (m *MockSeedPeerClient) ObtainSeeds(arg0 context.Context, arg1 *cdnsystem.SeedRequest, arg2 ...grpc.CallOption) (cdnsystem.Seeder_ObtainSeedsClient, error)
- func (m *MockSeedPeerClient) OnNotify(arg0 *config.DynconfigData)
- func (m *MockSeedPeerClient) StatPersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.StatPersistentCacheTaskRequest, ...) (*common0.PersistentCacheTask, error)
- func (m *MockSeedPeerClient) StatTask(arg0 context.Context, arg1 *dfdaemon.StatTaskRequest, arg2 ...grpc.CallOption) (*common0.Task, error)
- func (m *MockSeedPeerClient) SyncPieceTasks(arg0 context.Context, arg1 *common.PieceTaskRequest, arg2 ...grpc.CallOption) (cdnsystem.Seeder_SyncPieceTasksClient, error)
- func (m *MockSeedPeerClient) SyncPieces(arg0 context.Context, arg1 *dfdaemon.SyncPiecesRequest, ...) (dfdaemon.DfdaemonUpload_SyncPiecesClient, error)
- type MockSeedPeerClientMockRecorder
- func (mr *MockSeedPeerClientMockRecorder) Addrs() *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) Close() *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) DeletePersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) DeleteTask(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) DownloadPersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) DownloadPiece(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) DownloadTask(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) GetPieceTasks(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) ObtainSeeds(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) OnNotify(arg0 any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) StatPersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) StatTask(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) SyncPieceTasks(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockSeedPeerClientMockRecorder) SyncPieces(arg0, arg1 any, arg2 ...any) *gomock.Call
- type MockSeedPeerMockRecorder
- type MockTaskManager
- func (m *MockTaskManager) Delete(arg0 string)
- func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
- func (m *MockTaskManager) Load(arg0 string) (*Task, bool)
- func (m *MockTaskManager) LoadOrStore(arg0 *Task) (*Task, bool)
- func (m *MockTaskManager) Range(f func(any, any) bool)
- func (m *MockTaskManager) RunGC() error
- func (m *MockTaskManager) Store(arg0 *Task)
- type MockTaskManagerMockRecorder
- func (mr *MockTaskManagerMockRecorder) Delete(arg0 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Load(arg0 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Range(f any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) RunGC() *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Store(arg0 any) *gomock.Call
- type Network
- type Peer
- func (p *Peer) AppendPieceCost(duration time.Duration)
- func (p *Peer) CalculatePriority(dynconfig config.DynconfigInterface) commonv2.Priority
- func (p *Peer) Children() []*Peer
- func (p *Peer) DeleteAnnouncePeerStream()
- func (p *Peer) DeletePiece(key int32)
- func (p *Peer) DeleteReportPieceResultStream()
- func (p *Peer) DownloadTinyFile() ([]byte, error)deprecated
- func (p *Peer) LoadAnnouncePeerStream() (schedulerv2.Scheduler_AnnouncePeerServer, bool)
- func (p *Peer) LoadPiece(key int32) (*Piece, bool)
- func (p *Peer) LoadReportPieceResultStream() (schedulerv1.Scheduler_ReportPieceResultServer, bool)
- func (p *Peer) Parents() []*Peer
- func (p *Peer) PieceCosts() []time.Duration
- func (p *Peer) StoreAnnouncePeerStream(stream schedulerv2.Scheduler_AnnouncePeerServer)
- func (p *Peer) StorePiece(piece *Piece)
- func (p *Peer) StoreReportPieceResultStream(stream schedulerv1.Scheduler_ReportPieceResultServer)
- type PeerManager
- type PeerOption
- type Piece
- type Resource
- type SeedPeer
- type SeedPeerClient
- type Task
- func (t *Task) AddPeerEdge(fromPeer *Peer, toPeer *Peer) error
- func (t *Task) CanAddPeerEdge(fromPeerKey, toPeerKey string) bool
- func (t *Task) CanBackToSource() bool
- func (t *Task) CanReuseDirectPiece() bool
- func (t *Task) DeletePeer(key string)
- func (t *Task) DeletePeerInEdges(key string) error
- func (t *Task) DeletePeerOutEdges(key string) error
- func (t *Task) DeletePiece(key int32)
- func (t *Task) HasAvailablePeer(blocklist set.SafeSet[string]) bool
- func (t *Task) IsSeedPeerFailed() bool
- func (t *Task) LoadFinishedPeers() []*Peer
- func (t *Task) LoadPeer(key string) (*Peer, bool)
- func (t *Task) LoadPeers() []*Peer
- func (t *Task) LoadPiece(key int32) (*Piece, bool)
- func (t *Task) LoadRandomPeers(n uint) []*Peer
- func (t *Task) LoadSeedPeer() (*Peer, bool)
- func (t *Task) PeerCount() int
- func (t *Task) PeerDegree(key string) (int, error)
- func (t *Task) PeerInDegree(key string) (int, error)
- func (t *Task) PeerOutDegree(key string) (int, error)
- func (t *Task) ReportPieceResultToPeers(peerPacket *schedulerv1.PeerPacket, event string)
- func (t *Task) SizeScope() commonv2.SizeScope
- func (t *Task) StorePeer(peer *Peer)
- func (t *Task) StorePiece(piece *Piece)
- type TaskManager
- type TaskOption
Constants ¶
const ( // Peer has been created but did not start running. PeerStatePending = "Pending" // Peer successfully registered as empty scope size. PeerStateReceivedEmpty = "ReceivedEmpty" // Peer successfully registered as tiny scope size. PeerStateReceivedTiny = "ReceivedTiny" // Peer successfully registered as small scope size. PeerStateReceivedSmall = "ReceivedSmall" // Peer successfully registered as normal scope size. PeerStateReceivedNormal = "ReceivedNormal" // Peer is downloading resources from peer. PeerStateRunning = "Running" // Peer is downloading resources from back-to-source. PeerStateBackToSource = "BackToSource" // Peer has been downloaded successfully. PeerStateSucceeded = "Succeeded" // Peer has been downloaded failed. PeerStateFailed = "Failed" // Peer has been left. PeerStateLeave = "Leave" )
const ( // Peer is registered as empty scope size. PeerEventRegisterEmpty = "RegisterEmpty" // Peer is registered as tiny scope size. PeerEventRegisterTiny = "RegisterTiny" // Peer is registered as small scope size. PeerEventRegisterSmall = "RegisterSmall" // Peer is registered as normal scope size. PeerEventRegisterNormal = "RegisterNormal" // Peer is downloading. PeerEventDownload = "Download" // Peer is downloading back-to-source. PeerEventDownloadBackToSource = "DownloadBackToSource" // Peer downloaded successfully. PeerEventDownloadSucceeded = "DownloadSucceeded" // Peer downloaded failed. PeerEventDownloadFailed = "DownloadFailed" // Peer leaves. PeerEventLeave = "Leave" )
const ( // Tiny file size is 128 bytes. TinyFileSize = 128 // Empty file size is 0 bytes. EmptyFileSize = 0 )
const ( // Peer failure limit in task. FailedPeerCountLimit = 200 // Peer count limit for task. PeerCountLimitForTask = 300 )
const ( // Task has been created but did not start running. TaskStatePending = "Pending" // Task is downloading resources from seed peer or back-to-source. TaskStateRunning = "Running" // Task has been downloaded successfully. TaskStateSucceeded = "Succeeded" // Task has been downloaded failed. TaskStateFailed = "Failed" // Task has no peers. TaskStateLeave = "Leave" )
const ( // Task is downloading. TaskEventDownload = "Download" // Task downloaded successfully. TaskEventDownloadSucceeded = "DownloadSucceeded" // Task downloaded failed. TaskEventDownloadFailed = "DownloadFailed" // Task leaves. TaskEventLeave = "Leave" )
const (
// GC host id.
GCHostID = "host"
)
const (
// GC peer id.
GCPeerID = "peer"
)
const (
// GC task id.
GCTaskID = "task"
)
const ( // Default value of seed peer failed timeout. SeedPeerFailedTimeout = 30 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func IsPieceBackToSource ¶
IsPieceBackToSource returns whether the piece is downloaded back-to-source.
Types ¶
type Build ¶
type Build struct { // Git version. GitVersion string // Git commit. GitCommit string // Golang version. GoVersion string // Build platform. Platform string }
Build contains content for build.
type CPU ¶
type CPU struct { // Number of logical cores in the system. LogicalCount uint32 // Number of physical cores in the system. PhysicalCount uint32 // Percent calculates the percentage of cpu used. Percent float64 // Calculates the percentage of cpu used by process. ProcessPercent float64 // Times contains the amounts of time the CPU has spent performing different kinds of work. Times CPUTimes }
CPU contains content for cpu.
type CPUTimes ¶
type CPUTimes struct { // CPU time of user. User float64 // CPU time of system. System float64 // CPU time of idle. Idle float64 // CPU time of nice. Nice float64 // CPU time of iowait. Iowait float64 // CPU time of irq. Irq float64 // CPU time of softirq. Softirq float64 // CPU time of steal. Steal float64 // CPU time of guest. Guest float64 // CPU time of guest nice. GuestNice float64 }
CPUTimes contains content for cpu times.
type Disk ¶
type Disk struct { // Total amount of disk on the data path of dragonfly. Total uint64 // Free amount of disk on the data path of dragonfly. Free uint64 // Used amount of disk on the data path of dragonfly. Used uint64 // Used percent of disk on the data path of dragonfly directory. UsedPercent float64 // Total amount of indoes on the data path of dragonfly directory. InodesTotal uint64 // Used amount of indoes on the data path of dragonfly directory. InodesUsed uint64 // Free amount of indoes on the data path of dragonfly directory. InodesFree uint64 // Used percent of indoes on the data path of dragonfly directory. InodesUsedPercent float64 // Disk write bandwidth, unit is byte/s. WriteBandwidth uint64 // Disk read bandwidth, unit is byte/s. ReadBandwidth uint64 }
Disk contains content for disk.
type Host ¶
type Host struct { // ID is host id. ID string // Type is host type. Type types.HostType // Hostname is host name. Hostname string // IP is host ip. IP string // Port is grpc service port. Port int32 // DownloadPort is piece downloading port. DownloadPort int32 // ObjectStoragePort is object storage port. ObjectStoragePort int32 // shared with other peers. DisableShared bool // Host OS. OS string // Host platform. Platform string // Host platform family. PlatformFamily string // Host platform version. PlatformVersion string // Host kernel version. KernelVersion string // CPU Stat. CPU CPU // Memory Stat. Memory Memory // Network Stat. Network Network // Dist Stat. Disk Disk // Build information. Build Build // SchedulerClusterID is the scheduler cluster id matched by scopes. SchedulerClusterID uint64 // AnnounceInterval is the interval between host announces to scheduler. AnnounceInterval time.Duration // ConcurrentUploadLimit is concurrent upload limit count. ConcurrentUploadLimit *atomic.Int32 // ConcurrentUploadCount is concurrent upload count. ConcurrentUploadCount *atomic.Int32 // UploadCount is total upload count. UploadCount *atomic.Int64 // UploadFailedCount is upload failed count. UploadFailedCount *atomic.Int64 // Peer sync map. Peers *sync.Map // PeerCount is peer count. PeerCount *atomic.Int32 // CreatedAt is host create time. CreatedAt *atomic.Time // UpdatedAt is host update time. UpdatedAt *atomic.Time // Host log. Log *logger.SugaredLoggerOnWith }
Host contains content for host.
func NewHost ¶
func NewHost( id, ip, hostname string, port, downloadPort int32, typ types.HostType, options ...HostOption, ) *Host
New host instance.
func (*Host) FreeUploadCount ¶
FreeUploadCount return free upload count of host.
func (*Host) IsSeedPeer ¶ added in v2.1.62
IsSeedPeer return whether the host is seed peer.
type HostManager ¶
type HostManager interface { // Load returns host for a key. Load(string) (*Host, bool) // Store sets host. Store(*Host) // LoadOrStore returns host the key if present. // Otherwise, it stores and returns the given host. // The loaded result is true if the host was loaded, false if stored. LoadOrStore(*Host) (*Host, bool) // Delete deletes host for a key. Delete(string) // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. Range(f func(any, any) bool) // LoadRandom loads host randomly through the Range of sync.Map. LoadRandom(int, set.SafeSet[string]) []*Host // LoadAll loads all hosts through the Range of sync.Map. LoadAll() []*Host // Try to reclaim host. RunGC() error }
HostManager is the interface used for host manager.
type HostOption ¶
type HostOption func(h *Host)
HostOption is a functional option for configuring the host.
func WithAnnounceInterval ¶
func WithAnnounceInterval(announceInterval time.Duration) HostOption
WithAnnounceInterval sets host's announce interval.
func WithConcurrentUploadLimit ¶
func WithConcurrentUploadLimit(limit int32) HostOption
WithConcurrentUploadLimit sets host's ConcurrentUploadLimit.
func WithDisableShared ¶
func WithDisableShared(disableShared bool) HostOption
WithDisableShared sets host's DisableShared.
func WithKernelVersion ¶
func WithKernelVersion(kernelVersion string) HostOption
WithKernelVersion sets host's kernel version.
func WithObjectStoragePort ¶
func WithObjectStoragePort(port int32) HostOption
WithObjectStoragePort sets host's ObjectStoragePort.
func WithPlatform ¶
func WithPlatform(platform string) HostOption
WithPlatform sets host's platform.
func WithPlatformFamily ¶
func WithPlatformFamily(platformFamily string) HostOption
WithPlatformFamily sets host's platform family.
func WithPlatformVersion ¶
func WithPlatformVersion(platformVersion string) HostOption
WithPlatformVersion sets host's platform version.
func WithSchedulerClusterID ¶
func WithSchedulerClusterID(id uint64) HostOption
WithSchedulerClusterID sets host's SchedulerClusterID.
type Memory ¶
type Memory struct { // Total amount of RAM on this system. Total uint64 // RAM available for programs to allocate. Available uint64 // RAM used by programs. Used uint64 // Percentage of RAM used by programs. UsedPercent float64 // Calculates the percentage of memory used by process. ProcessUsedPercent float64 // This is the kernel's notion of free memory. Free uint64 }
Memory contains content for memory.
type MockHostManager ¶
type MockHostManager struct {
// contains filtered or unexported fields
}
MockHostManager is a mock of HostManager interface.
func NewMockHostManager ¶
func NewMockHostManager(ctrl *gomock.Controller) *MockHostManager
NewMockHostManager creates a new mock instance.
func (*MockHostManager) Delete ¶
func (m *MockHostManager) Delete(arg0 string)
Delete mocks base method.
func (*MockHostManager) EXPECT ¶
func (m *MockHostManager) EXPECT() *MockHostManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockHostManager) Load ¶
func (m *MockHostManager) Load(arg0 string) (*Host, bool)
Load mocks base method.
func (*MockHostManager) LoadAll ¶
func (m *MockHostManager) LoadAll() []*Host
LoadAll mocks base method.
func (*MockHostManager) LoadOrStore ¶
func (m *MockHostManager) LoadOrStore(arg0 *Host) (*Host, bool)
LoadOrStore mocks base method.
func (*MockHostManager) LoadRandom ¶
LoadRandom mocks base method.
func (*MockHostManager) Range ¶
func (m *MockHostManager) Range(f func(any, any) bool)
Range mocks base method.
func (*MockHostManager) Store ¶
func (m *MockHostManager) Store(arg0 *Host)
Store mocks base method.
type MockHostManagerMockRecorder ¶
type MockHostManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockHostManagerMockRecorder is the mock recorder for MockHostManager.
func (*MockHostManagerMockRecorder) Delete ¶
func (mr *MockHostManagerMockRecorder) Delete(arg0 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockHostManagerMockRecorder) Load ¶
func (mr *MockHostManagerMockRecorder) Load(arg0 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockHostManagerMockRecorder) LoadAll ¶
func (mr *MockHostManagerMockRecorder) LoadAll() *gomock.Call
LoadAll indicates an expected call of LoadAll.
func (*MockHostManagerMockRecorder) LoadOrStore ¶
func (mr *MockHostManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
LoadOrStore indicates an expected call of LoadOrStore.
func (*MockHostManagerMockRecorder) LoadRandom ¶
func (mr *MockHostManagerMockRecorder) LoadRandom(arg0, arg1 any) *gomock.Call
LoadRandom indicates an expected call of LoadRandom.
func (*MockHostManagerMockRecorder) Range ¶
func (mr *MockHostManagerMockRecorder) Range(f any) *gomock.Call
Range indicates an expected call of Range.
func (*MockHostManagerMockRecorder) RunGC ¶
func (mr *MockHostManagerMockRecorder) RunGC() *gomock.Call
RunGC indicates an expected call of RunGC.
type MockPeerManager ¶
type MockPeerManager struct {
// contains filtered or unexported fields
}
MockPeerManager is a mock of PeerManager interface.
func NewMockPeerManager ¶
func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager
NewMockPeerManager creates a new mock instance.
func (*MockPeerManager) Delete ¶
func (m *MockPeerManager) Delete(arg0 string)
Delete mocks base method.
func (*MockPeerManager) EXPECT ¶
func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPeerManager) Load ¶
func (m *MockPeerManager) Load(arg0 string) (*Peer, bool)
Load mocks base method.
func (*MockPeerManager) LoadOrStore ¶
func (m *MockPeerManager) LoadOrStore(arg0 *Peer) (*Peer, bool)
LoadOrStore mocks base method.
func (*MockPeerManager) Range ¶
func (m *MockPeerManager) Range(f func(any, any) bool)
Range mocks base method.
func (*MockPeerManager) Store ¶
func (m *MockPeerManager) Store(arg0 *Peer)
Store mocks base method.
type MockPeerManagerMockRecorder ¶
type MockPeerManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockPeerManagerMockRecorder is the mock recorder for MockPeerManager.
func (*MockPeerManagerMockRecorder) Delete ¶
func (mr *MockPeerManagerMockRecorder) Delete(arg0 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockPeerManagerMockRecorder) Load ¶
func (mr *MockPeerManagerMockRecorder) Load(arg0 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockPeerManagerMockRecorder) LoadOrStore ¶
func (mr *MockPeerManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
LoadOrStore indicates an expected call of LoadOrStore.
func (*MockPeerManagerMockRecorder) Range ¶
func (mr *MockPeerManagerMockRecorder) Range(f any) *gomock.Call
Range indicates an expected call of Range.
func (*MockPeerManagerMockRecorder) RunGC ¶
func (mr *MockPeerManagerMockRecorder) RunGC() *gomock.Call
RunGC indicates an expected call of RunGC.
type MockResource ¶
type MockResource struct {
// contains filtered or unexported fields
}
MockResource is a mock of Resource interface.
func NewMockResource ¶
func NewMockResource(ctrl *gomock.Controller) *MockResource
NewMockResource creates a new mock instance.
func (*MockResource) EXPECT ¶
func (m *MockResource) EXPECT() *MockResourceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockResource) HostManager ¶
func (m *MockResource) HostManager() HostManager
HostManager mocks base method.
func (*MockResource) PeerManager ¶
func (m *MockResource) PeerManager() PeerManager
PeerManager mocks base method.
func (*MockResource) SeedPeer ¶
func (m *MockResource) SeedPeer() SeedPeer
SeedPeer mocks base method.
func (*MockResource) TaskManager ¶
func (m *MockResource) TaskManager() TaskManager
TaskManager mocks base method.
type MockResourceMockRecorder ¶
type MockResourceMockRecorder struct {
// contains filtered or unexported fields
}
MockResourceMockRecorder is the mock recorder for MockResource.
func (*MockResourceMockRecorder) HostManager ¶
func (mr *MockResourceMockRecorder) HostManager() *gomock.Call
HostManager indicates an expected call of HostManager.
func (*MockResourceMockRecorder) PeerManager ¶
func (mr *MockResourceMockRecorder) PeerManager() *gomock.Call
PeerManager indicates an expected call of PeerManager.
func (*MockResourceMockRecorder) SeedPeer ¶
func (mr *MockResourceMockRecorder) SeedPeer() *gomock.Call
SeedPeer indicates an expected call of SeedPeer.
func (*MockResourceMockRecorder) Stop ¶
func (mr *MockResourceMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockResourceMockRecorder) TaskManager ¶
func (mr *MockResourceMockRecorder) TaskManager() *gomock.Call
TaskManager indicates an expected call of TaskManager.
type MockSeedPeer ¶
type MockSeedPeer struct {
// contains filtered or unexported fields
}
MockSeedPeer is a mock of SeedPeer interface.
func NewMockSeedPeer ¶
func NewMockSeedPeer(ctrl *gomock.Controller) *MockSeedPeer
NewMockSeedPeer creates a new mock instance.
func (*MockSeedPeer) Client ¶
func (m *MockSeedPeer) Client() SeedPeerClient
Client mocks base method.
func (*MockSeedPeer) EXPECT ¶
func (m *MockSeedPeer) EXPECT() *MockSeedPeerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSeedPeer) TriggerDownloadTask ¶
func (m *MockSeedPeer) TriggerDownloadTask(arg0 context.Context, arg1 string, arg2 *dfdaemon.DownloadTaskRequest) error
TriggerDownloadTask mocks base method.
func (*MockSeedPeer) TriggerTask ¶
func (m *MockSeedPeer) TriggerTask(arg0 context.Context, arg1 *http.Range, arg2 *Task) (*Peer, *scheduler.PeerResult, error)
TriggerTask mocks base method.
type MockSeedPeerClient ¶
type MockSeedPeerClient struct {
// contains filtered or unexported fields
}
MockSeedPeerClient is a mock of SeedPeerClient interface.
func NewMockSeedPeerClient ¶
func NewMockSeedPeerClient(ctrl *gomock.Controller) *MockSeedPeerClient
NewMockSeedPeerClient creates a new mock instance.
func (*MockSeedPeerClient) Addrs ¶
func (m *MockSeedPeerClient) Addrs() []string
Addrs mocks base method.
func (*MockSeedPeerClient) Close ¶
func (m *MockSeedPeerClient) Close() error
Close mocks base method.
func (*MockSeedPeerClient) DeletePersistentCacheTask ¶
func (m *MockSeedPeerClient) DeletePersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.DeletePersistentCacheTaskRequest, arg2 ...grpc.CallOption) error
DeletePersistentCacheTask mocks base method.
func (*MockSeedPeerClient) DeleteTask ¶
func (m *MockSeedPeerClient) DeleteTask(arg0 context.Context, arg1 *dfdaemon.DeleteTaskRequest, arg2 ...grpc.CallOption) error
DeleteTask mocks base method.
func (*MockSeedPeerClient) DownloadPersistentCacheTask ¶
func (m *MockSeedPeerClient) DownloadPersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.DownloadPersistentCacheTaskRequest, arg2 ...grpc.CallOption) (dfdaemon.DfdaemonUpload_DownloadPersistentCacheTaskClient, error)
DownloadPersistentCacheTask mocks base method.
func (*MockSeedPeerClient) DownloadPiece ¶
func (m *MockSeedPeerClient) DownloadPiece(arg0 context.Context, arg1 *dfdaemon.DownloadPieceRequest, arg2 ...grpc.CallOption) (*dfdaemon.DownloadPieceResponse, error)
DownloadPiece mocks base method.
func (*MockSeedPeerClient) DownloadTask ¶
func (m *MockSeedPeerClient) DownloadTask(arg0 context.Context, arg1 string, arg2 *dfdaemon.DownloadTaskRequest, arg3 ...grpc.CallOption) (dfdaemon.DfdaemonUpload_DownloadTaskClient, error)
DownloadTask mocks base method.
func (*MockSeedPeerClient) EXPECT ¶
func (m *MockSeedPeerClient) EXPECT() *MockSeedPeerClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSeedPeerClient) GetPieceTasks ¶
func (m *MockSeedPeerClient) GetPieceTasks(arg0 context.Context, arg1 *common.PieceTaskRequest, arg2 ...grpc.CallOption) (*common.PiecePacket, error)
GetPieceTasks mocks base method.
func (*MockSeedPeerClient) ObtainSeeds ¶
func (m *MockSeedPeerClient) ObtainSeeds(arg0 context.Context, arg1 *cdnsystem.SeedRequest, arg2 ...grpc.CallOption) (cdnsystem.Seeder_ObtainSeedsClient, error)
ObtainSeeds mocks base method.
func (*MockSeedPeerClient) OnNotify ¶
func (m *MockSeedPeerClient) OnNotify(arg0 *config.DynconfigData)
OnNotify mocks base method.
func (*MockSeedPeerClient) StatPersistentCacheTask ¶
func (m *MockSeedPeerClient) StatPersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.StatPersistentCacheTaskRequest, arg2 ...grpc.CallOption) (*common0.PersistentCacheTask, error)
StatPersistentCacheTask mocks base method.
func (*MockSeedPeerClient) StatTask ¶
func (m *MockSeedPeerClient) StatTask(arg0 context.Context, arg1 *dfdaemon.StatTaskRequest, arg2 ...grpc.CallOption) (*common0.Task, error)
StatTask mocks base method.
func (*MockSeedPeerClient) SyncPieceTasks ¶
func (m *MockSeedPeerClient) SyncPieceTasks(arg0 context.Context, arg1 *common.PieceTaskRequest, arg2 ...grpc.CallOption) (cdnsystem.Seeder_SyncPieceTasksClient, error)
SyncPieceTasks mocks base method.
func (*MockSeedPeerClient) SyncPieces ¶
func (m *MockSeedPeerClient) SyncPieces(arg0 context.Context, arg1 *dfdaemon.SyncPiecesRequest, arg2 ...grpc.CallOption) (dfdaemon.DfdaemonUpload_SyncPiecesClient, error)
SyncPieces mocks base method.
type MockSeedPeerClientMockRecorder ¶
type MockSeedPeerClientMockRecorder struct {
// contains filtered or unexported fields
}
MockSeedPeerClientMockRecorder is the mock recorder for MockSeedPeerClient.
func (*MockSeedPeerClientMockRecorder) Addrs ¶
func (mr *MockSeedPeerClientMockRecorder) Addrs() *gomock.Call
Addrs indicates an expected call of Addrs.
func (*MockSeedPeerClientMockRecorder) Close ¶
func (mr *MockSeedPeerClientMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockSeedPeerClientMockRecorder) DeletePersistentCacheTask ¶
func (mr *MockSeedPeerClientMockRecorder) DeletePersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
DeletePersistentCacheTask indicates an expected call of DeletePersistentCacheTask.
func (*MockSeedPeerClientMockRecorder) DeleteTask ¶
func (mr *MockSeedPeerClientMockRecorder) DeleteTask(arg0, arg1 any, arg2 ...any) *gomock.Call
DeleteTask indicates an expected call of DeleteTask.
func (*MockSeedPeerClientMockRecorder) DownloadPersistentCacheTask ¶
func (mr *MockSeedPeerClientMockRecorder) DownloadPersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
DownloadPersistentCacheTask indicates an expected call of DownloadPersistentCacheTask.
func (*MockSeedPeerClientMockRecorder) DownloadPiece ¶
func (mr *MockSeedPeerClientMockRecorder) DownloadPiece(arg0, arg1 any, arg2 ...any) *gomock.Call
DownloadPiece indicates an expected call of DownloadPiece.
func (*MockSeedPeerClientMockRecorder) DownloadTask ¶
func (mr *MockSeedPeerClientMockRecorder) DownloadTask(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
DownloadTask indicates an expected call of DownloadTask.
func (*MockSeedPeerClientMockRecorder) GetPieceTasks ¶
func (mr *MockSeedPeerClientMockRecorder) GetPieceTasks(arg0, arg1 any, arg2 ...any) *gomock.Call
GetPieceTasks indicates an expected call of GetPieceTasks.
func (*MockSeedPeerClientMockRecorder) ObtainSeeds ¶
func (mr *MockSeedPeerClientMockRecorder) ObtainSeeds(arg0, arg1 any, arg2 ...any) *gomock.Call
ObtainSeeds indicates an expected call of ObtainSeeds.
func (*MockSeedPeerClientMockRecorder) OnNotify ¶
func (mr *MockSeedPeerClientMockRecorder) OnNotify(arg0 any) *gomock.Call
OnNotify indicates an expected call of OnNotify.
func (*MockSeedPeerClientMockRecorder) StatPersistentCacheTask ¶
func (mr *MockSeedPeerClientMockRecorder) StatPersistentCacheTask(arg0, arg1 any, arg2 ...any) *gomock.Call
StatPersistentCacheTask indicates an expected call of StatPersistentCacheTask.
func (*MockSeedPeerClientMockRecorder) StatTask ¶
func (mr *MockSeedPeerClientMockRecorder) StatTask(arg0, arg1 any, arg2 ...any) *gomock.Call
StatTask indicates an expected call of StatTask.
func (*MockSeedPeerClientMockRecorder) SyncPieceTasks ¶
func (mr *MockSeedPeerClientMockRecorder) SyncPieceTasks(arg0, arg1 any, arg2 ...any) *gomock.Call
SyncPieceTasks indicates an expected call of SyncPieceTasks.
func (*MockSeedPeerClientMockRecorder) SyncPieces ¶
func (mr *MockSeedPeerClientMockRecorder) SyncPieces(arg0, arg1 any, arg2 ...any) *gomock.Call
SyncPieces indicates an expected call of SyncPieces.
type MockSeedPeerMockRecorder ¶
type MockSeedPeerMockRecorder struct {
// contains filtered or unexported fields
}
MockSeedPeerMockRecorder is the mock recorder for MockSeedPeer.
func (*MockSeedPeerMockRecorder) Client ¶
func (mr *MockSeedPeerMockRecorder) Client() *gomock.Call
Client indicates an expected call of Client.
func (*MockSeedPeerMockRecorder) Stop ¶
func (mr *MockSeedPeerMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockSeedPeerMockRecorder) TriggerDownloadTask ¶
func (mr *MockSeedPeerMockRecorder) TriggerDownloadTask(arg0, arg1, arg2 any) *gomock.Call
TriggerDownloadTask indicates an expected call of TriggerDownloadTask.
func (*MockSeedPeerMockRecorder) TriggerTask ¶
func (mr *MockSeedPeerMockRecorder) TriggerTask(arg0, arg1, arg2 any) *gomock.Call
TriggerTask indicates an expected call of TriggerTask.
type MockTaskManager ¶
type MockTaskManager struct {
// contains filtered or unexported fields
}
MockTaskManager is a mock of TaskManager interface.
func NewMockTaskManager ¶
func NewMockTaskManager(ctrl *gomock.Controller) *MockTaskManager
NewMockTaskManager creates a new mock instance.
func (*MockTaskManager) Delete ¶
func (m *MockTaskManager) Delete(arg0 string)
Delete mocks base method.
func (*MockTaskManager) EXPECT ¶
func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskManager) Load ¶
func (m *MockTaskManager) Load(arg0 string) (*Task, bool)
Load mocks base method.
func (*MockTaskManager) LoadOrStore ¶
func (m *MockTaskManager) LoadOrStore(arg0 *Task) (*Task, bool)
LoadOrStore mocks base method.
func (*MockTaskManager) Range ¶
func (m *MockTaskManager) Range(f func(any, any) bool)
Range mocks base method.
func (*MockTaskManager) Store ¶
func (m *MockTaskManager) Store(arg0 *Task)
Store mocks base method.
type MockTaskManagerMockRecorder ¶
type MockTaskManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskManagerMockRecorder is the mock recorder for MockTaskManager.
func (*MockTaskManagerMockRecorder) Delete ¶
func (mr *MockTaskManagerMockRecorder) Delete(arg0 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockTaskManagerMockRecorder) Load ¶
func (mr *MockTaskManagerMockRecorder) Load(arg0 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockTaskManagerMockRecorder) LoadOrStore ¶
func (mr *MockTaskManagerMockRecorder) LoadOrStore(arg0 any) *gomock.Call
LoadOrStore indicates an expected call of LoadOrStore.
func (*MockTaskManagerMockRecorder) Range ¶
func (mr *MockTaskManagerMockRecorder) Range(f any) *gomock.Call
Range indicates an expected call of Range.
func (*MockTaskManagerMockRecorder) RunGC ¶
func (mr *MockTaskManagerMockRecorder) RunGC() *gomock.Call
RunGC indicates an expected call of RunGC.
type Network ¶
type Network struct { // Return count of tcp connections opened and status is ESTABLISHED. TCPConnectionCount uint32 // Return count of upload tcp connections opened and status is ESTABLISHED. UploadTCPConnectionCount uint32 // Location path(area|country|province|city|...). Location string // IDC where the peer host is located IDC string // Download rate of the host, unit is byte/s. DownloadRate uint64 // Download rate limit of the host, unit is byte/s. DownloadRateLimit uint64 // Upload rate of the host, unit is byte/s. UploadRate uint64 // Upload rate limit of the host, unit is byte/s. UploadRateLimit uint64 }
Network contains content for network.
type Peer ¶
type Peer struct { // ID is peer id. ID string // Range is url range of request. Range *nethttp.Range // Priority is peer priority. Priority commonv2.Priority // Piece sync map. Pieces *sync.Map // Pieces is finished pieces bitset. FinishedPieces *bitset.BitSet // Cost is the cost of downloading. Cost *atomic.Duration // ReportPieceResultStream is the grpc stream of Scheduler_ReportPieceResultServer, // Used only in v1 version of the grpc. ReportPieceResultStream *atomic.Value // AnnouncePeerStream is the grpc stream of Scheduler_AnnouncePeerServer, // Used only in v2 version of the grpc. AnnouncePeerStream *atomic.Value // Peer state machine. FSM *fsm.FSM // Task is peer task. Task *Task // Host is peer host. Host *Host // BlockParents is bad parents ids. BlockParents set.SafeSet[string] // NeedBackToSource needs downloaded from source. // // When peer is registering, at the same time, // scheduler needs to create the new corresponding task and the seed peer is disabled, // NeedBackToSource is set to true. NeedBackToSource *atomic.Bool // PieceUpdatedAt is piece update time. PieceUpdatedAt *atomic.Time // CreatedAt is peer create time. CreatedAt *atomic.Time // UpdatedAt is peer update time. UpdatedAt *atomic.Time // Peer log. Log *logger.SugaredLoggerOnWith // contains filtered or unexported fields }
Peer contains content for peer.
func NewPeer ¶
func NewPeer(id string, task *Task, host *Host, options ...PeerOption) *Peer
New Peer instance.
func (*Peer) AppendPieceCost ¶
AppendPieceCost append piece cost to costs slice.
func (*Peer) CalculatePriority ¶
func (p *Peer) CalculatePriority(dynconfig config.DynconfigInterface) commonv2.Priority
CalculatePriority returns priority of peer.
func (*Peer) DeleteAnnouncePeerStream ¶
func (p *Peer) DeleteAnnouncePeerStream()
DeleteAnnouncePeerStream deletes the grpc stream of Scheduler_AnnouncePeerServer, Used only in v2 version of the grpc.
func (*Peer) DeletePiece ¶
DeletePiece deletes piece for a key.
func (*Peer) DeleteReportPieceResultStream ¶
func (p *Peer) DeleteReportPieceResultStream()
DeleteReportPieceResultStream deletes the grpc stream of Scheduler_ReportPieceResultServer, Used only in v1 version of the grpc.
func (*Peer) DownloadTinyFile
deprecated
func (*Peer) LoadAnnouncePeerStream ¶
func (p *Peer) LoadAnnouncePeerStream() (schedulerv2.Scheduler_AnnouncePeerServer, bool)
LoadAnnouncePeerStream return the grpc stream of Scheduler_AnnouncePeerServer, Used only in v2 version of the grpc.
func (*Peer) LoadReportPieceResultStream ¶
func (p *Peer) LoadReportPieceResultStream() (schedulerv1.Scheduler_ReportPieceResultServer, bool)
LoadReportPieceResultStream return the grpc stream of Scheduler_ReportPieceResultServer, Used only in v1 version of the grpc.
func (*Peer) PieceCosts ¶
PieceCosts return piece costs slice.
func (*Peer) StoreAnnouncePeerStream ¶
func (p *Peer) StoreAnnouncePeerStream(stream schedulerv2.Scheduler_AnnouncePeerServer)
StoreAnnouncePeerStream set the grpc stream of Scheduler_AnnouncePeerServer, Used only in v2 version of the grpc.
func (*Peer) StoreReportPieceResultStream ¶
func (p *Peer) StoreReportPieceResultStream(stream schedulerv1.Scheduler_ReportPieceResultServer)
StoreReportPieceResultStream set the grpc stream of Scheduler_ReportPieceResultServer, Used only in v1 version of the grpc.
type PeerManager ¶
type PeerManager interface { // Load returns peer for a key. Load(string) (*Peer, bool) // Store sets peer. Store(*Peer) // LoadOrStore returns peer the key if present. // Otherwise, it stores and returns the given peer. // The loaded result is true if the peer was loaded, false if stored. LoadOrStore(*Peer) (*Peer, bool) // Delete deletes peer for a key. Delete(string) // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. Range(f func(any, any) bool) // Try to reclaim peer. RunGC() error }
PeerManager is the interface used for peer manager.
type PeerOption ¶
type PeerOption func(peer *Peer)
PeerOption is a functional option for peer.
func WithAnnouncePeerStream ¶
func WithAnnouncePeerStream(stream schedulerv2.Scheduler_AnnouncePeerServer) PeerOption
WithAnnouncePeerStream set AnnouncePeerStream for peer.
func WithPriority ¶
func WithPriority(priority commonv2.Priority) PeerOption
WithPriority set Priority for peer.
type Piece ¶
type Piece struct { // Piece number. Number int32 // Parent peer id. ParentID string // Piece offset. Offset uint64 // Piece length. Length uint64 // Digest of the piece data. Digest *digest.Digest // Traffic type. TrafficType commonv2.TrafficType // Downloading piece costs time. Cost time.Duration // Piece create time. CreatedAt time.Time }
Piece represents information of piece.
type Resource ¶
type Resource interface { // SeedPeer interface. SeedPeer() SeedPeer // Host manager interface. HostManager() HostManager // Peer manager interface. PeerManager() PeerManager // Task manager interface. TaskManager() TaskManager // Stop resource service. Stop() error }
Resource is the interface used for resource.
func New ¶
func New(cfg *config.Config, gc gc.GC, dynconfig config.DynconfigInterface, transportCredentials credentials.TransportCredentials) (Resource, error)
New returns Resource interface.
type SeedPeer ¶
type SeedPeer interface { // TriggerDownloadTask triggers the seed peer to download task. // Used only in v2 version of the grpc. TriggerDownloadTask(context.Context, string, *dfdaemonv2.DownloadTaskRequest) error // TriggerTask triggers the seed peer to download task. // Used only in v1 version of the grpc. TriggerTask(context.Context, *http.Range, *Task) (*Peer, *schedulerv1.PeerResult, error) // Client returns grpc client of seed peer. Client() SeedPeerClient // Stop seed peer service. Stop() error }
SeedPeer is the interface used for seed peer.
type SeedPeerClient ¶
type SeedPeerClient interface { // Addrs returns the addresses of seed peers. Addrs() []string // Client is cdnsystem grpc client interface. cdnsystemclient.Client // V2 is dfdaemon v2 grpc client interface. dfdaemonclient.V2 // Observer is dynconfig observer interface. config.Observer }
SeedPeerClient is the interface used for client of seed peer.
type Task ¶
type Task struct { // ID is task id. ID string // Type is task type. Type commonv2.TaskType // URL is task download url. URL string // Digest of the task content, for example md5:xxx or sha256:yyy. Digest *digest.Digest // URL tag identifies different task for same url. Tag string // Application identifies different task for same url. Application string // FilteredQueryParams is filtered query params. FilteredQueryParams []string // Task request headers. Header map[string]string // Task piece length. PieceLength int32 // DirectPiece is tiny piece data. DirectPiece []byte // ContentLength is task total content length. ContentLength *atomic.Int64 // TotalPieceCount is total piece count. TotalPieceCount *atomic.Int32 // BackToSourceLimit is back-to-source limit. BackToSourceLimit *atomic.Int32 // BackToSourcePeers is back-to-source sync map. BackToSourcePeers set.SafeSet[string] // Task state machine. FSM *fsm.FSM // Piece sync map. Pieces *sync.Map // DAG is directed acyclic graph of peers. DAG dag.DAG[*Peer] // PeerFailedCount is peer failed count, // if one peer succeeds, the value is reset to zero. PeerFailedCount *atomic.Int32 // CreatedAt is task create time. CreatedAt *atomic.Time // UpdatedAt is task update time. UpdatedAt *atomic.Time // Task log. Log *logger.SugaredLoggerOnWith }
Task contains content for task.
func NewTask ¶
func NewTask(id, url, tag, application string, typ commonv2.TaskType, filteredQueryParams []string, header map[string]string, backToSourceLimit int32, options ...TaskOption) *Task
New task instance.
func (*Task) AddPeerEdge ¶
AddPeerEdge adds inedges between two peers.
func (*Task) CanAddPeerEdge ¶
CanAddPeerEdge finds whether there are peer circles through depth-first search.
func (*Task) CanBackToSource ¶
CanBackToSource represents whether task can back-to-source.
func (*Task) CanReuseDirectPiece ¶
CanReuseDirectPiece represents whether task can reuse data of direct piece.
func (*Task) DeletePeerInEdges ¶
DeletePeerInEdges deletes inedges of peer.
func (*Task) DeletePeerOutEdges ¶
DeletePeerOutEdges deletes outedges of peer.
func (*Task) DeletePiece ¶
DeletePiece deletes piece for a key.
func (*Task) HasAvailablePeer ¶
HasAvailablePeer returns whether there is an available peer.
func (*Task) IsSeedPeerFailed ¶
IsSeedPeerFailed returns whether the seed peer in the task failed.
func (*Task) LoadFinishedPeers ¶
LoadFinishedPeers return finished peers.
func (*Task) LoadRandomPeers ¶
LoadRandomPeers return random peers.
func (*Task) LoadSeedPeer ¶
LoadSeedPeer return latest seed peer in peers sync map.
func (*Task) PeerDegree ¶
PeerDegree returns the degree of peer.
func (*Task) PeerInDegree ¶
PeerInDegree returns the indegree of peer.
func (*Task) PeerOutDegree ¶
PeerOutDegree returns the outdegree of peer.
func (*Task) ReportPieceResultToPeers ¶
func (t *Task) ReportPieceResultToPeers(peerPacket *schedulerv1.PeerPacket, event string)
ReportPieceResultToPeers reports all peers in the task with the state code. Used only in v1 version of the grpc.
type TaskManager ¶
type TaskManager interface { // Load returns task for a key. Load(string) (*Task, bool) // Store sets task. Store(*Task) // LoadOrStore returns task the key if present. // Otherwise, it stores and returns the given task. // The loaded result is true if the task was loaded, false if stored. LoadOrStore(*Task) (*Task, bool) // Delete deletes task for a key. Delete(string) // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. Range(f func(any, any) bool) // Try to reclaim task. RunGC() error }
TaskManager is the interface used for task manager.
type TaskOption ¶
type TaskOption func(task *Task)
TaskOption is a functional option for task.
func WithPieceLength ¶
func WithPieceLength(pieceLength int32) TaskOption
WithPieceLength set PieceLength for task.