Search in sources :

Example 1 with RTCNodeKey

use of org.opennms.netmgt.rtc.datablock.RTCNodeKey in project opennms by OpenNMS.

the class DataManager method outageCreated.

/**
 * Handles a node outage created event. Add a lost service entry to the right
 * node
 *
 * @param nodeid
 *            the node id
 * @param ip
 *            the IP address
 * @param svcName
 *            the service name
 * @param t
 *            the time at which service was lost
 */
public synchronized void outageCreated(int nodeid, InetAddress ip, String svcName, long t) {
    RTCNodeKey key = new RTCNodeKey(nodeid, ip, svcName);
    RTCNode rtcN = m_map.getRTCNode(key);
    if (rtcN == null) {
        // oops! got a lost/regained service for a node that is not known?
        LOG.info("Received a outageCreated event for an unknown/irrelevant node: {}", key.toString());
        return;
    }
    // inform node
    rtcN.nodeLostService(t);
}
Also used : RTCNodeKey(org.opennms.netmgt.rtc.datablock.RTCNodeKey) RTCNode(org.opennms.netmgt.rtc.datablock.RTCNode)

Example 2 with RTCNodeKey

use of org.opennms.netmgt.rtc.datablock.RTCNodeKey in project opennms by OpenNMS.

the class DataManager method serviceDeleted.

/**
 * Remove node from the map and the categories on a 'serviceDeleted' event.
 *
 * @param nodeid
 *            the nodeid on which service was deleted
 * @param ip
 *            the ip on which service was deleted
 * @param svcName
 *            the service that was deleted
 */
public synchronized void serviceDeleted(int nodeid, InetAddress ip, String svcName) {
    // create lookup key
    RTCNodeKey key = new RTCNodeKey(nodeid, ip, svcName);
    // lookup the node
    RTCNode rtcN = m_map.getRTCNode(key);
    if (rtcN == null) {
        LOG.warn("Received a {} event for an unknown node: {}", EventConstants.SERVICE_DELETED_EVENT_UEI, key.toString());
        return;
    }
    // 
    // Go through from all the categories this node belongs to
    // and delete the service
    // 
    List<String> categories = rtcN.getCategories();
    ListIterator<String> catIter = categories.listIterator();
    while (catIter.hasNext()) {
        String catlabel = (String) catIter.next();
        RTCCategory cat = (RTCCategory) m_categories.get(catlabel);
        // get nodes in this category
        List<Integer> catNodes = cat.getNodes();
        // check if the category contains this node
        int nIndex = catNodes.indexOf(rtcN.getNodeID());
        if (nIndex != -1) {
            // remove from the category if it is the only service left.
            if (m_map.getServiceCount(nodeid, catlabel) == 1) {
                catNodes.remove(nIndex);
                LOG.info("Removing node from category: {}", catlabel);
            }
            // let the node know that this category is out
            catIter.remove();
        }
    }
    // finally remove from map
    m_map.delete(rtcN);
}
Also used : RTCNodeKey(org.opennms.netmgt.rtc.datablock.RTCNodeKey) RTCNode(org.opennms.netmgt.rtc.datablock.RTCNode) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory)

Example 3 with RTCNodeKey

use of org.opennms.netmgt.rtc.datablock.RTCNodeKey in project opennms by OpenNMS.

the class DataManager method outageResolved.

/**
 * Handles a node outage resolved event. Add a regained service entry to the right
 * node.
 *
 * @param nodeid
 *            the node id
 * @param ip
 *            the IP address
 * @param svcName
 *            the service name
 * @param t
 *            the time at which service was regained
 */
public synchronized void outageResolved(int nodeid, InetAddress ip, String svcName, long t) {
    RTCNodeKey key = new RTCNodeKey(nodeid, ip, svcName);
    RTCNode rtcN = m_map.getRTCNode(key);
    if (rtcN == null) {
        // oops! got a lost/regained service for a node that is not known?
        LOG.info("Received a outageResolved event for an unknown/irrelevant node: {}", key.toString());
        return;
    }
    // inform node
    rtcN.nodeRegainedService(t);
}
Also used : RTCNodeKey(org.opennms.netmgt.rtc.datablock.RTCNodeKey) RTCNode(org.opennms.netmgt.rtc.datablock.RTCNode)

Aggregations

RTCNode (org.opennms.netmgt.rtc.datablock.RTCNode)3 RTCNodeKey (org.opennms.netmgt.rtc.datablock.RTCNodeKey)3 RTCCategory (org.opennms.netmgt.rtc.datablock.RTCCategory)1