com.adventnet.utils.agent
Class DynamicRegistrationWithInstance

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
        |
        +--com.adventnet.utils.agent.DynamicRegistrationWithInstance

public class DynamicRegistrationWithInstance
extends SimpleRequestHandler

DynamicRegistrationWithInstance helps in dynamically registring subtrees by remote sub agents

Uses SNMP for registration and forwarding the requests

The subids (columnar leafNodes under the table )are:

To use this table without agentEntryInstance value, For example : to proxy to a subagent s1 for .1.3.6.1.2.1.1(system group of rfc1213-mib), the entryInstance should be set to ".0.0" so that entryInstance column is not considered for proxying. This enables to use the instanceBasedProxyTable(row based proxy table) as a normal proxy table.

Since:
AdventNet Agent Toolkit (Java Edition) 4.1 release Patch release 3.0

Field Summary
(package private)  java.util.Vector addVector
           
(package private)  RegistrationListener agent
           
(package private) static java.lang.String DEFAULTINSTANCE
           
static java.lang.String fieldSeparator
          The fieldSeparator of the file to Vector persistent files
(package private)  DynamicWithInstanceXMLToVector fileToVector
           
(package private)  UpdateListener listener
           
(package private)  java.lang.String managerHost
           
(package private) static int PROXYENTRYINSTANCE
           
(package private) static int PROXYENTRYOID
           
(package private) static int PROXYINSCOMMUNITY
           
(package private) static int PROXYINSHOST
           
(package private) static int PROXYINSPORTNUMBER
           
(package private) static int PROXYINSRETRIES
           
(package private) static int PROXYINSROWSTATUS
           
(package private) static int PROXYINSTIMEOUT
           
(package private) static int PROXYINSVERSION
           
(package private)  java.util.Hashtable proxyTable
           
(package private)  AgentTableModel tModelComplete
           
(package private)  int trapPort
           
(package private)  int trapVersion
           
 
Fields inherited from class com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
instrumentHandler, listener, tableListener, writeEachTime
 
Constructor Summary
DynamicRegistrationWithInstance()
          The default constructor for the Class
DynamicRegistrationWithInstance(boolean persistence)
          The secondary constructor of the class with the persistence flag.
DynamicRegistrationWithInstance(boolean fToVPersistence, java.lang.String dirStr, java.lang.String fileStr)
          The secondary constructor of the class with the persistence format flag FToV/XML format.
 
Method Summary
 void addRegistrationListener(RegistrationListener l)
          This method is called by BeanInfo for adding Registration Listener with PduRequestHandler
 void addRegistrationListener(RegistrationListener l, boolean remoteAccess)
          Add RegistrationListener (agent) to the Listener table.
 void addUpdateListener(UpdateListener l)
          Setter for UpdateListener.
(package private)  boolean checkForRowStatus(DynamicRegistrationEntry entry)
           
 void checkSubAgentHeartBeat(boolean b, java.lang.Long pollingInterval, java.lang.Integer timeOut, java.lang.Integer retries, SnmpAgent agentRef)
          This method is to enable Polling the SubAgent to see whether its alive.
static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String proxyingOID, java.lang.String entryInstance, java.lang.String agentHost, java.lang.Integer agentPort, java.lang.Integer version, java.lang.String community, java.lang.Long timeOut, java.lang.Long retries)
          This is static method for creating a DynamicRegistrationEntry with the RowStatus value as Active(1).
static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String proxyingOID, java.lang.String entryInstance, java.lang.String agentHost, java.lang.Integer agentPort, java.lang.Integer version, java.lang.String community, java.lang.Long timeOut, java.lang.Long retries, java.lang.Integer status)
          This is static method for creating a DynamicRegistrationEntry.
static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String entryInstance, java.lang.String proxyingOID, java.lang.String agentHost, java.lang.String community, long timeOut, int agentPort)
          Deprecated. - make use of the other method with additional parameters. This is static method for creating a DynamicRegistrationEntry.
 java.util.Vector getExtraVarBind()
          Getter for the Vector of Additional VarBinds sent along with the SubAgent LinkUp or LinkDown Traps.
 java.lang.String getFieldSeparator()
          Getter for FieldSeparator
 java.lang.String getFileName()
          Getter for the fileName.
 java.lang.String getLinkDownOid()
          Getter for the LinkDownOid sent with the LinkUp Traps.
 java.lang.String getLinkUpOid()
          Getter for the LinkUpOid sent with the LinkUp Traps.
 SnmpProxy getProxyCommand(java.lang.String oid)
          Getter for the Proxy command related to the oid registration specified.
 java.lang.String getRegisteredOid()
          Getter for registered oid.
protected  int[] getSubidList()
          This is the subid List which is registered with the source of SnmpPduRequestEvents
 java.util.Vector getTableVector()
          Getter for Table Elements.
 boolean isPersistence()
          Getter of the persistence flag.
protected  void processGetNextRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Processes the GetNextRequest message from the manager for the instanceBasedProxyTable.
protected  void processGetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Processes the GetRequest message from the manager for the instanceBasedProxyTable.
protected  void processGetRequest(SnmpVarBind varb, int req, VarBindRequestEvent pe, DynamicRegistrationEntry entry)
          Processes the GetRequest message from the manager for the instanceBasedProxyTable.
protected  void processSetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Processes the SetRequest message from the manager for the instanceBasedProxyTable.
 void registerSubAgent(DynamicSnmpProxy proxy, SnmpVar var, DynamicRegistrationEntry entry)
           
 void removeRegistrationListener(RegistrationListener l)
          Removes RegistrationListener(agent) from Listener Table.
 void removeSubAgent(DynamicRegistrationEntry ent)
          Deprecated. Use the other method.
 void removeSubAgent(DynamicRegistrationEntry ent, boolean isDestroy)
          This method is to remove the SubAgent Registration.
 void removeUpdateListener()
          sets UpdateListener to null.
 void setExtraVarBind(java.util.Vector addVector)
          Method to set Additional VarBinds to be sent along with the SubAgent LinkUp or LinkDown Traps.
 void setFieldSeparator(java.lang.String separator)
          Setter for FieldSeparator
 void setFileName(java.lang.String fileName)
          Setter for file name.
 void setFToVPersistence(boolean fToVPersistence)
          Setter for the FToV Persistence flag.
 void setLinkDownOid(java.lang.String linkDownOid)
          Setter for the LinkDownTrap OID.
 void setLinkUpOid(java.lang.String linkUpOid)
          Setter for the LinkUpTrap OID.
 void setManagerHost(java.lang.String managerHost)
          Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.
 void setPersistence(boolean persistence)
          Setter of the persistence flag.
 void setRegisteredOid(java.lang.String oid)
          Setter for registered oid.
 void setTableVector(java.util.Vector tableVector)
          sets Table Elements.
 void setTrapPort(int trapPort)
          Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.
 void setTrapVersion(int trapVersion)
          Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.
 
Methods inherited from class com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
addInstrumentHandler, addTableListener, getInstrument, getMibVarHash, getNextRequest, getObjectHash, getObjectTypeHash, getOidRep, getRequest, getTableListener, isWriteEachTime, processGetNextRequest, processGetRequest, processSetRequest, setRequest, setWriteEachTime, writeIntoFile
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileToVector

DynamicWithInstanceXMLToVector fileToVector

fieldSeparator

public static java.lang.String fieldSeparator
The fieldSeparator of the file to Vector persistent files

PROXYENTRYOID

static final int PROXYENTRYOID

PROXYENTRYINSTANCE

static final int PROXYENTRYINSTANCE

PROXYINSHOST

static final int PROXYINSHOST

PROXYINSPORTNUMBER

static final int PROXYINSPORTNUMBER

PROXYINSVERSION

static final int PROXYINSVERSION

PROXYINSCOMMUNITY

static final int PROXYINSCOMMUNITY

PROXYINSTIMEOUT

static final int PROXYINSTIMEOUT

PROXYINSRETRIES

static final int PROXYINSRETRIES

PROXYINSROWSTATUS

static final int PROXYINSROWSTATUS

proxyTable

java.util.Hashtable proxyTable

DEFAULTINSTANCE

static java.lang.String DEFAULTINSTANCE

tModelComplete

AgentTableModel tModelComplete

trapPort

int trapPort

managerHost

java.lang.String managerHost

trapVersion

int trapVersion

addVector

java.util.Vector addVector

listener

UpdateListener listener

agent

RegistrationListener agent
Constructor Detail

DynamicRegistrationWithInstance

public DynamicRegistrationWithInstance()
The default constructor for the Class

DynamicRegistrationWithInstance

public DynamicRegistrationWithInstance(boolean persistence)
The secondary constructor of the class with the persistence flag.
Parameters:
persistence - The persistence flag for the persistence to the fileSystem.
Since:
AdventNet Agent Toolkit (Java Edition) 4.2 release.

DynamicRegistrationWithInstance

public DynamicRegistrationWithInstance(boolean fToVPersistence,
                                       java.lang.String dirStr,
                                       java.lang.String fileStr)
The secondary constructor of the class with the persistence format flag FToV/XML format.
Parameters:
fToVPersistence - The fToVPersistence flag for the type of persistence to the fileSystem FToV/XML.
dirStr - The directory name for persistence.
fileStr - The file name of the file in file system.
Since:
AdventNet Agent Toolkit (Java Edition) 4.2 release.
Method Detail

setRegisteredOid

public void setRegisteredOid(java.lang.String oid)
Setter for registered oid.
Parameters:
oid - specifies the Entry OID of the Table which is used as the instancebasedProxyTable(similar to ".1.3.6.1.4.1.2162.10.3.1.2.3.4.1").
See Also:
getRegisteredOid()

getRegisteredOid

public java.lang.String getRegisteredOid()
Getter for registered oid.

Returns:
The String representation of OID of the Entry Node of the Table which is used as the instanceBasedProxyTable which is registered through setRegisteredOid method(default value ".1.3.6.1.4.1.2162.10.3.1.2.3.4.1" Entry Node OID of instanceBasedProxyTable in agent-sample-mib.txt).
See Also:
setRegisteredOid(String oid)

setTableVector

public void setTableVector(java.util.Vector tableVector)
sets Table Elements.
Parameters:
tableVector - specifies the Vector of Row Entries(DynamicRegistrationEntry objects of the instanceBasedProxyTable).
See Also:
getTableVector()

getTableVector

public java.util.Vector getTableVector()
Getter for Table Elements.
Returns:
The Vector with the Row Entries(DynamicRegistrationEntry objects of the instanceBasedProxyTable).
See Also:
setTableVector(Vector tableVector)

setExtraVarBind

public void setExtraVarBind(java.util.Vector addVector)
Method to set Additional VarBinds to be sent along with the SubAgent LinkUp or LinkDown Traps.
Parameters:
addVector - the Vector of additional VarBinds.

getExtraVarBind

public java.util.Vector getExtraVarBind()
Getter for the Vector of Additional VarBinds sent along with the SubAgent LinkUp or LinkDown Traps.
Returns:
the Vector of additional VarBinds.

setTrapPort

public void setTrapPort(int trapPort)
Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.

Since:
AdventNet Agent Toolkit (Java/JMX Edition) 5.0

setManagerHost

public void setManagerHost(java.lang.String managerHost)
Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.

Since:
AdventNet Agent Toolkit (Java/JMX Edition) 5.0

setTrapVersion

public void setTrapVersion(int trapVersion)
Deprecated. The method is no Longer used. The Traps will be sent to the Entries in the ForwardingTable.

Since:
AdventNet Agent Toolkit (Java/JMX Edition) 5.0

setLinkUpOid

public void setLinkUpOid(java.lang.String linkUpOid)
Setter for the LinkUpTrap OID. Default value will be .1.3.6.1.4.1.2162.10.3.1.6.1
Parameters:
The - LinkUpOid to be sent with the Traps.

getLinkUpOid

public java.lang.String getLinkUpOid()
Getter for the LinkUpOid sent with the LinkUp Traps.
Returns:
The LinkUp Oid String.

setLinkDownOid

public void setLinkDownOid(java.lang.String linkDownOid)
Setter for the LinkDownTrap OID. Default value will be .1.3.6.1.4.1.2162.10.3.1.6.2
Parameters:
The - LinkUpOid to be sent with the Traps.

getLinkDownOid

public java.lang.String getLinkDownOid()
Getter for the LinkDownOid sent with the LinkUp Traps.
Returns:
The LinkUp Oid String.

checkSubAgentHeartBeat

public void checkSubAgentHeartBeat(boolean b,
                                   java.lang.Long pollingInterval,
                                   java.lang.Integer timeOut,
                                   java.lang.Integer retries,
                                   SnmpAgent agentRef)
This method is to enable Polling the SubAgent to see whether its alive. If the SubAgent fails to respond within the specified timeout and retries values, the MasterAgent will stop proxying the Requests to the SubAgent until it comes back alive.
Parameters:
b - true to enable polling.
pollingInterval - The TimeInterval between consecutive polls.
timeOut - The TimeOut value for which this Poller should wait to getback the Response from the SubAgnet.
retries - the Retries value to specify the number of polls to get back the response.
agentRef - the SnmpAgent reference.

setFileName

public void setFileName(java.lang.String fileName)
Setter for file name.
Parameters:
fileName - specifies the fileName for the persistent fileSystem with the directory structure(similar to "conf"+File.separator+ "ProxyTable.xml").
See Also:
getFileName()

getFileName

public java.lang.String getFileName()
Getter for the fileName.
Returns:
The fileName of the persistent fileSystem with the directory structure (by default the value is "conf/ProxyTable.xml").
See Also:
setFileName(String fileName)

getSubidList

protected int[] getSubidList()
This is the subid List which is registered with the source of SnmpPduRequestEvents
Overrides:
getSubidList in class SimpleRequestHandler
Returns:
integer array {1,2,3,4,5,6,7,8,9} The subId list of the instanceBasedProxyTable.

processGetRequest

protected void processGetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Processes the GetRequest message from the manager for the instanceBasedProxyTable.
Overrides:
processGetRequest in class SimpleRequestHandler
Parameters:
varb - specifies the VarBind.
node - The node for which the Get Request is given.
pe - The VarBindRequestEvent created for the Get Request.
Throws:
AgentSnmpException -  

processGetRequest

protected void processGetRequest(SnmpVarBind varb,
                                 int req,
                                 VarBindRequestEvent pe,
                                 DynamicRegistrationEntry entry)
                          throws AgentSnmpException
Processes the GetRequest message from the manager for the instanceBasedProxyTable.
Parameters:
varb - specifies the VarBind.
req - specifies the subId for which the Get request is processed.
pe - The VarBindRequestEvent created for the Get Request.
entry - specifies the table entry for which the Get Request is processed
Throws:
AgentSnmpException -  

processSetRequest

protected void processSetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Processes the SetRequest message from the manager for the instanceBasedProxyTable.
Overrides:
processSetRequest in class SimpleRequestHandler
Parameters:
varb - specifies the VarBind.
node - The node for which the Set Request is given.
pe - The VarBindRequestEvent created for the Set Request.
Throws:
AgentSnmpException -  

processGetNextRequest

protected void processGetNextRequest(SnmpVarBind varb,
                                     AgentNode node,
                                     VarBindRequestEvent pe)
                              throws AgentSnmpException
Processes the GetNextRequest message from the manager for the instanceBasedProxyTable.
Overrides:
processGetNextRequest in class SimpleRequestHandler
Parameters:
varb - specifies the VarBind.
node - The node for which the Get Next Request is given.
pe - The VarBindRequestEvent created for the Get Next Request.
Throws:
AgentSnmpException -  

checkForRowStatus

boolean checkForRowStatus(DynamicRegistrationEntry entry)
                    throws AgentSnmpException

addUpdateListener

public void addUpdateListener(UpdateListener l)
Setter for UpdateListener.
Overrides:
addUpdateListener in class SimpleRequestHandler
Parameters:
l - The update listener for updating the file system.
See Also:
removeUpdateListener()

removeUpdateListener

public void removeUpdateListener()
sets UpdateListener to null.
Overrides:
removeUpdateListener in class SimpleRequestHandler
See Also:
addUpdateListener(UpdateListener l)

addRegistrationListener

public void addRegistrationListener(RegistrationListener l)
Deprecated. - use the other method. Add RegistrationListener (agent) to the Listener table. Registration Listener methods

Description copied from class: SimpleRequestHandler
This method is called by BeanInfo for adding Registration Listener with PduRequestHandler
Overrides:
addRegistrationListener in class SimpleRequestHandler
Parameters:
l - The Registration Listener to listen for Requests from the manager.
See Also:
removeRegistrationListener(RegistrationListener l)

addRegistrationListener

public void addRegistrationListener(RegistrationListener l,
                                    boolean remoteAccess)
Add RegistrationListener (agent) to the Listener table. Registration Listener methods
Parameters:
l - The Registration Listener to listen for Requests from the manager.
remoteAccess - specifies whether this proxyTable is to be remotely Accessible or not.
See Also:
removeRegistrationListener(RegistrationListener l)

removeRegistrationListener

public void removeRegistrationListener(RegistrationListener l)
Removes RegistrationListener(agent) from Listener Table. makes the registration Listener null.

Overrides:
removeRegistrationListener in class SimpleRequestHandler
See Also:
addRegistrationListener(RegistrationListener l, boolean remoteAccess)

registerSubAgent

public void registerSubAgent(DynamicSnmpProxy proxy,
                             SnmpVar var,
                             DynamicRegistrationEntry entry)

removeSubAgent

public void removeSubAgent(DynamicRegistrationEntry ent)
Deprecated. Use the other method.


removeSubAgent

public void removeSubAgent(DynamicRegistrationEntry ent,
                           boolean isDestroy)
This method is to remove the SubAgent Registration. Based on the boolean isDestroy the entry will be reoved from the proxyStorage.
Parameters:
ent - the DynamicRegistrationEntry for UnRegistration.
isDestroy - boolean to sepcify the removal of the entry.

createDynamicRegistrationEntry

public static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String proxyingOID,
                                                                      java.lang.String entryInstance,
                                                                      java.lang.String agentHost,
                                                                      java.lang.Integer agentPort,
                                                                      java.lang.Integer version,
                                                                      java.lang.String community,
                                                                      java.lang.Long timeOut,
                                                                      java.lang.Long retries)
This is static method for creating a DynamicRegistrationEntry with the RowStatus value as Active(1).
Parameters:
proxyingOID - specifies the actual proxying OID in the subAgent.
entryInstance - specifies the entry instance which is to be proxied.
agentHost - specifies the Host in which the subAgent is running(it may be in IpAddress or the Host name format).
community - specifies the Version of the proxied subAgent.
community - specifies the community of the proxied subAgent.
timeOut - specifies the timeOut parameter for the request to subAgent.
agentPort - specifies the Port at which the subAgent is running.
Returns:
The DynamicRegistrationEntry created with the above details.
Since:
AdventNetAgentToolktRelease 5.0 Beta.

createDynamicRegistrationEntry

public static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String proxyingOID,
                                                                      java.lang.String entryInstance,
                                                                      java.lang.String agentHost,
                                                                      java.lang.Integer agentPort,
                                                                      java.lang.Integer version,
                                                                      java.lang.String community,
                                                                      java.lang.Long timeOut,
                                                                      java.lang.Long retries,
                                                                      java.lang.Integer status)
This is static method for creating a DynamicRegistrationEntry.
Parameters:
proxyingOID - specifies the actual proxying OID in the subAgent.
entryInstance - specifies the entry instance which is to be proxied.
agentHost - specifies the Host in which the subAgent is running(it may be in IpAddress or the Host name format).
community - specifies the Version of the proxied subAgent.
community - specifies the community of the proxied subAgent.
timeOut - specifies the timeOut parameter for the request to subAgent.
agentPort - specifies the Port at which the subAgent is running.
status - specifies the RowStatus value for this entry (1 - 5).
Returns:
The DynamicRegistrationEntry created with the above details.
Since:
AdventNet Agent Toolkit (Java Edition) 5.1.0.

setPersistence

public void setPersistence(boolean persistence)
Setter of the persistence flag.
Parameters:
persistence - The persistence flag for the persistence of the Table Values to the fileSystem.
Since:
AdventNet Agent Toolkit (Java Edition) 4.2 release.

isPersistence

public boolean isPersistence()
Getter of the persistence flag.
Returns:
true if the persistence is turned ON.
Since:
AdventNet Agent Toolkit (Java Edition) 4.2 release.

setFToVPersistence

public void setFToVPersistence(boolean fToVPersistence)
Setter for the FToV Persistence flag.
Parameters:
fToVPersistence - The FToV Persistence.

getFieldSeparator

public java.lang.String getFieldSeparator()
Getter for FieldSeparator
Returns:
The fieldSeparator

setFieldSeparator

public void setFieldSeparator(java.lang.String separator)
Setter for FieldSeparator
Parameters:
fieldSeparator - The fieldSeparator value

getProxyCommand

public SnmpProxy getProxyCommand(java.lang.String oid)
Getter for the Proxy command related to the oid registration specified.
Parameters:
oid - The OID registered as the SubAgent.
Returns:
The SnmpProxy object which implements the Proxy operations.

createDynamicRegistrationEntry

public static DynamicRegistrationEntry createDynamicRegistrationEntry(java.lang.String entryInstance,
                                                                      java.lang.String proxyingOID,
                                                                      java.lang.String agentHost,
                                                                      java.lang.String community,
                                                                      long timeOut,
                                                                      int agentPort)
Deprecated. - make use of the other method with additional parameters. This is static method for creating a DynamicRegistrationEntry.

Parameters:
entryInstance - specifies the entry instance which is to be proxied.
proxyingOID - specifies the actual proxying OID in the subAgent.
agentHost - specifies the Host in which the subAgent is running(it may be in IpAddress or the Host name format).
community - specifies the community of the proxied subAgent.
timeOut - specifies the timeOut parameter for the request to subAgent.
agentPort - specifies the Port at which the subAgent is running.
Returns:
The DynamicRegistrationEntry created with the above details.
Since:
AdventNet Agent Toolkit (Java/JMX Edition) 5.0