Documentation ¶
Index ¶
- Variables
- type AssetForceState
- type AssetHash
- type AssetPullingInfo
- type AssetRePull
- type AssetState
- type Datastore
- func (d *Datastore) Batch(ctx context.Context) (datastore.Batch, error)
- func (d *Datastore) Close() error
- func (d *Datastore) Delete(ctx context.Context, key datastore.Key) error
- func (d *Datastore) Get(ctx context.Context, key datastore.Key) (value []byte, err error)
- func (d *Datastore) GetSize(ctx context.Context, key datastore.Key) (size int, err error)
- func (d *Datastore) Has(ctx context.Context, key datastore.Key) (exists bool, err error)
- func (d *Datastore) Put(ctx context.Context, key datastore.Key, value []byte) error
- func (d *Datastore) Query(ctx context.Context, q query.Query) (query.Results, error)
- func (d *Datastore) Sync(ctx context.Context, prefix datastore.Key) error
- type Ignorable
- type InfoUpdate
- type Manager
- func (m *Manager) CreateAssetPullTask(info *types.PullAssetReq, userID string) error
- func (m *Manager) CreateAssetUploadTask(hash string, req *types.CreateAssetReq) (*types.CreateAssetRsp, error)
- func (m *Manager) GenerateToken(assetCID string, sources []*types.CandidateDownloadInfo, ...) (map[string][]*types.CandidateDownloadInfo, []*types.TokenPayload, error)
- func (m *Manager) GetAssetCount() (int, error)
- func (m *Manager) GetAssetRecordInfo(cid string) (*types.AssetRecord, error)
- func (m *Manager) GetCandidateReplicaCount() int
- func (m *Manager) ListAssets() ([]AssetPullingInfo, error)
- func (m *Manager) Plan(events []statemachine.Event, user interface{}) (interface{}, uint64, error)
- func (m *Manager) RandomAsset(nodeID string, seed int64) (*cid.Cid, error)
- func (m *Manager) RemoveAsset(hash string) error
- func (m *Manager) RemoveReplica(cid, hash, nodeID string) error
- func (m *Manager) RestartPullAssets(hashes []types.AssetHash) error
- func (m *Manager) SaveTokenPayload(payloads []*types.TokenPayload) error
- func (m *Manager) Start(ctx context.Context)
- func (m *Manager) Terminate(ctx context.Context) error
- func (m *Manager) UpdateAssetExpiration(cid string, t time.Time) error
- type NodePulledResult
- type PullAssetFatalError
- type PullAssetRestart
- type PullFailed
- type PullRequestSent
- type PullSucceed
- type PulledResult
- type SelectFailed
- type SkipStep
Constants ¶
This section is empty.
Variables ¶
var ( // FailedStates contains a list of asset pull states that represent failures. FailedStates = []string{ SeedFailed.String(), CandidatesFailed.String(), EdgesFailed.String(), UploadFailed.String(), } // PullingStates contains a list of asset pull states that represent pulling. PullingStates = []string{ SeedSelect.String(), SeedPulling.String(), UploadInit.String(), SeedUploading.String(), CandidatesSelect.String(), CandidatesPulling.String(), EdgesSelect.String(), EdgesPulling.String(), } // ActiveStates contains a list of asset pull states that represent active. ActiveStates = append(append([]string{Servicing.String()}, FailedStates...), PullingStates...) )
var ( // MinRetryTime defines the minimum time duration between retries MinRetryTime = 1 * time.Minute // MaxRetryCount defines the maximum number of retries allowed MaxRetryCount = 3 )
Functions ¶
This section is empty.
Types ¶
type AssetForceState ¶
type AssetForceState struct { State AssetState Requester string Details string SeedNodeID string }
AssetForceState forces an asset state
type AssetPullingInfo ¶
type AssetPullingInfo struct { State AssetState Hash AssetHash CID string Size int64 Blocks int64 EdgeReplicas int64 CandidateReplicas int64 Bandwidth int64 EdgeReplicaSucceeds []string CandidateReplicaSucceeds []string EdgeWaitings int64 CandidateWaitings int64 RetryCount int64 ReplenishReplicas int64 Requester string Details string SeedNodeID string }
AssetPullingInfo represents asset pull information
func (*AssetPullingInfo) MarshalCBOR ¶
func (t *AssetPullingInfo) MarshalCBOR(w io.Writer) error
func (*AssetPullingInfo) ToAssetRecord ¶
func (state *AssetPullingInfo) ToAssetRecord() *types.AssetRecord
ToAssetRecord converts AssetPullingInfo to types.AssetRecord
func (*AssetPullingInfo) UnmarshalCBOR ¶
func (t *AssetPullingInfo) UnmarshalCBOR(r io.Reader) (err error)
type AssetRePull ¶
type AssetRePull struct{}
AssetRePull re-pull the asset
func (AssetRePull) Ignore ¶ added in v0.1.10
func (evt AssetRePull) Ignore()
type AssetState ¶
type AssetState string
AssetState represents the state of an asset in the process of being pulled.
const ( // SeedSelect select first candidate to pull seed asset SeedSelect AssetState = "SeedSelect" // SeedPulling Waiting for candidate nodes to pull seed asset SeedPulling AssetState = "SeedPulling" // UploadInit Initialize user upload preparation UploadInit AssetState = "UploadInit" // SeedUploading Waiting for user to upload asset to candidate node SeedUploading AssetState = "SeedUploading" // CandidatesSelect select candidates to pull asset CandidatesSelect AssetState = "CandidatesSelect" // CandidatesPulling candidate nodes pulling asset CandidatesPulling AssetState = "CandidatesPulling" // EdgesSelect select edges to pull asset EdgesSelect AssetState = "EdgesSelect" // EdgesPulling edge nodes pulling asset EdgesPulling AssetState = "EdgesPulling" // Servicing Asset cache completed and in service Servicing AssetState = "Servicing" // SeedFailed Unable to select candidate nodes or failed to pull seed asset SeedFailed AssetState = "SeedFailed" // CandidatesFailed Unable to select candidate nodes or failed to pull asset CandidatesFailed AssetState = "CandidatesFailed" // EdgesFailed Unable to select edge nodes or failed to pull asset EdgesFailed AssetState = "EdgesFailed" // UploadFailed User failed to upload assets UploadFailed AssetState = "UploadFailed" // Remove remove Remove AssetState = "Remove" )
Constants defining various states of the asset pulling process.
func (AssetState) String ¶
func (s AssetState) String() string
String returns the string representation of the AssetState.
type Datastore ¶
Datastore represents the asset datastore
func NewDatastore ¶
NewDatastore creates a new AssetDatastore
type InfoUpdate ¶
InfoUpdate update asset info
func (InfoUpdate) Ignore ¶ added in v0.1.10
func (evt InfoUpdate) Ignore()
type Manager ¶
Manager manages asset replicas
func NewManager ¶
func NewManager(nodeManager *node.Manager, ds datastore.Batching, configFunc dtypes.GetSchedulerConfigFunc, sdb *db.SQLDB) *Manager
NewManager returns a new AssetManager instance
func (*Manager) CreateAssetPullTask ¶
func (m *Manager) CreateAssetPullTask(info *types.PullAssetReq, userID string) error
CreateAssetPullTask create a new asset pull task
func (*Manager) CreateAssetUploadTask ¶ added in v0.1.10
func (m *Manager) CreateAssetUploadTask(hash string, req *types.CreateAssetReq) (*types.CreateAssetRsp, error)
CreateAssetUploadTask create a new asset upload task
func (*Manager) GenerateToken ¶ added in v0.1.10
func (m *Manager) GenerateToken(assetCID string, sources []*types.CandidateDownloadInfo, nodes map[string]*node.Node) (map[string][]*types.CandidateDownloadInfo, []*types.TokenPayload, error)
func (*Manager) GetAssetCount ¶ added in v0.1.10
func (*Manager) GetAssetRecordInfo ¶
func (m *Manager) GetAssetRecordInfo(cid string) (*types.AssetRecord, error)
GetAssetRecordInfo get the asset record info for cid
func (*Manager) GetCandidateReplicaCount ¶
GetCandidateReplicaCount get the candidate replica count from the configuration
func (*Manager) ListAssets ¶
func (m *Manager) ListAssets() ([]AssetPullingInfo, error)
ListAssets load asset pull infos from state machine
func (*Manager) RandomAsset ¶
RandomAsset get node asset with random seed
func (*Manager) RemoveAsset ¶
RemoveAsset removes an asset
func (*Manager) RemoveReplica ¶
RemoveReplica remove a replica for node
func (*Manager) RestartPullAssets ¶
RestartPullAssets restarts asset pulls
func (*Manager) SaveTokenPayload ¶ added in v0.1.10
func (m *Manager) SaveTokenPayload(payloads []*types.TokenPayload) error
type NodePulledResult ¶
NodePulledResult represents a result of a node pulling assets
func (*NodePulledResult) MarshalCBOR ¶
func (t *NodePulledResult) MarshalCBOR(w io.Writer) error
func (*NodePulledResult) UnmarshalCBOR ¶
func (t *NodePulledResult) UnmarshalCBOR(r io.Reader) (err error)
type PullAssetFatalError ¶
type PullAssetFatalError struct {
// contains filtered or unexported fields
}
PullAssetFatalError represents a fatal error in asset pulling
func (PullAssetFatalError) FormatError ¶
func (evt PullAssetFatalError) FormatError(xerrors.Printer) (next error)
FormatError Format error
type PullFailed ¶
type PullFailed struct {
// contains filtered or unexported fields
}
PullFailed indicates that a node has failed to pull an asset
func (PullFailed) FormatError ¶
func (evt PullFailed) FormatError(xerrors.Printer) (next error)
FormatError Format error
func (PullFailed) Ignore ¶ added in v0.1.10
func (evt PullFailed) Ignore()
type PullRequestSent ¶
type PullRequestSent struct{}
PullRequestSent indicates that a pull request has been sent
type PullSucceed ¶
type PullSucceed struct{}
PullSucceed indicates that a node has successfully pulled an asset
func (PullSucceed) Ignore ¶ added in v0.1.10
func (evt PullSucceed) Ignore()
type PulledResult ¶
PulledResult represents the result of node pulling
func (PulledResult) Ignore ¶ added in v0.1.10
func (evt PulledResult) Ignore()
type SelectFailed ¶
type SelectFailed struct {
// contains filtered or unexported fields
}
SelectFailed indicates that node selection has failed
func (SelectFailed) FormatError ¶
func (evt SelectFailed) FormatError(xerrors.Printer) (next error)
FormatError Format error