Class ClientContextImpl
- java.lang.Object
-
- org.epics.pvaccess.client.impl.remote.ClientContextImpl
-
- All Implemented Interfaces:
Context
,LoggerProvider
public class ClientContextImpl extends Object implements Context
Implementation of PVAJ JCAContext
.- Version:
- $Id$
- Author:
- Matej Sekoranja
-
-
Field Summary
Fields Modifier and Type Field Description protected String
addressList
A space-separated list of broadcast address for process variable name resolution.protected boolean
autoAddressList
Define whether or not the network interfaces should be discovered at runtime.protected Map<String,Map<InetSocketAddress,BeaconHandlerImpl>>
beaconHandlers
Beacon handler map.protected float
beaconPeriod
Period in second between two beacon signals.protected int
broadcastPort
Broadcast (beacon, search) port number to listen to.protected BlockingUDPTransport
broadcastTransport
Broadcast transport needed to listen for broadcasts.protected ChannelProvider
channelProvider
Provider implementation.protected Map<Integer,Channel>
channelsByCID
Map of channels (keys are CIDs).protected float
connectionTimeout
If the context doesn't see a beacon from a server that it is connected to for connectionTimeout seconds then a state-of-health message is sent to the server over TCP/IP.protected BlockingTCPConnector
connector
PVA connector (creates PVA virtual circuit).protected int
debugLevel
Debug level.protected InetSocketAddress
localBroadcastAddress
Local multicast address.protected Logger
logger
Context logger.protected Map<Integer,ResponseRequest>
pendingResponseRequests
Map of pending response requests (keys are IOID).static String
PROVIDER_NAME
Name if the provider this context provides.protected int
receiveBufferSize
Receive buffer size (max size of payload).protected BlockingUDPTransport
searchTransport
UDP transport needed for channel searches.protected org.epics.pvdata.misc.Timer
timer
Timer.protected TransportRegistry
transportRegistry
PVA transport (virtual circuit) registry.static Version
VERSION
Version.
-
Constructor Summary
Constructors Constructor Description ClientContextImpl()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkState()
Check context state and tries to establish necessary state.Channel
createChannelInternal(String name, ChannelRequester requester, short priority, InetSocketAddress[] addresses)
void
destroy()
void
destroyChannel(ChannelImpl channel, boolean force)
Destroy channel.void
dispose()
String
getAddressList()
Get search address list.BeaconHandler
getBeaconHandler(String protocol, InetSocketAddress responseFrom)
Get (and if necessary create) beacon handler.float
getBeaconPeriod()
Get beacon period (in seconds).int
getBroadcastPort()
Get broadcast port.BlockingUDPTransport
getBroadcastTransport()
Broadcast transport.ChannelImpl
getChannel(int channelID)
Searches for a channel with given channel ID.ChannelSearchManager
getChannelSearchManager()
Get channel search manager.Configuration
getConfiguration()
Get configuration instance.float
getConnectionTimeout()
Get connection timeout (in seconds).int
getDebugLevel()
Get internal debug level configuration, higher value means more, 0 means none.InetSocketAddress
getLocalMulticastAddress()
Get local multicast address (group).Logger
getLogger()
Get logger.ChannelProvider
getProvider()
int
getReceiveBufferSize()
Get receive buffer size (max size of payload).ResponseRequest
getResponseRequest(int ioid)
Searches for a response request with given channel IOID.BlockingUDPTransport
getSearchTransport()
Broadcast transport.Map<String,SecurityPlugin>
getSecurityPlugins()
Get map of available security plug-ins.org.epics.pvdata.misc.Timer
getTimer()
Get timer.TransportRegistry
getTransportRegistry()
Get PVA transport (virtual circuit) registry.Version
getVersion()
void
initialize()
protected void
initializeLogger()
Initialize context logger.boolean
isAutoAddressList()
Get auto search-list flag.boolean
isDestroyed()
Get destruction status.boolean
isInitialized()
Get initialization status.protected void
loadConfiguration()
Load configuration.void
newServerDetected()
Called each time new server is detected.void
printInfo()
void
printInfo(PrintStream out)
int
registerResponseRequest(ResponseRequest request)
Register response request.ResponseRequest
unregisterResponseRequest(ResponseRequest request)
Unregister response request.
-
-
-
Field Detail
-
PROVIDER_NAME
public static final String PROVIDER_NAME
Name if the provider this context provides.- See Also:
- Constant Field Values
-
VERSION
public static final Version VERSION
Version.
-
logger
protected Logger logger
Context logger.
-
debugLevel
protected int debugLevel
Debug level.
-
addressList
protected String addressList
A space-separated list of broadcast address for process variable name resolution. Each address must be of the form: ip.number:port or host.name:port
-
autoAddressList
protected boolean autoAddressList
Define whether or not the network interfaces should be discovered at runtime.
-
connectionTimeout
protected float connectionTimeout
If the context doesn't see a beacon from a server that it is connected to for connectionTimeout seconds then a state-of-health message is sent to the server over TCP/IP. If this state-of-health message isn't promptly replied to then the context will assume that the server is no longer present on the network and disconnect.
-
beaconPeriod
protected float beaconPeriod
Period in second between two beacon signals.
-
broadcastPort
protected int broadcastPort
Broadcast (beacon, search) port number to listen to.
-
receiveBufferSize
protected int receiveBufferSize
Receive buffer size (max size of payload).
-
timer
protected org.epics.pvdata.misc.Timer timer
Timer.
-
broadcastTransport
protected BlockingUDPTransport broadcastTransport
Broadcast transport needed to listen for broadcasts.
-
searchTransport
protected BlockingUDPTransport searchTransport
UDP transport needed for channel searches.
-
localBroadcastAddress
protected InetSocketAddress localBroadcastAddress
Local multicast address.
-
connector
protected BlockingTCPConnector connector
PVA connector (creates PVA virtual circuit).
-
transportRegistry
protected TransportRegistry transportRegistry
PVA transport (virtual circuit) registry. This registry contains all active transports - connections to PVA servers.
-
pendingResponseRequests
protected final Map<Integer,ResponseRequest> pendingResponseRequests
Map of pending response requests (keys are IOID).
-
beaconHandlers
protected final Map<String,Map<InetSocketAddress,BeaconHandlerImpl>> beaconHandlers
Beacon handler map.
-
channelProvider
protected ChannelProvider channelProvider
Provider implementation.
-
-
Method Detail
-
getVersion
public Version getVersion()
-
initializeLogger
protected void initializeLogger()
Initialize context logger.
-
getConfiguration
public Configuration getConfiguration()
Get configuration instance.- Returns:
- the configuration.
-
loadConfiguration
protected void loadConfiguration()
Load configuration.
-
checkState
protected void checkState() throws PVAException, IllegalStateException
Check context state and tries to establish necessary state.- Throws:
PVAException
- any PVA exception.IllegalStateException
- thrown if context is already destroyed.
-
initialize
public void initialize() throws PVAException
- Throws:
PVAException
-
destroy
public void destroy()
-
createChannelInternal
public Channel createChannelInternal(String name, ChannelRequester requester, short priority, InetSocketAddress[] addresses) throws PVAException
- Throws:
PVAException
-
destroyChannel
public void destroyChannel(ChannelImpl channel, boolean force) throws PVAException, IllegalStateException
Destroy channel.- Parameters:
channel
- the channel to destroy.force
- force-full (non-user) destruction.- Throws:
PVAException
- unexpected exception.IllegalStateException
- if channel is already destroyed.
-
getChannel
public ChannelImpl getChannel(int channelID)
Searches for a channel with given channel ID.- Parameters:
channelID
- CID.- Returns:
- channel with given CID,
null
if non-existent.
-
printInfo
public void printInfo()
-
printInfo
public void printInfo(PrintStream out)
-
isInitialized
public boolean isInitialized()
Get initialization status.- Returns:
- initialization status.
-
isDestroyed
public boolean isDestroyed()
Get destruction status.- Returns:
- destruction status.
-
getAddressList
public String getAddressList()
Get search address list.- Returns:
- get search address list.
-
isAutoAddressList
public boolean isAutoAddressList()
Get auto search-list flag.- Returns:
- auto search-list flag.
-
getBeaconPeriod
public float getBeaconPeriod()
Get beacon period (in seconds).- Returns:
- beacon period (in seconds).
-
getConnectionTimeout
public float getConnectionTimeout()
Get connection timeout (in seconds).- Returns:
- connection timeout (in seconds).
-
getLogger
public Logger getLogger()
Get logger.- Specified by:
getLogger
in interfaceLoggerProvider
- Returns:
- logger.
-
getDebugLevel
public int getDebugLevel()
Description copied from interface:Context
Get internal debug level configuration, higher value means more, 0 means none.- Specified by:
getDebugLevel
in interfaceContext
- Returns:
- debug level.
-
getReceiveBufferSize
public int getReceiveBufferSize()
Get receive buffer size (max size of payload).- Returns:
- receive buffer size (max size of payload).
-
getBroadcastPort
public int getBroadcastPort()
Get broadcast port.- Returns:
- broadcast port.
-
dispose
public void dispose()
-
getBroadcastTransport
public BlockingUDPTransport getBroadcastTransport()
Broadcast transport.- Returns:
- broadcast transport.
-
getSearchTransport
public BlockingUDPTransport getSearchTransport()
Broadcast transport.- Returns:
- broadcast transport.
-
getLocalMulticastAddress
public InetSocketAddress getLocalMulticastAddress()
Get local multicast address (group).- Returns:
- the address.
-
getTransportRegistry
public TransportRegistry getTransportRegistry()
Get PVA transport (virtual circuit) registry.- Specified by:
getTransportRegistry
in interfaceContext
- Returns:
- PVA transport (virtual circuit) registry.
-
getTimer
public org.epics.pvdata.misc.Timer getTimer()
Get timer.
-
getSecurityPlugins
public Map<String,SecurityPlugin> getSecurityPlugins()
Description copied from interface:Context
Get map of available security plug-ins.- Specified by:
getSecurityPlugins
in interfaceContext
- Returns:
- the map of available security plug-ins
-
getChannelSearchManager
public ChannelSearchManager getChannelSearchManager()
Get channel search manager.- Returns:
- channel search manager.
-
newServerDetected
public void newServerDetected()
Called each time new server is detected.
-
getResponseRequest
public ResponseRequest getResponseRequest(int ioid)
Searches for a response request with given channel IOID.- Parameters:
ioid
- I/O ID.- Returns:
- request response with given I/O ID.
-
registerResponseRequest
public int registerResponseRequest(ResponseRequest request)
Register response request.- Parameters:
request
- request to register.- Returns:
- request ID (IOID).
-
unregisterResponseRequest
public ResponseRequest unregisterResponseRequest(ResponseRequest request)
Unregister response request.- Parameters:
request
- request to unregister.- Returns:
- removed object, can be
null
-
getBeaconHandler
public BeaconHandler getBeaconHandler(String protocol, InetSocketAddress responseFrom)
Get (and if necessary create) beacon handler.- Parameters:
protocol
- protocol used.responseFrom
- remote source address of received beacon.- Returns:
- beacon handler for particular server.
-
getProvider
public ChannelProvider getProvider()
-
-