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 classAbstractCodec.ReadModestatic classAbstractCodec.WriteMode
-
Field Summary
Fields Modifier and Type Field Description protected booleanblockingProcessQueueprotected bytecommandprotected byteflagsprotected Loggerloggerstatic intMAX_ENSURE_BUFFER_SIZEstatic intMAX_ENSURE_DATA_SIZEstatic intMAX_ENSURE_SIZEstatic intMAX_MESSAGE_PROCESSstatic intMAX_MESSAGE_SENDprotected intpayloadSizeprotected AbstractCodec.ReadModereadModeprotected intremoteTransportSocketReceiveBufferSizeRemote side transport socket receive buffer size.protected ByteBuffersendBufferprotected Mailbox<TransportSender>sendQueueprotected InetSocketAddresssendToprotected ByteBuffersocketBufferprotected longtotalBytesSentTotal bytes sent.protected byteversionprotected AbstractCodec.WriteModewriteModeprotected booleanwriteOpReady
-
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 voidalignBuffer(int alignment)voidalignData(int alignment)static intalignedValue(int value, int alignment)voidclearSendQueue()voidendMessage()voidenqueueSendRequest(TransportSender sender)voidenqueueSendRequest(TransportSender sender, int requiredBufferSize)voidensureBuffer(int size)voidensureData(int size)voidflush(boolean lastMessageCompleted)voidflushSerializeBuffer()abstract InetSocketAddressgetLastReadBufferSocketAddress()abstract voidinvalidDataStreamHandler()abstract voidprocessApplicationMessage()abstract voidprocessControlMessage()voidprocessRead()voidprocessSendQueue()voidprocessWrite()voidputControlMessage(byte command, int data)abstract voidreadPollOne()abstract voidscheduleSend()protected voidsend(ByteBuffer buffer)Send a buffer through the transport.protected abstract voidsendBufferFull(int tries)abstract voidsendCompleted()voidsetByteOrder(ByteOrder byteOrder)voidsetRecipient(InetSocketAddress sendTo)voidsetSenderThread()voidstartMessage(byte command, int ensureCapacity)abstract booleanterminated()abstract voidwritePollOne()-
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:
alignBufferin interfaceorg.epics.pvdata.pv.SerializableControl
-
startMessage
public final void startMessage(byte command, int ensureCapacity)- Specified by:
startMessagein interfaceTransportSendControl
-
putControlMessage
public final void putControlMessage(byte command, int data)
-
endMessage
public final void endMessage()
- Specified by:
endMessagein interfaceTransportSendControl
-
ensureBuffer
public final void ensureBuffer(int size)
- Specified by:
ensureBufferin interfaceorg.epics.pvdata.pv.SerializableControl
-
flushSerializeBuffer
public void flushSerializeBuffer()
- Specified by:
flushSerializeBufferin interfaceorg.epics.pvdata.pv.SerializableControl
-
flush
public void flush(boolean lastMessageCompleted)
- Specified by:
flushin interfaceTransportSendControl
-
processWrite
public final void processWrite() throws IOException, ConnectionClosedException- Throws:
IOExceptionConnectionClosedException
-
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:
setRecipientin interfaceTransportSendControl
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
-
terminated
public abstract boolean terminated()
-
-