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
|
#ifndef AWS_S3_AUTO_RANGED_PUT_H
#define AWS_S3_AUTO_RANGED_PUT_H
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include "aws/s3/private/s3_meta_request_impl.h"
#include "s3_paginator.h"
enum aws_s3_auto_ranged_put_request_tag {
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_LIST_PARTS,
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_CREATE_MULTIPART_UPLOAD,
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_PART,
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_ABORT_MULTIPART_UPLOAD,
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_COMPLETE_MULTIPART_UPLOAD,
AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_MAX,
};
struct aws_s3_auto_ranged_put {
struct aws_s3_meta_request base;
/* Initialized either during creation in resume flow or as result of create multipart upload during normal flow. */
struct aws_string *upload_id;
/* Resume token used to resume the operation */
struct aws_s3_meta_request_resume_token *resume_token;
uint64_t content_length;
/* Only meant for use in the update function, which is never called concurrently. */
struct {
/*
* Next part number to send.
* Note: this follows s3 part number convention and counting starts with 1.
* Throughout codebase 0 based part numbers are usually referred to as part index.
*/
uint32_t next_part_number;
} threaded_update_data;
/*
* Should only be used during prepare requests. Note: stream reads must be sequential,
* so prepare currently never runs concurrently with another prepare
*/
struct {
/*
* How many parts have been read from input steam.
* Since reads are always sequential, this is essentially the number of how many parts were read from start of
* stream.
*/
uint32_t num_parts_read_from_stream;
} prepare_data;
/*
* Very similar to the etag_list used in complete_multipart_upload to create the XML payload. Each part will set the
* corresponding index to it's checksum result, so while the list is shared across threads each index will only be
* accessed once to initialize by the corresponding part number, and then again during the complete multipart upload
* request which will only be invoked after all other parts/threads have completed.
*/
struct aws_byte_buf *encoded_checksum_list;
/* Members to only be used when the mutex in the base type is locked. */
struct {
/* Array list of `struct aws_string *`. */
struct aws_array_list etag_list;
struct aws_s3_paginated_operation *list_parts_operation;
struct aws_string *list_parts_continuation_token;
uint32_t total_num_parts;
uint32_t num_parts_sent;
uint32_t num_parts_completed;
uint32_t num_parts_successful;
uint32_t num_parts_failed;
struct aws_http_headers *needed_response_headers;
int list_parts_error_code;
int create_multipart_upload_error_code;
int complete_multipart_upload_error_code;
int abort_multipart_upload_error_code;
uint32_t list_parts_sent : 1;
uint32_t list_parts_completed : 1;
uint32_t create_multipart_upload_sent : 1;
uint32_t create_multipart_upload_completed : 1;
uint32_t complete_multipart_upload_sent : 1;
uint32_t complete_multipart_upload_completed : 1;
uint32_t abort_multipart_upload_sent : 1;
uint32_t abort_multipart_upload_completed : 1;
} synced_data;
};
/* Creates a new auto-ranged put meta request. This will do a multipart upload in parallel when appropriate. */
struct aws_s3_meta_request *aws_s3_meta_request_auto_ranged_put_new(
struct aws_allocator *allocator,
struct aws_s3_client *client,
size_t part_size,
uint64_t content_length,
uint32_t num_parts,
const struct aws_s3_meta_request_options *options);
#endif
|