Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
feature: implement an empty scheduler and update the interface
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <starnop@163.com>
  • Loading branch information
starnop committed Apr 17, 2019
1 parent 4823ed0 commit 580bf38
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
26 changes: 26 additions & 0 deletions supernode/daemon/mgr/scheduler/manager.go
@@ -0,0 +1,26 @@
package scheduler

import (
"context"

"github.com/dragonflyoss/Dragonfly/supernode/daemon/mgr"
)

var _ mgr.SchedulerMgr = &Manager{}

// Manager is an implement of the interface of SchedulerMgr.
type Manager struct {
progressMgr mgr.ProgressMgr
}

// NewManager returns a new Manager.
func NewManager(progressMgr mgr.ProgressMgr) *Manager {
return &Manager{
progressMgr: progressMgr,
}
}

// Schedule gets scheduler result with specified taskID, clientID and peerID through some rules.
func (sm *Manager) Schedule(ctx context.Context, taskID, clientID, peerID string) ([]*mgr.PieceResult, error) {
return nil, nil
}
14 changes: 10 additions & 4 deletions supernode/daemon/mgr/scheduler_mgr.go
Expand Up @@ -2,12 +2,18 @@ package mgr

import (
"context"

"github.com/dragonflyoss/Dragonfly/apis/types"
)

// PieceResult contains the information about which piece to download from which node.
type PieceResult struct {
TaskID string
PieceNum int
PieceSize int32
DstPID string
}

// SchedulerMgr is responsible for calculating scheduling results according to certain rules.
type SchedulerMgr interface {
// Schedule get scheduler result with specified taskID, clientID through some rules.
Schedule(ctx context.Context, taskID, clientID string) ([]*types.PieceInfo, error)
// Schedule gets scheduler result with specified taskID, clientID and peerID through some rules.
Schedule(ctx context.Context, taskID, clientID, peerID string) ([]*PieceResult, error)
}

0 comments on commit 580bf38

Please sign in to comment.