persistentcache

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Index

Constants

View Source
const (
	// Peer has been created but did not start running.
	PeerStatePending = "Pending"

	// Peer is uploading resources for p2p cluster.
	PeerStateUploading = "Uploading"

	// Peer successfully registered and perpared to download.
	PeerStateReceived = "Received"

	// Peer is downloading resources from peer.
	PeerStateRunning = "Running"

	// Peer has been downloaded successfully.
	PeerStateSucceeded = "Succeeded"

	// Peer has been downloaded failed.
	PeerStateFailed = "Failed"
)
View Source
const (
	// Peer is uploding.
	PeerEventUpload = "Uploda"

	// Peer is registered and perpared to download.
	PeerEventRegister = "Register"

	// Peer is downloading.
	PeerEventDownload = "Download"

	// Peer downloaded or uploaded successfully.
	PeerEventSucceeded = "Succeeded"

	// Peer downloaded or uploaded failed.
	PeerEventFailed = "Failed"
)
View Source
const (
	// Task has been created but did not start uploading.
	TaskStatePending = "Pending"

	// Task is uploading resources for p2p cluster.
	TaskStateUploading = "Uploading"

	// Task has been uploaded successfully.
	TaskStateSucceeded = "Succeeded"

	// Task has been uploaded failed.
	TaskStateFailed = "Failed"
)
View Source
const (
	// Task is uploading.
	TaskEventUpload = "Upload"

	// Task uploaded successfully.
	TaskEventSucceeded = "Succeeded"

	// Task uploaded failed.
	TaskEventFailed = "Failed"
)
View Source
const (
	// GC persistent cache host id.
	GCHostID = "persistent-cache-host"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	// Git version.
	GitVersion string

	// Git commit.
	GitCommit string

	// Golang version.
	GoVersion string

	// Rust version.
	RustVersion 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

	// DisableShared is whether the host is disabled for
	// 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

	// AnnounceInterval is the interval between host announces to scheduler.
	AnnounceInterval time.Duration

	// ConcurrentUploadLimit is concurrent upload limit count.
	ConcurrentUploadLimit int32

	// ConcurrentUploadCount is concurrent upload count.
	ConcurrentUploadCount int32

	// UploadCount is total upload count.
	UploadCount int64

	// UploadFailedCount is upload failed count.
	UploadFailedCount int64

	// CreatedAt is host create time.
	CreatedAt time.Time

	// UpdatedAt is host update time.
	UpdatedAt time.Time

	// Host log.
	Log *logger.SugaredLoggerOnWith
}

Host contains content for host.

func NewHost

func NewHost(
	id, hostname, ip, os, platform, platformFamily, platformVersion, kernelVersion string, port, downloadPort, concurrentUploadCount int32,
	UploadCount, UploadFailedCount int64, disableShared bool, typ types.HostType, cpu CPU, memory Memory, network Network, disk Disk,
	build Build, announceInterval time.Duration, createdAt, updatedAt time.Time, log *logger.SugaredLoggerOnWith, options ...HostOption,
) *Host

New host instance.

type HostManager

type HostManager interface {
	// Load returns host by a key.
	Load(context.Context, string) (*Host, bool)

	// Store sets host.
	Store(context.Context, *Host) error

	// Delete deletes host by a key.
	Delete(context.Context, string) error

	// LoadAll returns all hosts.
	LoadAll(context.Context) ([]*Host, error)

	// RunGC runs garbage collection.
	RunGC() error
}

HostManager is the interface used for host manager.

type HostOption added in v2.1.64

type HostOption func(h *Host)

HostOption is a functional option for configuring the persistent cache host.

func WithConcurrentUploadLimit added in v2.1.64

func WithConcurrentUploadLimit(limit int32) HostOption

WithConcurrentUploadLimit sets persistent cache host's ConcurrentUploadLimit.

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 context.Context, arg1 string) error

Delete mocks base method.

func (*MockHostManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockHostManager) Load

func (m *MockHostManager) Load(arg0 context.Context, arg1 string) (*Host, bool)

Load mocks base method.

func (*MockHostManager) LoadAll

func (m *MockHostManager) LoadAll(arg0 context.Context) ([]*Host, error)

LoadAll mocks base method.

func (*MockHostManager) RunGC added in v2.1.64

func (m *MockHostManager) RunGC() error

RunGC mocks base method.

func (*MockHostManager) Store

func (m *MockHostManager) Store(arg0 context.Context, arg1 *Host) error

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, arg1 any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockHostManagerMockRecorder) Load

func (mr *MockHostManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call

Load indicates an expected call of Load.

func (*MockHostManagerMockRecorder) LoadAll

func (mr *MockHostManagerMockRecorder) LoadAll(arg0 any) *gomock.Call

LoadAll indicates an expected call of LoadAll.

func (*MockHostManagerMockRecorder) RunGC added in v2.1.64

RunGC indicates an expected call of RunGC.

func (*MockHostManagerMockRecorder) Store

func (mr *MockHostManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

type MockPeerManager added in v2.1.62

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

MockPeerManager is a mock of PeerManager interface.

func NewMockPeerManager added in v2.1.62

func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager

NewMockPeerManager creates a new mock instance.

func (*MockPeerManager) Delete added in v2.1.62

func (m *MockPeerManager) Delete(arg0 context.Context, arg1 string) error

Delete mocks base method.

func (*MockPeerManager) DeleteAllByHostID added in v2.1.64

func (m *MockPeerManager) DeleteAllByHostID(arg0 context.Context, arg1 string) error

DeleteAllByHostID mocks base method.

func (*MockPeerManager) DeleteAllByTaskID added in v2.1.63

func (m *MockPeerManager) DeleteAllByTaskID(arg0 context.Context, arg1 string) error

DeleteAllByTaskID mocks base method.

func (*MockPeerManager) EXPECT added in v2.1.62

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPeerManager) Load added in v2.1.62

func (m *MockPeerManager) Load(arg0 context.Context, arg1 string) (*Peer, bool)

Load mocks base method.

func (*MockPeerManager) LoadAll added in v2.1.62

func (m *MockPeerManager) LoadAll(arg0 context.Context) ([]*Peer, error)

LoadAll mocks base method.

func (*MockPeerManager) LoadAllByHostID added in v2.1.64

func (m *MockPeerManager) LoadAllByHostID(arg0 context.Context, arg1 string) ([]*Peer, error)

LoadAllByHostID mocks base method.

func (*MockPeerManager) LoadAllByTaskID added in v2.1.63

func (m *MockPeerManager) LoadAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)

LoadAllByTaskID mocks base method.

func (*MockPeerManager) Store added in v2.1.62

func (m *MockPeerManager) Store(arg0 context.Context, arg1 *Peer) error

Store mocks base method.

type MockPeerManagerMockRecorder added in v2.1.62

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

MockPeerManagerMockRecorder is the mock recorder for MockPeerManager.

func (*MockPeerManagerMockRecorder) Delete added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockPeerManagerMockRecorder) DeleteAllByHostID added in v2.1.64

func (mr *MockPeerManagerMockRecorder) DeleteAllByHostID(arg0, arg1 any) *gomock.Call

DeleteAllByHostID indicates an expected call of DeleteAllByHostID.

func (*MockPeerManagerMockRecorder) DeleteAllByTaskID added in v2.1.63

func (mr *MockPeerManagerMockRecorder) DeleteAllByTaskID(arg0, arg1 any) *gomock.Call

DeleteAllByTaskID indicates an expected call of DeleteAllByTaskID.

func (*MockPeerManagerMockRecorder) Load added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call

Load indicates an expected call of Load.

func (*MockPeerManagerMockRecorder) LoadAll added in v2.1.62

func (mr *MockPeerManagerMockRecorder) LoadAll(arg0 any) *gomock.Call

LoadAll indicates an expected call of LoadAll.

func (*MockPeerManagerMockRecorder) LoadAllByHostID added in v2.1.64

func (mr *MockPeerManagerMockRecorder) LoadAllByHostID(arg0, arg1 any) *gomock.Call

LoadAllByHostID indicates an expected call of LoadAllByHostID.

func (*MockPeerManagerMockRecorder) LoadAllByTaskID added in v2.1.63

func (mr *MockPeerManagerMockRecorder) LoadAllByTaskID(arg0, arg1 any) *gomock.Call

LoadAllByTaskID indicates an expected call of LoadAllByTaskID.

func (*MockPeerManagerMockRecorder) Store added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

type MockResource added in v2.1.62

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

MockResource is a mock of Resource interface.

func NewMockResource added in v2.1.62

func NewMockResource(ctrl *gomock.Controller) *MockResource

NewMockResource creates a new mock instance.

func (*MockResource) EXPECT added in v2.1.62

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResource) HostManager added in v2.1.62

func (m *MockResource) HostManager() HostManager

HostManager mocks base method.

func (*MockResource) PeerManager added in v2.1.62

func (m *MockResource) PeerManager() PeerManager

PeerManager mocks base method.

func (*MockResource) TaskManager added in v2.1.62

func (m *MockResource) TaskManager() TaskManager

TaskManager mocks base method.

type MockResourceMockRecorder added in v2.1.62

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

MockResourceMockRecorder is the mock recorder for MockResource.

func (*MockResourceMockRecorder) HostManager added in v2.1.62

func (mr *MockResourceMockRecorder) HostManager() *gomock.Call

HostManager indicates an expected call of HostManager.

func (*MockResourceMockRecorder) PeerManager added in v2.1.62

func (mr *MockResourceMockRecorder) PeerManager() *gomock.Call

PeerManager indicates an expected call of PeerManager.

func (*MockResourceMockRecorder) TaskManager added in v2.1.62

func (mr *MockResourceMockRecorder) TaskManager() *gomock.Call

TaskManager indicates an expected call of TaskManager.

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 context.Context, arg1 string) error

Delete mocks base method.

func (*MockTaskManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTaskManager) Load

func (m *MockTaskManager) Load(arg0 context.Context, arg1 string) (*Task, bool)

Load mocks base method.

func (*MockTaskManager) LoadAll

func (m *MockTaskManager) LoadAll(arg0 context.Context) ([]*Task, error)

LoadAll mocks base method.

func (*MockTaskManager) LoadCorrentReplicaCount added in v2.1.64

func (m *MockTaskManager) LoadCorrentReplicaCount(arg0 context.Context, arg1 string) (int64, error)

LoadCorrentReplicaCount mocks base method.

func (*MockTaskManager) LoadCurrentPersistentReplicaCount added in v2.1.64

func (m *MockTaskManager) LoadCurrentPersistentReplicaCount(arg0 context.Context, arg1 string) (int64, error)

LoadCurrentPersistentReplicaCount mocks base method.

func (*MockTaskManager) Store

func (m *MockTaskManager) Store(arg0 context.Context, arg1 *Task) error

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, arg1 any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockTaskManagerMockRecorder) Load

func (mr *MockTaskManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call

Load indicates an expected call of Load.

func (*MockTaskManagerMockRecorder) LoadAll

func (mr *MockTaskManagerMockRecorder) LoadAll(arg0 any) *gomock.Call

LoadAll indicates an expected call of LoadAll.

func (*MockTaskManagerMockRecorder) LoadCorrentReplicaCount added in v2.1.64

func (mr *MockTaskManagerMockRecorder) LoadCorrentReplicaCount(arg0, arg1 any) *gomock.Call

LoadCorrentReplicaCount indicates an expected call of LoadCorrentReplicaCount.

func (*MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount added in v2.1.64

func (mr *MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount(arg0, arg1 any) *gomock.Call

LoadCurrentPersistentReplicaCount indicates an expected call of LoadCurrentPersistentReplicaCount.

func (*MockTaskManagerMockRecorder) Store

func (mr *MockTaskManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

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 added in v2.1.61

type Peer struct {
	// ID is persistent cache peer id.
	ID string

	// Persistent is whether the peer is persistent.
	Persistent bool

	// Pieces is finished pieces bitset.
	FinishedPieces *bitset.BitSet

	// Persistent cache peer state machine.
	FSM *fsm.FSM

	// Task is persistent cache task.
	Task *Task

	// Host is the peer host.
	Host *Host

	// BlockParents is bad parents ids.
	BlockParents []string

	// Cost is the cost of downloading.
	Cost time.Duration

	// CreatedAt is persistent cache peer create time.
	CreatedAt time.Time

	// UpdatedAt is persistent cache peer update time.
	UpdatedAt time.Time

	// Persistent cache peer log.
	Log *logger.SugaredLoggerOnWith
}

Peer contains content for persistent cache peer.

func NewPeer added in v2.1.61

func NewPeer(id, state string, persistent bool, finishedPieces *bitset.BitSet, blockParents []string, task *Task, host *Host,
	cost time.Duration, createdAt, updatedAt time.Time, log *logger.SugaredLoggerOnWith) *Peer

New persistent cache peer instance.

type PeerManager added in v2.1.62

type PeerManager interface {
	// Load returns peer by a key.
	Load(context.Context, string) (*Peer, bool)

	// Store sets peer.
	Store(context.Context, *Peer) error

	// Delete deletes peer by a key.
	Delete(context.Context, string) error

	// LoadAll returns all peers.
	LoadAll(context.Context) ([]*Peer, error)

	// LoadAllByTaskID returns all peers by task id.
	LoadAllByTaskID(context.Context, string) ([]*Peer, error)

	// DeleteAllByTaskID deletes all peers by task id.
	DeleteAllByTaskID(context.Context, string) error

	// LoadAllByHostID returns all peers by host id.
	LoadAllByHostID(context.Context, string) ([]*Peer, error)

	// DeleteAllByHostID deletes all peers by host id.
	DeleteAllByHostID(context.Context, string) error
}

PeerManager is the interface used for peer manager.

type Resource added in v2.1.62

type Resource interface {
	// Host manager interface.
	HostManager() HostManager

	// Peer manager interface.
	PeerManager() PeerManager

	// Task manager interface.
	TaskManager() TaskManager
}

Resource is the interface used for resource.

func New added in v2.1.62

func New(cfg *config.Config, gc gc.GC, rdb redis.UniversalClient, transportCredentials credentials.TransportCredentials) (Resource, error)

New returns Resource interface.

type Task

type Task struct {
	// ID is task id.
	ID string

	// Replica count of the persistent cache task. The persistent cache task will
	// not be deleted when dfdamon runs garbage collection. It only be deleted
	// when the task is deleted by the user.
	PersistentReplicaCount uint64

	// Digest of the persistent cache task content, for example md5:xxx or sha256:yyy.
	Digest *digest.Digest

	// Tag is used to distinguish different persistent cache tasks.
	Tag string

	// Application of persistent cache task.
	Application string

	// Persistet cache task piece length.
	PieceLength int32

	// ContentLength is persistent cache task total content length.
	ContentLength int64

	// TotalPieceCount is total piece count.
	TotalPieceCount int32

	// Persistent cache task state machine.
	FSM *fsm.FSM

	// TTL is persistent cache task time to live.
	TTL time.Duration

	// CreatedAt is persistent cache task create time.
	CreatedAt time.Time

	// UpdatedAt is persistent cache task update time.
	UpdatedAt time.Time

	// Persistent cache task log.
	Log *logger.SugaredLoggerOnWith
}

Task contains content for persistent cache task.

func NewTask

func NewTask(id, tag, application, state string, persistentReplicaCount uint64, pieceLength int32,
	contentLength int64, totalPieceCount int32, digest *digest.Digest, ttl time.Duration, createdAt, updatedAt time.Time,
	log *logger.SugaredLoggerOnWith) *Task

New persistent cache task instance.

type TaskManager

type TaskManager interface {
	// Load returns persistent cache task by a key.
	Load(context.Context, string) (*Task, bool)

	// LoadCorrentReplicaCount returns current replica count of the persistent cache task.
	LoadCorrentReplicaCount(context.Context, string) (int64, error)

	// LoadCurrentPersistentReplicaCount returns current persistent replica count of the persistent cache task.
	LoadCurrentPersistentReplicaCount(context.Context, string) (int64, error)

	// Store sets persistent cache task.
	Store(context.Context, *Task) error

	// Delete deletes persistent cache task by a key.
	Delete(context.Context, string) error

	// LoadAll returns all persistent cache tasks.
	LoadAll(context.Context) ([]*Task, error)
}

TaskManager is the interface used for persistent cache task manager.

Jump to

Keyboard shortcuts

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