Directory: | cvmfs/ |
---|---|
File: | cvmfs/ingestion/task_write.cc |
Date: | 2025-02-09 02:34:19 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 34 | 38 | 89.5% |
Branches: | 21 | 35 | 60.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /** | ||
2 | * This file is part of the CernVM File System. | ||
3 | */ | ||
4 | |||
5 | |||
6 | #include "task_write.h" | ||
7 | |||
8 | #include <cstdlib> | ||
9 | |||
10 | #include "upload_facility.h" | ||
11 | #include "util/exception.h" | ||
12 | #include "util/logging.h" | ||
13 | |||
14 | |||
15 | 418870 | void TaskWrite::OnBlockComplete( | |
16 | const upload::UploaderResults &results, | ||
17 | BlockItem *block_item) | ||
18 | { | ||
19 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 418870 times.
|
418870 | if (results.return_code != 0) { |
20 | ✗ | PANIC(kLogStderr, "block upload failed (code: %d)", results.return_code); | |
21 | } | ||
22 | |||
23 |
1/2✓ Branch 0 taken 418870 times.
✗ Branch 1 not taken.
|
418870 | delete block_item; |
24 | 418870 | } | |
25 | |||
26 | |||
27 | 250522 | void TaskWrite::OnChunkComplete( | |
28 | const upload::UploaderResults &results, | ||
29 | ChunkItem *chunk_item) | ||
30 | { | ||
31 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 250522 times.
|
250522 | if (results.return_code != 0) { |
32 | ✗ | PANIC(kLogStderr, "chunk upload failed (code: %d)", results.return_code); | |
33 | } | ||
34 | |||
35 | 250522 | FileItem *file_item = chunk_item->file_item(); | |
36 |
1/2✓ Branch 4 taken 250522 times.
✗ Branch 5 not taken.
|
501044 | file_item->RegisterChunk(FileChunk(*chunk_item->hash_ptr(), |
37 | 250522 | chunk_item->offset(), | |
38 | chunk_item->size())); | ||
39 |
1/2✓ Branch 0 taken 250522 times.
✗ Branch 1 not taken.
|
250522 | delete chunk_item; |
40 | |||
41 |
2/2✓ Branch 1 taken 250083 times.
✓ Branch 2 taken 439 times.
|
250522 | if (file_item->IsProcessed()) { |
42 | 250083 | tubes_out_->DispatchAny(file_item); | |
43 | } | ||
44 | 250522 | } | |
45 | |||
46 | |||
47 | 668728 | void TaskWrite::Process(BlockItem *input_block) { | |
48 | 668728 | ChunkItem *chunk_item = input_block->chunk_item(); | |
49 | |||
50 | 668668 | upload::UploadStreamHandle *handle = chunk_item->upload_handle(); | |
51 |
2/2✓ Branch 0 taken 250353 times.
✓ Branch 1 taken 418278 times.
|
668631 | if (handle == NULL) { |
52 | // The closure passed here, is called by the AbstractUploader as soon as | ||
53 | // it successfully committed the complete chunk | ||
54 | 751174 | handle = uploader_->InitStreamedUpload( | |
55 |
2/4✓ Branch 1 taken 250380 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250441 times.
✗ Branch 5 not taken.
|
250353 | upload::AbstractUploader::MakeClosure( |
56 | &TaskWrite::OnChunkComplete, this, chunk_item)); | ||
57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 250441 times.
|
250441 | assert(handle != NULL); |
58 | 250441 | chunk_item->set_upload_handle(handle); | |
59 | } | ||
60 | |||
61 |
2/3✓ Branch 1 taken 418519 times.
✓ Branch 2 taken 250394 times.
✗ Branch 3 not taken.
|
668670 | switch (input_block->type()) { |
62 | 418519 | case BlockItem::kBlockData: | |
63 |
1/2✓ Branch 2 taken 418837 times.
✗ Branch 3 not taken.
|
418443 | uploader_->ScheduleUpload( |
64 | handle, | ||
65 | upload::AbstractUploader::UploadBuffer( | ||
66 | 418451 | input_block->size(), input_block->data()), | |
67 |
1/2✓ Branch 1 taken 418499 times.
✗ Branch 2 not taken.
|
418519 | upload::AbstractUploader::MakeClosure( |
68 | &TaskWrite::OnBlockComplete, this, input_block)); | ||
69 | 418837 | break; | |
70 | 250394 | case BlockItem::kBlockStop: | |
71 | // If there is a sole piece and a legacy bulk chunk, two times the same | ||
72 | // chunk is being uploaded. Well. It doesn't hurt. | ||
73 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 250386 times.
|
250394 | if (chunk_item->IsSolePiece()) { |
74 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | chunk_item->MakeBulkChunk(); |
75 | } | ||
76 |
1/2✓ Branch 2 taken 250501 times.
✗ Branch 3 not taken.
|
250387 | uploader_->ScheduleCommit(handle, *chunk_item->hash_ptr()); |
77 |
1/2✓ Branch 0 taken 250502 times.
✗ Branch 1 not taken.
|
250501 | delete input_block; |
78 | 250518 | break; | |
79 | ✗ | default: | |
80 | ✗ | PANIC(NULL); | |
81 | } | ||
82 | 669355 | } | |
83 |