com.adventnet.snmp.snmp2.agent
Class AgentTree

java.lang.Object
  |
  +--com.adventnet.utils.btree.TreeFramework
        |
        +--com.adventnet.snmp.snmp2.agent.AgentTree

public class AgentTree
extends com.adventnet.utils.btree.TreeFramework

This tree holds AgentNodes which are identified by PduRequestHandler.

This tree holds all the nodes associated with the Oids that are registered with the PduRequestHandler by the VarBindRequestListeners. The registration with PduRequestHandler can be with subidlist as null or with subids specified.

If subidlist is null, then any incoming oid which falls in the registered oid tree will be given to that VarBindRequestListener (provided no other listener registered specifically for the incoming oid).

For example, if a listener L1 is registered for mib-2 (.1.3.6.1.2.1) and L2 for sysName(.1.3.6.1.2.1.1.5). If the incoming oid is for sysUpTime(.1.3.6.1.2.1.1.3) then listener L1 is called.(i.e any oid with in mib-2 and sysName will be given to the listener L1). If incoming oid is .1.3.6.1.2.1.1.5 , then listener L2 will be called.

See Also:
AgentNode

Field Summary
 java.util.Vector holderVector
          The vector containing the list of Holders registered in this Tree.
(package private) static int noOfRecCount
           
 
Fields inherited from class com.adventnet.utils.btree.TreeFramework
elementCount, root
 
Constructor Summary
AgentTree()
          No arg constructor for AgentTree preloads .1 as root
AgentTree(int i)
          The constructor for AgentTree with the root as argument.
 
Method Summary
 void addCell(com.adventnet.utils.btree.TreeCell cell)
          add a AgentNode.
 void addCell(com.adventnet.utils.btree.TreeCell cell, com.adventnet.utils.btree.TreeCell parent)
          add a AgentNode.
 com.adventnet.utils.btree.TreeCell getCell(java.lang.Object key1)
          Getter for the cell with the given key Override this method if there are any specific considerations
 com.adventnet.utils.btree.TreeCell getCell(java.lang.Object key1, boolean flag)
          Getter for the cell with the given key and request flag Override this method if there are any specific considerations
 com.adventnet.utils.btree.TreeCell getHolder(java.lang.Object key)
          Method to get the Holder associated with this key.
(package private)  AgentNode getLeafNodeInSubTree(AgentNode node)
           
(package private) static int getMinSize(int[] oid1, int[] oid2)
           
(package private)  AgentNode getNearestLeafNodeInSubTree(AgentNode node, java.lang.Object oid)
           
 com.adventnet.utils.btree.TreeCell getNextCell(AgentNode node, java.lang.Object key)
          Getter of the Next cell.
 com.adventnet.utils.btree.TreeCell getNextCell(java.lang.Object key)
          Getter of the next cell with the given key
(package private)  VarBindRequestListenerHolder getNextFailedVarBindRequestListenerHolder(AgentNode node)
          This method is called by VarBindRequestListenerManager when a VarBindRequestListener has failed to process a SnmpVarBind
(package private)  AgentNode getNextLevelCell(AgentNode node)
           
(package private)  AgentNode getNextLevelValidCell(AgentNode node)
           
 com.adventnet.utils.btree.TreeCell getNextRegisteredCell(java.lang.Object key)
          Getter of the next cell with the given key with registration in the tree.
(package private)  VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(AgentNode node)
           
(package private)  VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(SnmpVarBind varb)
           
 com.adventnet.utils.btree.TreeCell getPreviousCell(java.lang.Object key, boolean previousFlag)
          Getter of the previous cell before the given key
(package private)  VarBindRequestListenerHolder getVarBindRequestListenerHolder(AgentNode node)
           
(package private)  VarBindRequestListenerHolder getVarBindRequestListenerHolder(SnmpVarBind varb)
           
 void printRegistrations()
          Utility method which prints the Node Registrations
 void printTree()
          Utility method which prints the Tree
protected  void removeHolderFromVector(AgentNode node)
          The method removes a Holder from the Tree Holder Vector.
protected  void sortNodes(AgentNode child)
          This method is added for Sorting the Nodes that were added to the Holder Vector.
 
Methods inherited from class com.adventnet.utils.btree.TreeFramework
deleteCell, deleteCell, getElements, getRoot, incrementElementCount, setRoot, size
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

holderVector

public java.util.Vector holderVector
The vector containing the list of Holders registered in this Tree.

noOfRecCount

static int noOfRecCount
Constructor Detail

AgentTree

public AgentTree()
No arg constructor for AgentTree preloads .1 as root

AgentTree

public AgentTree(int i)
The constructor for AgentTree with the root as argument.
Parameters:
i - - the root to be set.
Method Detail

addCell

public void addCell(com.adventnet.utils.btree.TreeCell cell)
             throws java.lang.ClassCastException
add a AgentNode. Inserts the AgentNode at the appropriate place
Overrides:
addCell in class com.adventnet.utils.btree.TreeFramework
Parameters:
cell - the TreeCell to be added
Throws:
java.lang.ClassCastException - thrown if the cell is not AgentNode

addCell

public void addCell(com.adventnet.utils.btree.TreeCell cell,
                    com.adventnet.utils.btree.TreeCell parent)
             throws java.lang.ClassCastException
add a AgentNode. to the parent at the appropriate place
Overrides:
addCell in class com.adventnet.utils.btree.TreeFramework
Parameters:
cell - the child TreeCell
parent - the parent TreeCell
Throws:
java.lang.ClassCastException - thrown if the cell is not AgentNode

getCell

public com.adventnet.utils.btree.TreeCell getCell(java.lang.Object key1)
Getter for the cell with the given key Override this method if there are any specific considerations
Overrides:
getCell in class com.adventnet.utils.btree.TreeFramework
Parameters:
Object - key of the cell.
Returns:
the cell

getCell

public com.adventnet.utils.btree.TreeCell getCell(java.lang.Object key1,
                                                  boolean flag)
Getter for the cell with the given key and request flag Override this method if there are any specific considerations
Parameters:
key1 - Key of the cell.
flag - Request Flag for the Proxy options.
Returns:
the TreeCell

getPreviousCell

public com.adventnet.utils.btree.TreeCell getPreviousCell(java.lang.Object key,
                                                          boolean previousFlag)
Getter of the previous cell before the given key
Parameters:
Object - key of the current cell.
previousFlag - The flag determining the recursion, API should call it using false value.
Returns:
the previous cell , null if there is no previous cell

getNextRegisteredCell

public com.adventnet.utils.btree.TreeCell getNextRegisteredCell(java.lang.Object key)
Getter of the next cell with the given key with registration in the tree.
Parameters:
Object - key of the cell.
Returns:
the next cell, null if there is no cell

getNextCell

public com.adventnet.utils.btree.TreeCell getNextCell(java.lang.Object key)
Getter of the next cell with the given key
Overrides:
getNextCell in class com.adventnet.utils.btree.TreeFramework
Parameters:
Object - key of the cell.
Returns:
the next cell , null if there is no cell

getNextCell

public com.adventnet.utils.btree.TreeCell getNextCell(AgentNode node,
                                                      java.lang.Object key)
Getter of the Next cell. Note this method is especially helpful when we are involved with GetNext requests
Parameters:
node - the Node for which the next is to be got
key - the key object
Returns:
the next cell, null if there is no cell

getNextLevelCell

AgentNode getNextLevelCell(AgentNode node)
Returns:
the child in the Same Level who is next null in case there is no such child

getNextLevelValidCell

AgentNode getNextLevelValidCell(AgentNode node)
Returns:
the child in the Same Level who is next

printTree

public void printTree()
Utility method which prints the Tree

printRegistrations

public void printRegistrations()
Utility method which prints the Node Registrations

getVarBindRequestListenerHolder

VarBindRequestListenerHolder getVarBindRequestListenerHolder(AgentNode node)
Returns:
the VarBindRequestListenerHolder associated with a GET request

getVarBindRequestListenerHolder

VarBindRequestListenerHolder getVarBindRequestListenerHolder(SnmpVarBind varb)
Returns:
the VarBindRequestListenerHolder associated with a GET request

getNextVarBindRequestListenerHolder

VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(AgentNode node)
Returns:
the VarBindRequestListenerHolder associated with a GETNEXT request

getNextVarBindRequestListenerHolder

VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(SnmpVarBind varb)
Returns:
the VarBindRequestListenerHolder associated with a getNext request

getNextFailedVarBindRequestListenerHolder

VarBindRequestListenerHolder getNextFailedVarBindRequestListenerHolder(AgentNode node)
This method is called by VarBindRequestListenerManager when a VarBindRequestListener has failed to process a SnmpVarBind
Parameters:
node - node for which we need to do all our processing
Returns:
the Next VarBindRequestListenerHolder return null if there is no holder which is interested

getLeafNodeInSubTree

AgentNode getLeafNodeInSubTree(AgentNode node)

getNearestLeafNodeInSubTree

AgentNode getNearestLeafNodeInSubTree(AgentNode node,
                                      java.lang.Object oid)

sortNodes

protected void sortNodes(AgentNode child)
This method is added for Sorting the Nodes that were added to the Holder Vector. API users may not require this method.
Parameters:
child - the AgentNode to be added in the Vector.

getMinSize

static int getMinSize(int[] oid1,
                      int[] oid2)

removeHolderFromVector

protected void removeHolderFromVector(AgentNode node)
The method removes a Holder from the Tree Holder Vector. This will be called during the unregistration of a Listener. API users need not require this method.
Parameters:
node - the Node whose Holder has to be removed.

getHolder

public com.adventnet.utils.btree.TreeCell getHolder(java.lang.Object key)
Method to get the Holder associated with this key.
Parameters:
key - - The int[] key for which the TreeCell is to be got.
Returns:
the TreeCell for the given key if exists else a null.