Package com.cosylab.epics.caj.cas
Class CAJServerContext
- java.lang.Object
-
- gov.aps.jca.cas.ServerContext
-
- com.cosylab.epics.caj.cas.CAJServerContext
-
- All Implemented Interfaces:
CAContext,LoggerProvider,Configurable
public class CAJServerContext extends ServerContext implements CAContext, Configurable
Implementation of CAJ JCAContext.- Version:
- $id$
- Author:
- Matej Sekoranja
-
-
Field Summary
Fields Modifier and Type Field Description protected CASAcceptoracceptorCAS acceptor (accepts CA virtual circuit).protected booleanautoBeaconAddressListDefine whether or not the network interfaces should be discovered at runtime.protected StringbeaconAddressListA space-separated list of broadcast address which to send beacons.protected BeaconEmitterbeaconEmitterBeacon emitter..protected floatbeaconPeriodPeriod in second between two beacon signals.protected intbeaconPortPort number for the repeater to listen to.protected BroadcastTransportbroadcastTransportBroadcast transport needed for channel searches.protected CachedByteBufferAllocatorcachedBufferAllocatorCached byte buffer allocator.static StringCAJ_SINGLE_THREADED_MODELString value of the JVM property key to turn on single threaded model.protected ArrayListcontextExceptionListenersList of context exception listeners.protected ArrayListcontextMessageListenersList of context message listeners.protected StringignoreAddressListA space-separated list of address from which to ignore name resolution requests.protected LeaderFollowersThreadPoolleaderFollowersThreadPoolLeader/followers thread pool.protected LoggerloggerContext logger.protected intmaxArrayBytesLength in bytes of the maximum array size that may pass through CA.protected ReactorreactorReactor.protected ObjectrunLockRun lock.protected ServerserverServer.protected inttcpServerPortThe TCP server port (used to establish channels).protected TimertimerTimer.protected CATransportRegistrytransportRegistryCA transport (virtual circuit) registry.protected intudpServerPortThe UDP server port (used for pv name search requests).static VersionVERSIONVersion.
-
Constructor Summary
Constructors Constructor Description CAJServerContext()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddContextExceptionListener(ContextExceptionListener l)Add a ContextExceptionListener to this context.voidaddContextMessageListener(ContextMessageListener l)Add a ContextMessageListener to this context.protected voidcheckState()Check context state and tries to establish necessary state.voidconfigure(Configuration configuration)Pass theConfigurationto theConfigurableclass.voiddestroy()Clear all resources attached to this ContextintgenerateChannelSID()Generate channel SID.StringgetBeaconAddressList()Get beacon address list.floatgetBeaconPeriod()Get beacon period (in seconds).intgetBeaconPort()Get beacon port.intgetBroadcastPort()Get broadcast port.BroadcastTransportgetBroadcastTransport()Broadcast transport.CachedByteBufferAllocatorgetCachedBufferAllocator()Get cached byte allocator.ContextExceptionListener[]getContextExceptionListeners()ContextMessageListener[]getContextMessageListeners()StringgetIgnoreAddressList()Get ignore search address list.intgetLastReceivedSequenceNumber(int seqNo)Set last UDP recived sequence number.LeaderFollowersThreadPoolgetLeaderFollowersThreadPool()Get LF thread pool.LoggergetLogger()Get logger.intgetMaxArrayBytes()Get max array payload size.ReactorgetReactor()Get context reactor.ServergetServer()Get server implementation.InetAddressgetServerInetAddress()Get server newtwork (IP) address.intgetServerPort()Deprecated.intgetTcpServerPort()Get the TCP server port number (used to establish channels).TimergetTimer()Get timer.CATransportRegistrygetTransportRegistry()Get CA transport (virtual circuit) registry.intgetUdpServerPort()Get the UDP server port number (used for pv name search requests).StringgetUserName()Get user name (used to report to the server).VersiongetVersion()Get context version.voidinitialize(Server server)Set server and initialize.protected voidinitializeLogger()Initialize context logger.voidinvalidateLastReceivedSequence()Invalidate last (UDP) received sequence.booleanisAutoBeaconAddressList()Get beacon address list auto flag.booleanisDestroyed()Get destruction status.booleanisInitialized()Get initialization status.protected voidloadConfiguration()Load configuration.voidprintInfo(PrintStream out)Prints detailed information about the Context to the specified output stream.voidremoveContextExceptionListener(ContextExceptionListener l)Removes a ContextExceptionListener from this context.voidremoveContextMessageListener(ContextMessageListener l)Removes a ContextMessageListener from this context.voidrun(int seconds)Run server (process events).voidsetLastReceivedSequenceNumber(int seqNo)Set last UDP recived sequence number.voidsetServerPort(int port)Deprecated.voidsetTcpServerPort(int port)Set the TCP server port number (used to establish channels).voidsetUdpServerPort(int port)Set the UDP server port number (used for pv name search requests).voidshutdown()Shutdown (stop executing run() method) of this Context.-
Methods inherited from class gov.aps.jca.cas.ServerContext
dispose, printInfo
-
-
-
-
Field Detail
-
VERSION
public static final Version VERSION
Version.
-
CAJ_SINGLE_THREADED_MODEL
public static final String CAJ_SINGLE_THREADED_MODEL
String value of the JVM property key to turn on single threaded model.- See Also:
- Constant Field Values
-
logger
protected Logger logger
Context logger.
-
beaconAddressList
protected String beaconAddressList
A space-separated list of broadcast address which to send beacons. Each address must be of the form: ip.number:port or host.name:port
-
ignoreAddressList
protected String ignoreAddressList
A space-separated list of address from which to ignore name resolution requests. Each address must be of the form: ip.number:port or host.name:port
-
autoBeaconAddressList
protected boolean autoBeaconAddressList
Define whether or not the network interfaces should be discovered at runtime.
-
beaconPeriod
protected float beaconPeriod
Period in second between two beacon signals.
-
beaconPort
protected int beaconPort
Port number for the repeater to listen to.
-
tcpServerPort
protected int tcpServerPort
The TCP server port (used to establish channels).
-
udpServerPort
protected int udpServerPort
The UDP server port (used for pv name search requests).
-
maxArrayBytes
protected int maxArrayBytes
Length in bytes of the maximum array size that may pass through CA.
-
contextMessageListeners
protected ArrayList contextMessageListeners
List of context message listeners.
-
contextExceptionListeners
protected ArrayList contextExceptionListeners
List of context exception listeners.
-
timer
protected Timer timer
Timer.
-
reactor
protected Reactor reactor
Reactor.
-
leaderFollowersThreadPool
protected LeaderFollowersThreadPool leaderFollowersThreadPool
Leader/followers thread pool.
-
broadcastTransport
protected BroadcastTransport broadcastTransport
Broadcast transport needed for channel searches.
-
beaconEmitter
protected BeaconEmitter beaconEmitter
Beacon emitter..
-
acceptor
protected CASAcceptor acceptor
CAS acceptor (accepts CA virtual circuit).
-
transportRegistry
protected CATransportRegistry transportRegistry
CA transport (virtual circuit) registry. This registry contains all active transports - connections to CA servers.
-
cachedBufferAllocator
protected CachedByteBufferAllocator cachedBufferAllocator
Cached byte buffer allocator. Used by transports which as send buffers.
-
server
protected Server server
Server.
-
runLock
protected Object runLock
Run lock.
-
-
Method Detail
-
getVersion
public Version getVersion()
Get context version.- Specified by:
getVersionin classServerContext- Returns:
- context version.
- See Also:
Context.getVersion()
-
initializeLogger
protected void initializeLogger()
Initialize context logger.
-
loadConfiguration
protected void loadConfiguration()
Load configuration.
-
configure
public void configure(Configuration configuration) throws ConfigurationException
Description copied from interface:ConfigurablePass theConfigurationto theConfigurableclass. This method must always be called after the constructor and before any other method.- Specified by:
configurein interfaceConfigurable- Parameters:
configuration- the class configurations.- Throws:
ConfigurationException- if an error occurs- See Also:
Configurable.configure(gov.aps.jca.configuration.Configuration)
-
getContextMessageListeners
public ContextMessageListener[] getContextMessageListeners() throws IllegalStateException
- Specified by:
getContextMessageListenersin classServerContext- Returns:
- array of context message listeners.
- Throws:
IllegalStateException- illegal or inappropriate invocation of error- See Also:
Context.getContextMessageListeners()
-
addContextMessageListener
public void addContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
Description copied from class:ServerContextAdd a ContextMessageListener to this context.- Specified by:
addContextMessageListenerin classServerContext- Parameters:
l- The listener interface for receiving ContextMessageEvents- Throws:
CAException- JCA ExceptionIllegalStateException- null listener- See Also:
Context.addContextMessageListener(gov.aps.jca.event.ContextMessageListener)
-
removeContextMessageListener
public void removeContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
Description copied from class:ServerContextRemoves a ContextMessageListener from this context.- Specified by:
removeContextMessageListenerin classServerContext- Parameters:
l- the listener to remove- Throws:
CAException- CA ExceptionIllegalStateException- if the context has been destroyed.- See Also:
Context.removeContextMessageListener(gov.aps.jca.event.ContextMessageListener)
-
getContextExceptionListeners
public ContextExceptionListener[] getContextExceptionListeners() throws IllegalStateException
- Specified by:
getContextExceptionListenersin classServerContext- Returns:
- an array containing all ContextExceptionListeners attached to this context.
- Throws:
IllegalStateException- if the context has been destroyed.- See Also:
Context.getContextExceptionListeners()
-
addContextExceptionListener
public void addContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
Description copied from class:ServerContextAdd a ContextExceptionListener to this context.- Specified by:
addContextExceptionListenerin classServerContext- Parameters:
l- the listener to add- Throws:
CAException- CA ExceptionIllegalStateException- if the context has been destroyed.- See Also:
Context.addContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)
-
removeContextExceptionListener
public void removeContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
Description copied from class:ServerContextRemoves a ContextExceptionListener from this context.- Specified by:
removeContextExceptionListenerin classServerContext- Parameters:
l- the listener to remove- Throws:
CAException- CA ExceptionIllegalStateException- if the context has been destroyed.- See Also:
Context.removeContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)
-
checkState
protected void checkState() throws CAException, IllegalStateExceptionCheck context state and tries to establish necessary state.- Throws:
CAException- JCA ExceptionIllegalStateException- illegal or inappropriate invocation of error
-
initialize
public void initialize(Server server) throws CAException, IllegalStateException
Set server and initialize.- Specified by:
initializein classServerContext- Parameters:
server-Serverimplementation providingProcessVariableaccess (existance test and attach).- Throws:
CAException- IllegalStateExceptionIllegalStateException- See Also:
ServerContext.initialize(gov.aps.jca.cas.Server)
-
run
public void run(int seconds) throws CAException, IllegalStateExceptionRun server (process events).- Specified by:
runin classServerContext- Parameters:
seconds- time in seconds the server will process events (method will block), if0the method would block untildestory()is called.- Throws:
IllegalStateException- if server is already destroyed.CAException- JCA Exception
-
shutdown
public void shutdown() throws CAException, IllegalStateExceptionDescription copied from class:ServerContextShutdown (stop executing run() method) of this Context. After shutdown Context cannot be rerun again, destory() has to be called to clear all used resources.- Specified by:
shutdownin classServerContext- Throws:
CAException- CA ExceptionIllegalStateException- if the context has been destroyed.- See Also:
ServerContext.shutdown()
-
destroy
public void destroy() throws CAException, IllegalStateExceptionDescription copied from class:ServerContextClear all resources attached to this Context- Specified by:
destroyin classServerContext- Throws:
CAException- CA ExceptionIllegalStateException- if the context has been destroyed.- See Also:
Context.destroy()
-
printInfo
public void printInfo(PrintStream out) throws IllegalStateException
Description copied from class:ServerContextPrints detailed information about the Context to the specified output stream.- Overrides:
printInfoin classServerContext- Parameters:
out- the output stream.- Throws:
IllegalStateException- if the context has been destroyed.- See Also:
Context.printInfo(java.io.PrintStream)
-
isInitialized
public boolean isInitialized()
Get initialization status.- Returns:
- initialization status.
-
isDestroyed
public boolean isDestroyed()
Get destruction status.- Returns:
- destruction status.
-
getBeaconAddressList
public String getBeaconAddressList()
Get beacon address list.- Returns:
- beacon address list.
-
isAutoBeaconAddressList
public boolean isAutoBeaconAddressList()
Get beacon address list auto flag.- Returns:
- beacon address list auto flag.
-
getBeaconPeriod
public float getBeaconPeriod()
Get beacon period (in seconds).- Returns:
- beacon period (in seconds).
-
getLogger
public Logger getLogger()
Get logger.- Specified by:
getLoggerin interfaceLoggerProvider- Returns:
- logger.
-
getMaxArrayBytes
public int getMaxArrayBytes()
Get max array payload size.- Returns:
- max array payload size.
-
getBeaconPort
public int getBeaconPort()
Get beacon port.- Returns:
- beacon port.
-
getServerPort
public int getServerPort()
Deprecated.Get the TCP server port number (used to establish channels). Deprecated - use getTcpServerPort instead.- Specified by:
getServerPortin interfaceCAContext- Returns:
- server port.
-
setServerPort
public void setServerPort(int port)
Deprecated.Set the TCP server port number (used to establish channels). Deprecated - use setTcpServerPort instead.- Parameters:
port- new server port number.
-
getTcpServerPort
public int getTcpServerPort()
Get the TCP server port number (used to establish channels).- Returns:
- the port number.
-
setTcpServerPort
public void setTcpServerPort(int port)
Set the TCP server port number (used to establish channels).- Parameters:
port- new server port number.
-
getUdpServerPort
public int getUdpServerPort()
Get the UDP server port number (used for pv name search requests). Note: the TCP and UDP server ports are often the same number, but do not have to be. The UDP port number is what is used in a client addr_list to find a server and the TCP port number is provided to clients in the pv name search response.- Returns:
- the port number.
-
setUdpServerPort
public void setUdpServerPort(int port)
Set the UDP server port number (used for pv name search requests). Note: the TCP and UDP server ports are often the same number, but do not have to be. The UDP port number is what is used in a client addr_list to find a server and the TCP port number is provided to clients in the pv name search response.- Parameters:
port- new server port number.
-
getBroadcastPort
public int getBroadcastPort()
Get broadcast port.- Specified by:
getBroadcastPortin interfaceCAContext- Returns:
- broadcast port.
-
getIgnoreAddressList
public String getIgnoreAddressList()
Get ignore search address list.- Returns:
- ignore search addrresr list.
-
getServerInetAddress
public InetAddress getServerInetAddress()
Get server newtwork (IP) address.- Returns:
- server network (IP) address,
nullif not bounded.
-
getReactor
public Reactor getReactor()
Get context reactor.- Specified by:
getReactorin interfaceCAContext- Returns:
- context reactor.
-
getBroadcastTransport
public BroadcastTransport getBroadcastTransport()
Broadcast transport.- Specified by:
getBroadcastTransportin interfaceCAContext- Returns:
- broadcast transport.
-
getTransportRegistry
public CATransportRegistry getTransportRegistry()
Get CA transport (virtual circuit) registry.- Specified by:
getTransportRegistryin interfaceCAContext- Returns:
- CA transport (virtual circuit) registry.
-
getTimer
public Timer getTimer()
Get timer.
-
getCachedBufferAllocator
public CachedByteBufferAllocator getCachedBufferAllocator()
Get cached byte allocator.- Specified by:
getCachedBufferAllocatorin interfaceCAContext- Returns:
- cached byte allocator.
-
getLeaderFollowersThreadPool
public LeaderFollowersThreadPool getLeaderFollowersThreadPool()
Get LF thread pool.- Specified by:
getLeaderFollowersThreadPoolin interfaceCAContext- Returns:
- LF thread pool, can be
nullif disabled.
-
getServer
public Server getServer()
Get server implementation.- Returns:
- server implementation.
-
generateChannelSID
public int generateChannelSID()
Generate channel SID.- Returns:
- channel SID.
-
setLastReceivedSequenceNumber
public final void setLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.- Parameters:
seqNo- last UDP recived sequence number.
-
getLastReceivedSequenceNumber
public final int getLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.- Parameters:
seqNo- last UDP recived sequence number.
-
invalidateLastReceivedSequence
public final void invalidateLastReceivedSequence()
Description copied from interface:CAContextInvalidate last (UDP) received sequence.- Specified by:
invalidateLastReceivedSequencein interfaceCAContext- See Also:
CAContext.invalidateLastReceivedSequence()
-
getUserName
public String getUserName()
Description copied from interface:CAContextGet user name (used to report to the server).- Specified by:
getUserNamein interfaceCAContext- Returns:
- String username
- See Also:
CAContext.getUserName()
-
-