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 BlockingTCPAcceptor
acceptor
PVAS acceptor (accepts PVA virtual circuit).protected boolean
autoBeaconAddressList
Define whether or not the network interfaces should be discovered at runtime.protected String
beaconAddressList
A space-separated list of broadcast address which to send beacons.protected BeaconEmitter
beaconEmitter
Beacon emitter.protected float
beaconPeriod
Period in second between two beacon signals.protected int
broadcastPort
Broadcast port number to listen to.protected BlockingUDPTransport
broadcastTransport
Broadcast transport needed for channel searches.protected Map<String,ChannelProvider>
channelNameToProvider
Channel (name) to provider mapping.protected String
channelProviderNames
Channel provider name.protected ArrayList<ChannelProvider>
channelProviders
Channel provider.protected int
debugLevel
Debug level.protected String
ignoreAddressList
A space-separated list of address from which to ignore name resolution requests.protected BlockingUDPTransport
localMulticastTransport
Local multicast transport needed for unicast channel searches to be multicasted locally.protected Logger
logger
Context logger.protected int
receiveBufferSize
Length in bytes of the maximum buffer (payload) size that may pass through PVA.protected Object
runLock
Run lock.protected int
serverPort
Port number for the server to listen to.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 ServerContextImpl()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkState()
Check context state and tries to establish necessary state.void
destroy()
Clear all resources attached to this context.void
dispose()
Dispose (destroy) server context.String
getBeaconAddressList()
Get beacon address list.float
getBeaconPeriod()
Get beacon period (in seconds).BeaconServerStatusProvider
getBeaconServerStatusProvider()
Get registered beacon server status provider.int
getBroadcastPort()
Get broadcast port.BlockingUDPTransport
getBroadcastTransport()
Broadcast transport.Map<String,ChannelProvider>
getChannelNameToProviderMap()
Retrun channel (name) to provider mapping.String
getChannelProviderNames()
Get channel provider name.List<ChannelProvider>
getChannelProviders()
Get channel providers.Configuration
getConfiguration()
Get configuration instance.int
getDebugLevel()
Get internal debug level configuration, higher value means more, 0 means none.byte[]
getGUID()
Returns GUID (12-byte array)String
getIgnoreAddressList()
Get ignore search address list.BlockingUDPTransport
getLocalMulticastTransport()
Local multicast transport.Logger
getLogger()
Get logger.int
getReceiveBufferSize()
Get receiver buffer (payload) size.Map<String,SecurityPlugin>
getSecurityPlugins()
Get map of available security plug-ins.InetAddress
getServerInetAddress()
Get server newtwork (IP) address.int
getServerPort()
Get server port.ResponseHandler
getServerResponseHandler()
Get server response handler.org.epics.pvdata.misc.Timer
getTimer()
Get timer.TransportRegistry
getTransportRegistry()
Get PVA transport (virtual circuit) registry.Version
getVersion()
Get context implementation version.void
initialize(ChannelProvider channelProvider)
SetChannelProvider
implementation and initialize server.void
initialize(ChannelProviderRegistry providerRegistry)
SetChannelAccess
implementation and initialize server.protected void
initializeLogger()
Initialize context logger.boolean
isAutoBeaconAddressList()
Get beacon address list auto flag.boolean
isDestroyed()
Get destruction status.boolean
isInitialized()
Get initialization status.protected void
loadConfiguration()
Load configuration.void
printInfo()
Prints detailed information about the context to the standard output stream.void
printInfo(PrintStream out)
Prints detailed information about the context to the specified output stream.void
run(int seconds)
Run server (process events).void
setBeaconServerStatusProvider(BeaconServerStatusProvider beaconServerStatusProvider)
Set beacon server status provider.void
setChannelProviderNames(String providerNames)
void
setServerPort(int port)
Set server port number.void
shutdown()
Shutdown (stop executing run() method) of this context.static ServerContextImpl
startPVAServer(String providerNames, int timeToRun, boolean runInSeparateThread, PrintStream printInfoStream)
CreateServerContextImpl
instance 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:ServerContext
Get context implementation version.- Specified by:
getVersion
in 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, IllegalStateException
Check 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:ServerContext
SetChannelAccess
implementation and initialize server. ServedChannelProvider
(s) is read from configuration.- Specified by:
initialize
in 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:ServerContext
SetChannelProvider
implementation and initialize server.- Specified by:
initialize
in 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, IllegalStateException
Run server (process events).- Specified by:
run
in interfaceServerContext
- Parameters:
seconds
- time in seconds the server will process events (method will block), if0
the method would block untildestory()
is called.- Throws:
IllegalStateException
- if server is already destroyed.PVAException
- exception.
-
shutdown
public void shutdown() throws PVAException, IllegalStateException
Description copied from interface:ServerContext
Shutdown (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:
shutdown
in interfaceServerContext
- Throws:
PVAException
- any other PVA exception.IllegalStateException
- if the context has been destroyed.
-
destroy
public void destroy() throws PVAException, IllegalStateException
Description copied from interface:ServerContext
Clear all resources attached to this context.- Specified by:
destroy
in interfaceServerContext
- Throws:
PVAException
- any other PVA exception.IllegalStateException
- if the context has been destroyed.
-
printInfo
public void printInfo()
Description copied from interface:ServerContext
Prints detailed information about the context to the standard output stream.- Specified by:
printInfo
in interfaceServerContext
-
printInfo
public void printInfo(PrintStream out)
Description copied from interface:ServerContext
Prints detailed information about the context to the specified output stream.- Specified by:
printInfo
in interfaceServerContext
- Parameters:
out
- output stream.
-
dispose
public void dispose()
Description copied from interface:ServerContext
Dispose (destroy) server context. This callsdestroy()
and silently handles all exceptions.- Specified by:
dispose
in 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:
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 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:
setBeaconServerStatusProvider
in interfaceServerContext
- Parameters:
beaconServerStatusProvider
-BeaconServerStatusProvider
implementation to set
-
getServerInetAddress
public InetAddress getServerInetAddress()
Get server newtwork (IP) address.- Returns:
- server network (IP) address,
null
if 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:
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
-
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
CreateServerContextImpl
instance and start server.- Parameters:
providerNames
- providers to use,null
to use defaults orPVAConstants.PVA_ALL_PROVIDERS
to use all providers.timeToRun
- time (in seconds) to run,0
untildestroy()
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.
-
-