Class ChannelData
java.lang.Object
org.apache.catalina.tribes.io.ChannelData
- All Implemented Interfaces:
Serializable
,Cloneable
,ChannelMessage
The
ChannelData
object is used to transfer a message through the channel interceptor stack and
eventually out on a transport to be sent to another node. While the message is being processed by the different
interceptors, the message data can be manipulated as each interceptor seems appropriate.- Author:
- Peter Rossbach
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates an empty channel data with a new unique IdChannelData
(boolean generateUUID) Create an empty channel data objectChannelData
(byte[] uniqueId, XByteBuffer message, long timestamp) Creates a new channel data object with data -
Method Summary
Modifier and TypeMethodDescriptionstatic String
bToS
(byte[] data) clone()
Create a shallow clone, only the data gets recreatedDeep clone, all fields MUST get clonedboolean
Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())void
Generates a UUID and invokes setUniqueIdGet the address that this message originated from.static ChannelData
getDataFromPackage
(byte[] b) static ChannelData
Deserializes a ChannelData object from a byte arraybyte[]
Serializes the ChannelData object into a byte[] arraybyte[]
getDataPackage
(byte[] data, int offset) int
returns the byte buffer that contains the actual message payloadint
The message options is a 32 bit flag set that triggers interceptors and message behavior.long
Timestamp of when the message was created.byte[]
Each message must have a globally unique Id. interceptors heavily depend on this id for message processingint
hashCode()
static boolean
sendAckAsync
(int options) Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received but not yet processedstatic boolean
sendAckSync
(int options) Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received and processedvoid
setAddress
(Member address) Sets the source or reply-to address of this messagevoid
setMessage
(XByteBuffer message) The byte buffer that contains the actual message payloadvoid
setOptions
(int options) sets the option bits for this messagevoid
setTimestamp
(long timestamp) Sets the timestamp of this message.void
setUniqueId
(byte[] uniqueId) toString()
-
Field Details
-
EMPTY_DATA_ARRAY
-
USE_SECURE_RANDOM_FOR_UUID
public static volatile boolean USE_SECURE_RANDOM_FOR_UUID
-
-
Constructor Details
-
ChannelData
public ChannelData()Creates an empty channel data with a new unique Id- See Also:
-
ChannelData
public ChannelData(boolean generateUUID) Create an empty channel data object- Parameters:
generateUUID
- boolean - if true, a unique Id will be generated
-
ChannelData
Creates a new channel data object with data- Parameters:
uniqueId
- - unique message idmessage
- - message datatimestamp
- - message timestamp
-
-
Method Details
-
getMessage
Description copied from interface:ChannelMessage
returns the byte buffer that contains the actual message payload- Specified by:
getMessage
in interfaceChannelMessage
- Returns:
- XByteBuffer
-
setMessage
Description copied from interface:ChannelMessage
The byte buffer that contains the actual message payload- Specified by:
setMessage
in interfaceChannelMessage
- Parameters:
message
- XByteBuffer
-
getTimestamp
public long getTimestamp()Description copied from interface:ChannelMessage
Timestamp of when the message was created.- Specified by:
getTimestamp
in interfaceChannelMessage
- Returns:
- long timestamp in milliseconds
-
setTimestamp
public void setTimestamp(long timestamp) Description copied from interface:ChannelMessage
Sets the timestamp of this message.- Specified by:
setTimestamp
in interfaceChannelMessage
- Parameters:
timestamp
- The timestamp
-
getUniqueId
public byte[] getUniqueId()Description copied from interface:ChannelMessage
Each message must have a globally unique Id. interceptors heavily depend on this id for message processing- Specified by:
getUniqueId
in interfaceChannelMessage
- Returns:
- byte
-
setUniqueId
public void setUniqueId(byte[] uniqueId) -
getOptions
public int getOptions()Description copied from interface:ChannelMessage
The message options is a 32 bit flag set that triggers interceptors and message behavior.- Specified by:
getOptions
in interfaceChannelMessage
- Returns:
- int - the option bits set for this message
- See Also:
-
setOptions
public void setOptions(int options) Description copied from interface:ChannelMessage
sets the option bits for this message- Specified by:
setOptions
in interfaceChannelMessage
- Parameters:
options
- int- See Also:
-
getAddress
Description copied from interface:ChannelMessage
Get the address that this message originated from. Almost alwaysChannel.getLocalMember(boolean)
. This would be set to a different address if the message was being relayed from a host other than the one that originally sent it.- Specified by:
getAddress
in interfaceChannelMessage
- Returns:
- the source or reply-to address of this message
-
setAddress
Description copied from interface:ChannelMessage
Sets the source or reply-to address of this message- Specified by:
setAddress
in interfaceChannelMessage
- Parameters:
address
- Member
-
generateUUID
public void generateUUID()Generates a UUID and invokes setUniqueId -
getDataPackageLength
public int getDataPackageLength() -
getDataPackage
public byte[] getDataPackage()Serializes the ChannelData object into a byte[] array- Returns:
- byte[]
-
getDataPackage
public byte[] getDataPackage(byte[] data, int offset) -
getDataFromPackage
Deserializes a ChannelData object from a byte array- Parameters:
xbuf
- byte[]- Returns:
- ChannelData
-
getDataFromPackage
-
hashCode
-
equals
-
clone
Create a shallow clone, only the data gets recreated- Specified by:
clone
in interfaceChannelMessage
- Overrides:
clone
in classObject
- Returns:
- ClusterData
-
deepclone
Description copied from interface:ChannelMessage
Deep clone, all fields MUST get cloned- Specified by:
deepclone
in interfaceChannelMessage
- Returns:
- ChannelMessage
-
sendAckSync
public static boolean sendAckSync(int options) Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received and processed- Parameters:
options
- int - the options for the message- Returns:
- boolean
- See Also:
-
sendAckAsync
public static boolean sendAckAsync(int options) Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received but not yet processed- Parameters:
options
- int - the options for the message- Returns:
- boolean
- See Also:
-
toString
-
bToS
-