public abstract class TextProtocol extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
TextProtocol.Fail |
static class |
TextProtocol.InvalidMessageException
Used to indicate a message format or invalid content exception.
|
class |
TextProtocol.Message
Base message class for all messages exchanged in the protocol.
|
static class |
TextProtocol.MessageError |
class |
TextProtocol.MessageExchange
A single request/response interaction, targetted at a given service
running at a particular remote socket address.
|
static class |
TextProtocol.MessageOp
The Operations that are part of the protocol.
|
class |
TextProtocol.OK |
class |
TextProtocol.ProtocolError |
class |
TextProtocol.RequestMessage
Base class for all Request messages
|
class |
TextProtocol.ResponseMessage
Base classes for response messages.
|
protected static class |
TextProtocol.StringFormatable |
static class |
TextProtocol.TOKENS
Represents the tokens on a message line.
|
protected static interface |
TextProtocol.WireFormatable |
| Modifier and Type | Field and Description |
|---|---|
protected DataChannelFactory |
channelFactory |
TextProtocol.MessageOp |
FAIL_RESP |
protected Formatter |
formatter |
protected Logger |
logger |
protected String |
messageNocheckSuffix |
TextProtocol.MessageOp |
OK_RESP |
TextProtocol.MessageOp |
PROTOCOL_ERROR |
protected RepImpl |
repImpl
The rep impl using this protocol.
|
static String |
SEPARATOR |
static String |
SEPARATOR_REGEXP |
| Constructor and Description |
|---|
TextProtocol(String version,
String groupName,
NameIdPair nameIdPair,
RepImpl repImpl,
DataChannelFactory channelFactory)
Creates an instance of the Protocol.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMajorVersionNumber(String version)
Returns the Integer number which represents a Protocol version.
|
NameIdPair |
getNameIdPair() |
int |
getOpenTimeout() |
Set<String> |
getOps(Class<? extends TextProtocol.Message> messageType)
Returns the messages, of the specified type, used by the protocol
|
int |
getReadTimeout() |
TextProtocol.RequestMessage |
getRequestMessage(DataChannel channel)
Reads the channel and returns a read request.
|
protected void |
initializeMessageOps(TextProtocol.MessageOp[] protocolOps)
The messages as defined by the subclass.
|
int |
messageCount() |
TextProtocol.Message |
parse(String line)
Parses a line into a Request/Response message.
|
TextProtocol.RequestMessage |
parseRequest(String requestLine)
Converts a request line into a requestMessage.
|
TextProtocol.ResponseMessage |
process(Object requestProcessor,
TextProtocol.RequestMessage requestMessage) |
void |
processIME(DataChannel channel,
TextProtocol.InvalidMessageException ime)
Process an IME encountered during request processing by writing a
ProtocolError message as a response and logging it.
|
protected TextProtocol.MessageOp |
replaceOp(String op,
TextProtocol.MessageOp message)
For testing only.
|
static void |
setSerDeHook(TestHook<String> serDeHook)
Sets the hook that is invoked post serialization on request messages and
pre deserialization on response messages.
|
protected void |
setTimeouts(RepImpl repImpl,
DurationConfigParam openTimeoutConfig,
DurationConfigParam readTimeoutConfig)
Set the network timeouts associated with uses of this protocol instance.
|
void |
updateNodeIds(Set<Integer> newMemberIds)
Updates the current set of nodes that are permitted to communicate via
this protocol, or null for unrestricted.
|
protected final String messageNocheckSuffix
public static final String SEPARATOR
public static final String SEPARATOR_REGEXP
public final TextProtocol.MessageOp PROTOCOL_ERROR
public final TextProtocol.MessageOp OK_RESP
public final TextProtocol.MessageOp FAIL_RESP
protected final Logger logger
protected final Formatter formatter
protected final RepImpl repImpl
protected final DataChannelFactory channelFactory
public TextProtocol(String version, String groupName, NameIdPair nameIdPair, RepImpl repImpl, DataChannelFactory channelFactory)
version - the protocol version numbergroupName - the name of the group executing this protocolnameIdPair - a unique identifier for this noderepImpl - for logging, may be nullchannelFactory - the factory for channel creationpublic static void setSerDeHook(TestHook<String> serDeHook)
protected void setTimeouts(RepImpl repImpl, DurationConfigParam openTimeoutConfig, DurationConfigParam readTimeoutConfig)
protected void initializeMessageOps(TextProtocol.MessageOp[] protocolOps)
protocolOps - the message ops defined by the subclass.protected TextProtocol.MessageOp replaceOp(String op, TextProtocol.MessageOp message)
public Set<String> getOps(Class<? extends TextProtocol.Message> messageType)
public int getOpenTimeout()
public int getReadTimeout()
public NameIdPair getNameIdPair()
public int messageCount()
public void updateNodeIds(Set<Integer> newMemberIds)
newMemberIds - public int getMajorVersionNumber(String version)
public TextProtocol.Message parse(String line) throws TextProtocol.InvalidMessageException
line - containing the messageTextProtocol.InvalidMessageExceptionpublic TextProtocol.RequestMessage parseRequest(String requestLine) throws TextProtocol.InvalidMessageException
requestLine - TextProtocol.InvalidMessageExceptionpublic TextProtocol.RequestMessage getRequestMessage(DataChannel channel) throws IOException
channel - the channel delivering the requestIOExceptionpublic void processIME(DataChannel channel, TextProtocol.InvalidMessageException ime)
channel - the channel used to write the ProtocolError messageime - the exceptionpublic TextProtocol.ResponseMessage process(Object requestProcessor, TextProtocol.RequestMessage requestMessage)
Copyright © 2024. All rights reserved.