com.sun.enterprise.mgmt.transport
Interface Message

All Superinterfaces:
Serializable
All Known Implementing Classes:
MessageImpl

public interface Message
extends Serializable

This 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_MESSAGE and TYPE_MCAST_MESSAGE are required. TYPE_PING_MESSAGE, TYPE_PONG_MESSAGE are 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's PeerID from which the message is sent, SOURCE_PEER_ID_TAG key is used.

Author:
Bongjae Chang

Field Summary
static long serialVersionUID
           
static String SOURCE_PEER_ID_TAG
          The element's key for storing and getting source's PeerID
static String TARGET_PEER_ID_TAG
          The element's key for storing and getting destination's PeerID
static int TYPE_CLUSTER_MANAGER_MESSAGE
          The type of the ClusterManager message
static int TYPE_HEALTH_MONITOR_MESSAGE
          The type of HealthMonitor's message Currently, HealthMessage will be used for message elements
static int TYPE_MASTER_NODE_MESSAGE
          The type of the MasterNode message
static int TYPE_MCAST_MESSAGE
          The type of the LWRMulticast message
static int TYPE_PING_MESSAGE
          Currently, this type is used in only Grizzly transport layer when NetworkManager.isConnected(com.sun.enterprise.ee.cms.impl.base.PeerID) send the ping message to suspicious member
static 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
 
Method Summary
 Object addMessageElement(String key, Serializable value)
          Adds a special element to this message with key-value pair
 Object getMessageElement(String key)
          Returns the value to which the specified key is mapped, or null if this message contains no mapping for the key
 Set<Map.Entry<String,Serializable>> getMessageElements()
          Returns a Set element view of the mappings contained in this message
 Buffer getPlainBuffer(ExpandableBufferWriterFactory bufferWriterFactory)
          Returns a Buffer of this message
 ByteBuffer getPlainByteBuffer()
          Returns a ByteBuffer of this message
 byte[] getPlainBytes()
          Returns a byte array of this message
 int getType()
          Returns the message's type i.g.
 int getVersion()
          Returns the message's version
 void initialize(int type, Map<String,Serializable> messages)
          Initializes this message with initial type and key-value pair's map
 int parseHeader(Buffer buffer, int offset)
          Parses the message's header from given ByteBuffer
 int parseHeader(byte[] bytes, int offset)
          Parses the message's header from given byte array
 void parseMessage(Buffer buffer, int offset, int length)
          Parses the message's body from given ByteBuffer
 void parseMessage(byte[] bytes, int offset, int length)
          Parses the message's body from given byte array
 Object removeMessageElement(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 the ClusterManager message

See Also:
Constant Field Values

TYPE_HEALTH_MONITOR_MESSAGE

static final int TYPE_HEALTH_MONITOR_MESSAGE
The type of HealthMonitor's message Currently, HealthMessage will 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 MasterNode message

See Also:
Constant Field Values

TYPE_MCAST_MESSAGE

static final int TYPE_MCAST_MESSAGE
The type of the LWRMulticast message

See Also:
Constant Field Values

TYPE_PING_MESSAGE

static final int TYPE_PING_MESSAGE
Currently, this type is used in only Grizzly transport layer when NetworkManager.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 String SOURCE_PEER_ID_TAG
The element's key for storing and getting source's PeerID

See Also:
Constant Field Values

TARGET_PEER_ID_TAG

static final String TARGET_PEER_ID_TAG
The element's key for storing and getting destination's PeerID

See Also:
Constant Field Values
Method Detail

initialize

void initialize(int type,
                Map<String,Serializable> messages)
                throws IllegalArgumentException
Initializes this message with initial type and key-value pair's map

Parameters:
type - message type
messages - key-value pair's message
Throws:
IllegalArgumentException - if the argument is not valid

parseHeader

int parseHeader(byte[] bytes,
                int offset)
                throws IllegalArgumentException
Parses the message's header from given byte array

Parameters:
bytes - byte array which should be parsed
offset - offset from which the message should be parsed
Returns:
the message's length(body length) which this message contains
Throws:
IllegalArgumentException - if the argument is not valid or an unexpected error occurs

parseHeader

int parseHeader(Buffer buffer,
                int offset)
                throws IllegalArgumentException
Parses the message's header from given ByteBuffer

Parameters:
buffer - ByteBuffer which should be parsed
offset - offset from which the message should be parsed
Returns:
the message's length(body length) which this message contains
Throws:
IllegalArgumentException - if the argument is not valid or an unexpected error occurs

parseMessage

void parseMessage(byte[] bytes,
                  int offset,
                  int length)
                  throws IllegalArgumentException,
                         MessageIOException
Parses the message's body from given byte array

Parameters:
bytes - byte array which should be parsed
offset - offset from which the message should be parsed
length - the message's length(body length)
Throws:
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
MessageIOException - if an I/O error occurs

parseMessage

void parseMessage(Buffer buffer,
                  int offset,
                  int length)
                  throws IllegalArgumentException,
                         MessageIOException
Parses the message's body from given ByteBuffer

Parameters:
buffer - ByteBuffer which should be parsed
offset - offset from which the message should be parsed
length - the message's length(body length)
Throws:
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
MessageIOException - 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_MESSAGE or TYPE_HEALTH_MONITOR_MESSAGE's integer value or etc...

Returns:
message type

addMessageElement

Object addMessageElement(String key,
                         Serializable value)
Adds a special element to this message with key-value pair

Parameters:
key - key with which the specified value is to be associated
value - 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

Object getMessageElement(String key)
Returns the value to which the specified key is mapped, or null if 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 null if this message contains no mapping for the key

removeMessageElement

Object removeMessageElement(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

Set<Map.Entry<String,Serializable>> getMessageElements()
Returns a Set element 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 a Buffer of this message

Parameters:
bufferWriterFactory - ExpandableBufferWriterFactory.
Returns:
a Buffer
Throws:
MessageIOException - if an I/O error occurs

getPlainByteBuffer

ByteBuffer getPlainByteBuffer()
                              throws MessageIOException
Returns a ByteBuffer of this message

Returns:
a ByteBuffer
Throws:
MessageIOException - if an I/O error occurs

getPlainBytes

byte[] getPlainBytes()
                     throws MessageIOException
Returns a byte array of this message

Returns:
byte array
Throws:
MessageIOException - if an I/O error occurs


Copyright © 2012. All Rights Reserved.