Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scheduler metrics add default value of biz tag #1151

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scheduler/resource/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ import (
"d7y.io/dragonfly/v2/scheduler/config"
)

const (
// Default value of biz tag for cdn peer
cdnBizTag = "d7y/cdn"
)

type CDN interface {
// TriggerTask start to trigger cdn task
TriggerTask(context.Context, *Task) (*Peer, *rpcscheduler.PeerResult, error)
Expand Down Expand Up @@ -146,7 +151,7 @@ func (c *cdn) initPeer(task *Task, ps *cdnsystem.PieceSeed) (*Peer, error) {
}

// New cdn peer
peer = NewPeer(ps.PeerId, task, host)
peer = NewPeer(ps.PeerId, task, host, WithBizTag(cdnBizTag))
peer.Log.Info("new cdn peer successfully")

// Store cdn peer
Expand Down
4 changes: 4 additions & 0 deletions scheduler/resource/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import (
const (
// Download tiny file timeout
downloadTinyFileContextTimeout = 2 * time.Minute

// Default value of biz tag
defaultBizTag = "unknow"
)

const (
Expand Down Expand Up @@ -156,6 +159,7 @@ type Peer struct {
func NewPeer(id string, task *Task, host *Host, options ...PeerOption) *Peer {
p := &Peer{
ID: id,
BizTag: defaultBizTag,
Pieces: &bitset.BitSet{},
pieceCosts: []int64{},
Stream: &atomic.Value{},
Expand Down