Class FragmentationInterceptor.FragCollection

  • Enclosing class:
    FragmentationInterceptor

    public static class FragmentationInterceptor.FragCollection
    extends java.lang.Object
    Collection that holds the fragments of a message for reassembly.
    • Constructor Summary

      Constructors 
      Constructor Description
      FragCollection​(ChannelMessage msg)
      Creates a new fragment collection for the given message.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMessage​(ChannelMessage msg)
      Adds a fragment message to this collection.
      ChannelMessage assemble()
      Assembles all fragments into a single complete message.
      ChannelMessage assembleIfComplete()
      Assembles the complete message if all fragments have been received and this collection has not been assembled before.
      boolean complete()
      Checks if all fragments have been received.
      boolean expired​(long expire)
      Checks if this fragment collection has expired.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FragCollection

        public FragCollection​(ChannelMessage msg)
        Creates a new fragment collection for the given message.
        Parameters:
        msg - The channel message containing fragment metadata
    • Method Detail

      • addMessage

        public void addMessage​(ChannelMessage msg)
        Adds a fragment message to this collection.
        Parameters:
        msg - The fragment message to add
      • complete

        public boolean complete()
        Checks if all fragments have been received.
        Returns:
        true if all fragments are present
      • assemble

        public ChannelMessage assemble()
        Assembles all fragments into a single complete message.
        Returns:
        The assembled channel message
        Throws:
        java.lang.IllegalStateException - if not all fragments have been received
      • assembleIfComplete

        public ChannelMessage assembleIfComplete()
        Assembles the complete message if all fragments have been received and this collection has not been assembled before. The one-shot guarantee makes the completion of a message delivered exactly once, even when the last fragments are processed concurrently on multiple threads.
        Returns:
        The assembled channel message, or null if the message is incomplete or was assembled by an earlier call
      • expired

        public boolean expired​(long expire)
        Checks if this fragment collection has expired.
        Parameters:
        expire - The expiration time in milliseconds
        Returns:
        true if the collection has expired