public abstract class BinaryProtocol
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
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 |
Modifier and Type | Field and Description |
---|---|
BinaryProtocol.MessageOp |
CLIENT_VERSION |
protected int |
codeVersion |
protected int |
configuredVersion |
protected EnvironmentImpl |
envImpl |
protected java.util.logging.Formatter |
formatter |
protected java.nio.ByteBuffer |
header |
BinaryProtocol.MessageOp |
INCOMPATIBLE_VERSION |
protected java.util.logging.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 |
Modifier | Constructor and Description |
---|---|
protected |
BinaryProtocol(NameIdPair nameIdPair,
int codeVersion,
int configuredVersion,
EnvironmentImpl envImpl)
Returns a Protocol object configured that implements the specified
(supported) version.
|
Modifier and Type | Method and Description |
---|---|
int |
getPredefinedMessageCount() |
StatGroup |
getStats(StatsConfig config) |
java.lang.String |
getString(java.nio.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(java.lang.String s,
java.nio.ByteBuffer buffer) |
BinaryProtocol.Message |
read(java.nio.channels.ReadableByteChannel channel)
Read and parse an incoming message, specifying the incoming version.
|
<T extends BinaryProtocol.Message> |
read(java.nio.channels.ReadableByteChannel channel,
java.lang.Class<T> cl) |
void |
resetStats() |
int |
stringSize(java.lang.String s) |
void |
write(BinaryProtocol.Message message,
NamedChannel namedChannel)
Write a message out to a channel.
|
void |
write(BinaryProtocol.Message message,
java.nio.channels.WritableByteChannel channel)
Write a message out to a channel.
|
protected static final int MESSAGE_HEADER_SIZE
protected final java.nio.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 java.util.logging.Logger logger
protected final java.util.logging.Formatter formatter
protected final EnvironmentImpl envImpl
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.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(java.lang.String s)
public void putString(java.lang.String s, java.nio.ByteBuffer buffer)
public java.lang.String getString(java.nio.ByteBuffer buffer)
buffer
- the buffer containing the stringpublic BinaryProtocol.Message read(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
channel
- the channel to read from. Declared as a
ReadableByteChannel rather than the more obvious SocketChannel to
facilitate unit testing.java.io.IOException
public <T extends BinaryProtocol.Message> T read(java.nio.channels.ReadableByteChannel channel, java.lang.Class<T> cl) throws java.io.IOException, BinaryProtocol.ProtocolException
java.io.IOException
BinaryProtocol.ProtocolException
public void write(BinaryProtocol.Message message, NamedChannel namedChannel) throws java.io.IOException
java.io.IOException
public void write(BinaryProtocol.Message message, java.nio.channels.WritableByteChannel channel) throws java.io.IOException
java.io.IOException
Copyright (c) 2004-2012 Oracle. All rights reserved.