forked from dragonflyoss/Dragonfly2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
294 lines (211 loc) · 6.77 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
* Copyright 2022 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package storage
import (
"time"
"github.com/XDTD/Dragonfly2/scheduler/resource"
)
// Task contains content for task.
type Task struct {
// ID is task id.
ID string `csv:"id"`
// URL is task download url.
URL string `csv:"url"`
// Type is task type.
Type string `csv:"type"`
// ContentLength is task total content length.
ContentLength int64 `csv:"contentLength"`
// TotalPieceCount is total piece count.
TotalPieceCount int32 `csv:"totalPieceCount"`
// BackToSourceLimit is back-to-source limit.
BackToSourceLimit int32 `csv:"backToSourceLimit"`
// BackToSourcePeerCount is back-to-source peer count.
BackToSourcePeerCount int32 `csv:"backToSourcePeerCount"`
// State is the download state of the task.
State string `csv:"state"`
// CreatedAt is peer create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
// UpdatedAt is peer update nanosecond time.
UpdatedAt int64 `csv:"updatedAt"`
}
// Host contains content for host.
type Host struct {
// ID is host id.
ID string `csv:"id"`
// Type is host type.
Type string `csv:"type"`
// Hostname is host name.
Hostname string `csv:"hostname"`
// IP is host ip.
IP string `csv:"ip"`
// Port is grpc service port.
Port int32 `csv:"port"`
// DownloadPort is piece downloading port.
DownloadPort int32 `csv:"downloadPort"`
// Host OS.
OS string `csv:"os"`
// Host platform.
Platform string `csv:"platform"`
// Host platform family.
PlatformFamily string `csv:"platformFamily"`
// Host platform version.
PlatformVersion string `csv:"platformVersion"`
// Host kernel version.
KernelVersion string `csv:"kernelVersion"`
// ConcurrentUploadLimit is concurrent upload limit count.
ConcurrentUploadLimit int32 `csv:"concurrentUploadLimit"`
// ConcurrentUploadCount is concurrent upload count.
ConcurrentUploadCount int32 `csv:"concurrentUploadCount"`
// UploadCount is total upload count.
UploadCount int64 `csv:"uploadCount"`
// UploadFailedCount is upload failed count.
UploadFailedCount int64 `csv:"uploadFailedCount"`
// CPU Stat.
CPU resource.CPU `csv:"cpu"`
// Memory Stat.
Memory resource.Memory `csv:"memory"`
// Network Stat.
Network resource.Network `csv:"network"`
// Disk Stat.
Disk resource.Disk `csv:"disk"`
// Build information.
Build resource.Build `csv:"build"`
// CreatedAt is peer create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
// UpdatedAt is peer update nanosecond time.
UpdatedAt int64 `csv:"updatedAt"`
}
// Piece contains content for piece.
type Piece struct {
// Length is piece length.
Length int64 `csv:"length"`
// Cost is the cost time for downloading piece.
Cost int64 `csv:"cost"`
// CreatedAt is piece create time.
CreatedAt int64 `csv:"createdAt"`
}
// Parent contains content for parent.
type Parent struct {
// ID is peer id.
ID string `csv:"id"`
// Tag is peer tag.
Tag string `csv:"tag"`
// Application is peer application.
Application string `csv:"application"`
// State is the download state of the peer.
State string `csv:"state"`
// Cost is the task download duration of nanosecond.
Cost int64 `csv:"cost"`
// UploadPieceCount is upload piece count.
UploadPieceCount int32 `csv:"uploadPieceCount"`
// FinishedPieceCount is finished piece count.
FinishedPieceCount int32 `csv:"finishedPieceCount"`
// Host is peer host.
Host Host `csv:"host"`
// Pieces is downloaded pieces from parent host.
Pieces []Piece `csv:"pieces" csv[]:"10"`
// CreatedAt is peer create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
// UpdatedAt is peer update nanosecond time.
UpdatedAt int64 `csv:"updatedAt"`
}
// Error contains content for error.
type Error struct {
time.Duration
// Code is the code of error.
Code string `csv:"code"`
// Message is the message of error.
Message string `csv:"message"`
}
// Download contains content for download.
type Download struct {
// ID is peer id.
ID string `csv:"id"`
// Tag is peer tag.
Tag string `csv:"tag"`
// Application is peer application.
Application string `csv:"application"`
// State is the download state of the peer.
State string `csv:"state"`
// Error is the details of error.
Error Error `csv:"error"`
// Cost is the task download duration of nanosecond.
Cost int64 `csv:"cost"`
// FinishedPieceCount is finished piece count.
FinishedPieceCount int32 `csv:"finishedPieceCount"`
// Task is peer task.
Task Task `csv:"task"`
// Host is peer host.
Host Host `csv:"host"`
// Parents is peer parents.
Parents []Parent `csv:"parents" csv[]:"20"`
// CreatedAt is peer create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
// UpdatedAt is peer update nanosecond time.
UpdatedAt int64 `csv:"updatedAt"`
}
// Probes contains content for probes.
type Probes struct {
// AverageRTT is the average round-trip time of probes.
AverageRTT int64 `csv:"averageRTT"`
// CreatedAt is probe create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
// UpdatedAt is probe update nanosecond time.
UpdatedAt int64 `csv:"updatedAt"`
}
// SrcHost contains content for source host.
type SrcHost struct {
// ID is host id.
ID string `csv:"id"`
// Type is host type.
Type string `csv:"type"`
// Hostname is host name.
Hostname string `csv:"hostname"`
// IP is host ip.
IP string `csv:"ip"`
// Port is grpc service port.
Port int32 `csv:"port"`
// Network Stat.
Network resource.Network `csv:"network"`
}
// DestHost contains content for destination host.
type DestHost struct {
// ID is host id.
ID string `csv:"id"`
// Type is host type.
Type string `csv:"type"`
// Hostname is host name.
Hostname string `csv:"hostname"`
// IP is host ip.
IP string `csv:"ip"`
// Port is grpc service port.
Port int32 `csv:"port"`
// Network Stat.
Network resource.Network `csv:"network"`
// Probes is the network information probed to destination host.
Probes Probes `csv:"probes"`
}
// NetworkTopology contains content for network topology.
type NetworkTopology struct {
// ID is network topology id.
ID string `csv:"id"`
// Host is probe source host.
Host SrcHost `csv:"host"`
// DestHosts is the destination hosts probed from source host.
DestHosts []DestHost `csv:"destHosts" csv[]:"5"`
// CreatedAt is network topology create nanosecond time.
CreatedAt int64 `csv:"createdAt"`
}