Class ServerContextImpl
- java.lang.Object
-
- org.epics.pvaccess.server.impl.remote.ServerContextImpl
-
- All Implemented Interfaces:
Context,ServerContext,LoggerProvider
public class ServerContextImpl extends Object implements ServerContext, Context
Implementation ofServerContext.- Version:
- $Id$
- Author:
- Matej Sekoranja
-
-
Field Summary
Fields Modifier and Type Field Description protected BlockingTCPAcceptoracceptorPVAS acceptor (accepts PVA 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 intbroadcastPortBroadcast port number to listen to.protected BlockingUDPTransportbroadcastTransportBroadcast transport needed for channel searches.protected Map<String,ChannelProvider>channelNameToProviderChannel (name) to provider mapping.protected StringchannelProviderNamesChannel provider name.protected ArrayList<ChannelProvider>channelProvidersChannel provider.protected intdebugLevelDebug level.protected StringignoreAddressListA space-separated list of address from which to ignore name resolution requests.protected BlockingUDPTransportlocalMulticastTransportLocal multicast transport needed for unicast channel searches to be multicasted locally.protected LoggerloggerContext logger.protected intreceiveBufferSizeLength in bytes of the maximum buffer (payload) size that may pass through PVA.protected ObjectrunLockRun lock.protected intserverPortPort number for the server to listen to.protected org.epics.pvdata.misc.TimertimerTimer.protected TransportRegistrytransportRegistryPVA transport (virtual circuit) registry.static VersionVERSIONVersion.
-
Constructor Summary
Constructors Constructor Description ServerContextImpl()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckState()Check context state and tries to establish necessary state.voiddestroy()Clear all resources attached to this context.voiddispose()Dispose (destroy) server context.StringgetBeaconAddressList()Get beacon address list.floatgetBeaconPeriod()Get beacon period (in seconds).BeaconServerStatusProvidergetBeaconServerStatusProvider()Get registered beacon server status provider.intgetBroadcastPort()Get broadcast port.BlockingUDPTransportgetBroadcastTransport()Broadcast transport.Map<String,ChannelProvider>getChannelNameToProviderMap()Retrun channel (name) to provider mapping.StringgetChannelProviderNames()Get channel provider name.List<ChannelProvider>getChannelProviders()Get channel providers.ConfigurationgetConfiguration()Get configuration instance.intgetDebugLevel()Get internal debug level configuration, higher value means more, 0 means none.byte[]getGUID()Returns GUID (12-byte array)StringgetIgnoreAddressList()Get ignore search address list.BlockingUDPTransportgetLocalMulticastTransport()Local multicast transport.LoggergetLogger()Get logger.intgetReceiveBufferSize()Get receiver buffer (payload) size.Map<String,SecurityPlugin>getSecurityPlugins()Get map of available security plug-ins.InetAddressgetServerInetAddress()Get server newtwork (IP) address.intgetServerPort()Get server port.ResponseHandlergetServerResponseHandler()Get server response handler.org.epics.pvdata.misc.TimergetTimer()Get timer.TransportRegistrygetTransportRegistry()Get PVA transport (virtual circuit) registry.VersiongetVersion()Get context implementation version.voidinitialize(ChannelProvider channelProvider)SetChannelProviderimplementation and initialize server.voidinitialize(ChannelProviderRegistry providerRegistry)SetChannelAccessimplementation and initialize server.protected voidinitializeLogger()Initialize context logger.booleanisAutoBeaconAddressList()Get beacon address list auto flag.booleanisDestroyed()Get destruction status.booleanisInitialized()Get initialization status.protected voidloadConfiguration()Load configuration.voidprintInfo()Prints detailed information about the context to the standard output stream.voidprintInfo(PrintStream out)Prints detailed information about the context to the specified output stream.voidrun(int seconds)Run server (process events).voidsetBeaconServerStatusProvider(BeaconServerStatusProvider beaconServerStatusProvider)Set beacon server status provider.voidsetChannelProviderNames(String providerNames)voidsetServerPort(int port)Set server port number.voidshutdown()Shutdown (stop executing run() method) of this context.static ServerContextImplstartPVAServer(String providerNames, int timeToRun, boolean runInSeparateThread, PrintStream printInfoStream)CreateServerContextImplinstance and start server.
-
-
-
Field Detail
-
VERSION
public static final Version VERSION
Version.
-
logger
protected Logger logger
Context logger.
-
debugLevel
protected int debugLevel
Debug level.
-
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.
-
broadcastPort
protected int broadcastPort
Broadcast port number to listen to.
-
serverPort
protected int serverPort
Port number for the server to listen to.
-
receiveBufferSize
protected int receiveBufferSize
Length in bytes of the maximum buffer (payload) size that may pass through PVA.
-
timer
protected org.epics.pvdata.misc.Timer timer
Timer.
-
broadcastTransport
protected BlockingUDPTransport broadcastTransport
Broadcast transport needed for channel searches.
-
localMulticastTransport
protected BlockingUDPTransport localMulticastTransport
Local multicast transport needed for unicast channel searches to be multicasted locally.
-
beaconEmitter
protected BeaconEmitter beaconEmitter
Beacon emitter.
-
acceptor
protected BlockingTCPAcceptor acceptor
PVAS acceptor (accepts PVA virtual circuit).
-
transportRegistry
protected TransportRegistry transportRegistry
PVA transport (virtual circuit) registry. This registry contains all active transports - connections to PVA servers.
-
channelProviderNames
protected String channelProviderNames
Channel provider name.
-
channelProviders
protected final ArrayList<ChannelProvider> channelProviders
Channel provider.
-
channelNameToProvider
protected final Map<String,ChannelProvider> channelNameToProvider
Channel (name) to provider mapping. Used when there are more that one provider used.
-
runLock
protected final Object runLock
Run lock.
-
-
Method Detail
-
getGUID
public byte[] getGUID()
Returns GUID (12-byte array)- Returns:
- GUID.
-
getVersion
public Version getVersion()
Description copied from interface:ServerContextGet context implementation version.- Specified by:
getVersionin interfaceServerContext- Returns:
- version of the context implementation.
-
initializeLogger
protected void initializeLogger()
Initialize context logger.
-
getConfiguration
public Configuration getConfiguration()
Get configuration instance.- Returns:
- the configuration.
-
loadConfiguration
protected void loadConfiguration()
Load configuration.
-
setChannelProviderNames
public void setChannelProviderNames(String providerNames)
-
checkState
protected final void checkState() throws PVAException, IllegalStateExceptionCheck context state and tries to establish necessary state.- Throws:
PVAException- any PVA exception.IllegalStateException- thrown if context was already destroyed.
-
initialize
public void initialize(ChannelProviderRegistry providerRegistry) throws PVAException, IllegalStateException
Description copied from interface:ServerContextSetChannelAccessimplementation and initialize server. ServedChannelProvider(s) is read from configuration.- Specified by:
initializein interfaceServerContext- Parameters:
providerRegistry- channel provider registry to use.- Throws:
PVAException- any other PVA exception.IllegalStateException- thrown in instance is in illegal state (e.g. destroyed).
-
initialize
public void initialize(ChannelProvider channelProvider) throws PVAException, IllegalStateException
Description copied from interface:ServerContextSetChannelProviderimplementation and initialize server.- Specified by:
initializein interfaceServerContext- Parameters:
channelProvider- provider to be served.- Throws:
PVAException- any other PVA exception.IllegalStateException- thrown in instance is in illegal state (e.g. destroyed).
-
run
public void run(int seconds) throws PVAException, IllegalStateExceptionRun server (process events).- Specified by:
runin interfaceServerContext- 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.PVAException- exception.
-
shutdown
public void shutdown() throws PVAException, IllegalStateExceptionDescription copied from interface:ServerContextShutdown (stop executing run() method) of this context. After shutdown Context cannot be rerun again, destroy() has to be called to clear all used resources.- Specified by:
shutdownin interfaceServerContext- Throws:
PVAException- any other PVA exception.IllegalStateException- if the context has been destroyed.
-
destroy
public void destroy() throws PVAException, IllegalStateExceptionDescription copied from interface:ServerContextClear all resources attached to this context.- Specified by:
destroyin interfaceServerContext- Throws:
PVAException- any other PVA exception.IllegalStateException- if the context has been destroyed.
-
printInfo
public void printInfo()
Description copied from interface:ServerContextPrints detailed information about the context to the standard output stream.- Specified by:
printInfoin interfaceServerContext
-
printInfo
public void printInfo(PrintStream out)
Description copied from interface:ServerContextPrints detailed information about the context to the specified output stream.- Specified by:
printInfoin interfaceServerContext- Parameters:
out- output stream.
-
dispose
public void dispose()
Description copied from interface:ServerContextDispose (destroy) server context. This callsdestroy()and silently handles all exceptions.- Specified by:
disposein interfaceServerContext
-
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.
-
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 receiver buffer (payload) size.- Returns:
- max payload size.
-
getServerPort
public int getServerPort()
Get server port.- Returns:
- server port.
-
setServerPort
public void setServerPort(int port)
Set server port number.- Parameters:
port- new server port number.
-
getBroadcastPort
public int getBroadcastPort()
Get broadcast port.- Returns:
- broadcast port.
-
getIgnoreAddressList
public String getIgnoreAddressList()
Get ignore search address list.- Returns:
- ignore search addrresr list.
-
getBeaconServerStatusProvider
public BeaconServerStatusProvider getBeaconServerStatusProvider()
Get registered beacon server status provider.- Returns:
- registered beacon server status provider.
-
setBeaconServerStatusProvider
public void setBeaconServerStatusProvider(BeaconServerStatusProvider beaconServerStatusProvider)
Set beacon server status provider.- Specified by:
setBeaconServerStatusProviderin interfaceServerContext- Parameters:
beaconServerStatusProvider-BeaconServerStatusProviderimplementation to set
-
getServerInetAddress
public InetAddress getServerInetAddress()
Get server newtwork (IP) address.- Returns:
- server network (IP) address,
nullif not bounded.
-
getBroadcastTransport
public BlockingUDPTransport getBroadcastTransport()
Broadcast transport.- Returns:
- broadcast transport.
-
getLocalMulticastTransport
public BlockingUDPTransport getLocalMulticastTransport()
Local multicast transport.- Returns:
- multicast transport.
-
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
-
getChannelProviderNames
public String getChannelProviderNames()
Get channel provider name.- Returns:
- channel provider name.
-
getChannelProviders
public List<ChannelProvider> getChannelProviders()
Get channel providers.- Returns:
- channel provider.
-
getChannelNameToProviderMap
public Map<String,ChannelProvider> getChannelNameToProviderMap()
Retrun channel (name) to provider mapping.- Returns:
- the map.
-
getServerResponseHandler
public ResponseHandler getServerResponseHandler()
Get server response handler.- Returns:
- server response handler.
-
startPVAServer
public static ServerContextImpl startPVAServer(String providerNames, int timeToRun, boolean runInSeparateThread, PrintStream printInfoStream) throws PVAException
CreateServerContextImplinstance and start server.- Parameters:
providerNames- providers to use,nullto use defaults orPVAConstants.PVA_ALL_PROVIDERSto use all providers.timeToRun- time (in seconds) to run,0untildestroy()is called.runInSeparateThread- run in separate thread flag.printInfoStream- stream instance where to print context info, can benull- Returns:
- the server context instance.
- Throws:
PVAException- thrown on exception.
-
-