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 Details

  • Method Details

    • updateAndGet

      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)
      Adds numBytes, 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 whether numBytes reaches the total size of the transfer, or false if the total is unknown.
    • snapshot

      public TransferProgressSnapshot snapshot(long numBytes)
      Returns the latest snapshot with its transferred byte count set to numBytes, capped to [0, totalBytes].
    • snapshot

      public TransferProgressSnapshot snapshot()
      Description copied from interface: TransferProgress
      Takes a snapshot of the current progress, represented by an immutable TransferProgressSnapshot.
      Specified by:
      snapshot in interface TransferProgress
    • toString

      public String toString()
      Overrides:
      toString in class Object