@Test public void testExpandNotifParms() throws Exception { String expandResult = NotificationManager.expandNotifParms("%foo%", new TreeMap<String,String>()); assertEquals("%foo%", expandResult); expandResult = NotificationManager.expandNotifParms("%foo%", Collections.singletonMap("foo", "bar")); assertEquals("%foo%", expandResult); expandResult = NotificationManager.expandNotifParms("Notice #%noticeid% RESOLVED: ", Collections.singletonMap("noticeid", "999")); assertEquals("Notice #999 RESOLVED: ", expandResult); expandResult = NotificationManager.expandNotifParms("RESOLVED: ", Collections.singletonMap("noticeid", "999")); assertEquals("RESOLVED: ", expandResult); expandResult = NotificationManager.expandNotifParms("Notice %noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", new TreeMap<String,String>()); assertEquals("Notice %noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", expandResult); EventBuilder bldr = new EventBuilder(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "testExpandNotifParms"); bldr.setDescription("High threshold exceeded for %service% datasource %parm[ds]% on interface %interface%, parms: %parm[all]%"); bldr.setLogMessage("High threshold exceeded for %service% datasource %parm[ds]% on interface %interface%, parms: %parm[all]%"); bldr.setNodeid(0); bldr.setInterface(addr("0.0.0.0")); bldr.addParam("ds", "dsk-usr-pcent"); bldr.addParam("value", "Crap! There's only 15% free on the SAN and we need 20%! RUN AWAY!"); bldr.addParam("threshold", ""); bldr.addParam("trigger", ""); bldr.addParam("rearm", ""); bldr.addParam("label", ""); bldr.addParam("ifIndex", ""); Notification[] notifications = null; notifications = m_notificationManager.getNotifForEvent(null); assertNull(notifications); notifications = m_notificationManager.getNotifForEvent(bldr.getEvent()); assertNotNull(notifications); assertEquals(1, notifications.length); Map<String,String> paramMap = BroadcastEventProcessor.buildParameterMap(notifications[0], bldr.getEvent(), 9999); assertEquals("High disk Threshold exceeded on 0.0.0.0, dsk-usr-pcent with Crap! There's only 15% free on the SAN and we need 20%! RUN AWAY!", paramMap.get("-tm")); expandResult = NotificationManager.expandNotifParms("Notice #%noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", paramMap); assertEquals("Notice #9999: Disk threshold exceeded on %nodelabel%: %parm[all]%.", expandResult); }
static Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); paramMap.put("noticeid", Integer.toString(noticeId)); String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap); 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()); NotificationManager.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); }
BroadcastEventProcessor implements EventListener { static Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); paramMap.put("noticeid", Integer.toString(noticeId)); String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap); 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()); NotificationManager.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); } }
BroadcastEventProcessor implements EventListener { static Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); paramMap.put("noticeid", Integer.toString(noticeId)); String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap); 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()); NotificationManager.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); } BroadcastEventProcessor(); }
BroadcastEventProcessor implements EventListener { static Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); paramMap.put("noticeid", Integer.toString(noticeId)); String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap); 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()); NotificationManager.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); } BroadcastEventProcessor(); void close(); void onEvent(Event event); boolean computeNullSafeStatus(); String getName(); Map<String, String> rebuildParameterMap(final int notifId, final String resolutionPrefix, final boolean skipNumericPrefix); String scheduledOutage(long nodeId, String theInterface); DestinationPathManager getDestinationPathManager(); void setDestinationPathManager(
            DestinationPathManager destinationPathManager); EventIpcManager getEventManager(); void setEventManager(EventIpcManager eventManager); GroupManager getGroupManager(); void setGroupManager(GroupManager groupManager); NotifdConfigManager getNotifdConfigManager(); void setNotifdConfigManager(NotifdConfigManager notifdConfigManager); NotificationCommandManager getNotificationCommandManager(); void setNotificationCommandManager(
            NotificationCommandManager notificationCommandManager); NotificationManager getNotificationManager(); void setNotificationManager(NotificationManager notificationManager); PollOutagesConfigManager getPollOutagesConfigManager(); void setPollOutagesConfigManager(
            PollOutagesConfigManager pollOutagesConfigManager); UserManager getUserManager(); void setUserManager(UserManager userManager); synchronized Map<String, NoticeQueue> getNoticeQueues(); void setNoticeQueues(Map<String, NoticeQueue> noticeQueues); }
BroadcastEventProcessor implements EventListener { static Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); paramMap.put("noticeid", Integer.toString(noticeId)); String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap); 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()); NotificationManager.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); } BroadcastEventProcessor(); void close(); void onEvent(Event event); boolean computeNullSafeStatus(); String getName(); Map<String, String> rebuildParameterMap(final int notifId, final String resolutionPrefix, final boolean skipNumericPrefix); String scheduledOutage(long nodeId, String theInterface); DestinationPathManager getDestinationPathManager(); void setDestinationPathManager(
            DestinationPathManager destinationPathManager); EventIpcManager getEventManager(); void setEventManager(EventIpcManager eventManager); GroupManager getGroupManager(); void setGroupManager(GroupManager groupManager); NotifdConfigManager getNotifdConfigManager(); void setNotifdConfigManager(NotifdConfigManager notifdConfigManager); NotificationCommandManager getNotificationCommandManager(); void setNotificationCommandManager(
            NotificationCommandManager notificationCommandManager); NotificationManager getNotificationManager(); void setNotificationManager(NotificationManager notificationManager); PollOutagesConfigManager getPollOutagesConfigManager(); void setPollOutagesConfigManager(
            PollOutagesConfigManager pollOutagesConfigManager); UserManager getUserManager(); void setUserManager(UserManager userManager); synchronized Map<String, NoticeQueue> getNoticeQueues(); void setNoticeQueues(Map<String, NoticeQueue> noticeQueues);  }