com.cosylab.epics.caj.impl
Class CATransport

java.lang.Object
  extended by com.cosylab.epics.caj.impl.CATransport
All Implemented Interfaces:
ReactorHandler, Transport, Timer.TimerRunnable

public class CATransport
extends Object
implements Transport, ReactorHandler, Timer.TimerRunnable

CA transport implementation.

Version:
$id$
Author:
Matej Sekoranja

Field Summary
protected  short priority
          Process priority.
protected  ResponseHandler responseHandler
          CA reponse handler.
 
Constructor Summary
CATransport(CAJContext context, TransportClient client, ResponseHandler responseHandler, SocketChannel channel, short remoteTransportRevision, short priority)
           
 
Method Summary
 boolean acquire(TransportClient client)
          Acquires transport.
 void beaconArrivalNotify()
          Beacon arrival.
 void changedTransport()
          Changed transport (server restared) notify.
 void close(boolean forced)
          Close connection.
protected  void disableFlowControl()
          Disable flow control (enables events).
 void echoNotify()
          Called when echo request (state-of-health message) was responed.
protected  void enableFlowControl()
          Enable flow control (disables events).
 boolean flush()
          Flush send buffer.
 boolean flushInternal()
          Flush send buffer (blocks until flushed).
 CAContext getContext()
          Get context transport is living in.
 short getMinorRevision()
          Transport protocol minor revision.
 short getPriority()
          Transport priority.
 InetSocketAddress getRemoteAddress()
          Get remote address.
 void handleEvent(SelectionKey key)
          Handle IO event.
protected  void processRead()
          Process input (read) IO event.
protected  void processRead(ByteBuffer socketBuffer)
          Process input.
protected  void processWrite()
          Process output (write) IO event.
 void release(TransportClient client)
          Releases transport.
 void send(ByteBuffer buffer)
          Send a buffer through the transport.
 void submit(Request requestMessage)
          Enqueue (if supported or if necessary send immediately) request message.
 void timeout(long timeToRun)
          Beacon timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

responseHandler

protected ResponseHandler responseHandler
CA reponse handler.


priority

protected short priority
Process priority.

Constructor Detail

CATransport

public CATransport(CAJContext context,
                   TransportClient client,
                   ResponseHandler responseHandler,
                   SocketChannel channel,
                   short remoteTransportRevision,
                   short priority)
Parameters:
context -
responseHandler -
client -
channel -
remoteTransportRevision -
priority -
Method Detail

close

public void close(boolean forced)
Close connection.

Parameters:
forced - flag indicating if forced (e.g. forced disconnect) is required

acquire

public boolean acquire(TransportClient client)
Acquires transport.

Parameters:
client - client (channel) acquiring the transport
Returns:
true if transport was granted, false otherwise.

release

public void release(TransportClient client)
Releases transport.

Parameters:
client - client (channel) releasing the transport

getMinorRevision

public short getMinorRevision()
Description copied from interface: Transport
Transport protocol minor revision.

Specified by:
getMinorRevision in interface Transport
Returns:
protocol minor revision.
See Also:
Transport.getMinorRevision()

handleEvent

public void handleEvent(SelectionKey key)
Handle IO event.

Specified by:
handleEvent in interface ReactorHandler
Parameters:
key - key to be processed.
See Also:
ReactorHandler.handleEvent(java.nio.channels.SelectionKey)

processRead

protected void processRead()
Process input (read) IO event. Alsp handles subscription flow control.


processRead

protected void processRead(ByteBuffer socketBuffer)
Process input.


processWrite

protected void processWrite()
Process output (write) IO event.


disableFlowControl

protected void disableFlowControl()
Disable flow control (enables events).


enableFlowControl

protected void enableFlowControl()
Enable flow control (disables events).


send

public void send(ByteBuffer buffer)
          throws IOException
Send a buffer through the transport. NOTE: TCP sent buffer/sending has to be synchronized.

Parameters:
buffer - buffer to be sent
Throws:
IOException

flush

public boolean flush()
Flush send buffer. ... by enabling SelectionKey.OP_WRITE and process in reactor.

Specified by:
flush in interface Transport
Returns:
true on success, false on failure.
See Also:
Transport.flush()

flushInternal

public boolean flushInternal()
Flush send buffer (blocks until flushed).

Returns:
success flag.
See Also:
Transport.flush()

submit

public void submit(Request requestMessage)
            throws IOException
Description copied from interface: Transport
Enqueue (if supported or if necessary send immediately) request message. Message is sent immediately if its priority equals SEND_IMMEDIATELY_PRIORITY.

Specified by:
submit in interface Transport
Parameters:
requestMessage - request message to enqueue.
Throws:
IOException
See Also:
Transport.submit(com.cosylab.epics.caj.impl.Request)

getContext

public CAContext getContext()
Description copied from interface: Transport
Get context transport is living in.

Specified by:
getContext in interface Transport
Returns:
context transport is living in.
See Also:
Transport.getContext()

getRemoteAddress

public InetSocketAddress getRemoteAddress()
Description copied from interface: Transport
Get remote address.

Specified by:
getRemoteAddress in interface Transport
Returns:
remote address.
See Also:
Transport.getRemoteAddress()

getPriority

public short getPriority()
Description copied from interface: Transport
Transport priority.

Specified by:
getPriority in interface Transport
Returns:
protocol priority.
See Also:
Transport.getPriority()

beaconArrivalNotify

public void beaconArrivalNotify()
Beacon arrival.


timeout

public void timeout(long timeToRun)
Beacon timer.

Specified by:
timeout in interface Timer.TimerRunnable
Parameters:
timeToRun - time in ms to run.
See Also:
Timer.TimerRunnable.timeout(long)

echoNotify

public void echoNotify()
Called when echo request (state-of-health message) was responed.


changedTransport

public void changedTransport()
Changed transport (server restared) notify.



Copyright © 2004-2013 Cosylab. All Rights Reserved.