blackboard
Class LanNode

java.lang.Object
  extended byjava.util.Observable
      extended byblackboard.LanNode
All Implemented Interfaces:
Cloneable, Serializable

public class LanNode
extends Observable
implements Serializable, Cloneable

A node on the network, typically a computer. This class stores information on whether or not this particular node is "up" (ie responding to pings) and also any number of OID properties obtained through SNMP. The class also automatically keeps track of the time it was last updated, the time that it was first discovered that the node was down (ie not responding to pings), and whether or not the node has been checked out (ie write-lock). This class should be thread-safe. TO DO: - allow inserting a Map of OID-value's instead of using the setOID() individually. ( ie setOID(Map) ) Testing: - test to make sure that if writing and reading occur at the same time that there is no non-sensical output on the reads.

See Also:
Serialized Form

Field Summary
 boolean isTrap
           
static boolean READONLY
           
static boolean WRITEABLE
           
 
Constructor Summary
LanNode()
          Creates a LanNode with default values and an IP of "0.0.0.0".
LanNode(InetAddress ip)
          Creates a LanNode with default values and an IP defined by the passed InetAddress.
LanNode(InetAddress ip, Set OIDs)
          Creates a LanNode with default values, an IP defined by the passed InetAddress, and will add the set of OIDs passed to it to the table for the backend to query.
 
Method Summary
 void addOID(String OID)
          Adds an OID key into the table for the backend to update with information
protected  void checkIn()
          Run this method before placing a LanNode into the BlackBoard.
protected  LanNode checkOut(boolean write)
          After retreiving this LanNode, the BlackBoard will call this method before giving this node to the calling program.
 void clearUAND()
          Deprecated. use Observable methods instead.
 Object clone()
          Produces a shallow copy of the LanNode.
protected  void deleteNode()
           
 Date downSince()
          Returns the time that this node was first discovered to be down.
 boolean equals(Object obj)
          Two LanNodes are considered equal if they both point to the same IP address.
 Object getFrontEndInfo(Object key)
          Returns a reference to the value associated with the key for use by the frontend.
 InetAddress getIp()
          returns a copy of the IP of this node.
 String getLastTrapEvent()
           
 Object getOID(String OID)
          Returns the value associated with the OID as an Object.
 boolean getServerStatus()
          Getter for property isServer.
 Set getSetOfOID()
          Returns a Set of OID String's that contains all of the OID's that require polling for this LanNode.
 void giveFocus()
           
 int hashCode()
          Since the hashCode method must return the same hashCode during an execution, this method will return the hashCode produced by the InetAddress held within this node.
protected  boolean isCheckedOut()
           
 boolean isDeleted()
          Returns whether or not this node has been deleted.
protected  boolean isInBlackBoard()
          Returns whether or not this LanNode has been added to the BlackBoard.
 boolean isLocked()
          Returns true if this LanNode has been locked (ie read-only), true otherwise.
 boolean isPolling()
          Getter for property polling.
 boolean isSnmpEnabled()
          Getter for property snmpEnabled.
 boolean isUp()
          Getter for property isUp.
 boolean isUpdatedAndNotDisplayed()
          Deprecated. use hasChanged() instead.
 boolean isUpStatusPending()
          Getter for property upStatusPending.
 Date lastUpdated()
          Getter for property lastUpdated.
 void setFrontEndInfo(Object key, Object value)
          This method is to be used exclusively by the frontend to store information on how to display this particular LanNode.
 void setIp(InetAddress ip)
          Changes this LanNode's IP address.
 void setIsUp(boolean isUp)
          Setter for property isUp.
 void setOID(String OID, Object value)
          Set's a value for the associated OID key.
 void setPolling(boolean polling)
          Setter for property polling.
 void setServerStatus(boolean newServerStatus)
          Setter for property isServer.
 void setSnmpEnabled(boolean snmpEnabled)
          Setter for property snmpEnabled.
 void takeFocus()
           
 String toString()
           
 void trapEvent(String description)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WRITEABLE

public static final boolean WRITEABLE
See Also:
Constant Field Values

READONLY

public static final boolean READONLY
See Also:
Constant Field Values

isTrap

public boolean isTrap
Constructor Detail

LanNode

public LanNode()
Creates a LanNode with default values and an IP of "0.0.0.0".


LanNode

public LanNode(InetAddress ip)
Creates a LanNode with default values and an IP defined by the passed InetAddress.

Parameters:
ip - IP address of this particular LanNode.

LanNode

public LanNode(InetAddress ip,
               Set OIDs)
Creates a LanNode with default values, an IP defined by the passed InetAddress, and will add the set of OIDs passed to it to the table for the backend to query.

Parameters:
ip - IP address of this particular LanNode.
OIDs - Set of OID keys in String format.
Method Detail

checkOut

protected LanNode checkOut(boolean write)
                    throws LanNodeAlreadyCheckedOut,
                           LanNodeIsDeleted
After retreiving this LanNode, the BlackBoard will call this method before giving this node to the calling program. If the requested node is already checked out then a LanNodeAlreadyCheckedOut exception will be thrown. Precondition: this.inBlackBoard && this.lock

Parameters:
write - if this is true then it will return a writable LanNode
Returns:
a writable clone of this LanNode
Throws:
LanNodeAlreadyCheckedOut
LanNodeIsDeleted

checkIn

protected void checkIn()
Run this method before placing a LanNode into the BlackBoard. This will ensure that its locked and that no one can make copies of writable LanNodes that have been checked-out. Make sure that you first test to see if the LanNode is flagged as already being in the BlackBoard and if it isn't, first run this method and THEN add it to the BlackBoard.


isInBlackBoard

protected boolean isInBlackBoard()
Returns whether or not this LanNode has been added to the BlackBoard.

Returns:
boolean

deleteNode

protected void deleteNode()

isCheckedOut

protected boolean isCheckedOut()

clone

public Object clone()
Produces a shallow copy of the LanNode. In other words, since the LanNode essentially only holds references to actual variables, this will create a new LanNode pointing to the same variables as the original. Clones of a deleted node are permitted. Note: Do not make copies of LanNode's that have been checked out from the BlackBoard for writing. Such a copy would violate the r/w locks and will throw a LockViolation.

Returns:
shallow copy of LanNode
Throws:
CloneNotSupportedException - only when a copy of an unlocked LanNode is made

isLocked

public boolean isLocked()
Returns true if this LanNode has been locked (ie read-only), true otherwise. If the node is not locked then that means it was checked out for updating (ie read-write access).

Returns:
is this LanNode locked?

lastUpdated

public Date lastUpdated()
Getter for property lastUpdated.

Returns:
Value of property lastUpdated.

downSince

public Date downSince()
Returns the time that this node was first discovered to be down.

Returns:
time the node was first discovered to be down

isUpdatedAndNotDisplayed

public boolean isUpdatedAndNotDisplayed()
Deprecated. use hasChanged() instead.

Getter for property updatedAndNotDisplayed.

Returns:
true if this node was updated and the display has not been updated yet

clearUAND

public void clearUAND()
Deprecated. use Observable methods instead.

Used to clear the updatedAndNotDisplayed flag. Make sure to clear this flag BEFORE you display the information. This way, if someone else updates the node in the middle of displaying it, the displaying program will end up displaying a mix of old and new info, but since the flag will be set to true then the displayer should reupdate the display again (and therefore overwrite the previous old information in the display).


isUp

public boolean isUp()
Getter for property isUp.

Returns:
boolean specifying if this node is responding to pings

setIsUp

public void setIsUp(boolean isUp)
             throws LanNodeIsDeleted
Setter for property isUp.

Parameters:
isUp - set to true if this node is responding to pings
Throws:
LanNodeIsDeleted

setOID

public void setOID(String OID,
                   Object value)
            throws LanNodeIsDeleted
Set's a value for the associated OID key. If the OID already exists in the mapping than this value will replace it. The values stored with each OID are of type Object so that there is no restriction on the type of information to be stored. After putting these values into the mapping, be sure not to alter them since you are only passing references and this method does NOT make copies. OID's should be sent as Strings. Make sure that anything passed as either a key or a value is Serializable!

Parameters:
OID - String representing the OID
value - Object representing the value for this particular OID
Throws:
LanNodeIsDeleted

getOID

public Object getOID(String OID)
              throws LanNodeIsDeleted
Returns the value associated with the OID as an Object. The XML file will tell you which datatype this particular OID contains. This returns a reference to the value and NOT a copy.

Parameters:
OID - String representing the OID to be retrieved
Returns:
value associated with the OID
Throws:
LanNodeIsDeleted

getSetOfOID

public Set getSetOfOID()
                throws LanNodeIsDeleted
Returns a Set of OID String's that contains all of the OID's that require polling for this LanNode. So, to completely update a nodes SNMP values, you iterate through this Set and make a setOID() call for each OID with the value received from the SNMP call. The OID's are not in any particular order. Remember: Since this is a Set, the values will be saved as Object's and need to be cast as String's. All OID keys WILL be instances of type String.

Returns:
Set of String of all the OID's that require information
Throws:
LanNodeIsDeleted - when this node has been deleted

setFrontEndInfo

public void setFrontEndInfo(Object key,
                            Object value)
                     throws LanNodeIsDeleted
This method is to be used exclusively by the frontend to store information on how to display this particular LanNode. Any syntax of key's and value's may be used provided they remain consistent (since both the key's and value's are of type Object). If the key already exists than it's value will be over-written. Since this is used exclusively by the FrontEnd then changes can be made to this information without checking it out for writing. (ie. the lock flag is not checked) Be aware that this mapping saves only the references and not copies of the values. (so if you change it afterwards then it will be changed in the Map as well) Also, make sure that anything passed as either a key or a value is Serializable!

Parameters:
key - arbitrary frontend property key
value - value associated with the key
Throws:
LanNodeIsDeleted

getFrontEndInfo

public Object getFrontEndInfo(Object key)
                       throws LanNodeIsDeleted
Returns a reference to the value associated with the key for use by the frontend. If no value is associated with this key or the key is not currently in the mapping then a null will be returned.

Parameters:
key - key associated with the value you wish returned
Returns:
value associated with the key
Throws:
LanNodeIsDeleted

getIp

public InetAddress getIp()
returns a copy of the IP of this node.

Returns:
IP of this node.

setIp

public void setIp(InetAddress ip)
           throws LanNodeIsDeleted
Changes this LanNode's IP address. The LanNode does not consider this a proper "update" though so the lastUpdated date will not be changed. However, the isUpdatedAndNotDisplayed() will return true so the change in IP will be reflected in the frontend.

Parameters:
ip - New IP address.
Throws:
LanNodeIsDeleted

isDeleted

public boolean isDeleted()
Returns whether or not this node has been deleted.

Returns:
boolean

equals

public boolean equals(Object obj)

Two LanNodes are considered equal if they both point to the same IP address. To test if two LanNodes point to the same information has to be done through some other method.

Also, a subclass of LanNode can not be considered equal to a LanNode under any circumstances and will automatically return a false

Returns:
returns true if the object passed has the same ip address as this node.

hashCode

public int hashCode()
Since the hashCode method must return the same hashCode during an execution, this method will return the hashCode produced by the InetAddress held within this node.


toString

public String toString()

getServerStatus

public boolean getServerStatus()
Getter for property isServer.

Returns:
Value of property isServer.

setServerStatus

public void setServerStatus(boolean newServerStatus)
Setter for property isServer.

Parameters:
newServerStatus - New value of property isServer.

isSnmpEnabled

public boolean isSnmpEnabled()
Getter for property snmpEnabled.

Returns:
Value of property snmpEnabled.

setSnmpEnabled

public void setSnmpEnabled(boolean snmpEnabled)
Setter for property snmpEnabled.

Parameters:
snmpEnabled - New value of property snmpEnabled.

isPolling

public boolean isPolling()
Getter for property polling.

Returns:
Value of property polling.

setPolling

public void setPolling(boolean polling)
Setter for property polling.

Parameters:
polling - New value of property polling.

giveFocus

public void giveFocus()

takeFocus

public void takeFocus()

trapEvent

public void trapEvent(String description)
               throws LanNodeIsDeleted
Throws:
LanNodeIsDeleted

getLastTrapEvent

public String getLastTrapEvent()

addOID

public void addOID(String OID)
Adds an OID key into the table for the backend to update with information

Parameters:
OID - key to add to the table for backend to do an SNMP query on.

isUpStatusPending

public boolean isUpStatusPending()
Getter for property upStatusPending.

Returns:
Value of property upStatusPending.