tango.net.cluster.tina.ProtocolWriter

License:

BSD style: see license.txt

Version:

July 2004: Initial release

Author:

Kris
class ProtocolWriter #
Objects passed around a cluster are prefixed with a header, so the receiver can pick them apart correctly. This header consists of:
1
2
3
4
5
6
7
8
9
the packet size, including the header (16 bits)
a command code (8 bits)
a version id (8 bits)
a timestamp (64 bits)
length of the channel name (32 bits)
the channel name
length of the key (32 bits)
the key
an optional payload (an IMessage instance)
Everything is written in Network order (big endian)
enum Command #
protocol commands
this(IBuffer buffer) #
Construct a ProtocolWriter upon the given buffer. As Objects are serialized, their content is written to this buffer. The buffer content is then typically flushed to some external conduit, such as a file or socket.
Note that serialized data is always in Network order.
ProtocolWriter put(Command cmd, char[] channel, char[] element = null, IMessage msg = null) #
Stuff the request into our output buffer. Note that this protocol is prefixed by a 'size' value, requiring that all messages can be contained within the buffer. This is not considered a serious limitation, as the messages are not intended to be "large" given that they're traversing the network.
ProtocolWriter reply(ClusterContent content) #
Emit a ClusterContent constructed by ProtocolReader.getPacket
ProtocolWriter exception(char[] message) #
Write an exception message
ProtocolWriter success(char[] message = null) #
Write an "OK" confirmation
ProtocolWriter full(char[] message) #
Indicate something has filled up
void flush() #
Flush the output