Class BlockingUDPTransport
- java.lang.Object
-
- org.epics.pvaccess.impl.remote.udp.BlockingUDPTransport
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Transport
,TransportSendControl
,org.epics.pvdata.pv.DeserializableControl
,org.epics.pvdata.pv.SerializableControl
public class BlockingUDPTransport extends Object implements Transport, TransportSendControl
PVA UDP transport implementation.- Version:
- $Id$
- Author:
- Matej Sekoranja
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BlockingUDPTransport.InetAddressType
InetAddress type.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
closed
Closed status.protected ResponseHandler
responseHandler
Response handler.
-
Constructor Summary
Constructors Constructor Description BlockingUDPTransport(Context context, ResponseHandler responseHandler, DatagramChannel channel, InetSocketAddress bindAddress, InetSocketAddress[] sendAddresses, short remoteTransportRevision)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acquire(TransportClient client)
Acquires transport.void
alignBuffer(int alignment)
void
alignData(int alignment)
void
aliveNotification()
Alive notification.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.org.epics.pvdata.pv.Field
cachedDeserialize(ByteBuffer buffer)
void
cachedSerialize(org.epics.pvdata.pv.Field field, ByteBuffer buffer)
void
changedTransport()
Notification that transport has changed (server restarted).void
close()
Close transport.void
endMessage()
void
enqueueSendRequest(TransportSender sender)
Enqueue send request.void
ensureBuffer(int size)
void
ensureData(int size)
boolean
flush()
Flush...void
flush(boolean lastMessageCompleted)
void
flushSerializeBuffer()
InetSocketAddress
getBindAddress()
Get bind address.Context
getContext()
Get context transport is living in.InetSocketAddress[]
getIgnoredAddresses()
Get list of ignored addresses.short
getPriority()
Transport priority.int
getReceiveBufferSize()
Get receive buffer size.InetSocketAddress
getRemoteAddress()
Get remote address.byte
getRevision()
Transport protocol revision.SecurityPlugin.SecuritySession
getSecuritySession()
InetSocketAddress[]
getSendAddresses()
Get list of send addresses.int
getSocketReceiveBufferSize()
Get socket receive buffer size.String
getType()
Get protocol type (e.g.boolean
isOpen()
MembershipKey
join(InetAddress group, NetworkInterface nif)
protected void
processRead()
Process input (read) IO event.protected void
processWrite()
Process output (write) IO event.void
release(TransportClient client)
Releases transport.boolean
send(ByteBuffer buffer)
Send a buffer through the transport.void
send(ByteBuffer buffer, InetSocketAddress address)
Send a buffer through the transport immediately.boolean
send(ByteBuffer buffer, BlockingUDPTransport.InetAddressType target)
Send a buffer through the transport.void
setByteOrder(ByteOrder byteOrder)
Set byte order.void
setIgnoredAddresses(InetSocketAddress[] addresses)
Set ignore list.void
setMutlicastNIF(NetworkInterface nif, boolean loopback)
void
setRecipient(InetSocketAddress sendTo)
void
setRemoteRevision(byte minor)
Set remote transport protocol revision.void
setRemoteTransportReceiveBufferSize(int receiveBufferSize)
Set remote transport receive buffer size.void
setRemoteTransportSocketReceiveBufferSize(int socketReceiveBufferSize)
Set remote transport socket receive buffer size.void
setSendAddresses(InetSocketAddress[] addresses)
Set list of send addresses.void
start()
Start processing requests.void
startMessage(byte command, int ensureCapacity)
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.
-
-
-
Field Detail
-
responseHandler
protected final ResponseHandler responseHandler
Response handler.
-
closed
protected volatile boolean closed
Closed status.
-
-
Constructor Detail
-
BlockingUDPTransport
public BlockingUDPTransport(Context context, ResponseHandler responseHandler, DatagramChannel channel, InetSocketAddress bindAddress, InetSocketAddress[] sendAddresses, short remoteTransportRevision)
-
-
Method Detail
-
start
public void start()
Start processing requests.
-
close
public void close() throws IOException
Close transport.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
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.
-
processRead
protected void processRead()
Process input (read) IO event.
-
processWrite
protected void processWrite()
Process output (write) IO event.
-
send
public boolean send(ByteBuffer buffer, BlockingUDPTransport.InetAddressType target)
Send a buffer through the transport.- Parameters:
buffer
- buffer to send.target
- filter (selector) of what addresses to use when sending.- Returns:
- success status.
-
send
public boolean send(ByteBuffer buffer)
Send a buffer through the transport.- Parameters:
buffer
- buffer to send.- Returns:
- success status.
-
send
public void send(ByteBuffer buffer, InetSocketAddress address)
Send a buffer through the transport immediately.- Parameters:
buffer
- buffer to send.address
- send address.
-
join
public MembershipKey join(InetAddress group, NetworkInterface nif) throws IOException
- Throws:
IOException
-
setMutlicastNIF
public void setMutlicastNIF(NetworkInterface nif, boolean loopback) throws IOException
- Throws:
IOException
-
getRevision
public byte getRevision()
Description copied from interface:Transport
Transport protocol revision.- Specified by:
getRevision
in interfaceTransport
- Returns:
- protocol revision.
- See Also:
Transport.getRevision()
-
getType
public String getType()
Get protocol type (e.g. tpc, udp, ssl, etc.).- Specified by:
getType
in interfaceTransport
- Returns:
- protocol type.
- See Also:
Transport.getType()
-
changedTransport
public void changedTransport()
Description copied from interface:Transport
Notification that transport has changed (server restarted).- Specified by:
changedTransport
in interfaceTransport
- See Also:
Transport.changedTransport()
-
getContext
public Context getContext()
Description copied from interface:Transport
Get context transport is living in.- Specified by:
getContext
in interfaceTransport
- Returns:
- context transport is living in.
- See Also:
Transport.getContext()
-
getPriority
public short getPriority()
Description copied from interface:Transport
Transport priority.- Specified by:
getPriority
in interfaceTransport
- Returns:
- protocol priority.
- See Also:
Transport.getPriority()
-
flush
public boolean flush()
Flush...- Returns:
- success status.
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:Transport
Get remote address.- Specified by:
getRemoteAddress
in interfaceTransport
- Returns:
- remote address.
- See Also:
Transport.getRemoteAddress()
-
getSendAddresses
public InetSocketAddress[] getSendAddresses()
Get list of send addresses.- Returns:
- send addresses.
-
getIgnoredAddresses
public InetSocketAddress[] getIgnoredAddresses()
Get list of ignored addresses.- Returns:
- ignored addresses.
-
getBindAddress
public InetSocketAddress getBindAddress()
Get bind address.- Returns:
- bind address.
-
setSendAddresses
public void setSendAddresses(InetSocketAddress[] addresses)
Set list of send addresses.- Parameters:
addresses
- list of send addresses, non-null
.
-
setIgnoredAddresses
public void setIgnoredAddresses(InetSocketAddress[] addresses)
Set ignore list.- Parameters:
addresses
- list of ignored addresses.
-
getReceiveBufferSize
public int getReceiveBufferSize()
Description copied from interface:Transport
Get receive buffer size.- Specified by:
getReceiveBufferSize
in interfaceTransport
- Returns:
- receive buffer size.
- See Also:
Transport.getReceiveBufferSize()
-
setRemoteRevision
public void setRemoteRevision(byte minor)
Description copied from interface:Transport
Set remote transport protocol revision.- Specified by:
setRemoteRevision
in interfaceTransport
- Parameters:
minor
- protocol revision.
-
setRemoteTransportReceiveBufferSize
public void setRemoteTransportReceiveBufferSize(int receiveBufferSize)
Description copied from interface:Transport
Set remote transport receive buffer size.- Specified by:
setRemoteTransportReceiveBufferSize
in interfaceTransport
- Parameters:
receiveBufferSize
- receive buffer size.- See Also:
Transport.setRemoteTransportReceiveBufferSize(int)
-
setRemoteTransportSocketReceiveBufferSize
public void setRemoteTransportSocketReceiveBufferSize(int socketReceiveBufferSize)
Description copied from interface:Transport
Set remote transport socket receive buffer size.- Specified by:
setRemoteTransportSocketReceiveBufferSize
in interfaceTransport
- Parameters:
socketReceiveBufferSize
- remote socket receive buffer size.- See Also:
Transport.setRemoteTransportSocketReceiveBufferSize(int)
-
getSocketReceiveBufferSize
public int getSocketReceiveBufferSize()
Description copied from interface:Transport
Get socket receive buffer size.- Specified by:
getSocketReceiveBufferSize
in interfaceTransport
- Returns:
- socket receive buffer size.
- See Also:
Transport.getSocketReceiveBufferSize()
-
enqueueSendRequest
public final void enqueueSendRequest(TransportSender sender)
Description copied from interface:Transport
Enqueue send request.- Specified by:
enqueueSendRequest
in interfaceTransport
- Parameters:
sender
- sender to enqueue.
-
ensureBuffer
public void ensureBuffer(int size)
- Specified by:
ensureBuffer
in interfaceorg.epics.pvdata.pv.SerializableControl
-
alignBuffer
public void alignBuffer(int alignment)
- Specified by:
alignBuffer
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
-
startMessage
public final void startMessage(byte command, int ensureCapacity)
- Specified by:
startMessage
in interfaceTransportSendControl
-
endMessage
public final void endMessage()
- Specified by:
endMessage
in interfaceTransportSendControl
-
setRecipient
public final void setRecipient(InetSocketAddress sendTo)
- Specified by:
setRecipient
in interfaceTransportSendControl
-
ensureData
public void ensureData(int size)
- Specified by:
ensureData
in interfaceorg.epics.pvdata.pv.DeserializableControl
-
cachedSerialize
public void cachedSerialize(org.epics.pvdata.pv.Field field, ByteBuffer buffer)
- Specified by:
cachedSerialize
in interfaceorg.epics.pvdata.pv.SerializableControl
-
cachedDeserialize
public org.epics.pvdata.pv.Field cachedDeserialize(ByteBuffer buffer)
- Specified by:
cachedDeserialize
in interfaceorg.epics.pvdata.pv.DeserializableControl
-
alignData
public void alignData(int alignment)
- Specified by:
alignData
in interfaceorg.epics.pvdata.pv.DeserializableControl
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
Description copied from interface:Transport
Set byte order.- Specified by:
setByteOrder
in interfaceTransport
- Parameters:
byteOrder
- byte order to set.
-
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.
-
verified
public void verified(org.epics.pvdata.pv.Status status)
Description copied from interface:Transport
Acknowledge that transport was verified.
-
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
-
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
.
-
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.
-
getSecuritySession
public SecurityPlugin.SecuritySession getSecuritySession()
- Specified by:
getSecuritySession
in interfaceTransport
-
-