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

Commit

Permalink
add more comments of supernode implements
Browse files Browse the repository at this point in the history
adjust format

Signed-off-by: henry.hj <[email protected]>
  • Loading branch information
henry.hj committed Apr 28, 2020
1 parent 86d0561 commit 9bc80a4
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 179 deletions.
8 changes: 4 additions & 4 deletions cmd/supernode/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func setupFlags(cmd *cobra.Command) {
"download limit for supernode to serve download tasks")

flagSet.Int64("peer-expire-time", defaultBaseProperties.PeerExpireTime,
"peer expire time is the time that a rt task peer node is treated expired " +
"if the peer doesn't send heartbeat or registry tasks anymore")
"peer expire time is the time that a rt task peer node is treated expired "+
"if the peer doesn't send heartbeat or registry tasks anymore")

flagSet.Int("max-seed-per-object", defaultBaseProperties.MaxSeedPerObject,
"max number of seed nodes per one object ")
Expand Down Expand Up @@ -285,11 +285,11 @@ func bindRootFlags(v *viper.Viper) error {
flag: "peer-gc-delay",
},
{
key: "base.maxSeedPerObject",
key: "base.maxSeedPerObject",
flag: "max-seed-per-object",
},
{
key: "peerExpireTime",
key: "peerExpireTime",
flag: "peer-expire-time",
},
}
Expand Down
2 changes: 1 addition & 1 deletion supernode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ type BaseProperties struct {

// max number of seed node of one object
// default: 64
MaxSeedPerObject int `yaml:"maxSeedPerObject"`
MaxSeedPerObject int `yaml:"maxSeedPerObject"`

// CleanRatio is the ratio to clean the disk and it is based on 10.
// It means the value of CleanRatio should be [1-10].
Expand Down
11 changes: 6 additions & 5 deletions supernode/daemon/mgr/gc/gc_seed_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package gc

import (
"context"

"github.com/sirupsen/logrus"
)

func (gcm *Manager) gcSeedTaskPeers(ctx context.Context) {
peerIds := gcm.seedTaskMgr.ScanDownPeers(ctx)
logrus.Infof("gc peers %v", peerIds)
for _, peerId := range peerIds {
gcm.seedTaskMgr.DeRegisterPeer(ctx, peerId)
peerIDs := gcm.seedTaskMgr.ScanDownPeers(ctx)
logrus.Infof("gc peers %v", peerIDs)
for _, peerID := range peerIDs {
gcm.seedTaskMgr.DeRegisterPeer(ctx, peerID)
}
}
}
22 changes: 11 additions & 11 deletions supernode/daemon/mgr/seed_task_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ package mgr

import (
"context"
"github.com/dragonflyoss/Dragonfly/apis/types"
"github.com/dragonflyoss/Dragonfly/supernode/daemon/mgr/seed_task"
"net/http"

"github.com/dragonflyoss/Dragonfly/apis/types"
"github.com/dragonflyoss/Dragonfly/supernode/daemon/mgr/seedtask"
)

type SeedTaskMgr interface {
Register(ctx context.Context, request *types.TaskRegisterRequest) (*seedtask.TaskRegistryResponce, error)

Register(ctx context.Context, request *types.TaskRegisterRequest) (*seed_task.TaskRegistryResponce, error)

GetTasksInfo(ctx context.Context, taskId string) ([]*seed_task.SeedTaskInfo, error)
GetTasksInfo(ctx context.Context, taskID string) ([]*seedtask.SeedInfo, error)

DeRegisterTask(ctx context.Context, peerId, taskId string) error
DeRegisterTask(ctx context.Context, peerID, taskID string) error

DeRegisterPeer(ctx context.Context, peerId string) error
DeRegisterPeer(ctx context.Context, peerID string) error

EvictTask(ctx context.Context, taskId string) error
EvictTask(ctx context.Context, taskID string) error

HasTasks(ctx context.Context, taskId string) bool
HasTasks(ctx context.Context, taskID string) bool

ReportPeerHealth(ctx context.Context, peerId string) (*types.HeartBeatResponse, error)
ReportPeerHealth(ctx context.Context, peerID string) (*types.HeartBeatResponse, error)

ScanDownPeers(ctx context.Context) []string

IsSeedTask(ctx context.Context, request *http.Request) bool
}
}
Loading

0 comments on commit 9bc80a4

Please sign in to comment.