org.opennms.netmgt.xml.event.Event.setDistPoller()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.opennms.netmgt.xml.event.Event.setDistPoller()方法的一些代码示例,展示了Event.setDistPoller()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.setDistPoller()方法的具体详情如下:
包路径:org.opennms.netmgt.xml.event.Event
类名称:Event
方法名:setDistPoller

Event.setDistPoller介绍

[英]Sets the value of field 'distPoller'.
[中]设置字段“distPoller”的值。

代码示例

代码示例来源:origin: OpenNMS/opennms

public EventBuilder setDistPoller(final String distPoller) {
  m_event.setDistPoller(distPoller);
  return this;
}

代码示例来源:origin: OpenNMS/opennms

@Override
public void process(final Exchange exchange) throws Exception {
  final String eventXml = exchange.getIn().getBody(String.class);
  final Event event = JaxbUtils.unmarshal(Event.class, eventXml);
  final String systemId = exchange.getIn().getHeader(EVENT_HEADER_SYSTEMID, String.class);
  if (event.getNodeid() > 0) {
    String foreignSource = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNSOURCE, String.class);
    String foreignId = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNID, String.class);
    OnmsNode node = nodeDao.findByForeignId(foreignSource, foreignId);
    if (node != null && node.getId() != null) {
      event.setNodeid(node.getId().longValue());
      event.setDistPoller(systemId);
      event.setSource("Endpoint="+systemId+":"+event.getSource());
    } else {
      LOG.warn("Could not find node {}/{} in the database, cannot update node ID to local value; discarding event", foreignSource, foreignId);
      // Halt the route if we cannot translate the node ID
      exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
    }
  }
  exchange.getIn().setBody(event, Event.class);
}

代码示例来源:origin: org.opennms.features.amqp/org.opennms.features.amqp.event-receiver

@Override
public void process(final Exchange exchange) throws Exception {
  final String eventXml = exchange.getIn().getBody(String.class);
  final Event event = JaxbUtils.unmarshal(Event.class, eventXml);
  final String systemId = exchange.getIn().getHeader(EVENT_HEADER_SYSTEMID, String.class);
  if (event.getNodeid() > 0) {
    String foreignSource = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNSOURCE, String.class);
    String foreignId = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNID, String.class);
    OnmsNode node = nodeDao.findByForeignId(foreignSource, foreignId);
    if (node != null && node.getId() != null) {
      event.setNodeid(node.getId().longValue());
      event.setDistPoller(systemId);
      event.setSource("Endpoint="+systemId+":"+event.getSource());
    } else {
      LOG.warn("Could not find node {}/{} in the database, cannot update node ID to local value; discarding event", foreignSource, foreignId);
      // Halt the route if we cannot translate the node ID
      exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
    }
  }
  exchange.getIn().setBody(event, Event.class);
}

代码示例来源:origin: org.opennms.features.activemq/org.opennms.features.activemq.event-receiver

@Override
  public void process(final Exchange exchange) throws Exception {
    final Event event = exchange.getIn().getBody(Event.class);
    
    String systemId = exchange.getIn().getHeader(EVENT_HEADER_SYSTEMID, String.class);

    if (event.getNodeid() > 0) {
      String foreignSource = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNSOURCE, String.class);
      String foreignId = exchange.getIn().getHeader(EVENT_HEADER_FOREIGNID, String.class);

      OnmsNode node = nodeDao.findByForeignId(foreignSource, foreignId);

      if (node != null && node.getId() != null) {
        event.setNodeid(node.getId().longValue());
        event.setDistPoller(systemId);
        event.setSource("Endpoint="+systemId+":"+event.getSource());
      } else {
        LOG.warn("Could not find node {}/{} in the database, cannot update node ID to local value; discarding event", foreignSource, foreignId);
        // Halt the route if we cannot translate the node ID
        exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
      }
    }
  }
}

相关文章