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.offset
and marshalling onlyBytesMessage.length
bytes.
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 Message
original_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 Message
copyPayload(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()
Message
getOriginalMessage()
short
getType()
Returns the type of the message, e.g.boolean
hasArray()
Returns true if this message has a byte[] array as payload (even if it's null!), false otherwiseboolean
hasPayload()
Returns true if the message has a payload, e.g.void
readPayload(java.io.DataInput in)
protected int
sizeOfPayload()
java.lang.String
toString()
void
writePayload(java.io.DataOutput out)
-
Methods inherited from class org.jgroups.BytesMessage
getArray, getLength, getObject, getObject, getOffset, setArray, setArray, setFlag, setObject, size
-
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, 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:Message
Returns the type of the message, e.g. BYTES_MSG, OBJ_MSG etc- Specified by:
getType
in interfaceMessage
- Overrides:
getType
in classBytesMessage
-
hasArray
public boolean hasArray()
Description copied from interface:Message
Returns true if this message has a byte[] array as payload (even if it's null!), false otherwise- Specified by:
hasArray
in interfaceMessage
- Overrides:
hasArray
in classBytesMessage
-
hasPayload
public boolean hasPayload()
Description copied from interface:Message
Returns true if the message has a payload, e.g. a byte[] array in aBytesMessage
or an object in anObjectMessage
. This is more generic thanMessage.hasArray()
, as it is not just applicable to a byte array.- Specified by:
hasPayload
in interfaceMessage
- Overrides:
hasPayload
in classBytesMessage
- Returns:
- True if the message has a payload
-
create
public java.util.function.Supplier<Message> create()
Description copied from interface:Constructable
Creates an instance of the class implementing this interface- Specified by:
create
in interfaceConstructable<Message>
- Overrides:
create
in classBytesMessage
-
sizeOfPayload
protected int sizeOfPayload()
- Overrides:
sizeOfPayload
in classBytesMessage
-
copyPayload
protected Message copyPayload(Message copy)
Description copied from class:BytesMessage
Copies 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:
copyPayload
in classBytesMessage
-
writePayload
public void writePayload(java.io.DataOutput out) throws java.io.IOException
- Specified by:
writePayload
in interfaceMessage
- Overrides:
writePayload
in classBytesMessage
- Throws:
java.io.IOException
-
readPayload
public void readPayload(java.io.DataInput in) throws java.io.IOException
- Specified by:
readPayload
in interfaceMessage
- Overrides:
readPayload
in classBytesMessage
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classBaseMessage
-
createMessage
protected <T extends BytesMessage> T createMessage()
- Overrides:
createMessage
in classBytesMessage
-
-