public class NodeLabel extends Object
This class contains convenience functions for retrieving and modifying the label associated with a managed node. The 'node' table contains a 'nodelabel' and 'nodelabelsource' field. The 'nodelabel' is a user-friendly name associated with the node. This name can be user-defined (via the WEB UI) or can be auto-generated based on what OpenNMS knows about the node and its interfaces. The 'nodelabelsource' field is a single character flag which indicates what the source for the node label was.
Valid values for node label source are: 'U' User defined 'H' Primary interface's IP host name 'S' Node's MIB-II sysName 'A' Primary interface's IP address
Modifier and Type | Field and Description |
---|---|
static int |
MAX_NODE_LABEL_LENGTH
Maximum length for node label
|
static char |
SOURCE_ADDRESS
Constant
SOURCE_ADDRESS='A' |
static char |
SOURCE_HOSTNAME
Constant
SOURCE_HOSTNAME='H' |
static char |
SOURCE_NETBIOS
Constant
SOURCE_NETBIOS='N' |
static char |
SOURCE_SYSNAME
Constant
SOURCE_SYSNAME='S' |
static char |
SOURCE_UNKNOWN
Initalization value for node label source flag
|
static char |
SOURCE_USERDEFINED
Valid values for node label source flag
|
Constructor and Description |
---|
NodeLabel()
Default constructor
|
NodeLabel(String nodeLabel,
char nodeLabelSource)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static void |
assignLabel(int nodeID,
NodeLabel nodeLabel)
This method updates the 'nodelabel' and 'nodelabelsource' fields of the
'node' table for the specified nodeID.
|
static void |
assignLabel(int nodeID,
NodeLabel nodeLabel,
Connection dbConnection)
This method updates the 'nodelabel' and 'nodelabelsource' fields of the
'node' table for the specified nodeID.
|
static NodeLabel |
computeLabel(int nodeID)
This method determines what label should be associated with a particular
node.
|
static NodeLabel |
computeLabel(int nodeID,
Connection dbConnection)
This method determines what label should be associated with a particular
node.
|
String |
getLabel()
Returns the node label .
|
char |
getSource()
Returns the node label source flag .
|
static NodeLabel |
retrieveLabel(int nodeID)
This method queries the 'node' table for the value of the 'nodelabel' and
'nodelabelsource' fields for the node with the provided nodeID.
|
static NodeLabel |
retrieveLabel(int nodeID,
Connection dbConnection)
This method queries the 'node' table for the value of the 'nodelabel' and
'nodelabelsource' fields for the node with the provided nodeID.
|
void |
setLabel(String nodeLabel)
Sets the node label.
|
void |
setSource(char nodeLabelSource)
Sets the node label source flag
|
String |
toString()
This method is responsible for returning a String object which represents
the content of this NodeLabel.
|
public static final char SOURCE_USERDEFINED
public static final char SOURCE_NETBIOS
SOURCE_NETBIOS='N'
public static final char SOURCE_HOSTNAME
SOURCE_HOSTNAME='H'
public static final char SOURCE_SYSNAME
SOURCE_SYSNAME='S'
public static final char SOURCE_ADDRESS
SOURCE_ADDRESS='A'
public static final char SOURCE_UNKNOWN
public static final int MAX_NODE_LABEL_LENGTH
public NodeLabel()
public NodeLabel(String nodeLabel, char nodeLabelSource)
nodeLabel
- Node labelnodeLabelSource
- Flag indicating source of node labelnodeLabelSource
- Flag indicating source of node labelpublic String getLabel()
public char getSource()
public void setLabel(String nodeLabel)
nodeLabel
- Node labelpublic void setSource(char nodeLabelSource)
nodeLabelSource
- Flag indicating source of node labelpublic static NodeLabel retrieveLabel(int nodeID) throws SQLException
nodeID
- Unique identifier of the node to be updated.SQLException
- if any.public static NodeLabel retrieveLabel(int nodeID, Connection dbConnection) throws SQLException
nodeID
- Unique ID of node whose label info is to be retrieveddbConnection
- SQL database connectionSQLException
- if any.public static void assignLabel(int nodeID, NodeLabel nodeLabel) throws SQLException
nodeID
- Unique identifier of the node to be updated.nodeLabel
- Object containing label and source values.SQLException
- if any.public static void assignLabel(int nodeID, NodeLabel nodeLabel, Connection dbConnection) throws SQLException
nodeID
- Unique identifier of the node to be updated.nodeLabel
- Object containing label and source values.dbConnection
- SQL database connectionSQLException
- if any.public static NodeLabel computeLabel(int nodeID) throws SQLException
nodeID
- Unique identifier of the node to be updated.SQLException
- if any.public static NodeLabel computeLabel(int nodeID, Connection dbConnection) throws SQLException
nodeID
- Unique identifier of the node to be updated.dbConnection
- SQL database connectionSQLException
- if any.Copyright © 2015. All Rights Reserved.