本文整理汇总了Java中org.opennms.netmgt.model.OnmsEvent.setAlarm方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsEvent.setAlarm方法的具体用法?Java OnmsEvent.setAlarm怎么用?Java OnmsEvent.setAlarm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.model.OnmsEvent
的用法示例。
在下文中一共展示了OnmsEvent.setAlarm方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@Before
public void setUp(){
m_dbPopulator.populateDatabase();
OnmsEvent event = new OnmsEvent();
event.setDistPoller(getDistPoller("localhost", "127.0.0.1"));
event.setAlarm(m_dbPopulator.getAlarmDao().get(1));
event.setNode(m_dbPopulator.getNode1());
event.setEventUei("uei.opennms.org/test2");
event.setEventTime(new Date());
event.setEventSource("test");
event.setEventCreateTime(new Date());
event.setEventSeverity(OnmsSeverity.CLEARED.getId());
event.setEventLog("Y");
event.setEventDisplay("Y");
event.setIfIndex(11);
event.setIpAddr(InetAddressUtils.getInetAddress("192.168.1.1"));
event.setEventLogMsg("This is a test log message");
event.setEventDescr("This is a test event");
event.setServiceType(m_dbPopulator.getServiceTypeDao().get(1));
m_dbPopulator.getEventDao().save(event);
m_dbPopulator.getEventDao().flush();
}
示例2: testSave
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@Test
@Transactional
public void testSave() {
OnmsEvent event = new OnmsEvent();
event.setDistPoller(m_distPollerDao.load("localhost"));
event.setEventCreateTime(new Date());
event.setEventDescr("event dao test");
event.setEventHost("localhost");
event.setEventLog("Y");
event.setEventDisplay("Y");
event.setEventLogGroup("event dao test log group");
event.setEventLogMsg("event dao test log msg");
event.setEventSeverity(7);
event.setEventSource("EventDaoTest");
event.setEventTime(new Date());
event.setEventUei("uei://org/opennms/test/EventDaoTest");
OnmsNode node = (OnmsNode) m_nodeDao.findAll().iterator().next();
OnmsIpInterface iface = (OnmsIpInterface)node.getIpInterfaces().iterator().next();
OnmsMonitoredService service = (OnmsMonitoredService)iface.getMonitoredServices().iterator().next();
event.setNode(node);
event.setServiceType(service.getServiceType());
OnmsAlarm alarm = new OnmsAlarm();
event.setAlarm(alarm);
event.setIpAddr(iface.getIpAddress());
m_eventDao.save(event);
OnmsEvent newEvent = m_eventDao.load(event.getId());
assertEquals("uei://org/opennms/test/EventDaoTest", newEvent.getEventUei());
assertNotNull(newEvent.getServiceType());
assertEquals(service.getNodeId(), newEvent.getNode().getId());
assertEquals(event.getIpAddr(), newEvent.getIpAddr());
}
示例3: createNewAlarm
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
private static OnmsAlarm createNewAlarm(OnmsEvent e, Event event) {
OnmsAlarm alarm;
alarm = new OnmsAlarm();
alarm.setAlarmType(event.getAlarmData().getAlarmType());
alarm.setClearKey(event.getAlarmData().getClearKey());
alarm.setCounter(1);
alarm.setDescription(e.getEventDescr());
alarm.setDistPoller(e.getDistPoller());
alarm.setEventParms(e.getEventParms());
alarm.setFirstEventTime(e.getEventTime());
alarm.setIfIndex(e.getIfIndex());
alarm.setIpAddr(e.getIpAddr());
alarm.setLastEventTime(e.getEventTime());
alarm.setLastEvent(e);
alarm.setLogMsg(e.getEventLogMsg());
alarm.setMouseOverText(e.getEventMouseOverText());
alarm.setNode(e.getNode());
alarm.setOperInstruct(e.getEventOperInstruct());
alarm.setReductionKey(event.getAlarmData().getReductionKey());
alarm.setServiceType(e.getServiceType());
alarm.setSeverity(OnmsSeverity.get(e.getEventSeverity())); //TODO: what to do?
alarm.setSuppressedUntil(e.getEventTime()); //TODO: fix UI to not require this be set
alarm.setSuppressedTime(e.getEventTime()); //TODO: Fix UI to not require this be set
//alarm.setTTicketId(e.getEventTTicket());
//alarm.setTTicketState(TroubleTicketState.CANCEL_FAILED); //FIXME
alarm.setUei(e.getEventUei());
e.setAlarm(alarm);
return alarm;
}
示例4: reduceEvent
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
private static void reduceEvent(OnmsEvent e, OnmsAlarm alarm) {
alarm.setLastEvent(e);
alarm.setLastEventTime(e.getEventTime());
// Update any dynamic fields that the user will want to see the latest
// values for to values from the latest event
alarm.setLogMsg(e.getEventLogMsg());
alarm.setEventParms(e.getEventParms());
alarm.setCounter(alarm.getCounter() + 1);
e.setAlarm(alarm);
}
示例5: testSaveUserNotification
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@Test
@Transactional
public void testSaveUserNotification() {
OnmsEvent event = new OnmsEvent();
event.setDistPoller(m_distPollerDao.load("localhost"));
event.setEventCreateTime(new Date());
event.setEventDescr("event dao test");
event.setEventHost("localhost");
event.setEventLog("Y");
event.setEventDisplay("Y");
event.setEventLogGroup("event dao test log group");
event.setEventLogMsg("event dao test log msg");
event.setEventSeverity(7);
event.setEventSource("EventDaoTest");
event.setEventTime(new Date());
event.setEventUei("uei://org/opennms/test/UserNotificationDaoTest");
OnmsAlarm alarm = new OnmsAlarm();
event.setAlarm(alarm);
OnmsNode node = (OnmsNode) m_nodeDao.findAll().iterator().next();
OnmsIpInterface iface = (OnmsIpInterface)node.getIpInterfaces().iterator().next();
OnmsMonitoredService service = (OnmsMonitoredService)iface.getMonitoredServices().iterator().next();
event.setNode(node);
event.setServiceType(service.getServiceType());
event.setIpAddr(iface.getIpAddress());
m_eventDao.save(event);
OnmsEvent newEvent = m_eventDao.load(event.getId());
assertEquals("uei://org/opennms/test/UserNotificationDaoTest", newEvent.getEventUei());
OnmsNotification notification = new OnmsNotification();
notification.setEvent(newEvent);
notification.setTextMsg("Tests are fun!");
m_notificationDao.save(notification);
OnmsNotification newNotification = m_notificationDao.load(notification.getNotifyId());
assertEquals("uei://org/opennms/test/UserNotificationDaoTest", newNotification.getEvent().getEventUei());
OnmsUserNotification userNotif = new OnmsUserNotification();
userNotif.setNotification(notification);
userNotif.setNotifyTime(new Date());
userNotif.setUserId("OpenNMS User");
userNotif.setMedia("E-mail");
userNotif.setContactInfo("[email protected]");
m_userNotificationDao.save(userNotif);
assertNotNull(userNotif.getNotification());
assertEquals(userNotif.getUserId(), "OpenNMS User");
}
示例6: reduceEvent
import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
private static void reduceEvent(OnmsEvent e, OnmsAlarm alarm, Event event) {
//Always set these
alarm.setLastEvent(e);
alarm.setLastEventTime(e.getEventTime());
alarm.setCounter(alarm.getCounter() + 1);
if (!event.getAlarmData().hasUpdateFields()) {
//We always set these even if there are not update fields specified
alarm.setLogMsg(e.getEventLogMsg());
alarm.setEventParms(e.getEventParms());
} else {
for (UpdateField field : event.getAlarmData().getUpdateFieldList()) {
//Always set these, unless specified not to, in order to maintain current behavior
if (field.getFieldName().equalsIgnoreCase("LogMsg") && field.isUpdateOnReduction() == false) {
continue;
} else {
alarm.setLogMsg(e.getEventLogMsg());
}
if (field.getFieldName().equalsIgnoreCase("Parms") && field.isUpdateOnReduction() == false) {
continue;
} else {
alarm.setEventParms(e.getEventParms());
}
//Set these others
if (field.isUpdateOnReduction()) {
if (field.getFieldName().toLowerCase().startsWith("distpoller")) {
alarm.setDistPoller(e.getDistPoller());
} else if (field.getFieldName().toLowerCase().startsWith("ipaddr")) {
alarm.setIpAddr(e.getIpAddr());
} else if (field.getFieldName().toLowerCase().startsWith("mouseover")) {
alarm.setMouseOverText(e.getEventMouseOverText());
} else if (field.getFieldName().toLowerCase().startsWith("operinstruct")) {
alarm.setOperInstruct(e.getEventOperInstruct());
} else if (field.getFieldName().equalsIgnoreCase("severity")) {
alarm.setSeverity(OnmsSeverity.valueOf(e.getSeverityLabel()));
} else if (field.getFieldName().toLowerCase().contains("descr")) {
alarm.setDescription(e.getEventDescr());
alarm.setSeverity(OnmsSeverity.valueOf(e.getSeverityLabel()));
} else {
log().warn("reduceEvent: The specified field: "+field.getFieldName()+", is not supported.");
}
/* This doesn't work because the properties are not consistent from OnmsEvent to OnmsAlarm
try {
final BeanWrapper ew = PropertyAccessorFactory.forBeanPropertyAccess(e);
final BeanWrapper aw = PropertyAccessorFactory.forBeanPropertyAccess(alarm);
aw.setPropertyValue(field.getFieldName(), ew.getPropertyValue(field.getFieldName()));
} catch (BeansException be) {
System.out.println(be);
log().error("reduceEvent:", be);
continue;
}
*/
}
}
}
e.setAlarm(alarm);
}