Package org.jgroups.protocols
Class FRAG4
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.Fragmentation
-
- org.jgroups.protocols.FRAG2
-
- org.jgroups.protocols.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 toFRAG2
, this protocol does not need to serialize the message in order to break it into smaller fragments: if the message is aBytesMessage
, 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 ofFragmentedMessage
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.protocols.FRAG2
FRAG2.FragEntry
-
-
Field Summary
-
Fields inherited from class org.jgroups.protocols.FRAG2
avg_size_down, avg_size_up, curr_id, fragment_list, HAS_FRAG_HEADER, members
-
Fields inherited from class org.jgroups.protocols.Fragmentation
frag_size, num_frags_received, num_frags_sent
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description FRAG4()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Message
assembleMessage(Message[] fragments, boolean needs_deserialization, FragHeader hdr)
Assembles all the message fragments into one message.protected void
fragment(Message msg)
Send all fragments as separate messages (with same ID !).-
Methods inherited from class org.jgroups.protocols.FRAG2
clearAllFragments, clearFragmentsFor, down, down, getAvgSizeDown, getAvgSizeUp, getNextId, handleViewChange, init, resetStats, unfragment, up, up, up
-
Methods inherited from class org.jgroups.protocols.Fragmentation
getFragSize, getNumberOfReceivedFragments, getNumberOfSentFragments, setFragSize
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop, toString
-
-
-
-
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}
-
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 (useFRAG2.FragEntry.isComplete()
to verify) before calling this method)- Overrides:
assembleMessage
in classFRAG2
- Returns:
- the complete message
- Throws:
java.lang.Exception
-
-