Search in sources :

Example 1 with RTCNode

use of org.opennms.netmgt.rtc.datablock.RTCNode 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 RTCNode

use of org.opennms.netmgt.rtc.datablock.RTCNode 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 RTCNode

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

the class DataManager method interfaceReparented.

/**
 * Reparent an interface. This effectively means updating the nodelist of
 * the categories and the map
 *
 * Use the ip/oldnodeid combination to get all nodes that will be affected -
 * for each of these nodes, remove the old entry and add a new one with new
 * keys to the map
 *
 * <em>Note:</em> Each of these nodes could belong to more than one
 * category. However, category rule evaluation is done based ONLY on the IP -
 * therefore changing the nodeID on the node should update the categories
 * appropriately
 *
 * @param ip
 *            the interface to reparent
 * @param oldNodeId
 *            the node that the IP belonged to earlier
 * @param newNodeId
 *            the node that the IP now belongs to
 */
public synchronized void interfaceReparented(InetAddress ip, int oldNodeId, int newNodeId) {
    // get all RTCNodes with the IP/old node ID
    for (RTCNode rtcN : m_map.getRTCNodes(oldNodeId, ip)) {
        // remove the node with the old node id from the map
        m_map.delete(rtcN);
        // change the node ID on the RTCNode
        rtcN.setNodeID(newNodeId);
        // now add the node with the new node ID
        m_map.add(rtcN);
        // and the new node ID
        for (String catlabel : rtcN.getCategories()) {
            RTCCategory rtcCat = m_categories.get(catlabel);
            rtcCat.deleteNode(oldNodeId);
            rtcCat.addNode(newNodeId);
        }
    }
}
Also used : RTCNode(org.opennms.netmgt.rtc.datablock.RTCNode) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory)

Example 4 with RTCNode

use of org.opennms.netmgt.rtc.datablock.RTCNode 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)4 RTCNodeKey (org.opennms.netmgt.rtc.datablock.RTCNodeKey)3 RTCCategory (org.opennms.netmgt.rtc.datablock.RTCCategory)2