| java.lang.Object org.jgroups.Message
Message | public class Message implements Externalizable,Streamable(Code) | | A Message encapsulates data sent to members of a group. It contains among other things the
address of the sender, the destination address, a payload (byte buffer) and a list of
headers. Headers are added by protocols on the sender side and removed by protocols
on the receiver's side.
The byte buffer can point to a reference, and we can subset it using index and length. However,
when the message is serialized, we only write the bytes between index and length.
author: Bela Ban |
BUF_SET | final static byte BUF_SET(Code) | | |
DEST_SET | final static byte DEST_SET(Code) | | |
IPADDR_DEST | final static byte IPADDR_DEST(Code) | | |
IPADDR_SRC | final static byte IPADDR_SRC(Code) | | |
SRC_HOST_NULL | final static byte SRC_HOST_NULL(Code) | | |
SRC_SET | final static byte SRC_SET(Code) | | |
length | protected transient int length(Code) | | The number of bytes in the buffer (usually buf.length is buf not equal to null).
|
log | final protected static Log log(Code) | | |
nonStreamableHeaders | final static HashSet nonStreamableHeaders(Code) | | |
offset | protected transient int offset(Code) | | The index into the payload (usually 0)
|
Message | public Message(Address dest)(Code) | | Public constructor
Parameters: dest - Address of receiver. If it is null or a string, thenit is sent to the group (either to current group or to the group as givenin the string). If it is a Vector, then it contains a number of addressesto which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channelinstance must know what types of addresses it expects and downcastaccordingly. |
Message | public Message(Address dest, Address src, byte[] buf)(Code) | | Public constructor
Parameters: dest - Address of receiver. If it is null or a string, thenit is sent to the group (either to current group or to the group as givenin the string). If it is a Vector, then it contains a number of addressesto which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channelinstance must know what types of addresses it expects and downcastaccordingly. Parameters: src - Address of sender Parameters: buf - Message to be sent. Note that this buffer must not be modified (e.g. buf[0]=0 isnot allowed), since we don't copy the contents on clopy() or clone(). |
Message | public Message(Address dest, Address src, byte[] buf, int offset, int length)(Code) | | Constructs a message. The index and length parameters allow to provide a reference to
a byte buffer, rather than a copy, and refer to a subset of the buffer. This is important when
we want to avoid copying. When the message is serialized, only the subset is serialized.
Parameters: dest - Address of receiver. If it is null or a string, thenit is sent to the group (either to current group or to the group as givenin the string). If it is a Vector, then it contains a number of addressesto which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channelinstance must know what types of addresses it expects and downcastaccordingly. Parameters: src - Address of sender Parameters: buf - A reference to a byte buffer Parameters: offset - The index into the byte buffer Parameters: length - The number of bytes to be used from buf. Both index and length are checked forarray index violations and an ArrayIndexOutOfBoundsException will be thrown if invalid |
Message | public Message(Address dest, Address src, Serializable obj)(Code) | | Public constructor
Parameters: dest - Address of receiver. If it is null or a string, thenit is sent to the group (either to current group or to the group as givenin the string). If it is a Vector, then it contains a number of addressesto which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channelinstance must know what types of addresses it expects and downcastaccordingly. Parameters: src - Address of sender Parameters: obj - The object will be serialized into the byte buffer. Objecthas to be serializable ! Note that the resulting buffer must not be modified(e.g. buf[0]=0 is not allowed), since we don't copy the contents on clopy() or clone(). |
Message | public Message(boolean create_headers)(Code) | | |
copy | public Message copy(boolean copy_buffer)(Code) | | Create a copy of the message. If offset and length are used (to refer to another buffer), the copy will
contain only the subset offset and length point to, copying the subset into the new copy.
Parameters: copy_buffer - Message with specified data |
getBuffer | final public byte[] getBuffer()(Code) | | Returns a copy of the buffer if offset and length are used, otherwise a reference.
byte array with a copy of the buffer. |
getLength | public int getLength()(Code) | | Returns the number of bytes in the buffer
|
getOffset | public int getOffset()(Code) | | Returns the offset into the buffer at which the data starts
|
getRawBuffer | public byte[] getRawBuffer()(Code) | | Returns a reference to the payload (byte buffer). Note that this buffer should not be modified as
we do not copy the buffer on copy() or clone(): the buffer of the copied message is simply a reference to
the old buffer.
Even if offset and length are used: we return the entire buffer, not a subset.
|
putHeader | public void putHeader(String key, Header hdr)(Code) | | Puts a header given a key into the hashmap. Overwrites potential existing entry.
|
removeHeaders | public void removeHeaders()(Code) | | |
reset | public void reset()(Code) | | Nulls all fields of this message so that the message can be reused. Removes all headers from the
hashmap, but keeps the hashmap
|
setBuffer | final public void setBuffer(byte[] b)(Code) | | |
setBuffer | final public void setBuffer(byte[] b, int offset, int length)(Code) | | Set the internal buffer to point to a subset of a given buffer
Parameters: b - The reference to a given buffer. If null, we'll reset the buffer to null Parameters: offset - The initial position Parameters: length - The number of bytes |
size | public long size()(Code) | | Returns the exact size of the marshalled message. Uses method size() of each header to compute the size, so if
a Header subclass doesn't implement size() we will use an approximation. However, most relevant header subclasses
have size() implemented correctly. (See org.jgroups.tests.SizeTest).
The number of bytes for the marshalled message |
toStringAsObject | public String toStringAsObject()(Code) | | Tries to read an object from the message's buffer and prints it
|
|
|