Search in sources :

Example 1 with NotificationCenter

use of com.creditease.agent.feature.NotificationCenter in project uavstack by uavorg.

the class NotificationTask method run.

@Override
public void run() {
    NotificationEvent event = (NotificationEvent) this.get(NCConstant.NCEventParam);
    int priorityLevel = (int) this.get(NCConstant.PRIORITYLEVEL);
    NotificationCenter nc = (NotificationCenter) this.getConfigManager().getComponent(this.feature, "NotificationCenter");
    if (log.isTraceEnable()) {
        log.info(this, "NotificationTask Actions START: event=" + event.toJSONString());
    }
    /**
     * Step 1: get all actions for this event
     */
    Map<String, String> args = event.getArgs(true);
    Map<String, String> actionMap = new LinkedHashMap<String, String>();
    for (String key : args.keySet()) {
        if (key.indexOf("action_") != 0) {
            continue;
        }
        String actionTag = key.substring("action_".length());
        String actionStr = args.get(key);
        /**
         * find matched priority action
         */
        String actionPrame = getActionParmeByPriorityLevel(actionStr, priorityLevel);
        if (!StringHelper.isEmpty(actionPrame)) {
            actionMap.put(actionTag, actionPrame);
        }
    }
    /**
     * Step 1.5: send notify to push notify event action
     */
    String action4pushntf = new String();
    actionMap.put("pushntf", action4pushntf);
    /**
     * Step 2: execute actions
     */
    nc.executeNotifyAction(actionMap, event);
    if (log.isTraceEnable()) {
        log.info(this, "NotificationTask Actions END.");
    }
}
Also used : NotificationCenter(com.creditease.agent.feature.NotificationCenter) NotificationEvent(com.creditease.agent.monitor.api.NotificationEvent) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

NotificationCenter (com.creditease.agent.feature.NotificationCenter)1 NotificationEvent (com.creditease.agent.monitor.api.NotificationEvent)1 LinkedHashMap (java.util.LinkedHashMap)1