Class AbstractCodec
- java.lang.Object
-
- org.epics.pvaccess.impl.remote.codec.AbstractCodec
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
,WritableByteChannel
,TransportSendControl
,org.epics.pvdata.pv.SerializableControl
- Direct Known Subclasses:
BlockingAbstractCodec
,NonBlockingAbstractCodec
public abstract class AbstractCodec extends Object implements ReadableByteChannel, WritableByteChannel, TransportSendControl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractCodec.ReadMode
static class
AbstractCodec.WriteMode
-
Field Summary
Fields Modifier and Type Field Description protected boolean
blockingProcessQueue
protected byte
command
protected byte
flags
protected Logger
logger
static int
MAX_ENSURE_BUFFER_SIZE
static int
MAX_ENSURE_DATA_SIZE
static int
MAX_ENSURE_SIZE
static int
MAX_MESSAGE_PROCESS
static int
MAX_MESSAGE_SEND
protected int
payloadSize
protected AbstractCodec.ReadMode
readMode
protected int
remoteTransportSocketReceiveBufferSize
Remote side transport socket receive buffer size.protected ByteBuffer
sendBuffer
protected Mailbox<TransportSender>
sendQueue
protected InetSocketAddress
sendTo
protected ByteBuffer
socketBuffer
protected long
totalBytesSent
Total bytes sent.protected byte
version
protected AbstractCodec.WriteMode
writeMode
protected boolean
writeOpReady
-
Constructor Summary
Constructors Constructor Description AbstractCodec(boolean serverFlag, ByteBuffer receiveBuffer, ByteBuffer sendBuffer, int socketSendBufferSize, boolean blockingProcessQueue, Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
alignBuffer(int alignment)
void
alignData(int alignment)
static int
alignedValue(int value, int alignment)
void
clearSendQueue()
void
endMessage()
void
enqueueSendRequest(TransportSender sender)
void
enqueueSendRequest(TransportSender sender, int requiredBufferSize)
void
ensureBuffer(int size)
void
ensureData(int size)
void
flush(boolean lastMessageCompleted)
void
flushSerializeBuffer()
abstract InetSocketAddress
getLastReadBufferSocketAddress()
abstract void
invalidDataStreamHandler()
abstract void
processApplicationMessage()
abstract void
processControlMessage()
void
processRead()
void
processSendQueue()
void
processWrite()
void
putControlMessage(byte command, int data)
abstract void
readPollOne()
abstract void
scheduleSend()
protected void
send(ByteBuffer buffer)
Send a buffer through the transport.protected abstract void
sendBufferFull(int tries)
abstract void
sendCompleted()
void
setByteOrder(ByteOrder byteOrder)
void
setRecipient(InetSocketAddress sendTo)
void
setSenderThread()
void
startMessage(byte command, int ensureCapacity)
abstract boolean
terminated()
abstract void
writePollOne()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.nio.channels.ReadableByteChannel
read
-
Methods inherited from interface java.nio.channels.WritableByteChannel
write
-
-
-
-
Field Detail
-
logger
protected final Logger logger
-
MAX_MESSAGE_PROCESS
public static final int MAX_MESSAGE_PROCESS
- See Also:
- Constant Field Values
-
MAX_MESSAGE_SEND
public static final int MAX_MESSAGE_SEND
- See Also:
- Constant Field Values
-
MAX_ENSURE_SIZE
public static final int MAX_ENSURE_SIZE
- See Also:
- Constant Field Values
-
MAX_ENSURE_DATA_SIZE
public static final int MAX_ENSURE_DATA_SIZE
- See Also:
- Constant Field Values
-
MAX_ENSURE_BUFFER_SIZE
public static final int MAX_ENSURE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
socketBuffer
protected final ByteBuffer socketBuffer
-
readMode
protected AbstractCodec.ReadMode readMode
-
version
protected byte version
-
flags
protected byte flags
-
command
protected byte command
-
payloadSize
protected int payloadSize
-
sendBuffer
protected final ByteBuffer sendBuffer
-
remoteTransportSocketReceiveBufferSize
protected int remoteTransportSocketReceiveBufferSize
Remote side transport socket receive buffer size.
-
totalBytesSent
protected long totalBytesSent
Total bytes sent.
-
sendQueue
protected final Mailbox<TransportSender> sendQueue
-
blockingProcessQueue
protected final boolean blockingProcessQueue
-
sendTo
protected InetSocketAddress sendTo
-
writeMode
protected AbstractCodec.WriteMode writeMode
-
writeOpReady
protected boolean writeOpReady
-
-
Constructor Detail
-
AbstractCodec
public AbstractCodec(boolean serverFlag, ByteBuffer receiveBuffer, ByteBuffer sendBuffer, int socketSendBufferSize, boolean blockingProcessQueue, Logger logger)
-
-
Method Detail
-
processRead
public final void processRead() throws IOException, ConnectionClosedException, InvalidDataStreamException
-
processControlMessage
public abstract void processControlMessage()
-
processApplicationMessage
public abstract void processApplicationMessage() throws IOException
- Throws:
IOException
-
getLastReadBufferSocketAddress
public abstract InetSocketAddress getLastReadBufferSocketAddress()
-
invalidDataStreamHandler
public abstract void invalidDataStreamHandler()
-
readPollOne
public abstract void readPollOne() throws IOException
- Throws:
IOException
-
ensureData
public final void ensureData(int size)
-
alignedValue
public static final int alignedValue(int value, int alignment)
-
alignData
public void alignData(int alignment)
-
writePollOne
public abstract void writePollOne() throws IOException
- Throws:
IOException
-
alignBuffer
public void alignBuffer(int alignment)
- Specified by:
alignBuffer
in interfaceorg.epics.pvdata.pv.SerializableControl
-
startMessage
public final void startMessage(byte command, int ensureCapacity)
- Specified by:
startMessage
in interfaceTransportSendControl
-
putControlMessage
public final void putControlMessage(byte command, int data)
-
endMessage
public final void endMessage()
- Specified by:
endMessage
in interfaceTransportSendControl
-
ensureBuffer
public final void ensureBuffer(int size)
- Specified by:
ensureBuffer
in interfaceorg.epics.pvdata.pv.SerializableControl
-
flushSerializeBuffer
public void flushSerializeBuffer()
- Specified by:
flushSerializeBuffer
in interfaceorg.epics.pvdata.pv.SerializableControl
-
flush
public void flush(boolean lastMessageCompleted)
- Specified by:
flush
in interfaceTransportSendControl
-
processWrite
public final void processWrite() throws IOException, ConnectionClosedException
- Throws:
IOException
ConnectionClosedException
-
send
protected void send(ByteBuffer buffer) throws IOException
Send a buffer through the transport. NOTE: TCP sent buffer/sending has to be synchronized (not done by this method).- Parameters:
buffer
- buffer to be sent- Throws:
IOException
- IO exception rethrown.
-
sendBufferFull
protected abstract void sendBufferFull(int tries) throws IOException
- Throws:
IOException
-
scheduleSend
public abstract void scheduleSend()
-
sendCompleted
public abstract void sendCompleted()
-
processSendQueue
public final void processSendQueue() throws IOException
- Throws:
IOException
-
clearSendQueue
public final void clearSendQueue()
-
enqueueSendRequest
public final void enqueueSendRequest(TransportSender sender)
-
setSenderThread
public void setSenderThread()
-
enqueueSendRequest
public final void enqueueSendRequest(TransportSender sender, int requiredBufferSize)
-
setRecipient
public void setRecipient(InetSocketAddress sendTo)
- Specified by:
setRecipient
in interfaceTransportSendControl
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
-
terminated
public abstract boolean terminated()
-
-