Class ChannelImpl
- java.lang.Object
-
- org.epics.pvaccess.client.impl.remote.ChannelImpl
-
- All Implemented Interfaces:
Channel,SearchInstance,Lockable,TransportClient,TransportSender,org.epics.pvdata.misc.Timer.TimerCallback,org.epics.pvdata.pv.Requester
public class ChannelImpl extends Object implements Channel, SearchInstance, TransportClient, TransportSender, org.epics.pvdata.misc.Timer.TimerCallback
Implementation of PVAJ JCAChannel.- Version:
- $Id$
- Author:
- Matej Sekoranja
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.epics.pvaccess.client.Channel
Channel.ConnectionState
-
-
Field Summary
Fields Modifier and Type Field Description protected InetSocketAddress[]addressesList of fixed addresses, ifnullname resolution will be used.protected booleanallowCreationAllow reconnection flag.static org.epics.pvdata.pv.StatuschannelDestroyedstatic org.epics.pvdata.pv.StatuschannelDisconnectedprotected intchannelIDClient channel ID.protected Channel.ConnectionStateconnectionStateConnection status.protected ClientContextImplcontextContext.protected StringnameChannel name.protected shortpriorityProcess priority.protected intreferencesReference counting.protected ChannelRequesterrequesterChannel requester.protected Map<Integer,ResponseRequest>responseRequestsList of all channel's pending requests (keys are subscription IDs).protected intserverChannelIDServer channel ID.protected TransporttransportServer transport.
-
Constructor Summary
Constructors Modifier Constructor Description protectedChannelImpl(ClientContextImpl context, int channelID, String name, ChannelRequester requester, short priority, InetSocketAddress[] addresses)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquire()Increment reference.voidcallback()voidcancel()voidchannelDestroyedOnServer()TransportcheckAndGetTransport()Checks if channel is in connected state and returns transport.TransportcheckDestroyedAndGetTransport()Checks if channel is destroyed and returns transport,nullnot connected.protected voidconnect()voidconnectionCompleted(int sid)Called when channel created succeeded on the server.voidcreateChannel(Transport transport)Create a channel, i.e.ChannelArraycreateChannelArray(ChannelArrayRequester channelArrayRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelArray.voidcreateChannelFailed()Create channel failed.ChannelGetcreateChannelGet(ChannelGetRequester channelGetRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelGet.ChannelProcesscreateChannelProcess(ChannelProcessRequester channelProcessRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelProcess.ChannelPutcreateChannelPut(ChannelPutRequester channelPutRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelPut.ChannelPutGetcreateChannelPutGet(ChannelPutGetRequester channelPutGetRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelPutGet.ChannelRPCcreateChannelRPC(ChannelRPCRequester channelRPCRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a ChannelRPC (Remote Procedure Call).org.epics.pvdata.monitor.MonitorcreateMonitor(org.epics.pvdata.monitor.MonitorRequester monitorRequester, org.epics.pvdata.pv.PVStructure pvRequest)Create a Monitor.voiddestroy()Destroy the channel.voiddestroy(boolean force)voiddestroyChannel(boolean force)Actual destroy method, to be calledCAJContext.protected voiddisconnect()voiddisconnect(boolean initiateSearch, boolean remoteDestroy)Disconnected notification.AccessRightsgetAccessRights(org.epics.pvdata.pv.PVField pvField)Get the access rights for a field of a PVStructure created via a call to createPVStructure.intgetChannelID()Get client channel ID.StringgetChannelName()Get the channel name.ChannelRequestergetChannelRequester()Get the channel requester.Channel.ConnectionStategetConnectionState()Returns the connection state of this channel.ClientContextImplgetContext()Get context.voidgetField(GetFieldRequester requester, String subField)Get a Field which describes the subField.shortgetPriority()Get process priority.ChannelProvidergetProvider()Get the the channel provider of this channel.StringgetRemoteAddress()NOTE: synchronization guarantees thattransportis non-nullandstate == CONNECTED.StringgetRequesterName()intgetServerChannelID()Get SID.TransportgetTransport()Get transport used by this channel.AtomicIntegergetUserValue()voidinitiateSearch(boolean penalize)Initiate search (connect) procedure.booleanisConnected()Is the channel connected?voidlock()voidmessage(String message, org.epics.pvdata.pv.MessageType messageType)voidregisterResponseRequest(ResponseRequest responseRequest)Register a response request.voidsearchResponse(GUID guid, byte minorRevision, InetSocketAddress serverAddress)Search response from server (channel found).voidsend(ByteBuffer buffer, TransportSendControl control)Called by transport.voidtimeout()voidtimerStopped()StringtoString()voidtransportChanged()Notification of network change (server restarted).voidtransportClosed()Notification of forcefully closed transport.voidtransportResponsive(Transport transport)Notification of responsive transport (e.g.voidtransportUnresponsive()Notification of unresponsive transport (e.g.voidunlock()voidunregisterResponseRequest(ResponseRequest responseRequest)
-
-
-
Field Detail
-
channelID
protected final int channelID
Client channel ID.
-
name
protected final String name
Channel name.
-
context
protected final ClientContextImpl context
Context.
-
priority
protected final short priority
Process priority.
-
addresses
protected final InetSocketAddress[] addresses
List of fixed addresses, ifnullname resolution will be used.
-
connectionState
protected Channel.ConnectionState connectionState
Connection status.
-
requester
protected final ChannelRequester requester
Channel requester.
-
responseRequests
protected final Map<Integer,ResponseRequest> responseRequests
List of all channel's pending requests (keys are subscription IDs).
-
allowCreation
protected boolean allowCreation
Allow reconnection flag.
-
references
protected int references
Reference counting. NOTE: synced onthis.
-
transport
protected Transport transport
Server transport.
-
serverChannelID
protected int serverChannelID
Server channel ID.
-
channelDestroyed
public static final org.epics.pvdata.pv.Status channelDestroyed
-
channelDisconnected
public static final org.epics.pvdata.pv.Status channelDisconnected
-
-
Constructor Detail
-
ChannelImpl
protected ChannelImpl(ClientContextImpl context, int channelID, String name, ChannelRequester requester, short priority, InetSocketAddress[] addresses) throws PVAException
- Throws:
PVAException
-
-
Method Detail
-
createChannel
public void createChannel(Transport transport)
Create a channel, i.e. submit create channel request to the server. This method is called after search is complete.- Parameters:
transport- on what transport to create channel.
-
cancel
public void cancel()
- See Also:
ResponseRequest.cancel()
-
timeout
public void timeout()
- See Also:
ResponseRequest.timeout()
-
createChannelFailed
public void createChannelFailed()
Create channel failed.
-
connectionCompleted
public void connectionCompleted(int sid) throws IllegalStateExceptionCalled when channel created succeeded on the server.sidmight not be valid, this depends on protocol revision.- Parameters:
sid- server-side channel ID.- Throws:
IllegalStateException- when called in wrong state.
-
channelDestroyedOnServer
public void channelDestroyedOnServer()
-
destroy
public void destroy(boolean force) throws PVAException, IllegalStateException- Parameters:
force- force destruction regardless of reference count- Throws:
PVAException- thrown on unexpected exception.IllegalStateException- thrown if channel is already destroyed.
-
acquire
public void acquire()
Increment reference.
-
destroyChannel
public void destroyChannel(boolean force) throws PVAException, IllegalStateException, IOExceptionActual destroy method, to be calledCAJContext.- Parameters:
force- force destruction regardless of reference count- Throws:
PVAException- thrown on unexpected exception.IllegalStateException- thrown when channel is destroyed.IOException- thrown if IO exception occurs.
-
disconnect
public void disconnect(boolean initiateSearch, boolean remoteDestroy)Disconnected notification.- Parameters:
initiateSearch- flag to indicate if searching (connect) procedure should be initiatedremoteDestroy- issue channel destroy request.
-
initiateSearch
public void initiateSearch(boolean penalize)
Initiate search (connect) procedure.- Parameters:
penalize- register with penalty.
-
callback
public void callback()
- Specified by:
callbackin interfaceorg.epics.pvdata.misc.Timer.TimerCallback
-
timerStopped
public void timerStopped()
- Specified by:
timerStoppedin interfaceorg.epics.pvdata.misc.Timer.TimerCallback
-
getUserValue
public AtomicInteger getUserValue()
- Specified by:
getUserValuein interfaceSearchInstance
-
searchResponse
public void searchResponse(GUID guid, byte minorRevision, InetSocketAddress serverAddress)
Description copied from interface:SearchInstanceSearch response from server (channel found).- Specified by:
searchResponsein interfaceSearchInstance- Parameters:
guid- server GUIDminorRevision- server minor PVA revision.serverAddress- server address.
-
transportClosed
public void transportClosed()
Description copied from interface:TransportClientNotification of forcefully closed transport.- Specified by:
transportClosedin interfaceTransportClient- See Also:
TransportClient.transportClosed()
-
transportChanged
public void transportChanged()
Description copied from interface:TransportClientNotification of network change (server restarted).- Specified by:
transportChangedin interfaceTransportClient- See Also:
TransportClient.transportChanged()
-
transportResponsive
public void transportResponsive(Transport transport)
Description copied from interface:TransportClientNotification of responsive transport (e.g. heartbeat detected again), called to discardtransportUnresponsivenotification.- Specified by:
transportResponsivein interfaceTransportClient- Parameters:
transport- responsive transport.- See Also:
TransportClient.transportResponsive(org.epics.pvaccess.impl.remote.Transport)
-
transportUnresponsive
public void transportUnresponsive()
Description copied from interface:TransportClientNotification of unresponsive transport (e.g. no heartbeat detected) .- Specified by:
transportUnresponsivein interfaceTransportClient- See Also:
TransportClient.transportUnresponsive()
-
getConnectionState
public Channel.ConnectionState getConnectionState()
Description copied from interface:ChannelReturns the connection state of this channel.- Specified by:
getConnectionStatein interfaceChannel- Returns:
- the
ConnectionStatevalue.
-
getRemoteAddress
public String getRemoteAddress()
NOTE: synchronization guarantees thattransportis non-nullandstate == CONNECTED.- Specified by:
getRemoteAddressin interfaceChannel- Returns:
- the channel's remote address.
- See Also:
Channel.getRemoteAddress()
-
getChannelID
public int getChannelID()
Get client channel ID.- Specified by:
getChannelIDin interfaceSearchInstance- Returns:
- client channel ID.
-
getContext
public ClientContextImpl getContext()
Get context.- Returns:
- context.
-
checkAndGetTransport
public final Transport checkAndGetTransport()
Checks if channel is in connected state and returns transport.- Returns:
- used transport.
- Throws:
IllegalStateException- if not connected.
-
checkDestroyedAndGetTransport
public final Transport checkDestroyedAndGetTransport()
Checks if channel is destroyed and returns transport,nullnot connected.- Returns:
- used transport.
- Throws:
IllegalStateException- if not connected
-
getTransport
public Transport getTransport()
Get transport used by this channel.- Returns:
- transport used by this channel.
-
getServerChannelID
public int getServerChannelID()
Get SID.- Returns:
- SID.
-
registerResponseRequest
public void registerResponseRequest(ResponseRequest responseRequest)
Register a response request.- Parameters:
responseRequest- response request to register.
-
unregisterResponseRequest
public void unregisterResponseRequest(ResponseRequest responseRequest)
-
getPriority
public short getPriority()
Get process priority.- Returns:
- process priority.
-
connect
protected final void connect()
-
disconnect
protected void disconnect()
-
createChannelGet
public ChannelGet createChannelGet(ChannelGetRequester channelGetRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelGet. ChannelGetRequester.channelGetReady is called after both client and server are ready for the client to make a get request.- Specified by:
createChannelGetin interfaceChannel- Parameters:
channelGetRequester- The interface for notifying when this request is complete and when a channel get completes.pvRequest- A structure describing the desired set of fields from the remote PVRecord. This has the same form as a pvRequest to PVCopyFactory.create.- Returns:
ChannelGetinstance.
-
createMonitor
public org.epics.pvdata.monitor.Monitor createMonitor(org.epics.pvdata.monitor.MonitorRequester monitorRequester, org.epics.pvdata.pv.PVStructure pvRequest)Description copied from interface:ChannelCreate a Monitor.- Specified by:
createMonitorin interfaceChannel- Parameters:
monitorRequester- The requester.pvRequest- A structure describing the desired set of fields from the remote PVRecord. This has the same form as a pvRequest to PVCopyFactory.create.- Returns:
Monitorinstance.
-
createChannelProcess
public ChannelProcess createChannelProcess(ChannelProcessRequester channelProcessRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelProcess. ChannelProcessRequester.channelProcessReady is called after both client and server are ready for the client to make a process request.- Specified by:
createChannelProcessin interfaceChannel- Parameters:
channelProcessRequester- The interface for notifying when this request is complete and when channel completes processing.pvRequest- Additional options (e.g. triggering).- Returns:
ChannelProcessinstance.
-
createChannelPut
public ChannelPut createChannelPut(ChannelPutRequester channelPutRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelPut. ChannelPutRequester.channelPutReady is called after both client and server are ready for the client to make a put request.- Specified by:
createChannelPutin interfaceChannel- Parameters:
channelPutRequester- The interface for notifying when this request is complete and when a channel get completes.pvRequest- A structure describing the desired set of fields from the remote PVRecord. This has the same form as a pvRequest to PVCopyFactory.create.- Returns:
ChannelPutinstance.
-
createChannelPutGet
public ChannelPutGet createChannelPutGet(ChannelPutGetRequester channelPutGetRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelPutGet. ChannelPutGetRequester.channelPutGetReady is called after both client and server are ready for the client to make a putGet request.- Specified by:
createChannelPutGetin interfaceChannel- Parameters:
channelPutGetRequester- The interface for notifying when this request is complete and when a channel get completes.pvRequest- A structure describing the desired set of fields from the remote PVRecord. This has the same form as a pvRequest to PVCopyFactory.create.- Returns:
ChannelPutGetinstance.
-
createChannelRPC
public ChannelRPC createChannelRPC(ChannelRPCRequester channelRPCRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelRPC (Remote Procedure Call).- Specified by:
createChannelRPCin interfaceChannel- Parameters:
channelRPCRequester- The requester.pvRequest- Request options.- Returns:
ChannelRPCinstance.
-
getAccessRights
public AccessRights getAccessRights(org.epics.pvdata.pv.PVField pvField)
Description copied from interface:ChannelGet the access rights for a field of a PVStructure created via a call to createPVStructure. MATEJ Channel access can store this info via auxInfo.- Specified by:
getAccessRightsin interfaceChannel- Parameters:
pvField- The field for which access rights is desired.- Returns:
- The access rights.
-
getChannelName
public String getChannelName()
Description copied from interface:ChannelGet the channel name.- Specified by:
getChannelNamein interfaceChannel- Specified by:
getChannelNamein interfaceSearchInstance- Returns:
- The name.
-
getChannelRequester
public ChannelRequester getChannelRequester()
Description copied from interface:ChannelGet the channel requester.- Specified by:
getChannelRequesterin interfaceChannel- Returns:
- The requester.
-
getProvider
public ChannelProvider getProvider()
Description copied from interface:ChannelGet the the channel provider of this channel.- Specified by:
getProviderin interfaceChannel- Returns:
- The channel provider.
-
isConnected
public boolean isConnected()
Description copied from interface:ChannelIs the channel connected?- Specified by:
isConnectedin interfaceChannel- Returns:
- (false,true) means (not, is) connected.
-
getRequesterName
public String getRequesterName()
- Specified by:
getRequesterNamein interfaceorg.epics.pvdata.pv.Requester
-
message
public void message(String message, org.epics.pvdata.pv.MessageType messageType)
- Specified by:
messagein interfaceorg.epics.pvdata.pv.Requester
-
destroy
public void destroy()
Description copied from interface:ChannelDestroy the channel. It will not honor any further requests.
-
createChannelArray
public ChannelArray createChannelArray(ChannelArrayRequester channelArrayRequester, org.epics.pvdata.pv.PVStructure pvRequest)
Description copied from interface:ChannelCreate a ChannelArray.- Specified by:
createChannelArrayin interfaceChannel- Parameters:
channelArrayRequester- The ChannelArrayRequesterpvRequest- Additional options (e.g. triggering).- Returns:
ChannelArrayinstance.
-
getField
public void getField(GetFieldRequester requester, String subField)
Description copied from interface:ChannelGet a Field which describes the subField. GetFieldRequester.getDone is called after both client and server have processed the getField request. This is for clients that want to introspect a PVRecord via channel access.
-
send
public void send(ByteBuffer buffer, TransportSendControl control)
Description copied from interface:TransportSenderCalled by transport. By this call transport gives callee ownership over the buffer. Calls onTransportSendControlinstance must be made from calling thread. Moreover, ownership is valid only for the time of call of this method. NOTE: these limitations allow efficient implementation.- Specified by:
sendin interfaceTransportSender- Parameters:
buffer- buffer to send.control- transport send control instance.
-
-