org.mbari.siam.operations.portal
Class PortalConnection

java.lang.Object
  extended by org.mbari.siam.operations.portal.PortalConnection

public class PortalConnection
extends java.lang.Object

PortalConnection provides the interface and maintains state for one connection to a SIAM node from which data is retrieved (aka "target" node").

When Portal determines that the communications link to the target node is available, it calls attempts to "wake up" the node (which may be sleeping), and invokes PortalConnection.nodeLinkConnected() to retrieve data from the node's sensors. The retrieved packets are then distributed to shore clients, as well as saved in a file buffer. PortalConnection keeps track of which packets it has retrieved from each sensor; on subsequent retrievals it requests the "latest" data from the sensor.

PortalConnection stores client requests ("commands") until a communication link to the node is available, at which time PortalConnection sequentially forwards the requests to the node. Thus PortalConnection manages network traffic over the low-bandwidth link.

While interacting with a node on the MOOS network, the shore need only maintain a lease on the node from which data is being retrieved; the target node will ensure that any intermediate nodes/comms links are kept awake.

Author:
Bob Herlien - adapted from Portal.java

Constructor Summary
PortalConnection(java.net.InetAddress remoteAddr, java.net.InetAddress primaryAddr, Portal portal)
          Construct PortalConnection for node at specified address.
 
Method Summary
protected  boolean connectNode()
          Obtain the node proxy object and get a lease.
 boolean equals(java.lang.Object o)
          Returns true if object is PortalConnection to same InetAddress or if object is InetAddress which equals our _targetNodeAddr
 java.net.InetAddress getInetAddress()
          Return InetAddress of our remote connection
 Port[] getPortConfiguration()
          Return descriptions of devices on node.
 PortalSession getSession()
          get session tracker
 long getTargetDeviceID()
           
 long getTargetNodeID()
           
 int hashCode()
          Return hashCode of the connection's InetAddress
 boolean nodeConnected()
          Returns true if portal link is active and portal has valid RMI stub to remote node
 void nodeLinkConnected()
          Called by portal when "link up" message received from node.
 void nodeLinkDisconnecting(long nextConnectTime)
          Called by node when communication link is going down.
 void nodeLinkNotify(boolean on)
          Notify PortalConnection that network link has come up/down
protected  DevicePacketSet retrieveData(long deviceID, long startTime, long endTime)
          Retrieve data from specified device, within specified time-window.
 void setSession(PortalSession session)
          set session tracker
 void startSession()
          Get node server proxy, retrieve configuration, packets, etc.
 void terminateLease()
          Terminate lease on the target node
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortalConnection

public PortalConnection(java.net.InetAddress remoteAddr,
                        java.net.InetAddress primaryAddr,
                        Portal portal)
Construct PortalConnection for node at specified address.

Parameters:
remoteAddr - Address of target node
primaryAddr -
portal - Portal which contains this connection
Method Detail

getInetAddress

public java.net.InetAddress getInetAddress()
Return InetAddress of our remote connection


equals

public boolean equals(java.lang.Object o)
Returns true if object is PortalConnection to same InetAddress or if object is InetAddress which equals our _targetNodeAddr

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Return hashCode of the connection's InetAddress

Overrides:
hashCode in class java.lang.Object

nodeConnected

public boolean nodeConnected()
Returns true if portal link is active and portal has valid RMI stub to remote node


getPortConfiguration

public Port[] getPortConfiguration()
                            throws UnknownConfiguration
Return descriptions of devices on node.

Throws:
UnknownConfiguration

setSession

public void setSession(PortalSession session)
set session tracker


getSession

public PortalSession getSession()
get session tracker


startSession

public void startSession()
                  throws java.lang.Exception
Get node server proxy, retrieve configuration, packets, etc.

Throws:
java.lang.Exception

nodeLinkDisconnecting

public void nodeLinkDisconnecting(long nextConnectTime)
Called by node when communication link is going down.


nodeLinkConnected

public void nodeLinkConnected()
Called by portal when "link up" message received from node.


nodeLinkNotify

public void nodeLinkNotify(boolean on)
Notify PortalConnection that network link has come up/down


connectNode

protected boolean connectNode()
Obtain the node proxy object and get a lease. Return true on success, false on error.


retrieveData

protected DevicePacketSet retrieveData(long deviceID,
                                       long startTime,
                                       long endTime)
                                throws java.rmi.RemoteException,
                                       DeviceNotFound,
                                       NoDataException,
                                       java.io.IOException,
                                       TimeoutException
Retrieve data from specified device, within specified time-window.

Throws:
java.rmi.RemoteException
DeviceNotFound
NoDataException
java.io.IOException
TimeoutException

terminateLease

public void terminateLease()
                    throws LeaseRefused,
                           java.rmi.RemoteException
Terminate lease on the target node

Throws:
LeaseRefused
java.rmi.RemoteException

getTargetNodeID

public long getTargetNodeID()

getTargetDeviceID

public long getTargetDeviceID()


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.