Package org.jgroups
Class FragmentedMessage
- java.lang.Object
-
- org.jgroups.BaseMessage
-
- org.jgroups.BytesMessage
-
- org.jgroups.FragmentedMessage
-
- All Implemented Interfaces:
Constructable<Message>,Message,SizeStreamable,Streamable
public class FragmentedMessage extends BytesMessage
A message which refers to another message, but only marshals (Streamable.writeTo(DataOutput)) a part of the original message, starting at a givenBytesMessage.offsetand marshalling onlyBytesMessage.lengthbytes.
The marshalling is done usingPartialOutputStream.
Used byFRAG4.- Since:
- 5.0
- Author:
- Bela Ban
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jgroups.Message
Message.Flag, Message.TransientFlag
-
-
Field Summary
Fields Modifier and Type Field Description protected Messageoriginal_msg-
Fields inherited from class org.jgroups.BytesMessage
array, length, offset
-
Fields inherited from class org.jgroups.BaseMessage
dest, flags, headers, sender, transient_flags
-
Fields inherited from interface org.jgroups.Message
BYTES_MSG, COMPOSITE_MSG, EARLYBATCH_MSG, EMPTY_MSG, FRAG_MSG, LONG_MSG, NIO_MSG, OBJ_MSG
-
-
Constructor Summary
Constructors Constructor Description FragmentedMessage()FragmentedMessage(Message original_msg, int off, int len)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MessagecopyPayload(Message copy)Copies the byte array.java.util.function.Supplier<Message>create()Creates an instance of the class implementing this interfaceprotected <T extends BytesMessage>
TcreateMessage()MessagegetOriginalMessage()shortgetType()Returns the type of the message, e.g.booleanhasArray()Returns true if this message has a byte[] array as payload (even if it's null!), false otherwisebooleanhasPayload()Returns true if the message has a payload, e.g.protected intpayloadSize()voidreadPayload(java.io.DataInput in)java.lang.StringtoString()voidwritePayload(java.io.DataOutput out)-
Methods inherited from class org.jgroups.BytesMessage
getArray, getBytes, getLength, getObject, getObject, getOffset, setArray, setArray, setFlag, setObject
-
Methods inherited from class org.jgroups.BaseMessage
clearFlag, clearFlag, clearHeaders, copy, createHeaders, getDest, getFlags, getHeader, getHeaders, getNumHeaders, getPayload, getSrc, headers, headers, isFlagSet, isFlagSet, printHeaders, putHeader, putHeader, putHeaderIfAbsent, readFrom, serializedSize, setDest, setFlag, setFlag, setFlagIfAbsent, setPayload, setSrc, size, sizeNoAddrs, writeTo, writeToNoAddrs
-
-
-
-
Field Detail
-
original_msg
protected Message original_msg
-
-
Constructor Detail
-
FragmentedMessage
public FragmentedMessage()
-
FragmentedMessage
public FragmentedMessage(Message original_msg, int off, int len)
-
-
Method Detail
-
getOriginalMessage
public Message getOriginalMessage()
-
getType
public short getType()
Description copied from interface:MessageReturns the type of the message, e.g. BYTES_MSG, OBJ_MSG etc- Specified by:
getTypein interfaceMessage- Overrides:
getTypein classBytesMessage
-
hasArray
public boolean hasArray()
Description copied from interface:MessageReturns true if this message has a byte[] array as payload (even if it's null!), false otherwise- Specified by:
hasArrayin interfaceMessage- Overrides:
hasArrayin classBytesMessage
-
hasPayload
public boolean hasPayload()
Description copied from interface:MessageReturns true if the message has a payload, e.g. a byte[] array in aBytesMessageor an object in anObjectMessage. This is more generic thanMessage.hasArray(), as it is not just applicable to a byte array.- Specified by:
hasPayloadin interfaceMessage- Overrides:
hasPayloadin classBytesMessage- Returns:
- True if the message has a payload
-
create
public java.util.function.Supplier<Message> create()
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<Message>- Overrides:
createin classBytesMessage
-
payloadSize
protected int payloadSize()
- Overrides:
payloadSizein classBytesMessage
-
copyPayload
protected Message copyPayload(Message copy)
Description copied from class:BytesMessageCopies the byte array. If offset and length are used (to refer to another array), the copy will contain only the subset that offset and length point to, copying the subset into the new copy. Note that for headers, only the arrays holding references to the headers are copied, not the headers themselves ! The consequence is that the headers array of the copy hold the *same* references as the original, so do *not* modify the headers ! If you want to change a header, copy it and callBaseMessage.putHeader(short,Header)again.- Overrides:
copyPayloadin classBytesMessage
-
writePayload
public void writePayload(java.io.DataOutput out) throws java.io.IOException- Specified by:
writePayloadin interfaceMessage- Overrides:
writePayloadin classBytesMessage- Throws:
java.io.IOException
-
readPayload
public void readPayload(java.io.DataInput in) throws java.io.IOException- Specified by:
readPayloadin interfaceMessage- Overrides:
readPayloadin classBytesMessage- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBaseMessage
-
createMessage
protected <T extends BytesMessage> T createMessage()
- Overrides:
createMessagein classBytesMessage
-
-