OpenNMS API 1.2.9

## org.opennms.netmgt.capsd
Class DbIfServiceEntry

    java.lang.Object
      org.opennms.netmgt.capsd.DbIfServiceEntry

public final class DbIfServiceEntry
extends java.lang.Object

Once loaded or create, the class tracks any changes and will write those changes to the database whenever the `store` method is invoked. If a database conneciton is not passed to the store method, then a temporary one is allocated to write the results.

NOTE: if the connection is passed in and is not in auto commit mode, then the caller must call `commit` to inform the database that the transaction is complete.

Author:
  Weave , OpenNMS

Field Summary
`private static int` `CHANGED_IFINDEX`
`private static int` `CHANGED_LASTFAIL`
`private static int` `CHANGED_LASTGOOD`
`private static int` `CHANGED_NOTIFY`
`private static int` `CHANGED_QUALIFIER`
`private static int` `CHANGED_SOURCE`
`private static int` `CHANGED_STATUS`
`private int` `m_changed` The bit map used to determine which elements have changed since the record was created.
`private boolean` `m_fromDb` True if this recored was loaded from the database.
`private int` `m_ifIndex` The SNMP ifIndex
`private java.net.InetAddress` `m_ipAddr` The IP address.
`private java.sql.Timestamp` `m_lastFail` The last time the interface failed.
`private java.sql.Timestamp` `m_lastGood` The last time the interface succeeded.
`private int` `m_nodeId` The node identifier
`private char` `m_notify` The notification state.
`private java.lang.String` `m_qualifier` The qualifier string
`private int` `m_serviceId` The integer service id
`private char` `m_source` The managed status, if any
`private char` `m_status` The status of the interface
`(package private) static char` `NOTIFY_OFF`
`(package private) static char` `NOTIFY_ON`
`(package private) static char` `NOTIFY_UNKNOWN`
`(package private) static char` `SOURCE_FORCED`
`(package private) static char` `SOURCE_PLUGIN`
`(package private) static char` `SOURCE_UNKNOWN`
`private static java.lang.String` `SQL_LOAD_REC` The SQL statement used to read a node from the database.
`static char` `STATUS_ACTIVE`
`static char` `STATUS_DELETED`
`static char` `STATUS_FORCED`
`static char` `STATUS_NOT_POLLED`
`static char` `STATUS_RESUME`
`static char` `STATUS_SUSPEND`
`static char` `STATUS_UNKNOWN`
`static char` `STATUS_UNMANAGED`

Constructor Summary
`private` `DbIfServiceEntry()` Default constructor.
`private` `DbIfServiceEntry(int nid, java.net.InetAddress address, int sid, boolean exists)` Constructs a new interface.

Method Summary
`(package private) static DbIfServiceEntry` `create(int nid, java.net.InetAddress address, int sid)` Creates a new entry.
`(package private) static DbIfServiceEntry` `get(java.sql.Connection db, int nid, java.net.InetAddress addr, int sid)` Retreives a current record from the database based upon the key fields of nodeID and ipAddr.
`(package private) static DbIfServiceEntry` `get(int nid, java.net.InetAddress addr, int sid)` Retreives a current record from the database based upon the key fields of nodeID and ipAddr.
`(package private) java.net.InetAddress` `getIfAddress()` Returns the name of the distributed poller for the entry.
`(package private) int` `getIfIndex()` Returns the current ifIndex
`(package private) java.sql.Timestamp` `getLastFail()` Gets the last fail poll time of the record
`(package private) java.lang.String` `getLastFailString()` Gets the last fail poll time of the record
`(package private) java.sql.Timestamp` `getLastGood()` Gets the last good poll time of the record
`(package private) java.lang.String` `getLastGoodString()` Gets the last good poll time of the record
`(package private) int` `getNodeId()` Returns the node entry's unique identifier.
`(package private) char` `getNotify()` Gets the notification state.
`(package private) java.lang.String` `getQualifier()`
`(package private) int` `getServiceId()` Returns the service id of this service entry.
`(package private) char` `getSource()` Gets the source of the interface service.
`(package private) char` `getStatus()` Gets the current operational status field
`(package private) boolean` `hasIfIndex()` Returns true if the ifIndex is defined.
`(package private) boolean` `hasIfIndexChanged()`
`(package private) boolean` `hasNotifyChanged()`
`(package private) boolean` `hasQualifierChanged()`
`(package private) boolean` `hasSourceChanged()`
`(package private) boolean` `hasStatusChanged()`
`private void` `insert(java.sql.Connection c)` Inserts the new interface into the ipInterface table of the OpenNMS databasee.
`private boolean` `load(java.sql.Connection c)` Load the current interface from the database.
`static void` `main(java.lang.String[] args)` For debugging only
`(package private) void` `setIfIndex(int ndx)` Sets the ifIndex value
`(package private) void` `setLastFail(java.util.Date time)` Sets the current last fail poll time.
`(package private) void` `setLastFail(java.lang.String time)` Sets the current last fail poll time
`(package private) void` `setLastFail(java.sql.Timestamp time)` Sets the current last fail poll time.
`(package private) void` `setLastGood(java.util.Date time)` Sets the current last good poll time.
`(package private) void` `setLastGood(java.lang.String time)` Sets the current last good poll time
`(package private) void` `setLastGood(java.sql.Timestamp time)` Sets the current last good poll time.
`(package private) void` `setNotify(char notify)` Sets the notification state
`(package private) void` `setQualifier(java.lang.String qualifier)`
`(package private) void` `setSource(char src)` Sets the source of the interface service
`(package private) void` `setStatus(char status)` Sets the current status of the service
`(package private) void` `store()` Updates the interface information in the configured database.
`(package private) void` `store(java.sql.Connection db)` Updates the interface information in the configured database.
`java.lang.String` `toString()` Creates a string that displays the internal contents of the record.
`private void` `update(java.sql.Connection c)` Updates an existing record in the OpenNMS ifServices table.
`(package private) boolean` `updateIfIndex(int newIfIndex)`
`(package private) boolean` `updateNotify(char newNotify)`
`(package private) boolean` `updateQualifier(java.lang.String newQualifier)`
`(package private) boolean` `updateSource(char newSource)`
`(package private) boolean` `updateStatus(char newStatus)`

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

Field Detail

### STATUS_UNMANAGED

    public static final char STATUS_UNMANAGED

See Also:
  Constant Field Values

### STATUS_ACTIVE

    public static final char STATUS_ACTIVE

See Also:
  Constant Field Values

### STATUS_DELETED

    public static final char STATUS_DELETED

See Also:
  Constant Field Values

### STATUS_FORCED

    public static final char STATUS_FORCED

See Also:
  Constant Field Values

### STATUS_NOT_POLLED

    public static final char STATUS_NOT_POLLED

See Also:
  Constant Field Values

### STATUS_UNKNOWN

    public static final char STATUS_UNKNOWN

See Also:
  Constant Field Values

### STATUS_SUSPEND

    public static final char STATUS_SUSPEND

See Also:
  Constant Field Values

### STATUS_RESUME

    public static final char STATUS_RESUME

See Also:
  Constant Field Values

### SOURCE_PLUGIN

    static final char SOURCE_PLUGIN

See Also:
  Constant Field Values

### SOURCE_FORCED

    static final char SOURCE_FORCED

See Also:
  Constant Field Values

### SOURCE_UNKNOWN

    static final char SOURCE_UNKNOWN

See Also:
  Constant Field Values

### NOTIFY_ON

    static final char NOTIFY_ON

See Also:
  Constant Field Values

### NOTIFY_OFF

    static final char NOTIFY_OFF

See Also:
  Constant Field Values

### NOTIFY_UNKNOWN

    static final char NOTIFY_UNKNOWN

See Also:
  Constant Field Values

### SQL_LOAD_REC

    private static final java.lang.String SQL_LOAD_REC

  The SQL statement used to read a node from the database. This record is keyed by the node identifier and distributed poller name.

  See Also:
    Constant Field Values

### m_fromDb

    private boolean m_fromDb

  True if this recored was loaded from the database. False if it's new.

### m_nodeId

    private int m_nodeId

  The node identifier

### m_ipAddr

    private java.net.InetAddress m_ipAddr

  The IP address.

### m_serviceId

    private int m_serviceId

  The integer service id

### m_ifIndex

    private int m_ifIndex

  The SNMP ifIndex

### m_status

    private char m_status

  The status of the interface

### m_source

    private char m_source

  The managed status, if any

### m_lastFail

    private java.sql.Timestamp m_lastFail

  The last time the interface failed.

### m_lastGood

    private java.sql.Timestamp m_lastGood

  The last time the interface succeeded.

### m_notify

    private char m_notify

  The notification state.

### m_qualifier

    private java.lang.String m_qualifier

  The qualifier string

### m_changed

    private int m_changed

  The bit map used to determine which elements have changed since the record was created.

### CHANGED_IFINDEX

    private static final int CHANGED_IFINDEX

See Also:
  Constant Field Values

### CHANGED_LASTGOOD

    private static final int CHANGED_LASTGOOD

See Also:
  Constant Field Values

### CHANGED_LASTFAIL

    private static final int CHANGED_LASTFAIL

See Also:
  Constant Field Values

### CHANGED_STATUS

    private static final int CHANGED_STATUS

See Also:
  Constant Field Values

### CHANGED_SOURCE

    private static final int CHANGED_SOURCE

See Also:
  Constant Field Values

### CHANGED_NOTIFY

    private static final int CHANGED_NOTIFY

See Also:
  Constant Field Values

### CHANGED_QUALIFIER

    private static final int CHANGED_QUALIFIER

See Also:
  Constant Field Values

Constructor Detail

### DbIfServiceEntry

    private DbIfServiceEntry()

  Default constructor.

### DbIfServiceEntry

    private DbIfServiceEntry(int nid,
                             java.net.InetAddress address,
                             int sid,
                             boolean exists)

  Constructs a new interface.

Parameters:
  `nid` - The node identifier.
  `address` - The target interface address.
  `sid` - The service identifier
  `exists` - True if the interface already exists.

Method Detail

### insert

    private void insert(java.sql.Connection c)
                 throws java.sql.SQLException

  Inserts the new interface into the ipInterface table of the OpenNMS databasee.

  Parameters:
    `c` - The connection to the database.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### update

    private void update(java.sql.Connection c)
                 throws java.sql.SQLException

  Updates an existing record in the OpenNMS ifServices table.

  Parameters:
    `c` - The connection used for the update.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### load

    private boolean load(java.sql.Connection c)
                  throws java.sql.SQLException

  Load the current interface from the database. If the interface was modified, the modifications are lost. The nodeid and ip address must be set prior to this call.

  Parameters:
    `c` - The connection used to load the data.
  Throws:
    `java.sql.SQLException` - Thrown if an error occurs with the connection

### getNodeId

    int getNodeId()

  Returns the node entry's unique identifier. This is a non-mutable element. If the record does not yet exist in the database then a -1 is returned.

### getIfAddress

    java.net.InetAddress getIfAddress()

  Returns the name of the distributed poller for the entry. This is a non-mutable element of the record.

### getServiceId

    int getServiceId()

  Returns the service id of this service entry.

### getLastGoodString

    java.lang.String getLastGoodString()

  Gets the last good poll time of the record

### getLastGood

    java.sql.Timestamp getLastGood()

  Gets the last good poll time of the record

### setLastGood

    void setLastGood(java.lang.String time)
               throws java.text.ParseException

  Sets the current last good poll time

  Parameters:
    `time` - The poll time.
  Throws:
    `java.text.ParseException`

### setLastGood

    void setLastGood(java.util.Date time)

  Sets the current last good poll time.

  Parameters:
    `time` - The poll time.

### setLastGood

    void setLastGood(java.sql.Timestamp time)

  Sets the current last good poll time.

  Parameters:
    `time` - The poll time.

### getLastFailString

    java.lang.String getLastFailString()

  Gets the last fail poll time of the record

### getLastFail

    java.sql.Timestamp getLastFail()

  Gets the last fail poll time of the record

### setLastFail

    void setLastFail(java.lang.String time)
               throws java.text.ParseException

  Sets the current last fail poll time

  Parameters:
    `time` - The poll time.
  Throws:
    `java.text.ParseException`

### setLastFail

    void setLastFail(java.util.Date time)

  Sets the current last fail poll time.

  Parameters:
    `time` - The poll time.

### setLastFail

    void setLastFail(java.sql.Timestamp time)

  Sets the current last fail poll time.

  Parameters:
    `time` - The poll time.

### hasIfIndex

    boolean hasIfIndex()

  Returns true if the ifIndex is defined.

### getIfIndex

    int getIfIndex()

  Returns the current ifIndex

### setIfIndex

    void setIfIndex(int ndx)

  Sets the ifIndex value

  Parameters:
    `ndx` - The new ifIndex.

### hasIfIndexChanged

    boolean hasIfIndexChanged()

### updateIfIndex

    boolean updateIfIndex(int newIfIndex)

### getStatus

    char getStatus()

  Gets the current operational status field

### setStatus

    void setStatus(char status)

  Sets the current status of the service

  Parameters:
    `status` - The new status.

### hasStatusChanged

    boolean hasStatusChanged()

### updateStatus

    boolean updateStatus(char newStatus)

### getSource

    char getSource()

  Gets the source of the interface service.

### setSource

    void setSource(char src)

  Sets the source of the interface service

### hasSourceChanged

    boolean hasSourceChanged()

### updateSource

    boolean updateSource(char newSource)

### getNotify

    char getNotify()

  Gets the notification state.

### setNotify

    void setNotify(char notify)

  Sets the notification state

### hasNotifyChanged

    boolean hasNotifyChanged()

### updateNotify

    boolean updateNotify(char newNotify)

### getQualifier

    java.lang.String getQualifier()

### setQualifier

    void setQualifier(java.lang.String qualifier)

### hasQualifierChanged

    boolean hasQualifierChanged()

### updateQualifier

    boolean updateQualifier(java.lang.String newQualifier)

### store

    void store()
         throws java.sql.SQLException

  Updates the interface information in the configured database. If the interfaca does not exist the a new row in the table is created. If the element already exists then it's current row is updated as needed based upon the current changes to the node.

  Throws:
    `java.sql.SQLException`

### store

    void store(java.sql.Connection db)
         throws java.sql.SQLException

  Updates the interface information in the configured database. If the interfaca does not exist the a new row in the table is created. If the element already exists then it's current row is updated as needed based upon the current changes to the node.

  Parameters:
    `db` - The database connection used to write the record.
  Throws:
    `java.sql.SQLException`

### create

    static DbIfServiceEntry create(int nid,
                                   java.net.InetAddress address,
                                   int sid)

  Creates a new entry. The entry is created in memory, but is not written to the database until the first call to `store`.

  Parameters:
    `address` - The address of the interface.
    `nid` - The node id of the interface.
    `sid` - The service id for the interface.
  Returns:
    A new interface record.

### get

    static DbIfServiceEntry get(int nid,
                                java.net.InetAddress addr,
                                int sid)
                         throws java.sql.SQLException

  Retreives a current record from the database based upon the key fields of nodeID and ipAddr. If the record cannot be found then a null reference is returned.

  Parameters:
    `nid` - The node id key
    `addr` - The ip address.
    `sid` - The service id.
  Returns:
    The loaded entry or null if one could not be found.
  Throws:
    `java.sql.SQLException`

### get

    static DbIfServiceEntry get(java.sql.Connection db,
                                int nid,
                                java.net.InetAddress addr,
                                int sid)
                         throws java.sql.SQLException

  Retreives a current record from the database based upon the key fields of nodeID and ipAddr. If the record cannot be found then a null reference is returnd.

  Parameters:
    `db` - The databse connection used to load the entry.
    `nid` - The node id key
    `addr` - The internet address.
  Returns:
    The loaded entry or null if one could not be found.
  Throws:
    `java.sql.SQLException`

### toString

    public java.lang.String toString()

  Creates a string that displays the internal contents of the record. This is mainly just used for debug output since the format is ad-hoc.

### main

    public static void main(java.lang.String[] args)

  For debugging only

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.