Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 4_12
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.co.westhawk.snmp.stack
Class TimeWindow

    java.lang.Object
      |
      +--uk.co.westhawk.snmp.stack.TimeWindow

public class TimeWindow
extends java.lang.Object

TimeWindow keeps the lookup tables for the engine Id information. TimeWindow should be created only once. Only use the `getCurrent()` method to access any other method, i.e.

     if (TimeWindow.getCurrent() == null)
     {
         TimeWindow timew = new TimeWindow();
     }
     boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(host, port);

This class contains 2 lookup tables. One that matches the hostname+port onto the SNMP engine ID. Another that matches the SNMP engine ID with the timeline details about this engine.

This class will also update the timeline details every second.

Version:
  $Revision: 3.9 $ $Date: 2002/10/10 15:13:57 $
Author:
  Birgit Arkesteijn
See Also:
  `getCurrent()`

Field Summary
`static int` | `MaxTimeDifference` The maximum number of seconds the engine time in the Pdu is allowed to differ from my estimated engine time.

Constructor Summary
`TimeWindow()` Constructor.

Method Summary
`static TimeWindow` | `getCurrent()` Returns the current reference to this class.
`protected java.lang.String` | `getKey(java.lang.String host, int port)` Returns the key based on the specified hostname and port to the engine ID lookup table.
`java.lang.String` | `getSnmpEngineId(java.lang.String host, 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 host, 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 host, 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 host, int port, java.lang.String snmpEngineId)` Sets the SNMP engine ID that belongs to the specified host 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.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MaxTimeDifference

    public static final int MaxTimeDifference

  The maximum number of seconds the engine time in the Pdu is allowed to differ from my estimated engine time.

Constructor Detail

### TimeWindow

    public TimeWindow()

  Constructor.

Method Detail

### getCurrent

    public static TimeWindow getCurrent()

  Returns the current reference to this class. TimeWindow should be created only once. Only use the `getCurrent()` method to access any other method, i.e.

       if (TimeWindow.getCurrent() == null)
       {
           TimeWindow timew = new TimeWindow();
       }
       boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(host, port);

  Returns:
    the current timewindow

### getSnmpEngineId

    public java.lang.String getSnmpEngineId(java.lang.String host,
                                            int port)

  Returns the snmp engine ID. This method will lookup the engine ID based on the host and port. If it the engine ID is not known, null will be returned.
  Parameters:
    `host` - The hostname of the engine ID
    `port` - The port number of the engine ID
  Returns:
    the snmp engine ID
  See Also:
    `isSnmpEngineIdKnown(String, int)`

### isSnmpEngineIdKnown

    public boolean isSnmpEngineIdKnown(java.lang.String host,
                                       int port)

  Returns if the snmp engine ID is known. This method will lookup if the engine ID belonging to this host and port is known.

  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.

  Parameters:
    `host` - The hostname of the engine ID
    `port` - The port number of the engine ID
  Returns:
    whether the snmp engine ID is known

### setSnmpEngineId

    public void setSnmpEngineId(java.lang.String host,
                                int port,
                                java.lang.String snmpEngineId)

  Sets the SNMP engine ID that belongs to the specified host and port. The old SNMP engine ID (if any) will be overwritten.
  Parameters:
    `host` - The hostname of the engine ID
    `port` - The port number of the engine ID
    `snmpEngineId` - The engine ID

### isEngineIdOK

    public boolean isEngineIdOK(java.lang.String host,
                                int port,
                                java.lang.String snmpEngineId)

  Checks if the engine ID is OK. If there is no engine ID known for this host and port, the specified engine ID is added to the table.

  If there is already an engine ID for this host and port, the method returns true is they are the same and false if they differ. In the latter case the engine ID in the table is not updated.

  Parameters:
    `host` - The hostname of the engine ID
    `port` - The port number of the engine ID
    `snmpEngineId` - The engine ID
  Returns:
    whether the engine ID matches the stored engine ID
  See Also:
    `setSnmpEngineId(String, int, String)`

### isTimeLineKnown

    public boolean isTimeLineKnown(java.lang.String snmpEngineId)

  Returns if the timeline details of this snmp engine ID are known.
  Parameters:
    `snmpEngineId` - The engine ID
  Returns:
    whether the timeline details are known

### isOutsideTimeWindow

    public boolean isOutsideTimeWindow(java.lang.String snmpEngineId,
                                       int bootsA,
                                       int timeA)

  Returns if the time details are outside the time window. When a response or report is received, first check the time window before updating it. Always do an update, even if outside the time window!
  Parameters:
    `snmpEngineId` - The SNMP engine ID
    `bootsA` - The SNMP engine boots
    `timeA` - The SNMP engine time
  Returns:
    true if outside or when no details can be found. false if inside time window
  See Also:
    `updateTimeWindow(String, int, int, boolean)`

### updateTimeWindow

    public boolean updateTimeWindow(java.lang.String snmpEngineId,
                                    int bootsA,
                                    int timeA,
                                    boolean isAuthentic)

  Tries to update the time window and returns if succeeded. When a response or report is received, first check the time window before updating it.

  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.

  Parameters:
    `snmpEngineId` - The SNMP engine ID
    `bootsA` - The SNMP engine boots
    `timeA` - The SNMP engine time
  Returns:
    true if update succeeded, or false when not succeeded or when no details could be found.
  See Also:
    `isOutsideTimeWindow(String, int, int)`

### updateTimeWindows

    protected void updateTimeWindows()

  Updates the estimated engine time of all gathered time details. It calculats the seconds that have been passed since the last call and updates all time window nodes accordingly.
  See Also:
    `setTimeLine(String, TimeWindowNode)`, `getTimeLine(String)`

### getKey

    protected java.lang.String getKey(java.lang.String host,
                                      int port)

  Returns the key based on the specified hostname and port to the engine ID lookup table.
  Parameters:
    `host` - The hostname
    `port` - The port
  Returns:
    the key

### getTimeLine

    protected uk.co.westhawk.snmp.stack.TimeWindowNode getTimeLine(java.lang.String snmpEngineId)

  Returns the timeline details of the snmp engine ID. If there are no matching timeline details for this engine ID, null will be returned. The timeline details will be updated before the node is retrieved from the table.
  Parameters:
    `snmpEngineId` - The engine ID
  Returns:
    The timeline details
  See Also:
    `updateTimeWindows()`

### setTimeLine

    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. The timeline details will be updated before the node is put in the table.
  Parameters:
    `snmpEngineId` - The engine ID
    `newNode` - The added time window node node
  Returns:
    The timeline details
  See Also:
    `updateTimeWindows()`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 4_12
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD