Class DefaultTransferProgress
java.lang.Object
software.amazon.awssdk.transfer.s3.internal.progress.DefaultTransferProgress
- All Implemented Interfaces:
TransferProgress
@Mutable
@ThreadSafe
@SdkInternalApi
public final class DefaultTransferProgress
extends Object
implements TransferProgress
An SDK-internal implementation of
TransferProgress. The transferred byte count is kept in an AtomicLong and the
rest of the snapshot in an AtomicReference. snapshot() combines the two, while TransferProgressUpdater
is responsible for updating them.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongaddTransferredBytes(long numBytes) AddsnumBytes, which may be negative, to the transferred byte count and returns the new count.booleanReturns whether the total size of the transfer is known.booleanreachesTotalBytes(long numBytes) Returns whethernumBytesreaches the total size of the transfer, orfalseif the total is unknown.voidSets the transferred byte count to zero.snapshot()Takes a snapshot of the current progress, represented by an immutableTransferProgressSnapshot.snapshot(long numBytes) Returns the latest snapshot with its transferred byte count set tonumBytes, capped to[0, totalBytes].toString()Atomically updates the total bytes or response of the latest snapshot and returns the result.
-
Constructor Details
-
DefaultTransferProgress
-
-
Method Details
-
updateAndGet
public TransferProgressSnapshot updateAndGet(Consumer<DefaultTransferProgressSnapshot.Builder> updater) Atomically updates the total bytes or response of the latest snapshot and returns the result. The updater sees the current transferred byte count but must not change it.- Throws:
IllegalArgumentException- if the updater changes the transferred byte count
-
addTransferredBytes
public long addTransferredBytes(long numBytes) AddsnumBytes, which may be negative, to the transferred byte count and returns the new count. -
resetTransferredBytes
public void resetTransferredBytes()Sets the transferred byte count to zero. -
hasTotalBytes
public boolean hasTotalBytes()Returns whether the total size of the transfer is known. -
reachesTotalBytes
public boolean reachesTotalBytes(long numBytes) Returns whethernumBytesreaches the total size of the transfer, orfalseif the total is unknown. -
snapshot
Returns the latest snapshot with its transferred byte count set tonumBytes, capped to[0, totalBytes]. -
snapshot
Description copied from interface:TransferProgressTakes a snapshot of the current progress, represented by an immutableTransferProgressSnapshot.- Specified by:
snapshotin interfaceTransferProgress
-
toString
-