8#include <aws/transfer/Transfer_EXPORTS.h>
9#include <aws/core/utils/memory/stl/AWSString.h>
10#include <aws/core/utils/memory/stl/AWSSet.h>
11#include <aws/core/utils/memory/stl/AWSMap.h>
12#include <aws/core/utils/UUID.h>
13#include <aws/core/client/AWSError.h>
14#include <aws/core/client/AsyncCallerContext.h>
15#include <aws/s3/S3Errors.h>
19#include <condition_variable>
25 template <
typename T >
class Array;
51 PartState(
int partId, uint64_t bestProgressInBytes, uint64_t sizeInBytes,
bool lastPart =
false);
63 void OnDataTransferred(uint64_t amount,
const std::shared_ptr<TransferHandle> &transferHandle);
72 void SetDownloadBuffer(
unsigned char* downloadBuffer) { m_downloadBuffer = downloadBuffer; }
87 uint64_t m_currentProgressInBytes = 0;
88 uint64_t m_bestProgressInBytes = 0;
89 uint64_t m_sizeInBytes = 0;
90 uint64_t m_rangeBegin = 0;
92 std::atomic<Aws::IOStream *> m_downloadPartStream;
93 std::atomic<unsigned char*> m_downloadBuffer;
94 bool m_lastPart =
false;
154 const uint64_t fileOffset,
const uint64_t downloadBytes,
297 void SetVersionId(
const Aws::String& versionId) { std::lock_guard<std::mutex> locker(m_getterSetterLock); m_versionId = versionId; }
330 inline void SetContext(
const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) { std::lock_guard<std::mutex> locker(m_getterSetterLock); m_context = context; }
335 inline std::shared_ptr<const Aws::Client::AsyncCallerContext>
GetContext()
const { std::lock_guard<std::mutex> locker(m_getterSetterLock);
return m_context; }
373 bool expected =
false;
374 return m_lastPart.compare_exchange_strong(expected,
true);
384 void CleanupDownloadStream();
386 std::atomic<bool> m_isMultipart;
393 std::atomic<uint64_t> m_bytesTransferred;
394 std::atomic<bool> m_lastPart;
395 std::atomic<uint64_t> m_bytesTotalSize;
396 std::atomic<uint64_t> m_bytesAvailableFromStart;
398 uint32_t m_nextPartToWatch;
408 std::atomic<bool> m_cancel;
409 std::shared_ptr<const Aws::Client::AsyncCallerContext> m_context;
415 uint64_t m_downloadStreamBaseOffset;
417 mutable std::mutex m_downloadStreamLock;
418 mutable std::mutex m_partsLock;
419 mutable std::mutex m_statusLock;
420 mutable std::condition_variable m_waitUntilFinishedSignal;
421 mutable std::mutex m_getterSetterLock;
const Aws::String & GetETag() const
void OnDataTransferred(uint64_t amount, const std::shared_ptr< TransferHandle > &transferHandle)
uint64_t GetBestProgressInBytes() const
void SetDownloadPartStream(Aws::IOStream *downloadPartStream)
unsigned char * GetDownloadBuffer() const
void SetDownloadBuffer(unsigned char *downloadBuffer)
PartState(int partId, uint64_t bestProgressInBytes, uint64_t sizeInBytes, bool lastPart=false)
void SetETag(const Aws::String &eTag)
uint64_t GetRangeBegin() const
void SetRangeBegin(uint64_t rangeBegin)
Aws::String GetChecksum() const
uint64_t GetSizeInBytes() const
void SetSizeInBytes(uint64_t sizeInBytes)
void SetBestProgressInBytes(uint64_t progressInBytes)
void SetChecksum(const Aws::String &checksum)
Aws::IOStream * GetDownloadPartStream() const
const Aws::String & GetKey() const
const Aws::String GetVersionId() const
void WaitUntilFinished() const
bool HasFailedParts() const
uint64_t GetBytesAvailableFromStart() const
std::shared_ptr< const Aws::Client::AsyncCallerContext > GetContext() const
void UpdateStatus(TransferStatus value)
PartStateMap GetPendingParts() const
const Aws::String GetContentType() const
TransferStatus GetStatus() const
PartStateMap GetFailedParts() const
uint64_t GetBytesOffset() const
void AddQueuedPart(const PartPointer &partState)
PartStateMap GetCompletedParts() const
const CreateDownloadStreamCallback & GetCreateDownloadStreamFunction() const
TransferHandle(const Aws::String &bucketName, const Aws::String &keyName, const uint64_t fileOffset, const uint64_t downloadBytes, CreateDownloadStreamCallback createDownloadStreamFn, const Aws::String &targetFilePath="")
TransferHandle(const Aws::String &bucketName, const Aws::String &keyName, const Aws::String &targetFilePath="")
void UpdateBytesTransferred(uint64_t amount)
void ChangePartToCompleted(const PartPointer &partState, const Aws::String &eTag)
uint64_t GetBytesTotalSize() const
bool HasPendingParts() const
void SetBytesTotalSize(uint64_t value)
const Aws::String & GetTargetFilePath() const
void SetMetadata(const Aws::Map< Aws::String, Aws::String > &value)
void SetIsMultipart(bool value)
PartStateMap GetQueuedParts() const
Aws::String GetId() const
const Aws::String GetMultiPartId() const
void SetMultipartId(const Aws::String &value)
TransferHandle(const Aws::String &bucketName, const Aws::String &keyName, uint64_t totalSize, const Aws::String &targetFilePath="")
void SetContext(const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context)
void AddMetadataEntry(const Aws::String &key, const Aws::String &value)
TransferDirection GetTransferDirection() const
Aws::String WritePartToDownloadStream(Aws::IOStream *partStream, uint64_t writeOffset)
const Aws::Map< Aws::String, Aws::String > GetMetadata() const
void AddPendingPart(const PartPointer &partState)
uint64_t GetBytesTransferred() const
bool ShouldContinue() const
const Aws::Client::AWSError< Aws::S3::S3Errors > GetLastError() const
void SetError(const Aws::Client::AWSError< Aws::S3::S3Errors > &error)
TransferHandle(const Aws::String &bucketName, const Aws::String &keyName, CreateDownloadStreamCallback createDownloadStreamFn, const Aws::String &targetFilePath="")
bool HasQueuedParts() const
void ApplyDownloadConfiguration(const DownloadConfiguration &downloadConfig)
void GetAllPartsTransactional(PartStateMap &queuedParts, PartStateMap &pendingParts, PartStateMap &failedParts, PartStateMap &completedParts)
const Aws::String & GetBucketName() const
void SetVersionId(const Aws::String &versionId)
void SetContentType(const Aws::String &value)
void ChangePartToFailed(const PartPointer &partState)
@ EXACT_OBJECT_ALREADY_EXISTS
Aws::Map< int, PartPointer > PartStateMap
static const char CLASS_TAG[]
AWS_TRANSFER_API Aws::OStream & operator<<(Aws::OStream &s, TransferStatus status)
std::shared_ptr< PartState > PartPointer
std::function< Aws::IOStream *(void)> CreateDownloadStreamCallback
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
std::basic_iostream< char, std::char_traits< char > > IOStream
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::basic_ostream< char, std::char_traits< char > > OStream