|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.rep.utilint.BinaryProtocol
public abstract class BinaryProtocol
Supplies the basic infrastructure for BinaryProtocols used to exchange messages by the replications stream and during network based restore operations. Note that this class and its subclasses are not synchronized. There must be one instance of this class per thread of control. IMPORTANT: Please avoid all uses of ByteBuffer.get/put when serializing message fields of types: long, int and short to avoid byte order issues. Use LogUtils.read/write methods instead, since they use a single canonical byte-independent representation.
Nested Class Summary | |
---|---|
class |
BinaryProtocol.ClientVersion
|
class |
BinaryProtocol.IncompatibleVersion
|
class |
BinaryProtocol.Message
Base message class for all messages exchanged in the protocol. |
static class |
BinaryProtocol.MessageOp
The Operations that are part of the protocol. |
class |
BinaryProtocol.ProtocolError
|
static class |
BinaryProtocol.ProtocolException
Thrown in response to an unexpected response to a request. |
(package private) class |
BinaryProtocol.ProtocolVersion
Version broadcasts the sending node's protocol version. |
class |
BinaryProtocol.RejectMessage
The base class for reject responses to requests |
class |
BinaryProtocol.ServerVersion
|
protected class |
BinaryProtocol.SimpleMessage
Base class for simple messages. |
(package private) static interface |
BinaryProtocol.WireFormatable
|
Field Summary | |
---|---|
BinaryProtocol.MessageOp |
CLIENT_VERSION
|
protected int |
codeVersion
|
protected int |
configuredVersion
|
protected EnvironmentImpl |
envImpl
|
protected Formatter |
formatter
|
protected ByteBuffer |
header
|
BinaryProtocol.MessageOp |
INCOMPATIBLE_VERSION
|
protected Logger |
logger
|
protected static int |
MESSAGE_HEADER_SIZE
|
protected NameIdPair |
nameIdPair
|
protected LongStat |
nBytesRead
|
protected LongStat |
nBytesWritten
|
protected LongStat |
nMessagesRead
|
protected LongStat |
nMessagesWritten
|
protected LongStat |
nReadNanos
|
protected LongStat |
nWriteNanos
|
BinaryProtocol.MessageOp |
PROTOCOL_ERROR
|
BinaryProtocol.MessageOp |
SERVER_VERSION
|
protected StatGroup |
stats
|
Constructor Summary | |
---|---|
protected |
BinaryProtocol(NameIdPair nameIdPair,
int codeVersion,
int configuredVersion,
EnvironmentImpl envImpl)
Returns a Protocol object configured that implements the specified (supported) version. |
Method Summary | ||
---|---|---|
int |
getPredefinedMessageCount()
|
|
StatGroup |
getStats(StatsConfig config)
|
|
String |
getString(ByteBuffer buffer)
Reconstitutes the string serialized by the above method. |
|
int |
getVersion()
Returns the version associated with this protocol instance. |
|
protected void |
initializeMessageOps(BinaryProtocol.MessageOp[] protocolOps)
|
|
int |
messageCount()
|
|
void |
putString(String s,
ByteBuffer buffer)
|
|
BinaryProtocol.Message |
read(ReadableByteChannel channel)
Read and parse an incoming message, specifying the incoming version. |
|
|
read(ReadableByteChannel channel,
Class<T> cl)
|
|
void |
resetStats()
|
|
int |
stringSize(String s)
|
|
void |
write(BinaryProtocol.Message message,
NamedChannel namedChannel)
Write a message out to a channel. |
|
void |
write(BinaryProtocol.Message message,
WritableByteChannel channel)
Write a message out to a channel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int MESSAGE_HEADER_SIZE
protected final ByteBuffer header
protected final int codeVersion
protected int configuredVersion
protected final NameIdPair nameIdPair
public final BinaryProtocol.MessageOp CLIENT_VERSION
public final BinaryProtocol.MessageOp SERVER_VERSION
public final BinaryProtocol.MessageOp INCOMPATIBLE_VERSION
public final BinaryProtocol.MessageOp PROTOCOL_ERROR
protected final StatGroup stats
protected final LongStat nReadNanos
protected final LongStat nWriteNanos
protected final LongStat nBytesRead
protected final LongStat nMessagesRead
protected final LongStat nBytesWritten
protected final LongStat nMessagesWritten
protected final Logger logger
protected final Formatter formatter
protected final EnvironmentImpl envImpl
Constructor Detail |
---|
protected BinaryProtocol(NameIdPair nameIdPair, int codeVersion, int configuredVersion, EnvironmentImpl envImpl)
codeVersion
- the version actually implemented by the protocol.configuredVersion
- the version of the protocol that must be
implemented/simulated by this protocol when communicating with the
recipient.Method Detail |
---|
protected void initializeMessageOps(BinaryProtocol.MessageOp[] protocolOps)
public int messageCount()
public final int getPredefinedMessageCount()
public int getVersion()
public StatGroup getStats(StatsConfig config)
public void resetStats()
public int stringSize(String s)
public void putString(String s, ByteBuffer buffer)
public String getString(ByteBuffer buffer)
buffer
- the buffer containing the string
public BinaryProtocol.Message read(ReadableByteChannel channel) throws IOException
channel
- the channel to read from. Declared as a
ReadableByteChannel rather than the more obvious SocketChannel to
facilitate unit testing.
IOException
public <T extends BinaryProtocol.Message> T read(ReadableByteChannel channel, Class<T> cl) throws IOException, BinaryProtocol.ProtocolException
IOException
BinaryProtocol.ProtocolException
public void write(BinaryProtocol.Message message, NamedChannel namedChannel) throws IOException
IOException
public void write(BinaryProtocol.Message message, WritableByteChannel channel) throws IOException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |