dragonfly-api 2.2.30

Canonical location of the Dragonfly API definition
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
/*
 *     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.
 */

syntax = "proto3";

package dfdaemon.v2;

import "common.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

// DownloadTaskRequest represents request of DownloadTask.
message DownloadTaskRequest {
  // Download information.
  common.v2.Download download = 1;
}

// DownloadTaskStartedResponse represents task download started response of DownloadTaskResponse.
message DownloadTaskStartedResponse {
  // Task content length.
  uint64 content_length = 1;

  // Range is url range of request. If protocol is http, range
  // is parsed from http header. If other protocol, range comes
  // from download range field.
  optional common.v2.Range range = 2;

  // Task response headers.
  map<string, string> response_header = 3;

  // Need to download pieces.
  repeated common.v2.Piece pieces = 4;

  // is_finished indicates whether the download task is finished.
  bool is_finished = 5;
}

// DownloadPieceFinishedResponse represents piece download finished response of DownloadTaskResponse.
message DownloadPieceFinishedResponse {
  // Finished piece of task.
  common.v2.Piece piece = 1;
}

// DownloadTaskResponse represents response of DownloadTask.
message DownloadTaskResponse {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Peer id.
  string peer_id = 3;

  oneof response {
    DownloadTaskStartedResponse download_task_started_response = 4;
    DownloadPieceFinishedResponse download_piece_finished_response = 5;
  }
}

// SyncPiecesRequest represents request of SyncPieces.
message SyncPiecesRequest {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Interested piece numbers.
  repeated uint32 interested_piece_numbers = 3;
}

// SyncPiecesResponse represents response of SyncPieces.
message SyncPiecesResponse {
  // Exist piece number.
  uint32 number = 1;
  // Piece offset.
  uint64 offset = 2;
  // Piece length.
  uint64 length = 3;
  // IP is used to indicate the IP address of the peer. If protocol is rdma,
  // the IP is used to exchange the queue pair endpoint of IBVerbs.
  string ip = 4;
  // TCP port is used to indicate the tcp server port of the peer.
  optional int32 tcp_port = 5;
  // QUIC port is used to indicate the quic server port of the peer.
  optional int32 quic_port = 6;
}

// StatTaskRequest represents request of StatTask.
message StatTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;

  reserved 3;
  reserved "local_only";
}

// StatLocalTaskRequest represents request of StatLocalTask.
message StatLocalTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// StatLocalTaskResponse represents response of StatLocalTask.
message StatLocalTaskResponse {
  // Task id.
  string task_id = 1;
  // Task piece length.
  optional uint64 piece_length = 2;
  // Task content length.
  optional uint64 content_length = 3;
  // Task response headers.
  map<string, string> response_header = 4;
  // Uploading count is the count of the task being uploaded by other peers.
  uint64 uploading_count = 5;
  // Uploaded count is the count of the task has been uploaded by other peers.
  uint64 uploaded_count = 6;
  // Task create time.
  google.protobuf.Timestamp created_at = 7;
  // Task update time.
  google.protobuf.Timestamp updated_at = 8;
  // Task prefetch time.
  optional google.protobuf.Timestamp prefetched_at = 9;
  // Task fail time.
  optional google.protobuf.Timestamp failed_at = 10;
  // Task finish time.
  optional google.protobuf.Timestamp finished_at = 11;
}

// ListLocalTasksRequest represents request of ListLocalTasks.
message ListLocalTasksRequest {
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 1;
}

// ListLocalTasksResponse represents response of ListLocalTasks.
message ListLocalTasksResponse {
  // Task ids of the local tasks.
  repeated StatLocalTaskResponse tasks = 1;
}

// ListTaskEntriesRequest represents request of ListTaskEntries.
message ListTaskEntriesRequest {
  // Task id.
  string task_id = 1;
  // URL to be listed the entries.
  string url = 2;
  // HTTP header to be sent with the request.
  map<string, string> request_header = 3;
  // List timeout.
  optional google.protobuf.Duration timeout = 4;
  // certificate_chain is the client certs with DER format for the backend client to list the entries.
  repeated bytes certificate_chain = 5;
  // Object storage protocol information.
  optional common.v2.ObjectStorage object_storage = 6;
  // HDFS protocol information.
  optional common.v2.HDFS hdfs = 7;
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 8;
  // HuggingFace protocol information.
  optional common.v2.HuggingFace hugging_face = 9;
  // ModelScope protocol information.
  optional common.v2.ModelScope model_scope = 10;
}

// ListTaskEntriesResponse represents response of ListTaskEntries.
message ListTaskEntriesResponse {
  // Content length is the content length of the response
  uint64 content_length = 1;
  // HTTP header to be sent with the request.
  map<string, string> response_header = 2;
  // Backend HTTP status code.
  optional int32 status_code = 3;
  /// Entries is the information of the entries in the directory.
  repeated Entry entries = 4;
}

// Entry represents an entry in a directory.
message Entry {
  // URL of the entry.
  string url = 1;
  // Size of the entry.
  uint64 content_length = 2;
  // Is directory or not.
  bool is_dir = 3;
}

// DeleteTaskRequest represents request of DeleteTask.
message DeleteTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the delete request.
  optional string remote_ip = 2;
}

// DeleteLocalTaskRequest represents request of DeleteLocalTask.
message DeleteLocalTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the delete request.
  optional string remote_ip = 2;
}

// DownloadCacheTaskRequest represents request of DownloadCacheTask.
message DownloadCacheTaskRequest {
  // Download url.
  string url = 1;
  // Digest of the task digest, for example :xxx or sha256:yyy.
  optional string digest = 2;
  // Range is url range of request. If protocol is http, range
  // will set in request header. If protocol is others, range
  // will set in range field.
  optional common.v2.Range range = 3;
  // Task type.
  common.v2.TaskType type = 4;
  // URL tag identifies different task for same url.
  optional string tag = 5;
  // Application of task.
  optional string application = 6;
  // Peer priority.
  common.v2.Priority priority = 7;
  // Filtered query params to generate the task id.
  // When filter is ["Signature", "Expires", "ns"], for example:
  // http://example.com/xyz?Expires=e1&Signature=s1&ns=docker.io and http://example.com/xyz?Expires=e2&Signature=s2&ns=docker.io
  // will generate the same task id.
  // Default value includes the filtered query params of s3, gcs, oss, obs, cos.
  repeated string filtered_query_params = 8;
  // Task request headers.
  map<string, string> request_header = 9;
  // Task piece length.
  optional uint64 piece_length = 10;
  // File path to be downloaded. If output_path is set, the downloaded file will be saved to the specified path.
  // Dfdaemon will try to create hard link to the output path before starting the download. If hard link creation fails,
  // it will copy the file to the output path after the download is completed.
  // For more details refer to https://github.com/dragonflyoss/design/blob/main/systems-analysis/file-download-workflow-with-hard-link/README.md.
  optional string output_path = 11;
  // Download timeout.
  optional google.protobuf.Duration timeout = 12;
  // Dfdaemon cannot download the task from the source if disable_back_to_source is true.
  bool disable_back_to_source = 13;
  // Scheduler needs to schedule the task downloads from the source if need_back_to_source is true.
  bool need_back_to_source = 14;
  // certificate_chain is the client certs with DER format for the backend client to download back-to-source.
  repeated bytes certificate_chain = 15;
  // Prefetch pre-downloads all pieces of the task when the download task request is a range request.
  bool prefetch = 16;
  // Object storage protocol information.
  optional common.v2.ObjectStorage object_storage = 17;
  // HDFS protocol information.
  optional common.v2.HDFS hdfs = 18;
  // is_prefetch is the flag to indicate whether the request is a prefetch request.
  bool is_prefetch = 19;
  // need_piece_content is the flag to indicate whether the response needs to return piece content.
  bool need_piece_content = 20;
  // content_for_calculating_task_id is the content used to calculate the task id.
  // If content_for_calculating_task_id is set, use its value to calculate the task ID.
  // Otherwise, calculate the task ID based on url, piece_length, tag, application, and filtered_query_params.
  optional string content_for_calculating_task_id = 21;
  // remote_ip represents the IP address of the client initiating the download request.
  // For proxy requests, it is set to the IP address of the request source.
  // For dfget requests, it is set to the IP address of the dfget.
  optional string remote_ip = 22;
  // Overwrite indicates whether to overwrite the existing file at output path.
  bool overwrite = 23;
}

// DownloadCacheTaskStartedResponse represents cache task download started response of DownloadCacheTaskResponse.
message DownloadCacheTaskStartedResponse {
  // Task content length.
  uint64 content_length = 1;

  // Range is url range of request. If protocol is http, range
  // is parsed from http header. If other protocol, range comes
  // from download range field.
  optional common.v2.Range range = 2;

  // Task response headers.
  map<string, string> response_header = 3;

  // Need to download pieces.
  repeated common.v2.Piece pieces = 4;

  // is_finished indicates whether the download task is finished.
  bool is_finished = 5;
}

// DownloadCacheTaskResponse represents response of DownloadCacheTask.
message DownloadCacheTaskResponse {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Peer id.
  string peer_id = 3;

  oneof response {
    DownloadCacheTaskStartedResponse download_cache_task_started_response = 4;
    DownloadPieceFinishedResponse download_piece_finished_response = 5;
  }
}

// SyncCachePiecesRequest represents request of SyncCachePieces.
message SyncCachePiecesRequest {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Interested piece numbers.
  repeated uint32 interested_cache_piece_numbers = 3;
}

// SyncCachePiecesResponse represents response of SyncCachePieces.
message SyncCachePiecesResponse {
  // Exist piece number.
  uint32 number = 1;
  // Piece offset.
  uint64 offset = 2;
  // Piece length.
  uint64 length = 3;
}

// DownloadCachePieceRequest represents request of DownloadCachePiece.
message DownloadCachePieceRequest {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Piece number.
  uint32 piece_number = 3;
}

// DownloadCachePieceResponse represents response of DownloadCachePieces.
message DownloadCachePieceResponse {
  // Piece information.
  common.v2.Piece piece = 1;
  // Piece metadata digest, it is used to verify the integrity of the piece metadata.
  optional string digest = 2;
}

// StatCacheTaskRequest represents request of StatCacheTask.
message StatCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// DeleteCacheTaskRequest represents request of DeleteCacheTask.
message DeleteCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the delete request.
  optional string remote_ip = 2;
}

// DownloadPersistentTaskRequest represents request of DownloadPersistentTask.
message DownloadPersistentTaskRequest {
  // This is the url of the object storage protocal where the persistent task will be stored,
  // for example: `s3://<bucket>/path`, `gcs://<bucket>/path`. The combination of url,
  // object_storage.endpoint and object_storage.region must be unique, because
  // the persistent task cannot be overwritten once it is uploaded.
  string url = 1;
  // Object storage protocol information.
  common.v2.ObjectStorage object_storage = 2;
  // Persistent represents whether the persistent task is persistent.
  // If the persistent task is persistent, the persistent peer will
  // not be deleted when dfdaemon runs garbage collection.
  bool persistent = 3;
  // File path to be exported. If output_path is set, the exported file will be saved to the specified path.
  // Dfdaemon will try to create hard link to the output path before starting the export. If hard link creation fails,
  // it will copy the file to the output path after the export is completed.
  // For more details refer to https://github.com/dragonflyoss/design/blob/main/systems-analysis/file-download-workflow-with-hard-link/README.md.
  optional string output_path = 4;
  // Download timeout.
  optional google.protobuf.Duration timeout = 5;
  // need_piece_content is the flag to indicate whether the response needs to return piece content.
  bool need_piece_content = 6;
  // force_hard_link is the flag to indicate whether the exported file must be hard linked to the output path.
  // For more details refer to https://github.com/dragonflyoss/design/blob/main/systems-analysis/file-download-workflow-with-hard-link/README.md.
  bool force_hard_link = 7;
  // Verifies task data integrity after download using a digest. Supports CRC32, SHA256, and SHA512 algorithms.
  // Format: `<algorithm>:<hash>`, e.g., `crc32:xxx`, `sha256:yyy`, `sha512:zzz`.
  // Returns an error if the computed digest mismatches the expected value.
  //
  // Performance
  // Digest calculation increases processing time. Enable only when data integrity verification is critical.
  optional string digest = 8;
  // Remote IP represents the IP address of the client initiating the download request.
  optional string remote_ip = 9;
  // Overwrite indicates whether to overwrite the existing file at output path.
  bool overwrite = 10;
}

// DownloadPersistentTaskStartedResponse represents task download started response of DownloadPersistentTaskResponse.
message DownloadPersistentTaskStartedResponse {
  // Task content length.
  uint64 content_length = 1;
}

// DownloadPersistentTaskResponse represents response of DownloadPersistentTask.
message DownloadPersistentTaskResponse {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Peer id.
  string peer_id = 3;

  oneof response {
    DownloadPersistentTaskStartedResponse download_persistent_task_started_response = 4;
    DownloadPieceFinishedResponse download_piece_finished_response = 5;
  }
}

// UploadPersistentTaskRequest represents request of UploadPersistentTask.
message UploadPersistentTaskRequest {
  // This is the url of the object storage protocal where the persistent task will be stored,
  // for example: `s3://<bucket>/path`, `gcs://<bucket>/path`. The combination of url,
  // object_storage.endpoint and object_storage.region must be unique, because
  // the persistent task cannot be overwritten once it is uploaded.
  string url = 1;
  // Object storage protocol information.
  common.v2.ObjectStorage object_storage = 2;
  // Source file path of the persistent task.
  string path = 3;
  // Replica count of the persistent persistent task.
  uint64 persistent_replica_count = 4;
  // TTL of the persistent task.
  google.protobuf.Duration ttl = 5;
  // Download timeout.
  optional google.protobuf.Duration timeout = 6;
  // Remote IP represents the IP address of the client initiating the upload request.
  optional string remote_ip = 7;
}

// UpdatePersistentTaskRequest represents request of UpdatePersistentTask.
message UpdatePersistentTaskRequest {
  // Task id.
  string task_id = 1;
  // Persistent represents whether the persistent peer is persistent.
  // If the persistent peer is persistent, the persistent peer will
  // not be deleted when dfdaemon runs garbage collection. It only be deleted
  // when the task is deleted by the user.
  bool persistent = 2;
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 3;
}

// StatPersistentTaskRequest represents request of StatPersistentTask.
message StatPersistentTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// StatLocalPersistentTaskRequest represents request of StatLocalPersistentTask.
message StatLocalPersistentTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// StatLocalPersistentTaskResponse represents response of StatLocalPersistentTask.
message StatLocalPersistentTaskResponse {
  // Task id.
  string task_id = 1;
  // Persistent represents whether the persistent task is persistent.
  // If the persistent task is persistent, the persistent peer will
  // not be deleted when dfdamon runs garbage collection.
  bool persistent = 2;
  // TTL of the persistent task.
  google.protobuf.Duration ttl = 3;
  // Task piece length.
  optional uint64 piece_length = 4;
  // Task content length.
  optional uint64 content_length = 5;
  // Uploading count is the count of the persistent task being uploaded by other peers.
  uint64 uploading_count = 6;
  // Uploaded count is the count of the persistent task has been uploaded by other peers.
  uint64 uploaded_count = 7;
  // Task create time.
  google.protobuf.Timestamp created_at = 8;
  // Task update time.
  google.protobuf.Timestamp updated_at = 9;
  // Task fail time.
  optional google.protobuf.Timestamp failed_at = 10;
  // Task finish time.
  optional google.protobuf.Timestamp finished_at = 11;
}

// ListLocalPersistentTasksRequest represents request of ListLocalPersistentTasks.
message ListLocalPersistentTasksRequest {
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 1;
}

// ListLocalPersistentTasksResponse represents response of ListLocalPersistentTasks.
message ListLocalPersistentTasksResponse {
  // Task ids of the local tasks.
  repeated StatLocalPersistentTaskResponse tasks = 1;
}

// DeletePersistentTaskRequest represents request of DeletePersistentTask.
message DeletePersistentTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the delete request.
  optional string remote_ip = 2;
}

// SyncPersistentPiecesRequest represents request of SyncPersistentPieces.
message SyncPersistentPiecesRequest {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Interested piece numbers.
  repeated uint32 interested_piece_numbers = 3;
}

// SyncPersistentPiecesResponse represents response of SyncPersistentPieces.
message SyncPersistentPiecesResponse {
  // Exist piece number.
  uint32 number = 1;
  // Piece offset.
  uint64 offset = 2;
  // Piece length.
  uint64 length = 3;
  // IP is used to indicate the IP address of the peer. If protocol is rdma,
  // the IP is used to exchange the queue pair endpoint of IBVerbs.
  string ip = 4;
  // TCP port is used to indicate the tcp server port of the peer.
  optional int32 tcp_port = 5;
  // QUIC port is used to indicate the quic server port of the peer.
  optional int32 quic_port = 6;
}

// DownloadPersistentCacheTaskRequest represents request of DownloadPersistentCacheTask.
message DownloadPersistentCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Persistent represents whether the persistent cache task is persistent.
  // If the persistent cache task is persistent, the persistent cache peer will
  // not be deleted when dfdaemon runs garbage collection.
  bool persistent = 2;
  // Tag is used to distinguish different persistent cache tasks.
  optional string tag = 3;
  // Application of task.
  optional string application = 4;
  // File path to be exported. If output_path is set, the exported file will be saved to the specified path.
  // Dfdaemon will try to create hard link to the output path before starting the export. If hard link creation fails,
  // it will copy the file to the output path after the export is completed.
  // For more details refer to https://github.com/dragonflyoss/design/blob/main/systems-analysis/file-download-workflow-with-hard-link/README.md.
  optional string output_path = 5;
  // Download timeout.
  optional google.protobuf.Duration timeout = 6;
  // need_piece_content is the flag to indicate whether the response needs to return piece content.
  bool need_piece_content = 7;
  // force_hard_link is the flag to indicate whether the exported file must be hard linked to the output path.
  // For more details refer to https://github.com/dragonflyoss/design/blob/main/systems-analysis/file-download-workflow-with-hard-link/README.md.
  bool force_hard_link = 8;
  // Verifies task data integrity after download using a digest. Supports CRC32, SHA256, and SHA512 algorithms.
  // Format: `<algorithm>:<hash>`, e.g., `crc32:xxx`, `sha256:yyy`, `sha512:zzz`.
  // Returns an error if the computed digest mismatches the expected value.
  //
  // Performance
  // Digest calculation increases processing time. Enable only when data integrity verification is critical.
  optional string digest = 9;
  // Remote IP represents the IP address of the client initiating the download request.
  optional string remote_ip = 10;
  // Overwrite indicates whether to overwrite the existing file at output path.
  bool overwrite = 11;
}

// DownloadPersistentCacheTaskStartedResponse represents task download started response of DownloadPersistentCacheTaskResponse.
message DownloadPersistentCacheTaskStartedResponse {
  // Task content length.
  uint64 content_length = 1;
}

// DownloadPersistentCacheTaskResponse represents response of DownloadPersistentCacheTask.
message DownloadPersistentCacheTaskResponse {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Peer id.
  string peer_id = 3;

  oneof response {
    DownloadPersistentCacheTaskStartedResponse download_persistent_cache_task_started_response = 4;
    DownloadPieceFinishedResponse download_piece_finished_response = 5;
  }
}

// UploadPersistentCacheTaskRequest represents request of UploadPersistentCacheTask.
message UploadPersistentCacheTaskRequest {
  // content_for_calculating_task_id is the content used to calculate the task id.
  // If content_for_calculating_task_id is set, use its value to calculate the task ID.
  // Otherwise, calculate the task ID based on the file content, tag and application by blake3 algorithm`.
  optional string content_for_calculating_task_id = 1;
  // Upload file path of persistent cache task.
  string path = 2;
  // Replica count of the persistent persistent cache task.
  uint64 persistent_replica_count = 3;
  // Tag is used to distinguish different persistent cache tasks.
  optional string tag = 4;
  // Application of the persistent cache task.
  optional string application = 5;
  // Piece length of the persistent cache task, the value needs to be greater than or equal to 4194304(4MiB).
  optional uint64 piece_length = 6;
  // TTL of the persistent cache task.
  google.protobuf.Duration ttl = 7;
  // Download timeout.
  optional google.protobuf.Duration timeout = 8;
  // Remote IP represents the IP address of the client initiating the upload request.
  optional string remote_ip = 9;
}

// UpdatePersistentCacheTaskRequest represents request of UpdatePersistentCacheTask.
message UpdatePersistentCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Persistent represents whether the persistent cache peer is persistent.
  // If the persistent cache peer is persistent, the persistent cache peer will
  // not be deleted when dfdaemon runs garbage collection. It only be deleted
  // when the task is deleted by the user.
  bool persistent = 2;
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 3;
}

// StatPersistentCacheTaskRequest represents request of StatPersistentCacheTask.
message StatPersistentCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// StatLocalPersistentCacheTaskRequest represents request of StatLocalPersistentCacheTask.
message StatLocalPersistentCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the stat request.
  optional string remote_ip = 2;
}

// StatLocalPersistentTaskResponse represents response of StatLocalPersistentTask.
message StatLocalPersistentCacheTaskResponse {
  // Task id.
  string task_id = 1;
  // Persistent represents whether the persistent cache task is persistent.
  // If the persistent cache task is persistent, the persistent cache peer will
  // not be deleted when dfdamon runs garbage collection.
  bool persistent = 2;
  // TTL of the persistent task.
  google.protobuf.Duration ttl = 3;
  // Task piece length.
  optional uint64 piece_length = 4;
  // Task content length.
  optional uint64 content_length = 5;
  // Uploading count is the count of the persistent cache task being uploaded by other peers.
  uint64 uploading_count = 6;
  // Uploaded count is the count of the persistent cache task has been uploaded by other peers.
  uint64 uploaded_count = 7;
  // Task create time.
  google.protobuf.Timestamp created_at = 8;
  // Task update time.
  google.protobuf.Timestamp updated_at = 9;
  // Task fail time.
  optional google.protobuf.Timestamp failed_at = 10;
  // Task finish time.
  optional google.protobuf.Timestamp finished_at = 11;
}

// ListLocalPersistentCacheTasksRequest represents request of ListLocalPersistentCacheTasks.
message ListLocalPersistentCacheTasksRequest {
  // Remote IP represents the IP address of the client initiating the list request.
  optional string remote_ip = 1;
}

// ListLocalPersistentTasksResponse represents response of ListLocalPersistentTasks.
message ListLocalPersistentCacheTasksResponse {
  // Task ids of the local tasks.
  repeated StatLocalPersistentCacheTaskResponse tasks = 1;
}

// DeletePersistentCacheTaskRequest represents request of DeletePersistentCacheTask.
message DeletePersistentCacheTaskRequest {
  // Task id.
  string task_id = 1;
  // Remote IP represents the IP address of the client initiating the delete request.
  optional string remote_ip = 2;
}

// SyncPersistentCachePiecesRequest represents request of SyncPersistentCachePieces.
message SyncPersistentCachePiecesRequest {
  // Host id.
  string host_id = 1;
  // Task id.
  string task_id = 2;
  // Interested piece numbers.
  repeated uint32 interested_piece_numbers = 3;
}

// SyncPersistentCachePiecesResponse represents response of SyncPersistentCachePieces.
message SyncPersistentCachePiecesResponse {
  // Exist piece number.
  uint32 number = 1;
  // Piece offset.
  uint64 offset = 2;
  // Piece length.
  uint64 length = 3;
  // IP is used to indicate the IP address of the peer. If protocol is rdma,
  // the IP is used to exchange the queue pair endpoint of IBVerbs.
  string ip = 4;
  // TCP port is used to indicate the tcp server port of the peer.
  optional int32 tcp_port = 5;
  // QUIC port is used to indicate the quic server port of the peer.
  optional int32 quic_port = 6;
}

// SyncHostRequest represents request of SyncHost.
message SyncHostRequest {
  // Host id.
  string host_id = 1;
  // Peer id.
  string peer_id = 2;
}

// IBVerbsQueuePairEndpoint represents queue pair endpoint of IBVerbs.
message IBVerbsQueuePairEndpoint {
  // Number of the queue pair.
  uint32 num = 1;
  // Local identifier of the context.
  uint32 lid = 2;
  // Global identifier of the context.
  bytes gid = 3;
}

// DfdaemonUpload represents upload service of dfdaemon.
service DfdaemonUpload {
  // DownloadTask downloads task from p2p network.
  rpc DownloadTask(DownloadTaskRequest) returns (stream DownloadTaskResponse);

  // StatTask stats task information.
  rpc StatTask(StatTaskRequest) returns (common.v2.Task);

  // StatLocalTask stats local task information from peer.
  rpc StatLocalTask(StatLocalTaskRequest) returns (StatLocalTaskResponse);

  // ListTaskEntries lists task entries for downloading directory.
  rpc ListTaskEntries(ListTaskEntriesRequest) returns (ListTaskEntriesResponse);

  // DeleteTask deletes task from p2p network.
  rpc DeleteTask(DeleteTaskRequest) returns (google.protobuf.Empty);

  // SyncPieces syncs piece metadatas from remote peer.
  rpc SyncPieces(SyncPiecesRequest) returns (stream SyncPiecesResponse);

  // DownloadCacheTask downloads cache task from p2p network.
  rpc DownloadCacheTask(DownloadCacheTaskRequest) returns (stream DownloadCacheTaskResponse);

  // StatCacheTask stats cache task information.
  rpc StatCacheTask(StatCacheTaskRequest) returns (common.v2.CacheTask);

  // DeleteCacheTask deletes cache task from p2p network.
  rpc DeleteCacheTask(DeleteCacheTaskRequest) returns (google.protobuf.Empty);

  // SyncCachePieces syncs cache piece metadatas from remote peer.
  rpc SyncCachePieces(SyncCachePiecesRequest) returns (stream SyncCachePiecesResponse);

  // DownloadCachePiece downloads cache piece from the remote peer.
  rpc DownloadCachePiece(DownloadCachePieceRequest) returns (DownloadCachePieceResponse);

  // DownloadPersistentTask downloads persistent task from p2p network.
  rpc DownloadPersistentTask(DownloadPersistentTaskRequest) returns (stream DownloadPersistentTaskResponse);

  // SyncPersistentPieces syncs persistent pieces from remote peer.
  rpc SyncPersistentPieces(SyncPersistentPiecesRequest) returns (stream SyncPersistentPiecesResponse);

  // UpdatePersistentTask updates metadate of thr persistent task in p2p network.
  rpc UpdatePersistentTask(UpdatePersistentTaskRequest) returns (google.protobuf.Empty);

  // StatPersistentTask stats persistent task information.
  rpc StatPersistentTask(StatPersistentTaskRequest) returns (common.v2.PersistentTask);

  // DeletePersistentTask deletes persistent task from p2p network.
  rpc DeletePersistentTask(DeletePersistentTaskRequest) returns (google.protobuf.Empty);

  // DownloadPersistentCacheTask downloads persistent cache task from p2p network.
  rpc DownloadPersistentCacheTask(DownloadPersistentCacheTaskRequest) returns (stream DownloadPersistentCacheTaskResponse);

  // UpdatePersistentCacheTask updates metadate of thr persistent cache task in p2p network.
  rpc UpdatePersistentCacheTask(UpdatePersistentCacheTaskRequest) returns (google.protobuf.Empty);

  // StatPersistentCacheTask stats persistent cache task information.
  rpc StatPersistentCacheTask(StatPersistentCacheTaskRequest) returns (common.v2.PersistentCacheTask);

  // DeletePersistentCacheTask deletes persistent cache task from p2p network.
  rpc DeletePersistentCacheTask(DeletePersistentCacheTaskRequest) returns (google.protobuf.Empty);

  // SyncPersistentCachePieces syncs persistent cache pieces from remote peer.
  rpc SyncPersistentCachePieces(SyncPersistentCachePiecesRequest) returns (stream SyncPersistentCachePiecesResponse);

  // SyncHost sync host info from parents.
  rpc SyncHost(SyncHostRequest) returns (stream common.v2.Host);
}

// DfdaemonDownload represents download service of dfdaemon.
service DfdaemonDownload {
  // DownloadTask downloads task from p2p network.
  rpc DownloadTask(DownloadTaskRequest) returns (stream DownloadTaskResponse);

  // StatTask stats task information.
  rpc StatTask(StatTaskRequest) returns (common.v2.Task);

  // StatLocalTask stats local task information from peer.
  rpc StatLocalTask(StatLocalTaskRequest) returns (StatLocalTaskResponse);

  // ListLocalTasks lists local tasks from peer.
  rpc ListLocalTasks(ListLocalTasksRequest) returns (ListLocalTasksResponse);

  // ListTaskEntries lists task entries for downloading directory.
  rpc ListTaskEntries(ListTaskEntriesRequest) returns (ListTaskEntriesResponse);

  // DeleteTask deletes task from p2p network.
  rpc DeleteTask(DeleteTaskRequest) returns (google.protobuf.Empty);

  // DeleteLocalTask deletes local task from peer.
  rpc DeleteLocalTask(DeleteLocalTaskRequest) returns (google.protobuf.Empty);

  // DeleteHost releases host in scheduler.
  rpc DeleteHost(google.protobuf.Empty) returns (google.protobuf.Empty);

  // DownloadCacheTask downloads cache task from p2p network.
  rpc DownloadCacheTask(DownloadCacheTaskRequest) returns (stream DownloadCacheTaskResponse);

  // StatCacheTask stats cache task information.
  rpc StatCacheTask(StatCacheTaskRequest) returns (common.v2.CacheTask);

  // DeleteCacheTask deletes cache task from p2p network.
  rpc DeleteCacheTask(DeleteCacheTaskRequest) returns (google.protobuf.Empty);

  // DownloadPersistentTask downloads persistent task from p2p network.
  rpc DownloadPersistentTask(DownloadPersistentTaskRequest) returns (stream DownloadPersistentTaskResponse);

  // UploadPersistentTask uploads persistent task to p2p network.
  rpc UploadPersistentTask(UploadPersistentTaskRequest) returns (common.v2.PersistentTask);

  // StatPersistentTask stats persistent task information.
  rpc StatPersistentTask(StatPersistentTaskRequest) returns (common.v2.PersistentTask);

  // StatLocalPersistentTask stats local persistent task information from peer.
  rpc StatLocalPersistentTask(StatLocalPersistentTaskRequest) returns (StatLocalPersistentTaskResponse);

  // ListLocalPersistentTasks lists local persistent tasks from peer.
  rpc ListLocalPersistentTasks(ListLocalPersistentTasksRequest) returns (ListLocalPersistentTasksResponse);

  // DownloadPersistentCacheTask downloads persistent cache task from p2p network.
  rpc DownloadPersistentCacheTask(DownloadPersistentCacheTaskRequest) returns (stream DownloadPersistentCacheTaskResponse);

  // UploadPersistentCacheTask uploads persistent cache task to p2p network.
  rpc UploadPersistentCacheTask(UploadPersistentCacheTaskRequest) returns (common.v2.PersistentCacheTask);

  // StatPersistentCacheTask stats persistent cache task information.
  rpc StatPersistentCacheTask(StatPersistentCacheTaskRequest) returns (common.v2.PersistentCacheTask);

  // StatLocalPersistentCacheTask stats local persistent cache task information from peer.
  rpc StatLocalPersistentCacheTask(StatLocalPersistentCacheTaskRequest) returns (StatLocalPersistentCacheTaskResponse);

  // ListLocalPersistentCacheTasks lists local persistent cache tasks from peer.
  rpc ListLocalPersistentCacheTasks(ListLocalPersistentCacheTasksRequest) returns (ListLocalPersistentCacheTasksResponse);
}