当前位置: 首页>>代码示例>>Java>>正文


Java OnmsEvent.setAlarm方法代码示例

本文整理汇总了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();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:WebEventRepositoryFilterTest.java

示例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());
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:33,代码来源:EventDaoTest.java

示例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;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:30,代码来源:AlarmPersisterImpl.java

示例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);
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:11,代码来源:AlarmPersisterImpl.java

示例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");
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:50,代码来源:UserNotificationDaoTest.java

示例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);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:70,代码来源:AlarmPersisterImpl.java


注:本文中的org.opennms.netmgt.model.OnmsEvent.setAlarm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。