com.adventnet.snmp.snmp2
Class SnmpEngineEntry

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SnmpEngineEntry
All Implemented Interfaces:
java.io.Serializable

public class SnmpEngineEntry
extends java.lang.Object
implements java.io.Serializable

v3 only This class represents a particular SNMP entity and provides a unique mapping between the internet address and port of an entity to the engineID. An SnmpEngineEntry is created for each IPaddress and port of the SNMP entity. The SNMP entity may act as an agent or as a manager entity. This class maintains the host, port, time and boots values for each SNMP entity in addition to supporting the discovery process. The SnmpEngineTable maintains a table of SnmpEngineEntry Objects. Each SnmpEngineEntry Object created is added to the SnmpEngineTable.

For the entities acting like a manager, the attributes remoteHost, remotePort, engineID, engineBoots and engineTime, which are accessed by their respective get/set methods, represent the remote SNMP agent values. For the entities acting as an agent, the above attributes represent the entities own values.

See Also:
SnmpEngineTable, Serialized Form

Constructor Summary
SnmpEngineEntry(java.lang.String engineName)
          Constructs a new SnmpEngineEntry which represents a particular SnmpV3 entity for the specified engineName.
SnmpEngineEntry(java.lang.String address, int port)
          Constructs a new SnmpEngineEntry which represents a particular SnmpV3 entity for the specified host and port.
 
Method Summary
 SnmpEngineEntry copy()
           
 void discoverEngineID(SnmpSession session)
          Deprecated. This method doesn't throw any Exception and hence doesn't inform the user, in case of any error. As of WebNMS SNMP API 4 SP2 ( Release 4.0.2 ), replaced by discoverSnmpEngineID(SnmpSession)
 byte[] discoverSnmpEngineID(SnmpSession session)
          This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity.
 byte[] discoverSnmpEngineID(SnmpSession session, int timeout, int retries)
          This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity.
 int getEngineBoots()
          Returns the engine boots value of the corresponding SNMP entity.
 byte[] getEngineID()
          Returns the engineid of the coresponding Snmp entity.
 java.lang.String getEngineName()
          Returns the engineName of the corresponding Snmp entity when Independent transport provider is used.
 int getEngineTime()
          Gets the engine time of the corresponding Snmp entity.
 java.lang.Object getHashKey()
          Retrieve the hash key for this entry.
 int getLatestReceived()
           
 long getLocalTime()
           
 java.lang.String getRemoteHost()
          Returns the host name of the corresponding Snmp entity.
 int getRemotePort()
          Returns the port of the corresponding Snmp entity.
 int hashCode()
          Returns the hashCode for the object.
 int sendDiscoverMsg(SnmpSession session)
          This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity.
 void setEngineBoots(int boots)
          Sets the engineBoots value of the corresponding SNMP entity.
 void setEngineID(byte[] id)
          Sets the engineID of the corresponding Snmp entity.
 void setEngineTime(int time)
          Sets the engine time of the corresponding Snmp entity.
 void setLatestReceived(int lt)
           
 void setLocalTime(long t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpEngineEntry

public SnmpEngineEntry(java.lang.String address,
                       int port)
Constructs a new SnmpEngineEntry which represents a particular SnmpV3 entity for the specified host and port. In the context of a manager entity, the host and port represent the Snmp peer's values, where as in the case of an agent entity, it represents the entities own values.

Parameters:
address - The hostName for the new Snmp entity.
port - The port for the new Snmp entity.

SnmpEngineEntry

public SnmpEngineEntry(java.lang.String engineName)
Constructs a new SnmpEngineEntry which represents a particular SnmpV3 entity for the specified engineName. In the context of a manager entity, the engineName represents the Snmp peer's values, where as in the case of an agent entity, it represents the entities own values.

Parameters:
engineName - The stringified value of the engine name for the new Snmp entity.
Method Detail

getRemoteHost

public java.lang.String getRemoteHost()
Returns the host name of the corresponding Snmp entity. In the context of a manager entity, it returns the Snmp peer's hostName, where as in the case of an agent entity, it returns the entities own hostName.

Returns:
The hostName of corresponding Snmp entity.

getRemotePort

public int getRemotePort()
Returns the port of the corresponding Snmp entity. In the context of a manager entity, it returns the Snmp peer's port value, where as in the case of an agent entity, it returns the entities own port value.


getEngineID

public byte[] getEngineID()
Returns the engineid of the coresponding Snmp entity. In the context of a manager entity, it returns the Snmp peer's EngineID value, where as in the case of an agent entity, it returns the entities own engineID.

Returns:
The engineID of this Snmp entity.

setEngineID

public void setEngineID(byte[] id)
Sets the engineID of the corresponding Snmp entity. In the context of a manager entity, this represents the Snmp peer's EngineID value, where as in the case of an agent entity, it represents the entities own engineID.

Parameters:
id - The EngineID of the Snmp entity.

getEngineTime

public int getEngineTime()
Gets the engine time of the corresponding Snmp entity. This method returns the time which is the sum of the last recorded value and the difference between the present time and the previously recorded local time.In the context of a manager entity, this represents the Snmp peer's engineTime, where as in the case of an agent entity, it represents the entities own engineTime.

Returns:
This gives a time related to the last recorded value by adding the local time diff between the present and the local time when recorded.

setEngineTime

public void setEngineTime(int time)
Sets the engine time of the corresponding Snmp entity. In the context of a manager entity, this represents the Snmp peer's engineTime, where as in the case of an agent entity, it represents the entities own engineTime. Also updates the corresponging localTime notion.

Parameters:
time - The engine time to be set.

getLatestReceived

public int getLatestReceived()

setLatestReceived

public void setLatestReceived(int lt)

setLocalTime

public void setLocalTime(long t)

getLocalTime

public long getLocalTime()

getEngineBoots

public int getEngineBoots()
Returns the engine boots value of the corresponding SNMP entity. In the context of a manager entity, this represents the Snmp peer's engineBoots, where as in the case of an agent entity, it represents the entities own engineBoots.

Returns:
The engine boots of the Snmp entity.

setEngineBoots

public void setEngineBoots(int boots)
Sets the engineBoots value of the corresponding SNMP entity. In the context of a manager entity, this represents the Snmp peer's engineBoots, where as in the case of an agent entity, it represents the entities own engineBoots.

Parameters:
boots - The SnmpEngineBoots value to be set.

getHashKey

public java.lang.Object getHashKey()
Retrieve the hash key for this entry.

Returns:
the hash key as a String Object.

hashCode

public int hashCode()
Returns the hashCode for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

sendDiscoverMsg

public int sendDiscoverMsg(SnmpSession session)
This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity. This is an asynchronous discovery. A noAuthNoPriv Snmpv3 message with userName "initial" is sent to the host and port of this SnmpEngineEntry instance. The discovery message will be sent over the SnmpSession, which is the input parameter.

This performs an asynchronous discovery. This method sends the discovery message and returns. The response to the discovery which is a report PDU is handled in the SnmpSession receiver thread and the engineID is populated there.

Parameters:
session - The SnmpSession over which the discovery message is sent.
Returns:
The messageID of the request sent. Returns -1 if the session throws an exception while sending the request.

discoverEngineID

public void discoverEngineID(SnmpSession session)
Deprecated. This method doesn't throw any Exception and hence doesn't inform the user, in case of any error. As of WebNMS SNMP API 4 SP2 ( Release 4.0.2 ), replaced by discoverSnmpEngineID(SnmpSession)

This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity. This is a synchronous discovery. A noAuthNoPriv Snmpv3 message with userName "initial" is sent to the host and port of this SnmpEngineEntry instance. The discovery message will be sent over the SnmpSession, which is the input parameter.

This performs a synchronous discovery. This method sends the discovery message and returns only after receiving SNMP response, or timing out. Once the response is received the engineID of this SnmpEngineEntry object is populated.

Parameters:
session - The SnmpSession over which the discovery message is sent.

discoverSnmpEngineID

public byte[] discoverSnmpEngineID(SnmpSession session)
                            throws SnmpException,
                                   java.sql.SQLException
This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity. This is a synchronous discovery. A noAuthNoPriv Snmpv3 message with userName "initial" is sent to the host and port of this SnmpEngineEntry instance. The discovery message will be sent over the SnmpSession, which is the input parameter.

This performs a synchronous discovery. This method sends the discovery message and returns only after receiving SNMP response, or timing out. Once the response is received the engineID of this SnmpEngineEntry object is populated. If the discovery fails, then the SnmpEngineEntry object is removed.

Parameters:
session - The SnmpSession over which the discovery message is sent.
Throws:
SnmpException - will be thrown when there is a discovery failure
java.sql.SQLException - will be thrown in case of any database errors

discoverSnmpEngineID

public byte[] discoverSnmpEngineID(SnmpSession session,
                                   int timeout,
                                   int retries)
                            throws SnmpException,
                                   java.sql.SQLException
This performs the standard Snmpv3 discovery process to learn the engineID of the Snmp peer entity. This is a synchronous discovery. A noAuthNoPriv Snmpv3 message with userName "initial" is sent to the host and port of this SnmpEngineEntry instance. The discovery message will be sent over the SnmpSession, which is the input parameter.

This performs a synchronous discovery. This method sends the discovery message and returns only after receiving SNMP response, or timing out. Once the response is received the engineID of this SnmpEngineEntry object is populated. If the discovery fails, then the SnmpEngineEntry object is removed.

Parameters:
session - The SnmpSession over which the discovery message is sent.
timeout - The timeout for this synchronous request.
retries - The retries for this request.
Throws:
SnmpException - will be thrown when there is a discovery failure
java.sql.SQLException - will be thrown in case of any database errors

copy

public SnmpEngineEntry copy()

getEngineName

public java.lang.String getEngineName()
Returns the engineName of the corresponding Snmp entity when Independent transport provider is used.



Copyright (c)2010 ZOHO Corp., All Rights Reserved