Class UploadFileEntry
java.lang.Object
com.iizix.server.upload.UploadFileEntry
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionlongGets the compressed (on-the-wire) bytes acknowledged so far.Gets the compression the transfer uses, as confirmed by the reservation.longGets the uncompressed size the client declared.Gets the media type the client declared, lower case, empty if none.intGets the file index inside its reservation,0..N-1.getGroup()Gets the group name the client placed the file in.longGets the client's last-modified time.longGets the time of the last progress notification.Gets the original file name as the client sent it.longGets the uncompressed bytes acknowledged so far, for progress.Gets the sidecar record.Gets the reservation the file belongs to.getState()Gets the current state.booleanisFinal()Checks if no further byte is expected: verified, consumed, or terminal.booleanChecks 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.booleanChecks if the App holds the file paused: the servlet refuses its chunks with 423.booleanChecks if the client has reported the file paused; its next chunk is its resume.voidsetLastProgressAt(long now) Records the time of a progress notification.toString()Outputs to string, without the name and without the secret.
Method Details
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:IUploadFileGets the file index inside its reservation,0..N-1. It is part of the upload URL.- Specified by:
getFileIndexin interfaceIUploadFile- Returns:
- The file index.
getReservation
Description copied from interface:IUploadFileGets the reservation the file belongs to.- Specified by:
getReservationin interfaceIUploadFile- Returns:
- The reservation.
getOriginalName
Description copied from interface:IUploadFileGets the original file name as the client sent it. Metadata only: never a path.- Specified by:
getOriginalNamein interfaceIUploadFile- Returns:
- The name.
getDeclaredType
Description copied from interface:IUploadFileGets the media type the client declared, lower case, empty if none.- Specified by:
getDeclaredTypein interfaceIUploadFile- Returns:
- The declared type.
getDeclaredSize
public long getDeclaredSize()Description copied from interface:IUploadFileGets the uncompressed size the client declared.- Specified by:
getDeclaredSizein interfaceIUploadFile- Returns:
- The declared size in bytes.
getLastModified
public long getLastModified()Description copied from interface:IUploadFileGets the client's last-modified time.- Specified by:
getLastModifiedin interfaceIUploadFile- Returns:
- Milliseconds since the epoch, 0 if unknown.
getGroup
Description copied from interface:IUploadFileGets the group name the client placed the file in.- Specified by:
getGroupin interfaceIUploadFile- Returns:
- The group, empty if none.
getCompression
Description copied from interface:IUploadFileGets the compression the transfer uses, as confirmed by the reservation.- Specified by:
getCompressionin interfaceIUploadFile- Returns:
UploadFileRequest.COMPRESSION_NONEorUploadFileRequest.COMPRESSION_GZIP.
getState
Description copied from interface:IUploadFileGets the current state.- Specified by:
getStatein interfaceIUploadFile- Returns:
- The state.
getReason
Description copied from interface:IUploadFile- Specified by:
getReasonin interfaceIUploadFile- 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:IUploadFileGets the uncompressed bytes acknowledged so far, for progress.- Specified by:
getPlainBytesReceivedin interfaceIUploadFile- Returns:
- The plain high-water mark.
getBytesReceived
public long getBytesReceived()Description copied from interface:IUploadFileGets the compressed (on-the-wire) bytes acknowledged so far.- Specified by:
getBytesReceivedin interfaceIUploadFile- 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