Package xal.ca
Class AbstractBatchGetRequest<T extends ChannelRecord>
java.lang.Object
xal.ca.AbstractBatchGetRequest<T>
- All Implemented Interfaces:
BatchConnectionRequestListener
- Direct Known Subclasses:
BatchGetValueRequest
,BatchGetValueTimeRequest
public abstract class AbstractBatchGetRequest<T extends ChannelRecord>
extends Object
implements BatchConnectionRequestListener
AbstractBatchGetRequest
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractBatchGetRequest
(Collection<Channel> channels) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBatchGetRequestListener
(BatchGetRequestListener<T> listener) add the specified listener as a receiver of batch get request events from this instancevoid
addChannel
(Channel channel) add a new channel to the batch requestboolean
await
(double timeout) Synonym for waitForCompletion.void
batchConnectionRequestCompleted
(BatchConnectionRequest connectionRequest, int connectedCount, int disconnectedCount, int exceptionCount) event indicating that the batch request is completevoid
connectionChangeInBatch
(BatchConnectionRequest connectionRequest, Channel channel, boolean connected) event indicating that a connection change has occurred for a channelvoid
connectionExceptionInBatch
(BatchConnectionRequest connectionRequest, Channel channel, Exception exception) event indicating that an exception has been thrown for a channelprotected void
finalize()
dispose of the executorsget the collection of channels to processgetException
(Channel channel) Get the exception if any for the specified channelint
Get the number of exceptionsGet the failed channels for which exceptions were thrown during the requestGet the record if any for the specified channelint
get the number of recordsGet the channels which produced a resultboolean
determine if there were any exceptionsboolean
determine if there are any channels pending for either an exception or a completed get requestprotected void
check for the current status and post notifications if necessaryprotected void
processRecordEvent
(Channel channel, T channelRecord) Process the receipt of a new record eventprotected void
processRequest
(Channel channel) Process the get request for a single channelvoid
remove the specified listener from receiving batch get request events from this instanceprotected abstract void
requestChannelData
(Channel channel) Request to get the data for the channelvoid
submit()
submit as a batch the get requests for each channelboolean
submitAndWait
(double timeout) Submit a batch of get requests and wait for the requests to be completed or timeout.boolean
waitForCompletion
(double timeout) Wait up to the specified timeout for completion.
-
Constructor Details
-
AbstractBatchGetRequest
Primary Constructor- Parameters:
channels
- the channels for which get requests will be handled
-
-
Method Details
-
finalize
dispose of the executors -
addBatchGetRequestListener
add the specified listener as a receiver of batch get request events from this instance- Parameters:
listener
- a receiver which will receive events
-
removeBatchGetRequestListener
remove the specified listener from receiving batch get request events from this instance- Parameters:
listener
- receiver to remove from receiving events
-
addChannel
add a new channel to the batch request- Parameters:
channel
- a channel to add to the batch request
-
getChannels
get the collection of channels to process- Returns:
- a copy of the list of channels in the batch request
-
submit
public void submit()submit as a batch the get requests for each channel -
submitAndWait
public boolean submitAndWait(double timeout) Submit a batch of get requests and wait for the requests to be completed or timeout. Note that if this is called, within a channel access callback, requests will not be processed until the callback completes, so it is useless to wait. Instead, call waitForCompletion separately outside of the callback.- Parameters:
timeout
- the maximum time in seconds to wait for completion- Returns:
- true if complete or false if not
-
await
public boolean await(double timeout) Synonym for waitForCompletion. Wait up to the specified timeout for completion. This method should be called outside of a Channel Access callback otherwise events will not be processed.- Parameters:
timeout
- the maximum time in seconds to wait for completion- Returns:
- true if complete or false if not
-
waitForCompletion
public boolean waitForCompletion(double timeout) Wait up to the specified timeout for completion. This method should be called outside of a Channel Access callback otherwise events will not be processed.- Parameters:
timeout
- the maximum time in seconds to wait for completion- Returns:
- true if complete or false if not
-
requestChannelData
protected abstract void requestChannelData(Channel channel) throws ConnectionException, GetException Request to get the data for the channel- Parameters:
channel
- the channel for which to request data- Throws:
Exception
- when the request failsConnectionException
GetException
-
processRequest
Process the get request for a single channel- Parameters:
channel
- the channel for which to process the request
-
isComplete
public boolean isComplete()determine if there are any channels pending for either an exception or a completed get request- Returns:
- true if complete and false if not
-
hasExceptions
public boolean hasExceptions()determine if there were any exceptions- Returns:
- true if there are any exceptions and false if not
-
getRecordCount
public int getRecordCount()get the number of records- Returns:
- the number of records
-
getExceptionCount
public int getExceptionCount()Get the number of exceptions- Returns:
- the number of channels for which there was an exception during the request
-
getRecord
Get the record if any for the specified channel- Parameters:
channel
- the channel for which the record is fetched- Returns:
- the record for the specified channel or null if there is none
-
getException
Get the exception if any for the specified channel- Parameters:
channel
- the channel for which the exception is fetched- Returns:
- the exception for the specified channel or null if there is none
-
getFailedChannels
Get the failed channels for which exceptions were thrown during the request- Returns:
- the set of failed channels
-
getResultChannels
Get the channels which produced a result- Returns:
- the set of channels each for which a record was successfully fetched
-
processRecordEvent
Process the receipt of a new record event- Parameters:
channel
- the channel for which the event will be processedchannelRecord
- the fetched record
-
processCurrentStatus
protected void processCurrentStatus()check for the current status and post notifications if necessary -
batchConnectionRequestCompleted
public void batchConnectionRequestCompleted(BatchConnectionRequest connectionRequest, int connectedCount, int disconnectedCount, int exceptionCount) event indicating that the batch request is complete- Specified by:
batchConnectionRequestCompleted
in interfaceBatchConnectionRequestListener
- Parameters:
connectionRequest
- request for which the connection completedconnectedCount
- number of channels connecteddisconnectedCount
- number of channels disconnectedexceptionCount
- number of channels for which there were connection exceptions
-
connectionExceptionInBatch
public void connectionExceptionInBatch(BatchConnectionRequest connectionRequest, Channel channel, Exception exception) event indicating that an exception has been thrown for a channel- Specified by:
connectionExceptionInBatch
in interfaceBatchConnectionRequestListener
- Parameters:
connectionRequest
- in which the exception occurredchannel
- for which the exception occurredexception
- the exception thrown while attempting to connect
-
connectionChangeInBatch
public void connectionChangeInBatch(BatchConnectionRequest connectionRequest, Channel channel, boolean connected) event indicating that a connection change has occurred for a channel- Specified by:
connectionChangeInBatch
in interfaceBatchConnectionRequestListener
- Parameters:
connectionRequest
- in which the connection changedchannel
- for which the connection changedconnected
- status of the connection (true for connected and false for disconnected)
-