public class TimeWindow
extends java.lang.Object
getCurrent()
method to access any other method, i.e.
if (TimeWindow.getCurrent() == null) { TimeWindow timew = new TimeWindow(); } boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);
This class contains two lookup tables. One that maps the host address+port onto the SNMP engine ID and one that keeps the SNMP engine ID with the timeline details about this engine.
getCurrent()
Modifier and Type | Field and Description |
---|---|
static int |
MaxTimeDifference
The maximum number of seconds the engine time in the PDU is allowed
to differ from my estimated engine time.
|
Constructor and Description |
---|
TimeWindow()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearTimeWindow(java.lang.String snmpEngineId)
Clear all timing information for the given engine ID.
|
static TimeWindow |
getCurrent()
Returns the current reference to this class.
|
protected java.lang.String |
getKey(java.lang.String hostaddr,
int port)
Returns the key to the engine ID lookup table, based on the specified
host address and port.
|
java.lang.String |
getSnmpEngineId(java.lang.String hostaddr,
int port)
Returns the snmp engine ID.
|
protected uk.co.westhawk.snmp.stack.TimeWindowNode |
getTimeLine(java.lang.String snmpEngineId)
Returns the timeline details of the snmp engine ID.
|
boolean |
isEngineIdOK(java.lang.String hostaddr,
int port,
java.lang.String snmpEngineId)
Checks if the engine ID is OK.
|
boolean |
isOutsideTimeWindow(java.lang.String snmpEngineId,
int bootsA,
int timeA)
Returns if the time details are outside the time window.
|
boolean |
isSnmpEngineIdKnown(java.lang.String hostaddr,
int port)
Returns if the snmp engine ID is known.
|
boolean |
isTimeLineKnown(java.lang.String snmpEngineId)
Returns if the timeline details of this snmp engine ID are known.
|
void |
setSnmpEngineId(java.lang.String hostaddr,
int port,
java.lang.String snmpEngineId)
Sets the SNMP engine ID that belongs to the specified hostaddr and port.
|
protected uk.co.westhawk.snmp.stack.TimeWindowNode |
setTimeLine(java.lang.String snmpEngineId,
uk.co.westhawk.snmp.stack.TimeWindowNode newNode)
Sets the timeline details of the snmp engine ID.
|
java.lang.String |
toString()
Returns the string representation.
|
boolean |
updateTimeWindow(java.lang.String snmpEngineId,
int bootsA,
int timeA,
boolean isAuthentic)
Tries to update the time window and returns if succeeded.
|
protected void |
updateTimeWindows()
Updates the estimated engine time of all gathered time details.
|
public static final int MaxTimeDifference
150
.public static TimeWindow getCurrent()
if (TimeWindow.getCurrent() == null) { TimeWindow timew = new TimeWindow(); } boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);
public java.lang.String getSnmpEngineId(java.lang.String hostaddr, int port)
hostaddr
- The host address of the engine IDport
- The port number of the engine IDisSnmpEngineIdKnown(String, int)
public boolean isSnmpEngineIdKnown(java.lang.String hostaddr, int port)
When the SNMP engine ID is known, this doesn't necessarily mean that the timeline details of this engine ID are known, since it takes a second discovery step to find out.
hostaddr
- The host address of the engine IDport
- The port number of the engine IDpublic void setSnmpEngineId(java.lang.String hostaddr, int port, java.lang.String snmpEngineId)
hostaddr
- The host address of the engine IDport
- The port number of the engine IDsnmpEngineId
- The engine IDpublic boolean isEngineIdOK(java.lang.String hostaddr, int port, java.lang.String snmpEngineId)
If there is already an engine ID for this hostaddr and port, the method returns true if the specified engine ID is the same as the existing one, and false if they differ. In the latter case the engine ID in the table is not updated.
hostaddr
- The host address of the engine IDport
- The port number of the engine IDsnmpEngineId
- The engine IDsetSnmpEngineId(String, int, String)
public boolean isTimeLineKnown(java.lang.String snmpEngineId)
snmpEngineId
- The engine IDpublic boolean isOutsideTimeWindow(java.lang.String snmpEngineId, int bootsA, int timeA)
snmpEngineId
- The SNMP engine IDbootsA
- The SNMP engine bootstimeA
- The SNMP engine timeupdateTimeWindow(String, int, int, boolean)
public boolean updateTimeWindow(java.lang.String snmpEngineId, int bootsA, int timeA, boolean isAuthentic)
An update will only occur if the message was authentic and the bootsA and timeA meet the requirements. New data will be inserted if the (bootsA > 0), irrespectively whether the message was authentic or not.
snmpEngineId
- The SNMP engine IDbootsA
- The SNMP engine bootstimeA
- The SNMP engine timeisOutsideTimeWindow(String, int, int)
public void clearTimeWindow(java.lang.String snmpEngineId)
snmpEngineId
- The engine to clearprotected void updateTimeWindows()
protected java.lang.String getKey(java.lang.String hostaddr, int port)
hostaddr
- The host addressport
- The portprotected uk.co.westhawk.snmp.stack.TimeWindowNode getTimeLine(java.lang.String snmpEngineId)
snmpEngineId
- The engine IDupdateTimeWindows()
protected uk.co.westhawk.snmp.stack.TimeWindowNode setTimeLine(java.lang.String snmpEngineId, uk.co.westhawk.snmp.stack.TimeWindowNode newNode)
snmpEngineId
- The engine IDnewNode
- The added time window node nodeupdateTimeWindows()
public java.lang.String toString()
toString
in class java.lang.Object