本文整理了Java中org.opennms.netmgt.xml.event.Event.hasNodeid()
方法的一些代码示例,展示了Event.hasNodeid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.hasNodeid()
方法的具体详情如下:
包路径:org.opennms.netmgt.xml.event.Event
类名称:Event
方法名:hasNodeid
[英]Method hasNodeid.
[中]方法hasNodeid。
代码示例来源:origin: OpenNMS/opennms
/**
* Ensures that the given Event has a node id
*
* @param e
* the event
* @throws org.opennms.netmgt.capsd.InsufficientInformationException
* if a node id is not available
*/
static public void checkNodeId(Event e) throws InsufficientInformationException {
if (e == null) {
throw new NullPointerException("e is null");
} else if (!e.hasNodeid()) {
throw new InsufficientInformationException("nodeid for event is unavailable");
}
}
代码示例来源:origin: OpenNMS/opennms
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
if (event.hasNodeid()) {
try {
String foreignSource = eventUtil.getForeignSource(event.getNodeid());
if (foreignSource != null) {
return WebSecurityUtils.sanitizeString(foreignSource);
}
} catch (SQLException ex) {
// do nothing
LoggerFactory.getLogger(getClass()).info("ForeignSource unavailable for node with id:", event.getNodeid(), ex);
}
}
return "";
}
代码示例来源:origin: OpenNMS/opennms
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
String nodeLabel = null;
if (event.hasNodeid()) {
try {
nodeLabel = eventUtil.getNodeLabel(event.getNodeid());
} catch (SQLException e) {
// do nothing
LoggerFactory.getLogger(getClass()).info("Node Label unavailable for node with id: {}", event.getNodeid(), e);
}
}
if (nodeLabel != null) {
return WebSecurityUtils.sanitizeString(nodeLabel);
} else {
return "Unknown";
}
}
代码示例来源:origin: OpenNMS/opennms
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
if (event.hasNodeid()) {
try {
String foreignId = eventUtil.getForeignId(event.getNodeid());
if (foreignId != null) {
return WebSecurityUtils.sanitizeString(foreignId);
}
} catch (SQLException ex) {
// do nothing
LoggerFactory.getLogger(getClass()).info("ForeignId unavailable for node with id:", event.getNodeid(), ex);
}
}
return "";
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
if (event.hasNodeid()) {
try {
String foreignSource = eventUtil.getForeignSource(event.getNodeid());
if (foreignSource != null) {
return WebSecurityUtils.sanitizeString(foreignSource);
}
} catch (SQLException ex) {
// do nothing
LoggerFactory.getLogger(getClass()).info("ForeignSource unavailable for node with id:", event.getNodeid(), ex);
}
}
return "";
}
代码示例来源:origin: OpenNMS/opennms
/**
* <p>handleRancidDownLoadSuccess</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RANCID_DOWNLOAD_SUCCESS_UEI)
public void handleRancidDownLoadSuccess(Event e) {
LOG.debug("handleRancidDownLoadSuccess: get Event uei/id: {} / {}", e.getDbid(), e.getUei());
if (e.hasNodeid() ) {
int nodeId = Long.valueOf(e.getNodeid()).intValue();
if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
updateRancidNodeState(nodeId, false);
} else {
LOG.warn("node does not exist with nodeid: {}", e.getNodeid());
}
}
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
if (event.hasNodeid()) {
try {
String foreignId = eventUtil.getForeignId(event.getNodeid());
if (foreignId != null) {
return WebSecurityUtils.sanitizeString(foreignId);
}
} catch (SQLException ex) {
// do nothing
LoggerFactory.getLogger(getClass()).info("ForeignId unavailable for node with id:", event.getNodeid(), ex);
}
}
return "";
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
String nodeLabel = null;
if (event.hasNodeid()) {
try {
nodeLabel = eventUtil.getNodeLabel(event.getNodeid());
} catch (SQLException e) {
// do nothing
LoggerFactory.getLogger(getClass()).info("Node Label unavailable for node with id: {}", event.getNodeid(), e);
}
}
if (nodeLabel != null) {
return WebSecurityUtils.sanitizeString(nodeLabel);
} else {
return "Unknown";
}
}
代码示例来源:origin: OpenNMS/opennms
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
String nodeLocation = null;
if (event.hasNodeid()) {
try {
nodeLocation = eventUtil.getNodeLocation(event.getNodeid());
} catch (SQLException e) {
// do nothing
LoggerFactory.getLogger(getClass()).info("Node Location unavailable for node with id: {}", event.getNodeid(), e);
}
}
if (nodeLocation != null) {
return WebSecurityUtils.sanitizeString(nodeLocation);
} else {
return "Unknown";
}
}
代码示例来源:origin: OpenNMS/opennms
/**
* <p>handleRancidDownLoadFailure</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RANCID_DOWNLOAD_FAILURE_UEI)
public void handleRancidDownLoadFailure(Event e) {
LOG.debug("handleRancidDownLoadFailure: get Event uei/id: {} / {}", e.getDbid(), e.getUei());
if (e.hasNodeid()) {
int nodeId = Long.valueOf(e.getNodeid()).intValue();
if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
updateRancidNodeState(nodeId, false);
} else {
LOG.warn("node does not exist with nodeid: {}", e.getNodeid());
}
}
}
代码示例来源:origin: org.opennms/opennms-rancid-provisioning-adapter
/**
* <p>handleRancidDownLoadFailure</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RANCID_DOWNLOAD_FAILURE_UEI)
public void handleRancidDownLoadFailure(Event e) {
LOG.debug("handleRancidDownLoadFailure: get Event uei/id: {} / {}", e.getDbid(), e.getUei());
if (e.hasNodeid()) {
int nodeId = Long.valueOf(e.getNodeid()).intValue();
if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
updateRancidNodeState(nodeId, false);
} else {
LOG.warn("node does not exist with nodeid: {}", e.getNodeid());
}
}
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon
@Override
public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
String nodeLocation = null;
if (event.hasNodeid()) {
try {
nodeLocation = eventUtil.getNodeLocation(event.getNodeid());
} catch (SQLException e) {
// do nothing
LoggerFactory.getLogger(getClass()).info("Node Location unavailable for node with id: {}", event.getNodeid(), e);
}
}
if (nodeLocation != null) {
return WebSecurityUtils.sanitizeString(nodeLocation);
} else {
return "Unknown";
}
}
代码示例来源:origin: org.opennms/opennms-rancid-provisioning-adapter
/**
* <p>handleRancidDownLoadSuccess</p>
*
* @param e a {@link org.opennms.netmgt.xml.event.Event} object.
*/
@EventHandler(uei = EventConstants.RANCID_DOWNLOAD_SUCCESS_UEI)
public void handleRancidDownLoadSuccess(Event e) {
LOG.debug("handleRancidDownLoadSuccess: get Event uei/id: {} / {}", e.getDbid(), e.getUei());
if (e.hasNodeid() ) {
int nodeId = Long.valueOf(e.getNodeid()).intValue();
if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
updateRancidNodeState(nodeId, false);
} else {
LOG.warn("node does not exist with nodeid: {}", e.getNodeid());
}
}
}
代码示例来源:origin: OpenNMS/opennms
String nodeID = event.hasNodeid() ? String.valueOf(event.getNodeid()) : null;
String ipAddr = event.getInterface();
String service = event.getService();
代码示例来源:origin: OpenNMS/opennms
@Override
public void handleMessage(TrapLogDTO messageLog) {
try (Logging.MDCCloseable mdc = Logging.withPrefixCloseable(Trapd.LOG4J_CATEGORY)) {
final Log eventLog = toLog(messageLog);
eventForwarder.sendNowSync(eventLog);
// If configured, also send events for new suspects
if (config.getNewSuspectOnTrap()) {
eventLog.getEvents().getEventCollection().stream()
.filter(e -> !e.hasNodeid())
.forEach(e -> {
sendNewSuspectEvent(e.getInterface(), e.getDistPoller());
LOG.debug("Sent newSuspectEvent for interface {}", e.getInterface());
});
}
}
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.traps
@Override
public void handleMessage(TrapLogDTO messageLog) {
try (Logging.MDCCloseable mdc = Logging.withPrefixCloseable(Trapd.LOG4J_CATEGORY)) {
final Log eventLog = toLog(messageLog);
eventForwarder.sendNowSync(eventLog);
// If configured, also send events for new suspects
if (config.getNewSuspectOnTrap()) {
eventLog.getEvents().getEventCollection().stream()
.filter(e -> !e.hasNodeid())
.forEach(e -> {
sendNewSuspectEvent(e.getInterface(), e.getDistPoller());
LOG.debug("Sent newSuspectEvent for interface {}", e.getInterface());
});
}
}
}
代码示例来源:origin: OpenNMS/opennms
/**
* <p>getEventHost</p>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
* @return a {@link java.lang.String} object.
*/
@Override
public String getEventHost(final Event event) {
if (event.getHost() == null) {
return null;
}
// If the event doesn't have a node ID, we can't lookup the IP address and be sure we have the right one since we don't know what node it is on
if (!event.hasNodeid()) {
return event.getHost();
}
try {
return getHostName(event.getNodeid().intValue(), event.getHost());
} catch (final Throwable t) {
LOG.warn("Error converting host IP \"{}\" to a hostname, storing the IP.", event.getHost(), t);
return event.getHost();
}
}
代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon
/**
* <p>getEventHost</p>
*
* @param event a {@link org.opennms.netmgt.xml.event.Event} object.
* @return a {@link java.lang.String} object.
*/
@Override
public String getEventHost(final Event event) {
if (event.getHost() == null) {
return null;
}
// If the event doesn't have a node ID, we can't lookup the IP address and be sure we have the right one since we don't know what node it is on
if (!event.hasNodeid()) {
return event.getHost();
}
try {
return getHostName(event.getNodeid().intValue(), event.getHost());
} catch (final Throwable t) {
LOG.warn("Error converting host IP \"{}\" to a hostname, storing the IP.", event.getHost(), t);
return event.getHost();
}
}
代码示例来源:origin: OpenNMS/opennms
/**
*
*/
protected Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) {
Map<String, String> paramMap = new HashMap<String, String>();
NotificationManager.addNotificationParams(paramMap, notification);
// expand the event parameters for the messages
// call the notif expansion method before the event expansion because
// event expansion will
// throw away any expansion strings it doesn't recognize!
paramMap.put("noticeid", Integer.toString(noticeId));
// Replace the %noticeid% param
String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap);
String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap);
String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap);
Map<String, Map<String, String>> decodeMap = getVarbindsDecodeMap(event.getUei());
nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap, decodeMap);
nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap, decodeMap);
nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap, decodeMap);
paramMap.put(NotificationManager.PARAM_NODE, event.hasNodeid() ? String.valueOf(event.getNodeid()) : "");
paramMap.put(NotificationManager.PARAM_INTERFACE, event.getInterface());
paramMap.put(NotificationManager.PARAM_SERVICE, event.getService());
paramMap.put("eventID", String.valueOf(event.getDbid()));
paramMap.put("eventUEI", event.getUei());
m_eventUtil.expandMapValues(paramMap, event);
return Collections.unmodifiableMap(paramMap);
}
代码示例来源:origin: OpenNMS/opennms
.filter(e -> !e.hasNodeid())
.forEach(e -> {
LOG.trace("Syslogd: Found a new suspect {}", e.getInterface());
内容来源于网络,如有侵权,请联系作者删除!