feat: add finished piece count element in types (#2557)
Signed-off-by: XZ <834756128@qq.com>
This commit is contained in:
parent
94e4b7a5a2
commit
be6d8085c7
|
|
@ -1346,14 +1346,15 @@ func (v *V1) createDownloadRecord(peer *resource.Peer, parents []*resource.Peer,
|
||||||
var parentRecords []storage.Parent
|
var parentRecords []storage.Parent
|
||||||
for _, parent := range parents {
|
for _, parent := range parents {
|
||||||
parentRecord := storage.Parent{
|
parentRecord := storage.Parent{
|
||||||
ID: parent.ID,
|
ID: parent.ID,
|
||||||
Tag: parent.Task.Tag,
|
Tag: parent.Task.Tag,
|
||||||
Application: parent.Task.Application,
|
Application: parent.Task.Application,
|
||||||
State: parent.FSM.Current(),
|
State: parent.FSM.Current(),
|
||||||
Cost: parent.Cost.Load().Nanoseconds(),
|
Cost: parent.Cost.Load().Nanoseconds(),
|
||||||
UploadPieceCount: 0,
|
UploadPieceCount: 0,
|
||||||
CreatedAt: parent.CreatedAt.Load().UnixNano(),
|
FinishedPieceCount: int32(parent.FinishedPieces.Count()),
|
||||||
UpdatedAt: parent.UpdatedAt.Load().UnixNano(),
|
CreatedAt: parent.CreatedAt.Load().UnixNano(),
|
||||||
|
UpdatedAt: parent.UpdatedAt.Load().UnixNano(),
|
||||||
Host: storage.Host{
|
Host: storage.Host{
|
||||||
ID: parent.Host.ID,
|
ID: parent.Host.ID,
|
||||||
Type: parent.Host.Type.Name(),
|
Type: parent.Host.Type.Name(),
|
||||||
|
|
@ -1450,14 +1451,15 @@ func (v *V1) createDownloadRecord(peer *resource.Peer, parents []*resource.Peer,
|
||||||
}
|
}
|
||||||
|
|
||||||
download := storage.Download{
|
download := storage.Download{
|
||||||
ID: peer.ID,
|
ID: peer.ID,
|
||||||
Tag: peer.Task.Tag,
|
Tag: peer.Task.Tag,
|
||||||
Application: peer.Task.Application,
|
Application: peer.Task.Application,
|
||||||
State: peer.FSM.Current(),
|
State: peer.FSM.Current(),
|
||||||
Cost: peer.Cost.Load().Nanoseconds(),
|
Cost: peer.Cost.Load().Nanoseconds(),
|
||||||
Parents: parentRecords,
|
FinishedPieceCount: int32(peer.FinishedPieces.Count()),
|
||||||
CreatedAt: peer.CreatedAt.Load().UnixNano(),
|
Parents: parentRecords,
|
||||||
UpdatedAt: peer.UpdatedAt.Load().UnixNano(),
|
CreatedAt: peer.CreatedAt.Load().UnixNano(),
|
||||||
|
UpdatedAt: peer.UpdatedAt.Load().UnixNano(),
|
||||||
Task: storage.Task{
|
Task: storage.Task{
|
||||||
ID: peer.Task.ID,
|
ID: peer.Task.ID,
|
||||||
URL: peer.Task.URL,
|
URL: peer.Task.URL,
|
||||||
|
|
|
||||||
|
|
@ -125,16 +125,17 @@ var (
|
||||||
mockPieces = append(make([]Piece, 9), mockPiece)
|
mockPieces = append(make([]Piece, 9), mockPiece)
|
||||||
|
|
||||||
mockParent = Parent{
|
mockParent = Parent{
|
||||||
ID: "4",
|
ID: "4",
|
||||||
Tag: "m",
|
Tag: "m",
|
||||||
Application: "db",
|
Application: "db",
|
||||||
State: "Succeeded",
|
State: "Succeeded",
|
||||||
Cost: 1000,
|
Cost: 1000,
|
||||||
UploadPieceCount: 10,
|
UploadPieceCount: 10,
|
||||||
Host: mockHost,
|
FinishedPieceCount: 10,
|
||||||
Pieces: mockPieces,
|
Host: mockHost,
|
||||||
CreatedAt: time.Now().UnixNano(),
|
Pieces: mockPieces,
|
||||||
UpdatedAt: time.Now().UnixNano(),
|
CreatedAt: time.Now().UnixNano(),
|
||||||
|
UpdatedAt: time.Now().UnixNano(),
|
||||||
}
|
}
|
||||||
|
|
||||||
mockParents = append(make([]Parent, 19), mockParent)
|
mockParents = append(make([]Parent, 19), mockParent)
|
||||||
|
|
@ -148,12 +149,13 @@ var (
|
||||||
Code: "unknow",
|
Code: "unknow",
|
||||||
Message: "unknow",
|
Message: "unknow",
|
||||||
},
|
},
|
||||||
Cost: 1000,
|
Cost: 1000,
|
||||||
Task: mockTask,
|
FinishedPieceCount: 10,
|
||||||
Host: mockHost,
|
Task: mockTask,
|
||||||
Parents: mockParents,
|
Host: mockHost,
|
||||||
CreatedAt: time.Now().UnixNano(),
|
Parents: mockParents,
|
||||||
UpdatedAt: time.Now().UnixNano(),
|
CreatedAt: time.Now().UnixNano(),
|
||||||
|
UpdatedAt: time.Now().UnixNano(),
|
||||||
}
|
}
|
||||||
|
|
||||||
mockSrcHost = SrcHost{
|
mockSrcHost = SrcHost{
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,9 @@ type Parent struct {
|
||||||
// UploadPieceCount is upload piece count.
|
// UploadPieceCount is upload piece count.
|
||||||
UploadPieceCount int32 `csv:"uploadPieceCount"`
|
UploadPieceCount int32 `csv:"uploadPieceCount"`
|
||||||
|
|
||||||
|
// FinishedPieceCount is finished piece count.
|
||||||
|
FinishedPieceCount int32 `csv:"finishedPieceCount"`
|
||||||
|
|
||||||
// Host is peer host.
|
// Host is peer host.
|
||||||
Host Host `csv:"host"`
|
Host Host `csv:"host"`
|
||||||
|
|
||||||
|
|
@ -199,6 +202,9 @@ type Download struct {
|
||||||
// Cost is the task download duration of nanosecond.
|
// Cost is the task download duration of nanosecond.
|
||||||
Cost int64 `csv:"cost"`
|
Cost int64 `csv:"cost"`
|
||||||
|
|
||||||
|
// FinishedPieceCount is finished piece count.
|
||||||
|
FinishedPieceCount int32 `csv:"finishedPieceCount"`
|
||||||
|
|
||||||
// Task is peer task.
|
// Task is peer task.
|
||||||
Task Task `csv:"task"`
|
Task Task `csv:"task"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
5,d,mq,Succeeded,unknow,unknow,1000,1,example.com,normal,2048,1,10,2,Succeeded,1689072709228040702,1689072709228040802,2,normal,localhost,127.0.0.1,8080,8081,linux,ubuntu,debian,1.0.0,1.0.0,100,40,20,3,24,12,0.8,0.4,100,101,102,103,104,105,106,107,108,109,20,19,16,0.7,0.2,15,400,200,china,e1,100,88,56,0.9,200,180,160,0.6,3.0.0,2bf4d5e,1.19,linux,1689072709228040863,1689072709228044069,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0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,4,m,db,Succeeded,1000,10,2,normal,localhost,127.0.0.1,8080,8081,linux,ubuntu,debian,1.0.0,1.0.0,100,40,20,3,24,12,0.8,0.4,100,101,102,103,104,105,106,107,108,109,20,19,16,0.7,0.2,15,400,200,china,e1,100,88,56,0.9,200,180,160,0.6,3.0.0,2bf4d5e,1.19,linux,1689072709228040863,1689072709228044069,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,10,1689072709228044129,1689072709228045381,1689072709228045441,1689072709228053546,1689072709228053606
|
5,d,mq,Succeeded,unknow,unknow,1000,10,1,example.com,normal,2048,1,10,2,Succeeded,1689685929626279983,1689685929626280083,2,normal,localhost,127.0.0.1,8080,8081,linux,ubuntu,debian,1.0.0,1.0.0,100,40,20,3,24,12,0.8,0.4,100,101,102,103,104,105,106,107,108,109,20,19,16,0.7,0.2,15,400,200,china,e1,100,88,56,0.9,200,180,160,0.6,3.0.0,2bf4d5e,1.19,linux,1689685929626280163,1689685929626284802,,,,,0,0,0,,,,,0,0,,,,,,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,,,0,0,0,,,,,0,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,0,0,0,0,0,0,,,,,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,4,m,db,Succeeded,1000,10,10,2,normal,localhost,127.0.0.1,8080,8081,linux,ubuntu,debian,1.0.0,1.0.0,100,40,20,3,24,12,0.8,0.4,100,101,102,103,104,105,106,107,108,109,20,19,16,0.7,0.2,15,400,200,china,e1,100,88,56,0.9,200,180,160,0.6,3.0.0,2bf4d5e,1.19,linux,1689685929626280163,1689685929626284802,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,10,1689685929626284872,1689685929626286204,1689685929626286274,1689685929626310119,1689685929626310189
|
||||||
|
|
|
||||||
|
Loading…
Reference in New Issue