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

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

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

Event.getParm介绍

[英]Returns the Collection of parms for this event
[中]返回此事件的PARM集合

代码示例

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

public String get(Event event) {
    if (event != null && event.getParm(parmName) != null && event.getParm(parmName).getValue() != null) {
      return event.getParm(parmName).getValue().getContent();
    }
    return null;
  }
};

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

final Parm parm = event.getParm(OnmsRestEventsClient.NODE_LABEL);
if (parm != null) {
  event.getParmCollection().remove(parm);

代码示例来源:origin: org.opennms.features/org.opennms.features.opennms-es-rest

final Parm parm = event.getParm(OnmsRestEventsClient.NODE_LABEL);
if (parm != null) {
  event.getParmCollection().remove(parm);

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

private void checkParam(Event event, String name){
  Parm param = event.getParm(name);
  if(param == null || param.getValue() == null || Strings.isNullOrEmpty(Strings.nullToEmpty(param.getValue().toString()).trim())){
    throw new IllegalStateException("NodeLabelChangedEvent is not ready to be build, parameter "+name+" is missing.");
  }
}

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

final Parm foreignSource = event.getParm("_foreignSource");
if (foreignSource != null && foreignSource.getValue() != null) {
  final Parm foreignId = event.getParm("_foreignId");
  if (foreignId != null && foreignId.getValue() != null) {
    final OnmsNode node = getNodeDao().findByForeignId(foreignSource.getValue().getContent(), foreignId.getValue().getContent());

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

@EventHandler(uei=EventConstants.MONITORING_SYSTEM_ADDED_UEI)
public void onMonitoringSystemAdded(final Event e) {
  runInLoggingTransaction(() -> {
    final String id = e.getParm(EventConstants.PARAM_MONITORING_SYSTEM_ID).toString();
    LOG.debug("Monitoring system added: {}", id);
    if (id != null) {
      m_state.put(id, AggregateMinionStatus.up());
    }
  });
}

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

final Parm foreignSource = event.getParm("_foreignSource");
if (foreignSource != null && foreignSource.getValue() != null) {
  final Parm foreignId = event.getParm("_foreignId");
  if (foreignId != null && foreignId.getValue() != null) {
    final OnmsNode node = getNodeDao().findByForeignId(foreignSource.getValue().getContent(), foreignId.getValue().getContent());

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

private boolean isReloadConfigEvent(Event event) {
    boolean isTarget = false;
    
    if (EventConstants.RELOAD_DAEMON_CONFIG_UEI.equals(event.getUei())) {
      final Parm target = event.getParm(EventConstants.PARM_DAEMON_NAME);
      if (target != null && "Eventd".equalsIgnoreCase(target.getValue().getContent())) {
        isTarget = true;
      }
    // Deprecating this one...
    } else if (EventConstants.EVENTSCONFIG_CHANGED_EVENT_UEI.equals(event.getUei())) {
      isTarget = true;
    }
    
    return isTarget;
  }
}

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

@EventHandler(uei=EventConstants.MONITORING_SYSTEM_DELETED_UEI)
public void onMonitoringSystemDeleted(final Event e) {
  runInLoggingTransaction(() -> {
    final String id = e.getParm(EventConstants.PARAM_MONITORING_SYSTEM_ID).toString();
    if (id != null) {
      LOG.debug("Monitoring system removed: {}", id);
      final OnmsMinion minion = m_minions.get(id);
      m_minions.remove(id);
      m_state.remove(id);
      if (minion != null) {
        final Iterator<Entry<Integer,OnmsMinion>> it = m_minionNodes.entrySet().iterator();
        while (it.hasNext()) {
          final Entry<Integer,OnmsMinion> entry = it.next();
          if (entry.getValue().getId().equals(minion.getId())) {
            it.remove();
            break;
          };
        }
      }
    } else {
      LOG.warn("Monitoring system removed event received, but unable to determine ID: {}", e);
    }
  });
}

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

private boolean isReloadConfigEvent(Event event) {
    boolean isTarget = false;
    
    if (EventConstants.RELOAD_DAEMON_CONFIG_UEI.equals(event.getUei())) {
      final Parm target = event.getParm(EventConstants.PARM_DAEMON_NAME);
      if (target != null && "Eventd".equalsIgnoreCase(target.getValue().getContent())) {
        isTarget = true;
      }
    // Deprecating this one...
    } else if (EventConstants.EVENTSCONFIG_CHANGED_EVENT_UEI.equals(event.getUei())) {
      isTarget = true;
    }
    
    return isTarget;
  }
}

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

public static void handleReloadEvent(Event e, String daemonName, Consumer<Event> handleConfigurationChanged) {
  final Parm daemonNameParm = e.getParm(EventConstants.PARM_DAEMON_NAME);
  if (daemonNameParm == null || daemonNameParm.getValue() == null) {
    LOG.warn("The {} parameter has no value. Ignoring.", EventConstants.PARM_DAEMON_NAME);
    return;
  }
  if (daemonName.equalsIgnoreCase(daemonNameParm.getValue().getContent())) {
    LOG.info("Reloading {}.", daemonName);
    EventBuilder ebldr = null;
    try {
      handleConfigurationChanged.accept(e);
      LOG.info("Reload successful.");
      ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, daemonName);
      ebldr.addParam(EventConstants.PARM_DAEMON_NAME, daemonName);
    } catch (Exception t) {
      LOG.error("Reload failed.", t);
      ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, daemonName);
      ebldr.addParam(EventConstants.PARM_REASON, StringUtils.abbreviate(t.getLocalizedMessage(), 128));
    }
    ebldr.addParam(EventConstants.PARM_DAEMON_NAME, daemonName);
    EventIpcManagerFactory.getIpcManager().sendNow(ebldr.getEvent());
  }
}

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

LOG.debug("Received event: {}", event.getUei());
final String oldNodeId = event.getParm(EventConstants.PARM_OLD_NODEID).getValue().getContent();
final String newNodeId = event.getParm(EventConstants.PARM_NEW_NODEID).getValue().getContent();

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

@Test
  public void testPathOutages() throws Exception {
    Assert.assertNotNull(m_nodeDao);
    Assert.assertNotNull(m_pathOutageDao);
    Assert.assertNotNull(m_pathOutageManager);
    OnmsNode node = m_nodeDao.get(1);
    Assert.assertNotNull(node);
    OnmsPathOutage pathOutage = new OnmsPathOutage(node, InetAddressUtils.addr("169.254.0.1"), "ICMP");
    m_pathOutageDao.save(pathOutage);
    m_pathOutageDao.flush();
    m_pollerConfig.setPathOutageEnabled(true);
    CriticalPath path = m_pathOutageManager.getCriticalPath(1);
    Assert.assertEquals(InetAddrUtils.addr("169.254.0.1"), path.getIpAddress());

    Event nodeEvent = m_pollContext.createEvent(EventConstants.NODE_DOWN_EVENT_UEI, 1, null, null, new Date(), String.valueOf(PollStatus.SERVICE_UNAVAILABLE));
    Assert.assertNotNull(nodeEvent);
    Assert.assertEquals("169.254.0.1", nodeEvent.getParm(EventConstants.PARM_CRITICAL_PATH_IP).getValue().getContent());
    Assert.assertEquals(EventConstants.PARM_VALUE_PATHOUTAGE, nodeEvent.getParm(EventConstants.PARM_LOSTSERVICE_REASON).getValue().getContent());
  }
}

相关文章