Class FRAG4

  • All Implemented Interfaces:
    Lifecycle

    public class FRAG4
    extends FRAG2
    Fragmentation layer. Fragments messages larger than frag_size into smaller packets. Reassembles fragmented packets into bigger ones. The fragmentation ID is added to the messages as a header (and removed at the receiving side).
    Each fragment is identified by (a) the sender (part of the message to which the header is appended), (b) the fragmentation ID (which is unique (monotonically increasing) and (c) the fragement ID which ranges from 0 to number_of_fragments-1.
    Requirement: lossless delivery (e.g. NAKACK2, UNICAST3). No requirement on ordering. Works for both unicast and multicast messages.
    Compared to FRAG2, this protocol does not need to serialize the message in order to break it into smaller fragments: if the message is a BytesMessage, then we send all fragments with a reference to the original message's byte array, plus and offset and length. Otherwise, we use a number of FragmentedMessage instances, with a reference to the original message and also an offset and length. These serialize messages at the last possible moment, just before being sent by the transport.
    Version:
    5.0
    Author:
    Bela Ban
    • Constructor Detail

      • FRAG4

        public FRAG4()
    • Method Detail

      • fragment

        protected void fragment​(Message msg)
        Description copied from class: FRAG2
        Send all fragments as separate messages (with same ID !). Example:
             Given the generated ID is 2344, number of fragments=3, message {dst,src,buf}
             would be fragmented into:
        
             [2344,3,0]{dst,src,buf1},
             [2344,3,1]{dst,src,buf2} and
             [2344,3,2]{dst,src,buf3}
             
        Overrides:
        fragment in class FRAG2
      • assembleMessage

        protected Message assembleMessage​(Message[] fragments,
                                          boolean needs_deserialization,
                                          FragHeader hdr)
                                   throws java.lang.Exception
        Description copied from class: FRAG2
        Assembles all the message fragments into one message. This method does not check if the fragmentation is complete (use FRAG2.FragEntry.isComplete() to verify) before calling this method)
        Overrides:
        assembleMessage in class FRAG2
        Returns:
        the complete message
        Throws:
        java.lang.Exception