Class ChunkSessionInformation

java.lang.Object
eu.cloudnetservice.driver.network.chunk.ChunkSessionInformation
All Implemented Interfaces:
DataBufable, Closeable, AutoCloseable

public final class ChunkSessionInformation extends Object implements DataBufable, Closeable
Contains all needed information for a chunked data transfer to be initialized. The transfer information in this object are there to allow writes of additional information needed for the transfer to work, for example the target file name.
Since:
4.0
  • Field Details

    • chunkSize

      private int chunkSize
    • sessionUniqueId

      private UUID sessionUniqueId
    • transferChannel

      private String transferChannel
    • transferInformation

      private DataBuf transferInformation
  • Constructor Details

    • ChunkSessionInformation

      @Internal public ChunkSessionInformation()
      Used for network deserialization.
    • ChunkSessionInformation

      public ChunkSessionInformation(int chunkSize, @NonNull @NonNull UUID sessionUniqueId, @NonNull @NonNull String transferChannel, @NonNull @NonNull DataBuf transferInformation)
      Constructs a new chunk session information.
      Parameters:
      chunkSize - the size of data transferred in each chunk, should always be the exact amount of bytes.
      sessionUniqueId - the unique id of the transfer session, for identification reasons.
      transferChannel - the name of the channel the data is transferred in, for identification reasons.
      transferInformation - additional information for the transfer handler to handle the chunks correctly.
      Throws:
      NullPointerException - if the given session id, transfer channel or transfer information buffer is null.
  • Method Details

    • writeData

      public void writeData(@NonNull DataBuf.Mutable dataBuf)
      Writes all needed data from this object into the given data buf.
      Specified by:
      writeData in interface DataBufable
      Parameters:
      dataBuf - the buffer to write the data to.
    • readData

      public void readData(@NonNull @NonNull DataBuf dataBuf)
      Reads all data of this object from the given buffer. The deserializer uses the no-args constructor which must be available in this class and creates an empty instance of this class. This method is then responsible to fill the object data.

      The given buffer should NEVER be read from more than written into the buffer in the write method.

      Specified by:
      readData in interface DataBufable
      Parameters:
      dataBuf - the data buf to read the class data from.
    • chunkSize

      public int chunkSize()
      Get the size of a single chunk in the transfer.
      Returns:
      the size of a single chunk in the transfer.
    • sessionUniqueId

      @NonNull public @NonNull UUID sessionUniqueId()
      Get the session unique id.
      Returns:
      the session unique id.
    • transferChannel

      @NonNull public @NonNull String transferChannel()
      Get the transfer channel identifier.
      Returns:
      the transfer channel identifier.
    • transferInformation

      @NonNull public @NonNull DataBuf transferInformation()
      Get the buffer containing additional information about the transfer.
      Returns:
      the buffer containing additional information about the transfer.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • equals

      public boolean equals(@Nullable @Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @NonNull public @NonNull String toString()
      Overrides:
      toString in class Object