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 StringaddressListA space-separated list of broadcast address for process variable name resolution.protected booleanautoAddressListDefine whether or not the network interfaces should be discovered at runtime.protected Map<String,Map<InetSocketAddress,BeaconHandlerImpl>>beaconHandlersBeacon handler map.protected floatbeaconPeriodPeriod in second between two beacon signals.protected intbroadcastPortBroadcast (beacon, search) port number to listen to.protected BlockingUDPTransportbroadcastTransportBroadcast transport needed to listen for broadcasts.protected ChannelProviderchannelProviderProvider implementation.protected Map<Integer,Channel>channelsByCIDMap of channels (keys are CIDs).protected floatconnectionTimeoutIf 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 BlockingTCPConnectorconnectorPVA connector (creates PVA virtual circuit).protected intdebugLevelDebug level.protected InetSocketAddresslocalBroadcastAddressLocal multicast address.protected LoggerloggerContext logger.protected Map<Integer,ResponseRequest>pendingResponseRequestsMap of pending response requests (keys are IOID).static StringPROVIDER_NAMEName if the provider this context provides.protected intreceiveBufferSizeReceive buffer size (max size of payload).protected BlockingUDPTransportsearchTransportUDP transport needed for channel searches.protected org.epics.pvdata.misc.TimertimerTimer.protected TransportRegistrytransportRegistryPVA transport (virtual circuit) registry.static VersionVERSIONVersion.
-
Constructor Summary
Constructors Constructor Description ClientContextImpl()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckState()Check context state and tries to establish necessary state.ChannelcreateChannelInternal(String name, ChannelRequester requester, short priority, InetSocketAddress[] addresses)voiddestroy()voiddestroyChannel(ChannelImpl channel, boolean force)Destroy channel.voiddispose()StringgetAddressList()Get search address list.BeaconHandlergetBeaconHandler(String protocol, InetSocketAddress responseFrom)Get (and if necessary create) beacon handler.floatgetBeaconPeriod()Get beacon period (in seconds).intgetBroadcastPort()Get broadcast port.BlockingUDPTransportgetBroadcastTransport()Broadcast transport.ChannelImplgetChannel(int channelID)Searches for a channel with given channel ID.ChannelSearchManagergetChannelSearchManager()Get channel search manager.ConfigurationgetConfiguration()Get configuration instance.floatgetConnectionTimeout()Get connection timeout (in seconds).intgetDebugLevel()Get internal debug level configuration, higher value means more, 0 means none.InetSocketAddressgetLocalMulticastAddress()Get local multicast address (group).LoggergetLogger()Get logger.ChannelProvidergetProvider()intgetReceiveBufferSize()Get receive buffer size (max size of payload).ResponseRequestgetResponseRequest(int ioid)Searches for a response request with given channel IOID.BlockingUDPTransportgetSearchTransport()Broadcast transport.Map<String,SecurityPlugin>getSecurityPlugins()Get map of available security plug-ins.org.epics.pvdata.misc.TimergetTimer()Get timer.TransportRegistrygetTransportRegistry()Get PVA transport (virtual circuit) registry.VersiongetVersion()voidinitialize()protected voidinitializeLogger()Initialize context logger.booleanisAutoAddressList()Get auto search-list flag.booleanisDestroyed()Get destruction status.booleanisInitialized()Get initialization status.protected voidloadConfiguration()Load configuration.voidnewServerDetected()Called each time new server is detected.voidprintInfo()voidprintInfo(PrintStream out)intregisterResponseRequest(ResponseRequest request)Register response request.ResponseRequestunregisterResponseRequest(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, IllegalStateExceptionCheck 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,
nullif 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:
getLoggerin interfaceLoggerProvider- Returns:
- logger.
-
getDebugLevel
public int getDebugLevel()
Description copied from interface:ContextGet internal debug level configuration, higher value means more, 0 means none.- Specified by:
getDebugLevelin 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:
getTransportRegistryin 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:ContextGet map of available security plug-ins.- Specified by:
getSecurityPluginsin 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()
-
-