Interface Message
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
MessageImpl
public interface Message extends java.io.SerializableThis represents internal message interface which is sent and received on the top of Shoal management module Currently, six message types exist.TYPE_CLUSTER_MANAGER_MESSAGE,TYPE_HEALTH_MONITOR_MESSAGE,TYPE_MASTER_NODE_MESSAGEandTYPE_MCAST_MESSAGEare required.TYPE_PING_MESSAGE,TYPE_PONG_MESSAGEare optional. i.g. JXTA transport layer doesn't need it. This message can contain various elements with key-value pair. i.g. For the purpose of storing a source'sPeerIDfrom which the message is sent,SOURCE_PEER_ID_TAGkey is used.- Author:
- Bongjae Chang
-
-
Field Summary
Fields Modifier and Type Field Description static longserialVersionUIDstatic java.lang.StringSOURCE_PEER_ID_TAGThe element's key for storing and getting source'sPeerIDstatic java.lang.StringTARGET_PEER_ID_TAGThe element's key for storing and getting destination'sPeerIDstatic intTYPE_CLUSTER_MANAGER_MESSAGEThe type of theClusterManagermessagestatic intTYPE_HEALTH_MONITOR_MESSAGEThe type ofHealthMonitor's message Currently,HealthMessagewill be used for message elementsstatic intTYPE_MASTER_NODE_MESSAGEThe type of the com.sun.enterprise.mgmt.MasterNode messagestatic intTYPE_MCAST_MESSAGEThe type of theLWRMulticastmessagestatic intTYPE_PING_MESSAGECurrently, this type is used in only Grizzly transport layer whenNetworkManager.isConnected(com.sun.enterprise.ee.cms.impl.base.PeerID)send the ping message to suspicious memberstatic intTYPE_PONG_MESSAGECurrently, this type is used in only Grizzly transport layer in order to send own liveness to the sender when a ping message is received
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ObjectaddMessageElement(java.lang.String key, java.io.Serializable value)Adds a special element to this message with key-value pairjava.lang.ObjectgetMessageElement(java.lang.String key)Returns the value to which the specified key is mapped, ornullif this message contains no mapping for the keyjava.util.Set<java.util.Map.Entry<java.lang.String,java.io.Serializable>>getMessageElements()Returns aSetelement view of the mappings contained in this messageBuffergetPlainBuffer(ExpandableBufferWriterFactory bufferWriterFactory)Returns aBufferof this messagejava.nio.ByteBuffergetPlainByteBuffer()Returns aByteBufferof this messagebyte[]getPlainBytes()Returns a byte array of this messageintgetType()Returns the message's type i.g.intgetVersion()Returns the message's versionvoidinitialize(int type, java.util.Map<java.lang.String,java.io.Serializable> messages)Initializes this message with initial type and key-value pair's mapintparseHeader(byte[] bytes, int offset)Parses the message's header from given byte arrayintparseHeader(Buffer buffer, int offset)Parses the message's header from given ByteBuffervoidparseMessage(byte[] bytes, int offset, int length)Parses the message's body from given byte arrayvoidparseMessage(Buffer buffer, int offset, int length)Parses the message's body from given ByteBufferjava.lang.ObjectremoveMessageElement(java.lang.String key)Removes the mapping for a key from this message if it is present
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
TYPE_CLUSTER_MANAGER_MESSAGE
static final int TYPE_CLUSTER_MANAGER_MESSAGE
The type of theClusterManagermessage- See Also:
- Constant Field Values
-
TYPE_HEALTH_MONITOR_MESSAGE
static final int TYPE_HEALTH_MONITOR_MESSAGE
The type ofHealthMonitor's message Currently,HealthMessagewill be used for message elements- See Also:
- Constant Field Values
-
TYPE_MASTER_NODE_MESSAGE
static final int TYPE_MASTER_NODE_MESSAGE
The type of the com.sun.enterprise.mgmt.MasterNode message- See Also:
- Constant Field Values
-
TYPE_MCAST_MESSAGE
static final int TYPE_MCAST_MESSAGE
The type of theLWRMulticastmessage- See Also:
- Constant Field Values
-
TYPE_PING_MESSAGE
static final int TYPE_PING_MESSAGE
Currently, this type is used in only Grizzly transport layer whenNetworkManager.isConnected(com.sun.enterprise.ee.cms.impl.base.PeerID)send the ping message to suspicious member- See Also:
- Constant Field Values
-
TYPE_PONG_MESSAGE
static final int TYPE_PONG_MESSAGE
Currently, this type is used in only Grizzly transport layer in order to send own liveness to the sender when a ping message is received- See Also:
- Constant Field Values
-
SOURCE_PEER_ID_TAG
static final java.lang.String SOURCE_PEER_ID_TAG
The element's key for storing and getting source'sPeerID- See Also:
- Constant Field Values
-
TARGET_PEER_ID_TAG
static final java.lang.String TARGET_PEER_ID_TAG
The element's key for storing and getting destination'sPeerID- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
void initialize(int type, java.util.Map<java.lang.String,java.io.Serializable> messages) throws java.lang.IllegalArgumentExceptionInitializes this message with initial type and key-value pair's map- Parameters:
type- message typemessages- key-value pair's message- Throws:
java.lang.IllegalArgumentException- if the argument is not valid
-
parseHeader
int parseHeader(byte[] bytes, int offset) throws java.lang.IllegalArgumentExceptionParses the message's header from given byte array- Parameters:
bytes- byte array which should be parsedoffset- offset from which the message should be parsed- Returns:
- the message's length(body length) which this message contains
- Throws:
java.lang.IllegalArgumentException- if the argument is not valid or an unexpected error occurs
-
parseHeader
int parseHeader(Buffer buffer, int offset) throws java.lang.IllegalArgumentException
Parses the message's header from given ByteBuffer- Parameters:
buffer- ByteBuffer which should be parsedoffset- offset from which the message should be parsed- Returns:
- the message's length(body length) which this message contains
- Throws:
java.lang.IllegalArgumentException- if the argument is not valid or an unexpected error occurs
-
parseMessage
void parseMessage(byte[] bytes, int offset, int length) throws java.lang.IllegalArgumentException, MessageIOExceptionParses the message's body from given byte array- Parameters:
bytes- byte array which should be parsedoffset- offset from which the message should be parsedlength- the message's length(body length)- Throws:
java.lang.IllegalArgumentException- if the argument is not valid or an unexpected error occursMessageIOException- if an I/O error occurs
-
parseMessage
void parseMessage(Buffer buffer, int offset, int length) throws java.lang.IllegalArgumentException, MessageIOException
Parses the message's body from given ByteBuffer- Parameters:
buffer- ByteBuffer which should be parsedoffset- offset from which the message should be parsedlength- the message's length(body length)- Throws:
java.lang.IllegalArgumentException- if the argument is not valid or an unexpected error occursMessageIOException- if an I/O error occurs
-
getVersion
int getVersion()
Returns the message's version- Returns:
- message version
-
getType
int getType()
Returns the message's type i.g.TYPE_CLUSTER_MANAGER_MESSAGEorTYPE_HEALTH_MONITOR_MESSAGE's integer value or etc...- Returns:
- message type
-
addMessageElement
java.lang.Object addMessageElement(java.lang.String key, java.io.Serializable value)Adds a special element to this message with key-value pair- Parameters:
key- key with which the specified value is to be associatedvalue- serializable value to be associated with the specified key- Returns:
- the previous value associated with key, or null if there was no mapping for key
-
getMessageElement
java.lang.Object getMessageElement(java.lang.String key)
Returns the value to which the specified key is mapped, ornullif this message contains no mapping for the key- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this message contains no mapping for the key
-
removeMessageElement
java.lang.Object removeMessageElement(java.lang.String key)
Removes the mapping for a key from this message if it is present- Parameters:
key- key whose mapping is to be removed from the message- Returns:
- the previous value associated with key, or null if there was no mapping for key
-
getMessageElements
java.util.Set<java.util.Map.Entry<java.lang.String,java.io.Serializable>> getMessageElements()
Returns aSetelement view of the mappings contained in this message- Returns:
- a set element view of the mappings contained in this message
-
getPlainBuffer
Buffer getPlainBuffer(ExpandableBufferWriterFactory bufferWriterFactory) throws MessageIOException
Returns aBufferof this message- Parameters:
bufferWriterFactory-ExpandableBufferWriterFactory.- Returns:
- a Buffer
- Throws:
MessageIOException- if an I/O error occurs
-
getPlainByteBuffer
java.nio.ByteBuffer getPlainByteBuffer() throws MessageIOExceptionReturns aByteBufferof this message- Returns:
- a ByteBuffer
- Throws:
MessageIOException- if an I/O error occurs
-
getPlainBytes
byte[] getPlainBytes() throws MessageIOExceptionReturns a byte array of this message- Returns:
- byte array
- Throws:
MessageIOException- if an I/O error occurs
-
-