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

Commit

Permalink
add callsystem when registering
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <yb532204897@gmail.com>
  • Loading branch information
yeya24 committed Jul 25, 2019
1 parent 7eb39ea commit 574eb08
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 64 deletions.
43 changes: 25 additions & 18 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ definitions:
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recognizes.
callSystem:
type: "string"
description: |
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1

PeerCreateRequest:
type: "object"
Expand Down Expand Up @@ -840,9 +847,9 @@ definitions:
callSystem:
type: "string"
description: |
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
some black/white list to guarantee security, or some other purposes.
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1
filter:
type: "array"
Expand Down Expand Up @@ -958,20 +965,7 @@ definitions:
from source server as user's wish.
additionalProperties:
type: "string"
dfdaemon:
type: "boolean"
description: |
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recganises.
callSystem:
type: "string"
description: |
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
some black/white list to guarantee security, or some other purposes.
minLength: 1


TaskUpdateRequest:
type: "object"
description: "request used to update task attributes."
Expand Down Expand Up @@ -1169,7 +1163,20 @@ definitions:
supernodeIP:
type: "string"
description: "IP address of supernode which the peer connects to"

dfdaemon:
type: "boolean"
description: |
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recganises.
callSystem:
type: "string"
description: |
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1

ErrorResponse:
type: "object"
description: |
Expand Down
30 changes: 30 additions & 0 deletions apis/types/df_get_task.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions apis/types/task_create_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions apis/types/task_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions apis/types/task_register_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions supernode/daemon/mgr/dfgettask/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ func init() {
}

type DfgetTaskMgrTestSuite struct {
manager *Manager
}

// SetUpSuite does common setup in the beginning of each test.
func (s *DfgetTaskMgrTestSuite) SetUpSuite(c *check.C) {
s.manager, _ = NewManager()
}

func (s *DfgetTaskMgrTestSuite) TestDfgetTaskMgr(c *check.C) {
dfgetTaskManager, _ := NewManager()
clientID := "foo"
taskID := "00c4e7b174af7ed61c414b36ef82810ac0c98142c03e5748c00e1d1113f3c882"

Expand All @@ -51,11 +56,11 @@ func (s *DfgetTaskMgrTestSuite) TestDfgetTaskMgr(c *check.C) {
PeerID: "foo-192.168.10.11-1553838710990554281",
}

err := dfgetTaskManager.Add(context.Background(), dfgetTask)
err := s.manager.Add(context.Background(), dfgetTask)
c.Check(err, check.IsNil)

// Get
dt, err := dfgetTaskManager.Get(context.Background(), clientID, taskID)
dt, err := s.manager.Get(context.Background(), clientID, taskID)
c.Check(err, check.IsNil)
c.Check(dt, check.DeepEquals, &types.DfGetTask{
CID: clientID,
Expand All @@ -67,10 +72,10 @@ func (s *DfgetTaskMgrTestSuite) TestDfgetTaskMgr(c *check.C) {
})

// UpdateStatus
err = dfgetTaskManager.UpdateStatus(context.Background(), clientID, taskID, types.DfGetTaskStatusSUCCESS)
err = s.manager.UpdateStatus(context.Background(), clientID, taskID, types.DfGetTaskStatusSUCCESS)
c.Check(err, check.IsNil)

dt, err = dfgetTaskManager.Get(context.Background(), clientID, taskID)
dt, err = s.manager.Get(context.Background(), clientID, taskID)
c.Check(err, check.IsNil)
c.Check(dt, check.DeepEquals, &types.DfGetTask{
CID: clientID,
Expand All @@ -82,9 +87,9 @@ func (s *DfgetTaskMgrTestSuite) TestDfgetTaskMgr(c *check.C) {
})

// Delete
err = dfgetTaskManager.Delete(context.Background(), clientID, taskID)
err = s.manager.Delete(context.Background(), clientID, taskID)
c.Check(err, check.IsNil)

_, err = dfgetTaskManager.Get(context.Background(), clientID, taskID)
_, err = s.manager.Get(context.Background(), clientID, taskID)
c.Check(errors.IsDataNotFound(err), check.Equals, true)
}
4 changes: 2 additions & 2 deletions supernode/daemon/mgr/task/manager_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ func (tm *Manager) addOrUpdateTask(ctx context.Context, req *types.TaskCreateReq
var task *types.TaskInfo
newTask := &types.TaskInfo{
ID: taskID,
CallSystem: req.CallSystem,
Dfdaemon: req.Dfdaemon,
Headers: req.Headers,
Identifier: req.Identifier,
Md5: req.Md5,
Expand Down Expand Up @@ -155,6 +153,8 @@ func (tm *Manager) updateTask(taskID string, updateTaskInfo *types.TaskInfo) err
func (tm *Manager) addDfgetTask(ctx context.Context, req *types.TaskCreateRequest, task *types.TaskInfo) (*types.DfGetTask, error) {
dfgetTask := &types.DfGetTask{
CID: req.CID,
CallSystem: req.CallSystem,
Dfdaemon: req.Dfdaemon,
Path: req.Path,
PieceSize: task.PieceSize,
Status: types.DfGetTaskStatusWAITING,
Expand Down
4 changes: 0 additions & 4 deletions supernode/daemon/mgr/task/manager_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ func (s *TaskUtilTestSuite) TestAddOrUpdateTask(c *check.C) {
},
task: &types.TaskInfo{
ID: generateTaskID("http://aa.bb.com", "", ""),
CallSystem: "foo",
CdnStatus: types.TaskInfoCdnStatusWAITING,
Dfdaemon: true,
HTTPFileLength: 1000,
PieceSize: config.DefaultPieceSize,
PieceTotal: 1,
Expand All @@ -103,9 +101,7 @@ func (s *TaskUtilTestSuite) TestAddOrUpdateTask(c *check.C) {
},
task: &types.TaskInfo{
ID: generateTaskID("http://aa.bb.com", "", ""),
CallSystem: "foo",
CdnStatus: types.TaskInfoCdnStatusWAITING,
Dfdaemon: true,
HTTPFileLength: 1000,
PieceSize: config.DefaultPieceSize,
PieceTotal: 1,
Expand Down
1 change: 1 addition & 0 deletions supernode/server/0.3_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (s *Server) registry(ctx context.Context, rw http.ResponseWriter, req *http
peerID := peerCreateResponse.ID
taskCreateRequest := &types.TaskCreateRequest{
CID: request.CID,
CallSystem: request.CallSystem,
Dfdaemon: request.Dfdaemon,
Headers: cutil.ConvertHeaders(request.Headers),
Identifier: request.Identifier,
Expand Down

0 comments on commit 574eb08

Please sign in to comment.