Class UploadFileEntry

java.lang.Object
com.iizix.server.upload.UploadFileEntry
All Implemented Interfaces:
IUploadFile

public final class UploadFileEntry extends Object implements IUploadFile
The in-memory side of one file of a reservation: its sidecar record, its secret (memory only, never on disk, never logged) and the flags the registry keeps per file.

All mutation goes through the registry under the reservation's lock; the getters are safe to call from any thread because every mutable field is volatile or read through the record that the registry replaces atomically.

Author:
Christopher Mindus
  • Method Details

    • getRecord

      public FileRecord getRecord()
      Gets the sidecar record. Mutate it only under the reservation lock, through the registry.
      Returns:
      The record.
    • getLastProgressAt

      public long getLastProgressAt()
      Gets the time of the last progress notification.
      Returns:
      Milliseconds, 0 for none yet.
    • setLastProgressAt

      public void setLastProgressAt(long now)
      Records the time of a progress notification.
      Parameters:
      now - Milliseconds.
    • isInterruptPending

      public boolean isInterruptPending()
      Checks if a call that stops this file is waiting for the reservation lock: the App paused it or somebody cancelled it while a chunk of the reservation was in flight. The servlet reads it while it holds the lock, and then gives up the chunk it is receiving.
      Returns:
      true if the chunk in flight is to be given up.
    • getFileIndex

      public int getFileIndex()
      Description copied from interface: IUploadFile
      Gets the file index inside its reservation, 0..N-1. It is part of the upload URL.
      Specified by:
      getFileIndex in interface IUploadFile
      Returns:
      The file index.
    • getReservation

      public IUploadReservation getReservation()
      Description copied from interface: IUploadFile
      Gets the reservation the file belongs to.
      Specified by:
      getReservation in interface IUploadFile
      Returns:
      The reservation.
    • getOriginalName

      public String getOriginalName()
      Description copied from interface: IUploadFile
      Gets the original file name as the client sent it. Metadata only: never a path.
      Specified by:
      getOriginalName in interface IUploadFile
      Returns:
      The name.
    • getDeclaredType

      public String getDeclaredType()
      Description copied from interface: IUploadFile
      Gets the media type the client declared, lower case, empty if none.
      Specified by:
      getDeclaredType in interface IUploadFile
      Returns:
      The declared type.
    • getDeclaredSize

      public long getDeclaredSize()
      Description copied from interface: IUploadFile
      Gets the uncompressed size the client declared.
      Specified by:
      getDeclaredSize in interface IUploadFile
      Returns:
      The declared size in bytes.
    • getLastModified

      public long getLastModified()
      Description copied from interface: IUploadFile
      Gets the client's last-modified time.
      Specified by:
      getLastModified in interface IUploadFile
      Returns:
      Milliseconds since the epoch, 0 if unknown.
    • getGroup

      public String getGroup()
      Description copied from interface: IUploadFile
      Gets the group name the client placed the file in.
      Specified by:
      getGroup in interface IUploadFile
      Returns:
      The group, empty if none.
    • getCompression

      public String getCompression()
      Description copied from interface: IUploadFile
      Gets the compression the transfer uses, as confirmed by the reservation.
      Specified by:
      getCompression in interface IUploadFile
      Returns:
      UploadFileRequest.COMPRESSION_NONE or UploadFileRequest.COMPRESSION_GZIP.
    • getState

      public UploadState getState()
      Description copied from interface: IUploadFile
      Gets the current state.
      Specified by:
      getState in interface IUploadFile
      Returns:
      The state.
    • getReason

      public String getReason()
      Description copied from interface: IUploadFile
      Specified by:
      getReason in interface IUploadFile
      Returns:
      The reason, or null while none applies.
    • isPausedByApp

      public boolean isPausedByApp()
      Checks if the App holds the file paused: the servlet refuses its chunks with 423.
      Returns:
      true if paused by the App.
    • isPausedByClient

      public boolean isPausedByClient()
      Checks if the client has reported the file paused; its next chunk is its resume.
      Returns:
      true if paused by the client.
    • getPlainBytesReceived

      public long getPlainBytesReceived()
      Description copied from interface: IUploadFile
      Gets the uncompressed bytes acknowledged so far, for progress.
      Specified by:
      getPlainBytesReceived in interface IUploadFile
      Returns:
      The plain high-water mark.
    • getBytesReceived

      public long getBytesReceived()
      Description copied from interface: IUploadFile
      Gets the compressed (on-the-wire) bytes acknowledged so far.
      Specified by:
      getBytesReceived in interface IUploadFile
      Returns:
      The compressed high-water mark.
    • isFinal

      public boolean isFinal()
      Checks if no further byte is expected: verified, consumed, or terminal.
      Returns:
      true if final.
    • toString

      public String toString()
      Outputs to string, without the name and without the secret.
      Overrides:
      toString in class Object