Class NonBlockingServerTCPTransport
- java.lang.Object
-
- org.epics.pvaccess.impl.remote.codec.AbstractCodec
-
- org.epics.pvaccess.impl.remote.codec.impl.NonBlockingAbstractCodec
-
- org.epics.pvaccess.impl.remote.codec.impl.NonBlockingSocketAbstractCodec
-
- org.epics.pvaccess.impl.remote.tcp.NonBlockingTCPTransport
-
- org.epics.pvaccess.server.impl.remote.tcp.NonBlockingServerTCPTransport
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
,WritableByteChannel
,Lockable
,PollEvents
,ChannelHostingTransport
,Transport
,TransportSendControl
,TransportSender
,SecurityPlugin.SecurityPluginControl
,org.epics.pvdata.pv.DeserializableControl
,org.epics.pvdata.pv.SerializableControl
public class NonBlockingServerTCPTransport extends NonBlockingTCPTransport implements ChannelHostingTransport, TransportSender, SecurityPlugin.SecurityPluginControl
Server TCP transport implementation.- Version:
- $Id$
- Author:
- Matej Sekoranja
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.epics.pvaccess.impl.remote.codec.AbstractCodec
AbstractCodec.ReadMode, AbstractCodec.WriteMode
-
-
Field Summary
-
Fields inherited from class org.epics.pvaccess.impl.remote.tcp.NonBlockingTCPTransport
context, incomingIR, outgoingIR, priority, remoteTransportRevision, responseHandler, verified
-
Fields inherited from class org.epics.pvaccess.impl.remote.codec.impl.NonBlockingSocketAbstractCodec
channel, socketAddress
-
Fields inherited from class org.epics.pvaccess.impl.remote.codec.impl.NonBlockingAbstractCodec
key, poller
-
Fields inherited from class org.epics.pvaccess.impl.remote.codec.AbstractCodec
blockingProcessQueue, command, flags, logger, MAX_ENSURE_BUFFER_SIZE, MAX_ENSURE_DATA_SIZE, MAX_ENSURE_SIZE, MAX_MESSAGE_PROCESS, MAX_MESSAGE_SEND, payloadSize, readMode, remoteTransportSocketReceiveBufferSize, sendBuffer, sendQueue, sendTo, socketBuffer, totalBytesSent, version, writeMode, writeOpReady
-
-
Constructor Summary
Constructors Constructor Description NonBlockingServerTCPTransport(Context context, Poller poller, SocketChannel channel, ResponseHandler responseHandler, int receiveBufferSize)
Server TCP transport constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acquire(TransportClient client)
Acquires transport.void
aliveNotification()
Alive notification.void
authenticationCompleted(org.epics.pvdata.pv.Status status)
void
authNZInitialize(Object data)
Used to initialize authNZ (select security plug-in).void
authNZMessage(org.epics.pvdata.pv.PVField data)
Pass data to the active security plug-in session.void
close()
void
depreallocateChannelSID(int sid)
De-preallocate new channel SID.ServerChannel
getChannel(int sid)
Get channel by its SID.int
getChannelCount()
Get channel count.ServerChannel[]
getChannels()
Get an array of all hosted channels.SecurityPlugin.SecuritySession
getSecuritySession()
protected void
internalClose()
Called to any resources just before closing transportvoid
lock()
int
preallocateChannelSID()
Preallocate new channel SID.protected void
ready()
void
registerChannel(int sid, ServerChannel channel)
Register a new channel.void
release(TransportClient client)
Releases transport.void
send(ByteBuffer buffer, TransportSendControl control)
PVA connection validation request.void
sendSecurityPluginMessage(org.epics.pvdata.pv.PVField data)
void
unlock()
void
unregisterChannel(int sid)
Unregister a new channel (and deallocates its handle).void
verified(org.epics.pvdata.pv.Status status)
Acknowledge that transport was verified.boolean
verify(long timeoutMs)
Waits (if needed) until transport is verified, i.e.-
Methods inherited from class org.epics.pvaccess.impl.remote.tcp.NonBlockingTCPTransport
cachedDeserialize, cachedSerialize, changedTransport, getContext, getPriority, getReceiveBufferSize, getRemoteAddress, getRevision, getSocketReceiveBufferSize, getType, internalDestroy, processApplicationMessage, processControlMessage, setRemoteRevision, setRemoteTransportReceiveBufferSize, setRemoteTransportSocketReceiveBufferSize
-
Methods inherited from class org.epics.pvaccess.impl.remote.codec.impl.NonBlockingSocketAbstractCodec
getLastReadBufferSocketAddress, invalidDataStreamHandler, read, write
-
Methods inherited from class org.epics.pvaccess.impl.remote.codec.impl.NonBlockingAbstractCodec
isOpen, pollNotify, readPollOne, registeredNotify, scheduleSend, sendBufferFull, sendCompleted, terminated, writePollOne
-
Methods inherited from class org.epics.pvaccess.impl.remote.codec.AbstractCodec
alignBuffer, alignData, alignedValue, clearSendQueue, endMessage, enqueueSendRequest, enqueueSendRequest, ensureBuffer, ensureData, flush, flushSerializeBuffer, processRead, processSendQueue, processWrite, putControlMessage, send, setByteOrder, setRecipient, setSenderThread, startMessage
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.epics.pvaccess.impl.remote.Transport
enqueueSendRequest, setByteOrder
-
-
-
-
Constructor Detail
-
NonBlockingServerTCPTransport
public NonBlockingServerTCPTransport(Context context, Poller poller, SocketChannel channel, ResponseHandler responseHandler, int receiveBufferSize) throws SocketException
Server TCP transport constructor.- Parameters:
context
- context where transport lives in.poller
- poller to use.channel
- used socket channel.responseHandler
- response handler used to process PVA headers.receiveBufferSize
- receive buffer size.- Throws:
SocketException
- thrown on any socket exception.
-
-
Method Detail
-
internalClose
protected void internalClose()
Description copied from class:NonBlockingTCPTransport
Called to any resources just before closing transport- Overrides:
internalClose
in classNonBlockingTCPTransport
- See Also:
NonBlockingTCPTransport.internalClose()
-
preallocateChannelSID
public int preallocateChannelSID()
Preallocate new channel SID.- Specified by:
preallocateChannelSID
in interfaceChannelHostingTransport
- Returns:
- new channel server id (SID).
-
depreallocateChannelSID
public void depreallocateChannelSID(int sid)
De-preallocate new channel SID.- Specified by:
depreallocateChannelSID
in interfaceChannelHostingTransport
- Parameters:
sid
- preallocated channel SID.
-
registerChannel
public void registerChannel(int sid, ServerChannel channel)
Register a new channel.- Specified by:
registerChannel
in interfaceChannelHostingTransport
- Parameters:
sid
- preallocated channel SID.channel
- channel to register.
-
unregisterChannel
public void unregisterChannel(int sid)
Unregister a new channel (and deallocates its handle).- Specified by:
unregisterChannel
in interfaceChannelHostingTransport
- Parameters:
sid
- SID
-
getChannel
public ServerChannel getChannel(int sid)
Get channel by its SID.- Specified by:
getChannel
in interfaceChannelHostingTransport
- Parameters:
sid
- channel SID- Returns:
- channel with given SID,
null
otherwise
-
getChannels
public ServerChannel[] getChannels()
Description copied from interface:ChannelHostingTransport
Get an array of all hosted channels.- Specified by:
getChannels
in interfaceChannelHostingTransport
- Returns:
- an array of all hosted channels.
-
getChannelCount
public int getChannelCount()
Get channel count.- Specified by:
getChannelCount
in interfaceChannelHostingTransport
- Returns:
- channel count.
-
send
public void send(ByteBuffer buffer, TransportSendControl control)
PVA connection validation request. A server sends a validate connection message when it receives a new connection. The message indicates that the server is ready to receive requests; the client must not send any messages on the connection until it has received the validate connection message from the server. No reply to the message is expected by the server. The purpose of the validate connection message is two-fold: It informs the client of the protocol version supported by the server. It prevents the client from writing a request message to its local transport buffers until after the server has acknowledged that it can actually process the request. This avoids a race condition caused by the server's TCP/IP stack accepting connections in its backlog while the server is in the process of shutting down: if the client were to send a request in this situation, the request would be lost but the client could not safely re-issue the request because that might violate at-most-once semantics. The validate connection message guarantees that a server is not in the middle of shutting down when the server's TCP/IP stack accepts an incoming connection and so avoids the race condition.- Specified by:
send
in interfaceTransportSender
- Parameters:
buffer
- buffer to send.control
- transport send control instance.- See Also:
TransportSender.send(java.nio.ByteBuffer, org.epics.pvaccess.impl.remote.TransportSendControl)
-
acquire
public boolean acquire(TransportClient client)
Description copied from interface:Transport
Acquires transport.
-
release
public void release(TransportClient client)
Description copied from interface:Transport
Releases transport.
-
verified
public void verified(org.epics.pvdata.pv.Status status)
Description copied from interface:Transport
Acknowledge that transport was verified.- Specified by:
verified
in interfaceTransport
- Overrides:
verified
in classNonBlockingTCPTransport
- Parameters:
status
- verification status.
-
verify
public boolean verify(long timeoutMs)
Description copied from interface:Transport
Waits (if needed) until transport is verified, i.e. verified() method is being called.- Specified by:
verify
in interfaceTransport
- Overrides:
verify
in classNonBlockingTCPTransport
- Parameters:
timeoutMs
- timeout to wait for verification, infinite if 0.- Returns:
- completion status.
-
authNZInitialize
public void authNZInitialize(Object data)
Description copied from interface:Transport
Used to initialize authNZ (select security plug-in).- Specified by:
authNZInitialize
in interfaceTransport
- Parameters:
data
- any data.
-
authNZMessage
public void authNZMessage(org.epics.pvdata.pv.PVField data)
Description copied from interface:Transport
Pass data to the active security plug-in session.- Specified by:
authNZMessage
in interfaceTransport
- Parameters:
data
- the data (any data), can benull
.
-
sendSecurityPluginMessage
public void sendSecurityPluginMessage(org.epics.pvdata.pv.PVField data)
- Specified by:
sendSecurityPluginMessage
in interfaceSecurityPlugin.SecurityPluginControl
-
authenticationCompleted
public void authenticationCompleted(org.epics.pvdata.pv.Status status)
- Specified by:
authenticationCompleted
in interfaceSecurityPlugin.SecurityPluginControl
-
aliveNotification
public void aliveNotification()
Description copied from interface:Transport
Alive notification. This method needs to be called (by newly received data or beacon) at least once in this period, if not echo will be issued and if there is not response to it, transport will be considered as unresponsive.- Specified by:
aliveNotification
in interfaceTransport
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classNonBlockingAbstractCodec
- Throws:
IOException
-
getSecuritySession
public SecurityPlugin.SecuritySession getSecuritySession()
- Specified by:
getSecuritySession
in interfaceTransport
-
ready
protected void ready()
- Specified by:
ready
in classNonBlockingAbstractCodec
-
-