Class BlockingServerTCPTransport
- java.lang.Object
-
- org.epics.pvaccess.impl.remote.codec.AbstractCodec
-
- org.epics.pvaccess.impl.remote.codec.impl.BlockingAbstractCodec
-
- org.epics.pvaccess.impl.remote.codec.impl.BlockingSocketAbstractCodec
-
- org.epics.pvaccess.impl.remote.tcp.BlockingTCPTransport
-
- org.epics.pvaccess.server.impl.remote.tcp.BlockingServerTCPTransport
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ReadableByteChannel,WritableByteChannel,Lockable,ChannelHostingTransport,Transport,TransportSendControl,TransportSender,SecurityPlugin.SecurityPluginControl,org.epics.pvdata.pv.DeserializableControl,org.epics.pvdata.pv.SerializableControl
public class BlockingServerTCPTransport extends BlockingTCPTransport 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.BlockingTCPTransport
context, incomingIR, outgoingIR, priority, remoteTransportRevision, responseHandler, verified, verifiedCalled
-
Fields inherited from class org.epics.pvaccess.impl.remote.codec.impl.BlockingSocketAbstractCodec
channel, socketAddress
-
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 BlockingServerTCPTransport(Context context, SocketChannel channel, ResponseHandler responseHandler, int receiveBufferSize)Server TCP transport constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquire(TransportClient client)Acquires transport.voidaliveNotification()Alive notification.voidauthenticationCompleted(org.epics.pvdata.pv.Status status)voidauthNZInitialize(Object data)Used to initialize authNZ (select security plug-in).voidauthNZMessage(org.epics.pvdata.pv.PVField data)Pass data to the active security plug-in session.voidclose()voiddepreallocateChannelSID(int sid)De-preallocate new channel SID.ServerChannelgetChannel(int sid)Get channel by its SID.intgetChannelCount()Get channel count.ServerChannel[]getChannels()Get an array of all hosted channels.SecurityPlugin.SecuritySessiongetSecuritySession()protected voidinternalClose()Called to any resources just before closing transportvoidlock()intpreallocateChannelSID()Preallocate new channel SID.voidregisterChannel(int sid, ServerChannel channel)Register a new channel.voidrelease(TransportClient client)Releases transport.voidsend(ByteBuffer buffer, TransportSendControl control)PVA connection validation request.voidsendSecurityPluginMessage(org.epics.pvdata.pv.PVField data)voidunlock()voidunregisterChannel(int sid)Unregister a new channel (and deallocates its handle).voidverified(org.epics.pvdata.pv.Status status)Acknowledge that transport was verified.booleanverify(long timeoutMs)Waits (if needed) until transport is verified, i.e.-
Methods inherited from class org.epics.pvaccess.impl.remote.tcp.BlockingTCPTransport
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.BlockingSocketAbstractCodec
getLastReadBufferSocketAddress, invalidDataStreamHandler, read, write
-
Methods inherited from class org.epics.pvaccess.impl.remote.codec.impl.BlockingAbstractCodec
isOpen, readPollOne, receiveThread, scheduleSend, sendBufferFull, sendCompleted, sendThread, start, 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
-
BlockingServerTCPTransport
public BlockingServerTCPTransport(Context context, SocketChannel channel, ResponseHandler responseHandler, int receiveBufferSize) throws SocketException
Server TCP transport constructor.- Parameters:
context- context where transport lives in.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:BlockingTCPTransportCalled to any resources just before closing transport- Overrides:
internalClosein classBlockingTCPTransport- See Also:
BlockingTCPTransport.internalClose()
-
preallocateChannelSID
public int preallocateChannelSID()
Preallocate new channel SID.- Specified by:
preallocateChannelSIDin interfaceChannelHostingTransport- Returns:
- new channel server id (SID).
-
depreallocateChannelSID
public void depreallocateChannelSID(int sid)
De-preallocate new channel SID.- Specified by:
depreallocateChannelSIDin interfaceChannelHostingTransport- Parameters:
sid- preallocated channel SID.
-
registerChannel
public void registerChannel(int sid, ServerChannel channel)Register a new channel.- Specified by:
registerChannelin 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:
unregisterChannelin interfaceChannelHostingTransport- Parameters:
sid- SID
-
getChannel
public ServerChannel getChannel(int sid)
Get channel by its SID.- Specified by:
getChannelin interfaceChannelHostingTransport- Parameters:
sid- channel SID- Returns:
- channel with given SID,
nullotherwise
-
getChannels
public ServerChannel[] getChannels()
Description copied from interface:ChannelHostingTransportGet an array of all hosted channels.- Specified by:
getChannelsin interfaceChannelHostingTransport- Returns:
- an array of all hosted channels.
-
getChannelCount
public int getChannelCount()
Get channel count.- Specified by:
getChannelCountin 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:
sendin 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:TransportAcquires transport.
-
release
public void release(TransportClient client)
Description copied from interface:TransportReleases transport.
-
verified
public void verified(org.epics.pvdata.pv.Status status)
Description copied from interface:TransportAcknowledge that transport was verified.- Specified by:
verifiedin interfaceTransport- Overrides:
verifiedin classBlockingTCPTransport- Parameters:
status- verification status.
-
verify
public boolean verify(long timeoutMs)
Description copied from interface:TransportWaits (if needed) until transport is verified, i.e. verified() method is being called.- Specified by:
verifyin interfaceTransport- Overrides:
verifyin classBlockingTCPTransport- Parameters:
timeoutMs- timeout to wait for verification, infinite if 0.- Returns:
- completion status.
-
authNZInitialize
public void authNZInitialize(Object data)
Description copied from interface:TransportUsed to initialize authNZ (select security plug-in).- Specified by:
authNZInitializein interfaceTransport- Parameters:
data- any data.
-
authNZMessage
public void authNZMessage(org.epics.pvdata.pv.PVField data)
Description copied from interface:TransportPass data to the active security plug-in session.- Specified by:
authNZMessagein interfaceTransport- Parameters:
data- the data (any data), can benull.
-
sendSecurityPluginMessage
public void sendSecurityPluginMessage(org.epics.pvdata.pv.PVField data)
- Specified by:
sendSecurityPluginMessagein interfaceSecurityPlugin.SecurityPluginControl
-
authenticationCompleted
public void authenticationCompleted(org.epics.pvdata.pv.Status status)
- Specified by:
authenticationCompletedin interfaceSecurityPlugin.SecurityPluginControl
-
aliveNotification
public void aliveNotification()
Description copied from interface:TransportAlive 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:
aliveNotificationin interfaceTransport
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classBlockingAbstractCodec- Throws:
IOException
-
getSecuritySession
public SecurityPlugin.SecuritySession getSecuritySession()
- Specified by:
getSecuritySessionin interfaceTransport
-
-