Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 574eb08

Browse files
committed
add callsystem when registering
Signed-off-by: yeya24 <[email protected]>
1 parent 7eb39ea commit 574eb08

File tree

9 files changed

+97
-64
lines changed

9 files changed

+97
-64
lines changed

apis/swagger.yml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,13 @@ definitions:
702702
tells whether it is a call from dfdaemon. dfdaemon is a long running
703703
process which works for container engines. It translates the image
704704
pulling request into raw requests into those dfget recognizes.
705+
callSystem:
706+
type: "string"
707+
description: |
708+
This attribute represents where the dfget requests come from. Dfget will pass
709+
this field to supernode and supernode can do some checking and filtering via
710+
black/white list mechanism to guarantee security, or some other purposes like debugging.
711+
minLength: 1
705712

706713
PeerCreateRequest:
707714
type: "object"
@@ -840,9 +847,9 @@ definitions:
840847
callSystem:
841848
type: "string"
842849
description: |
843-
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
844-
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
845-
some black/white list to guarantee security, or some other purposes.
850+
This attribute represents where the dfget requests come from. Dfget will pass
851+
this field to supernode and supernode can do some checking and filtering via
852+
black/white list mechanism to guarantee security, or some other purposes like debugging.
846853
minLength: 1
847854
filter:
848855
type: "array"
@@ -958,20 +965,7 @@ definitions:
958965
from source server as user's wish.
959966
additionalProperties:
960967
type: "string"
961-
dfdaemon:
962-
type: "boolean"
963-
description: |
964-
tells whether it is a call from dfdaemon. dfdaemon is a long running
965-
process which works for container engines. It translates the image
966-
pulling request into raw requests into those dfget recganises.
967-
callSystem:
968-
type: "string"
969-
description: |
970-
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
971-
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
972-
some black/white list to guarantee security, or some other purposes.
973-
minLength: 1
974-
968+
975969
TaskUpdateRequest:
976970
type: "object"
977971
description: "request used to update task attributes."
@@ -1169,7 +1163,20 @@ definitions:
11691163
supernodeIP:
11701164
type: "string"
11711165
description: "IP address of supernode which the peer connects to"
1172-
1166+
dfdaemon:
1167+
type: "boolean"
1168+
description: |
1169+
tells whether it is a call from dfdaemon. dfdaemon is a long running
1170+
process which works for container engines. It translates the image
1171+
pulling request into raw requests into those dfget recganises.
1172+
callSystem:
1173+
type: "string"
1174+
description: |
1175+
This attribute represents where the dfget requests come from. Dfget will pass
1176+
this field to supernode and supernode can do some checking and filtering via
1177+
black/white list mechanism to guarantee security, or some other purposes like debugging.
1178+
minLength: 1
1179+
11731180
ErrorResponse:
11741181
type: "object"
11751182
description: |

apis/types/df_get_task.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/types/task_create_request.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/types/task_info.go

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/types/task_register_request.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

supernode/daemon/mgr/dfgettask/manager_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ func init() {
3535
}
3636

3737
type DfgetTaskMgrTestSuite struct {
38+
manager *Manager
39+
}
40+
41+
// SetUpSuite does common setup in the beginning of each test.
42+
func (s *DfgetTaskMgrTestSuite) SetUpSuite(c *check.C) {
43+
s.manager, _ = NewManager()
3844
}
3945

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

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

54-
err := dfgetTaskManager.Add(context.Background(), dfgetTask)
59+
err := s.manager.Add(context.Background(), dfgetTask)
5560
c.Check(err, check.IsNil)
5661

5762
// Get
58-
dt, err := dfgetTaskManager.Get(context.Background(), clientID, taskID)
63+
dt, err := s.manager.Get(context.Background(), clientID, taskID)
5964
c.Check(err, check.IsNil)
6065
c.Check(dt, check.DeepEquals, &types.DfGetTask{
6166
CID: clientID,
@@ -67,10 +72,10 @@ func (s *DfgetTaskMgrTestSuite) TestDfgetTaskMgr(c *check.C) {
6772
})
6873

6974
// UpdateStatus
70-
err = dfgetTaskManager.UpdateStatus(context.Background(), clientID, taskID, types.DfGetTaskStatusSUCCESS)
75+
err = s.manager.UpdateStatus(context.Background(), clientID, taskID, types.DfGetTaskStatusSUCCESS)
7176
c.Check(err, check.IsNil)
7277

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

8489
// Delete
85-
err = dfgetTaskManager.Delete(context.Background(), clientID, taskID)
90+
err = s.manager.Delete(context.Background(), clientID, taskID)
8691
c.Check(err, check.IsNil)
8792

88-
_, err = dfgetTaskManager.Get(context.Background(), clientID, taskID)
93+
_, err = s.manager.Get(context.Background(), clientID, taskID)
8994
c.Check(errors.IsDataNotFound(err), check.Equals, true)
9095
}

supernode/daemon/mgr/task/manager_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func (tm *Manager) addOrUpdateTask(ctx context.Context, req *types.TaskCreateReq
2828
var task *types.TaskInfo
2929
newTask := &types.TaskInfo{
3030
ID: taskID,
31-
CallSystem: req.CallSystem,
32-
Dfdaemon: req.Dfdaemon,
3331
Headers: req.Headers,
3432
Identifier: req.Identifier,
3533
Md5: req.Md5,
@@ -155,6 +153,8 @@ func (tm *Manager) updateTask(taskID string, updateTaskInfo *types.TaskInfo) err
155153
func (tm *Manager) addDfgetTask(ctx context.Context, req *types.TaskCreateRequest, task *types.TaskInfo) (*types.DfGetTask, error) {
156154
dfgetTask := &types.DfGetTask{
157155
CID: req.CID,
156+
CallSystem: req.CallSystem,
157+
Dfdaemon: req.Dfdaemon,
158158
Path: req.Path,
159159
PieceSize: task.PieceSize,
160160
Status: types.DfGetTaskStatusWAITING,

supernode/daemon/mgr/task/manager_util_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ func (s *TaskUtilTestSuite) TestAddOrUpdateTask(c *check.C) {
8181
},
8282
task: &types.TaskInfo{
8383
ID: generateTaskID("http://aa.bb.com", "", ""),
84-
CallSystem: "foo",
8584
CdnStatus: types.TaskInfoCdnStatusWAITING,
86-
Dfdaemon: true,
8785
HTTPFileLength: 1000,
8886
PieceSize: config.DefaultPieceSize,
8987
PieceTotal: 1,
@@ -103,9 +101,7 @@ func (s *TaskUtilTestSuite) TestAddOrUpdateTask(c *check.C) {
103101
},
104102
task: &types.TaskInfo{
105103
ID: generateTaskID("http://aa.bb.com", "", ""),
106-
CallSystem: "foo",
107104
CdnStatus: types.TaskInfoCdnStatusWAITING,
108-
Dfdaemon: true,
109105
HTTPFileLength: 1000,
110106
PieceSize: config.DefaultPieceSize,
111107
PieceTotal: 1,

supernode/server/0.3_bridge.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (s *Server) registry(ctx context.Context, rw http.ResponseWriter, req *http
7777
peerID := peerCreateResponse.ID
7878
taskCreateRequest := &types.TaskCreateRequest{
7979
CID: request.CID,
80+
CallSystem: request.CallSystem,
8081
Dfdaemon: request.Dfdaemon,
8182
Headers: cutil.ConvertHeaders(request.Headers),
8283
Identifier: request.Identifier,

0 commit comments

Comments
 (0)