| Directory: | cvmfs/ |
|---|---|
| File: | cvmfs/ingestion/task_write.cc |
| Date: | 2025-11-30 02:35:17 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 35 | 39 | 89.7% |
| 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 | 19267540 | void TaskWrite::OnBlockComplete(const upload::UploaderResults &results, | |
| 16 | BlockItem *block_item) { | ||
| 17 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19267540 times.
|
19267540 | if (results.return_code != 0) { |
| 18 | ✗ | PANIC(kLogStderr, "block upload failed (code: %d)", results.return_code); | |
| 19 | } | ||
| 20 | |||
| 21 |
1/2✓ Branch 0 taken 19267540 times.
✗ Branch 1 not taken.
|
19267540 | delete block_item; |
| 22 | 19267540 | } | |
| 23 | |||
| 24 | |||
| 25 | 11523532 | void TaskWrite::OnChunkComplete(const upload::UploaderResults &results, | |
| 26 | ChunkItem *chunk_item) { | ||
| 27 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11523532 times.
|
11523532 | if (results.return_code != 0) { |
| 28 | ✗ | PANIC(kLogStderr, "chunk upload failed (code: %d)", results.return_code); | |
| 29 | } | ||
| 30 | |||
| 31 | 11523532 | FileItem *file_item = chunk_item->file_item(); | |
| 32 |
1/2✓ Branch 3 taken 11523532 times.
✗ Branch 4 not taken.
|
23047064 | file_item->RegisterChunk(FileChunk( |
| 33 | 11523532 | *chunk_item->hash_ptr(), chunk_item->offset(), chunk_item->size())); | |
| 34 |
1/2✓ Branch 0 taken 11523532 times.
✗ Branch 1 not taken.
|
11523532 | delete chunk_item; |
| 35 | |||
| 36 |
2/2✓ Branch 1 taken 11503338 times.
✓ Branch 2 taken 20194 times.
|
11523532 | if (file_item->IsProcessed()) { |
| 37 | 11503338 | tubes_out_->DispatchAny(file_item); | |
| 38 | } | ||
| 39 | 11523532 | } | |
| 40 | |||
| 41 | |||
| 42 | 30773270 | void TaskWrite::Process(BlockItem *input_block) { | |
| 43 | 30773270 | ChunkItem *chunk_item = input_block->chunk_item(); | |
| 44 | |||
| 45 | 30772396 | upload::UploadStreamHandle *handle = chunk_item->upload_handle(); | |
| 46 |
2/2✓ Branch 0 taken 11521094 times.
✓ Branch 1 taken 19250106 times.
|
30771200 | if (handle == NULL) { |
| 47 | // The closure passed here, is called by the AbstractUploader as soon as | ||
| 48 | // it successfully committed the complete chunk | ||
| 49 | 34564156 | handle = uploader_->InitStreamedUpload( | |
| 50 |
2/4✓ Branch 1 taken 11521462 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11521600 times.
✗ Branch 5 not taken.
|
11521094 | upload::AbstractUploader::MakeClosure( |
| 51 | &TaskWrite::OnChunkComplete, this, chunk_item)); | ||
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11521600 times.
|
11521600 | assert(handle != NULL); |
| 53 | 11521600 | chunk_item->set_upload_handle(handle); | |
| 54 | } | ||
| 55 | |||
| 56 |
2/3✓ Branch 1 taken 19256408 times.
✓ Branch 2 taken 11520450 times.
✗ Branch 3 not taken.
|
30770970 | switch (input_block->type()) { |
| 57 | 19256408 | case BlockItem::kBlockData: | |
| 58 |
1/2✓ Branch 2 taken 19265700 times.
✗ Branch 3 not taken.
|
19254016 | uploader_->ScheduleUpload( |
| 59 | handle, | ||
| 60 | 19253694 | upload::AbstractUploader::UploadBuffer(input_block->size(), | |
| 61 | 19253786 | input_block->data()), | |
| 62 |
1/2✓ Branch 1 taken 19253786 times.
✗ Branch 2 not taken.
|
19256408 | upload::AbstractUploader::MakeClosure( |
| 63 | &TaskWrite::OnBlockComplete, this, input_block)); | ||
| 64 | 19265700 | break; | |
| 65 | 11520450 | case BlockItem::kBlockStop: | |
| 66 | // If there is a sole piece and a legacy bulk chunk, two times the same | ||
| 67 | // chunk is being uploaded. Well. It doesn't hurt. | ||
| 68 |
2/2✓ Branch 1 taken 46 times.
✓ Branch 2 taken 11520726 times.
|
11520450 | if (chunk_item->IsSolePiece()) { |
| 69 |
1/2✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
|
46 | chunk_item->MakeBulkChunk(); |
| 70 | } | ||
| 71 |
1/2✓ Branch 2 taken 11522612 times.
✗ Branch 3 not taken.
|
11520772 | uploader_->ScheduleCommit(handle, *chunk_item->hash_ptr()); |
| 72 |
1/2✓ Branch 0 taken 11522612 times.
✗ Branch 1 not taken.
|
11522612 | delete input_block; |
| 73 | 11522888 | break; | |
| 74 | ✗ | default: | |
| 75 | ✗ | PANIC(NULL); | |
| 76 | } | ||
| 77 | 30788588 | } | |
| 78 |