public class CAJContext extends Context implements CAContext, CAJConstants, Configurable
Context.| Modifier and Type | Field and 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 |
beaconHandlers
Beacon handler map.
|
protected float |
beaconPeriod
Period in second between two beacon signals.
|
protected BroadcastTransport |
broadcastTransport
Broadcast transport needed for channel searches.
|
protected CachedByteBufferAllocator |
cachedBufferAllocator
Cached byte buffer allocator.
|
static String |
CAJ_SINGLE_THREADED_MODEL
String value of the JVM property key to turn on single threaded model.
|
protected IntHashMap |
channelsByCID
Map of channels (keys are CIDs).
|
protected Map |
channelsByName
Map of channels (keys are names).
|
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 CAConnector |
connector
CA connector (creates CA virtual circuit).
|
protected ArrayList |
contextExceptionListeners
List of context exception listeners.
|
protected ArrayList |
contextMessageListeners
List of context message listeners.
|
protected EventDispatcher |
eventDispatcher
Event dispatcher.
|
protected LeaderFollowersThreadPool |
leaderFollowersThreadPool
Leader/followers thread pool.
|
protected Logger |
logger
Context logger.
|
protected int |
maxArrayBytes
Length in bytes of the maximum array size that may pass through CA.
|
protected float |
maxSearchInterval
Maximum interval in seconds between CA search broadcasts.
|
ArrayList<CAJNameClient> |
nameClients |
protected String |
nameServersList |
protected IntHashMap |
pendingResponseRequests
Map of pending response requests (keys are IOID).
|
protected Reactor |
reactor
Reactor.
|
protected boolean |
registrationConfirmed
Registration confirmation status.
|
protected int |
repeaterPort
Port number for the repeater to listen to.
|
protected int |
serverPort
Port number for the server to listen to.
|
protected Timer |
timer
Timer.
|
protected CATransportRegistry |
transportRegistry
CA transport (virtual circuit) registry.
|
static Version |
VERSION
Version.
|
CAJ_DEBUG, CAJ_STRIP_HOSTNAME| Constructor and Description |
|---|
CAJContext()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContextExceptionListener(ContextExceptionListener l)
Add a ContextExceptionListener to this context.
|
void |
addContextMessageListener(ContextMessageListener l)
Add a ContextMessageListener to this context.
|
void |
attachCurrentThread()
Attach the calling thread to the list of threads allowed to access this context and all its channels.
|
void |
beaconAnomalyNotify()
Called each time beacon anomaly is detected.
|
protected void |
checkState()
Check context state and tries to establish necessary state.
|
void |
configure(Configuration configuration)
Pass the
Configuration to the Configurable
class. |
Channel |
createChannel(String name,
ConnectionListener l,
short priority)
Create a new Channel using this context to access a process variable with a ConnectionListener
to receive ConnectionEvent from the newly created Channel.
|
void |
decrementPendingRequests(int usedSequenceNumberIO)
Decrement pending requests counter.
|
void |
destroy()
Clear all ressources attached to this Context
|
void |
destroyChannel(CAJChannel channel,
boolean force)
Destroy channel.
|
void |
flushIO()
Flush outstanding IO request to the servers.
|
String |
getAddressList()
Get search address list.
|
CABeaconHandler |
getBeaconHandler(InetSocketAddress responseFrom)
Get (and if necessary create) beacon handler.
|
float |
getBeaconPeriod()
Get beacon period (in seconds).
|
int |
getBroadcastPort()
Get broadcast port.
|
BroadcastTransport |
getBroadcastTransport()
Broadcast transport.
|
CachedByteBufferAllocator |
getCachedBufferAllocator()
Get cached byte allocator.
|
CAJChannel |
getChannel(int channelID)
Searches for a channel with given channel ID.
|
CAJChannel |
getChannel(String name,
short priority,
boolean acquire)
Searches for a channel with given channel name.
|
Channel[] |
getChannels()
Get all channels of this context.
|
ChannelSearchManager |
getChannelSearchManager()
Get channel search manager.
|
float |
getConnectionTimeout()
Get connection timeout (in seconds).
|
ContextExceptionListener[] |
getContextExceptionListeners() |
ContextMessageListener[] |
getContextMessageListeners() |
EventDispatcher |
getEventDispatcher()
Get event dispatcher.
|
int |
getLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.
|
LeaderFollowersThreadPool |
getLeaderFollowersThreadPool()
Get LF thread pool.
|
Logger |
getLogger()
Get logger.
|
int |
getMaxArrayBytes()
Get max size of payload.
|
float |
getMaxSearchInterval()
Get max.
|
Reactor |
getReactor()
Get context reactor.
|
int |
getRepeaterPort()
Get repeater port.
|
ResponseRequest |
getResponseRequest(int ioid)
Searches for a response request with given channel IOID.
|
int |
getServerPort()
Get server port.
|
Timer |
getTimer()
Get timer.
|
CATransport |
getTransport(TransportClient client,
InetSocketAddress serverAddress,
short minorRevision,
short priority)
Get, or create if necessary, transport of given server address.
|
CATransportRegistry |
getTransportRegistry()
Get CA transport (virtual circuit) registry.
|
String |
getUserName()
Get user name (used to report to the server).
|
Version |
getVersion()
Get context version.
|
int |
incrementPendingRequests()
Increment pending requests counter.
|
void |
initialize() |
protected void |
initializeLogger()
Initialize context logger.
|
void |
invalidateLastReceivedSequence()
Invalidate last (UDP) received sequence.
|
boolean |
isAutoAddressList()
Get auto search-list flag.
|
boolean |
isDestroyed()
Get destruction status.
|
boolean |
isDoNotShareChannels() |
boolean |
isInitialized()
Get initialization status.
|
boolean |
isRegistrationConfirmed()
Get repeater registration status.
|
protected void |
loadConfiguration()
Load configuration.
|
void |
modifyUserName(String userName)
Modifies client username and notifies connected servers about it.
|
void |
notifyException(ContextExceptionEvent event)
Notifies context listeners about exception.
|
void |
pendEvent(double timeout)
Process all pending events.
|
void |
pendIO(double timeout)
Process all pending IO operations.
|
void |
poll()
Flush the send buffer and process any outstanding CA background activity.
|
void |
printInfo(PrintStream out)
Prints detailed information about the Context to the specified output stream.
|
int |
registerResponseRequest(ResponseRequest request)
Register response request.
|
void |
removeContextExceptionListener(ContextExceptionListener l)
Removes a ContextExceptionListener from this context.
|
void |
removeContextMessageListener(ContextMessageListener l)
Removes a ContextMessageListener from this context.
|
void |
repeaterConfirm(InetSocketAddress responseFrom)
Repeater registration confirmation.
|
void |
searchResponse(int cid,
int sid,
short type,
int count,
short minorRevision,
InetSocketAddress serverAddress)
Search response from server (channel found).
|
void |
setDoNotShareChannels(boolean doNotShareChannels) |
void |
setLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.
|
boolean |
testIO()
Tests if all synchronous (ie not specifying listeners) get and channel creation requests are completed.
|
ResponseRequest |
unregisterResponseRequest(ResponseRequest request)
Unregister response request.
|
createChannel, createChannel, createChannel, dispose, printInfopublic static final Version VERSION
public static final String CAJ_SINGLE_THREADED_MODEL
protected Logger logger
protected String addressList
protected boolean autoAddressList
protected String nameServersList
protected float connectionTimeout
protected float beaconPeriod
protected int repeaterPort
protected int serverPort
protected int maxArrayBytes
protected float maxSearchInterval
protected ArrayList contextMessageListeners
protected ArrayList contextExceptionListeners
protected EventDispatcher eventDispatcher
protected Timer timer
protected Reactor reactor
protected LeaderFollowersThreadPool leaderFollowersThreadPool
protected boolean registrationConfirmed
protected BroadcastTransport broadcastTransport
protected CAConnector connector
public ArrayList<CAJNameClient> nameClients
protected CATransportRegistry transportRegistry
protected CachedByteBufferAllocator cachedBufferAllocator
protected IntHashMap channelsByCID
protected Map channelsByName
protected IntHashMap pendingResponseRequests
protected Map beaconHandlers
public Version getVersion()
getVersion in class ContextContext.getVersion()public boolean isDoNotShareChannels()
public void setDoNotShareChannels(boolean doNotShareChannels)
protected void initializeLogger()
protected void loadConfiguration()
public void configure(Configuration configuration) throws ConfigurationException
ConfigurableConfiguration to the Configurable
class. This method must always be called after the constructor
and before any other method.configure in interface Configurableconfiguration - the class configurations.ConfigurationException - if an error occursConfigurable.configure(gov.aps.jca.configuration.Configuration)public ContextMessageListener[] getContextMessageListeners() throws IllegalStateException
getContextMessageListeners in class ContextIllegalStateException - if the context has been destroyed.Context.getContextMessageListeners()public void addContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
ContextaddContextMessageListener in class Contextl - the listener to addIllegalStateException - if the context has been destroyed.CAExceptionContext.addContextMessageListener(gov.aps.jca.event.ContextMessageListener)public void removeContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
ContextremoveContextMessageListener in class Contextl - the listener to removeIllegalStateException - if the context has been destroyed.CAExceptionContext.removeContextMessageListener(gov.aps.jca.event.ContextMessageListener)public ContextExceptionListener[] getContextExceptionListeners() throws IllegalStateException
getContextExceptionListeners in class ContextIllegalStateException - if the context has been destroyed.Context.getContextExceptionListeners()public void addContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
ContextaddContextExceptionListener in class Contextl - the listener to addIllegalStateException - if the context has been destroyed.CAExceptionContext.addContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)public void removeContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
ContextremoveContextExceptionListener in class Contextl - the listener to removeIllegalStateException - if the context has been destroyed.CAExceptionContext.removeContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)public void notifyException(ContextExceptionEvent event)
event - context exception event to be fired.protected void checkState()
throws CAException,
IllegalStateException
CAException - JCA ExceptionIllegalStateException - IllegalStateExceptionpublic void initialize()
throws CAException
initialize in class ContextCAExceptionContext.initialize()public void destroy()
throws CAException,
IllegalStateException
Contextdestroy in class ContextIllegalStateException - if the context has been destroyed.CAExceptionContext.destroy()public Channel createChannel(String name, ConnectionListener l, short priority) throws CAException, IllegalStateException
ContextcreateChannel in class Contextname - the process variable to connect to.l - the ConnectionListener.priority - channel process priorityCAException - is thrown if a Channel Access error occured while creating the channel.IllegalStateException - if the context has been destroyed.Context.createChannel(java.lang.String, gov.aps.jca.event.ConnectionListener, short)public void destroyChannel(CAJChannel channel, boolean force) throws CAException, IllegalStateException
channel - CAJChannelforce - force destruction regardless of reference countCAException - force destruction regardless of reference countIllegalStateException - Signals that a method has been invoked at an illegal or inappropriate timepublic CAJChannel getChannel(int channelID)
channelID - CID.null if non-existant.public CAJChannel getChannel(String name, short priority, boolean acquire)
name - channel name.priority - channel priority.acquire - whether to acquire ownership (increment ref. counting)null if non-existant.public Channel[] getChannels()
ContextgetChannels in class ContextContext.getChannels()public void pendIO(double timeout)
throws TimeoutException,
CAException,
IllegalStateException
ContextpendIO in class Contexttimeout - the timeout limit.TimeoutException - if all the IO couldn't be processed.CAException - if a Channel Exception error occured while processing IOs.IllegalStateException - if the context has been destroyed.Context.pendIO(double)public boolean testIO()
throws CAException,
IllegalStateException
ContexttestIO in class ContextCAException - if a Channel Access error occured while testing IOsIllegalStateException - if the context has been destroyed.Context.testIO()public void pendEvent(double timeout)
throws CAException,
IllegalStateException
ContextpendEvent in class Contexttimeout - the time during which the Context will process events.CAException - if a Channel Access error occured while pending eventsIllegalStateException - if the context has been destroyed.Context.pendEvent(double)public void poll()
throws CAException,
IllegalStateException
Contextpoll in class ContextCAException - if a Channel Access error occured while testing IOsIllegalStateException - if the context has been destroyed.Context.poll()public void flushIO()
throws CAException,
IllegalStateException
ContextflushIO in class ContextCAException - if a Channel Access error occured while flushing IOsIllegalStateException - if the context has been destroyed.Context.flushIO()public void attachCurrentThread()
throws CAException,
IllegalStateException
ContextattachCurrentThread in class ContextIllegalStateException - if the context has been destroyed.
or if the context doesn't support multiple threads.CAExceptionContext.attachCurrentThread()public void printInfo(PrintStream out) throws IllegalStateException
ContextprintInfo in class Contextout - the output stream.IllegalStateException - if the context has been destroyed.Context.printInfo(java.io.PrintStream)public boolean isInitialized()
public boolean isDestroyed()
public String getAddressList()
public boolean isAutoAddressList()
public float getBeaconPeriod()
public float getConnectionTimeout()
public Logger getLogger()
getLogger in interface LoggerProviderpublic int getMaxArrayBytes()
public int getRepeaterPort()
public int getServerPort()
getServerPort in interface CAContextpublic int getBroadcastPort()
getBroadcastPort in interface CAContextpublic float getMaxSearchInterval()
public final EventDispatcher getEventDispatcher()
public Reactor getReactor()
getReactor in interface CAContextpublic BroadcastTransport getBroadcastTransport()
getBroadcastTransport in interface CAContextpublic CATransportRegistry getTransportRegistry()
getTransportRegistry in interface CAContextpublic Timer getTimer()
public ChannelSearchManager getChannelSearchManager()
public CachedByteBufferAllocator getCachedBufferAllocator()
getCachedBufferAllocator in interface CAContextpublic LeaderFollowersThreadPool getLeaderFollowersThreadPool()
getLeaderFollowersThreadPool in interface CAContextnull if disabled.public boolean isRegistrationConfirmed()
public void repeaterConfirm(InetSocketAddress responseFrom)
responseFrom - response from address.public void beaconAnomalyNotify()
public void searchResponse(int cid,
int sid,
short type,
int count,
short minorRevision,
InetSocketAddress serverAddress)
cid - client channel ID.sid - server channel ID.type - channel type code.count - channel element count.minorRevision - server minor CA revision.serverAddress - server address.public CATransport getTransport(TransportClient client, InetSocketAddress serverAddress, short minorRevision, short priority)
client - requesting connection (transport).serverAddress - required transport addressminorRevision - transport revision to be usedpriority - process priority.public ResponseRequest getResponseRequest(int ioid)
ioid - I/O ID.public int registerResponseRequest(ResponseRequest request)
request - request to register.public ResponseRequest unregisterResponseRequest(ResponseRequest request)
request - ResponseRequestnullpublic int incrementPendingRequests()
public void decrementPendingRequests(int usedSequenceNumberIO)
usedSequenceNumberIO - IO sequence number returned by incrementPendingRequestspublic final void setLastReceivedSequenceNumber(int seqNo)
seqNo - last UDP recived sequence number.public final int getLastReceivedSequenceNumber(int seqNo)
seqNo - last UDP recived sequence number.public final void invalidateLastReceivedSequence()
CAContextinvalidateLastReceivedSequence in interface CAContextCAContext.invalidateLastReceivedSequence()public CABeaconHandler getBeaconHandler(InetSocketAddress responseFrom)
responseFrom - remote source address of received beacon.public void modifyUserName(String userName)
userName - usernamepublic String getUserName()
CAContextgetUserName in interface CAContextCopyright © 2004-2020 EPICS. All Rights Reserved.