Search in sources :

Example 1 with BusinessServiceGraphImpl

use of org.opennms.netmgt.bsm.service.model.graph.internal.BusinessServiceGraphImpl in project opennms by OpenNMS.

the class DefaultBusinessServiceStateMachine method setBusinessServices.

@Override
public void setBusinessServices(List<BusinessService> businessServices) {
    m_rwLock.writeLock().lock();
    try {
        // Create a new graph
        BusinessServiceGraph g = new BusinessServiceGraphImpl(businessServices);
        // Prime the graph with the state from the previous graph and
        // keep track of the new reductions keys
        Set<String> reductionsKeysToLookup = Sets.newHashSet();
        for (String reductionKey : g.getReductionKeys()) {
            GraphVertex reductionKeyVertex = m_g.getVertexByReductionKey(reductionKey);
            if (reductionKeyVertex != null) {
                updateAndPropagateVertex(g, g.getVertexByReductionKey(reductionKey), reductionKeyVertex.getStatus());
            } else {
                reductionsKeysToLookup.add(reductionKey);
            }
        }
        if (m_alarmProvider == null && reductionsKeysToLookup.size() > 0) {
            LOG.warn("There are one or more reduction keys to lookup, but no alarm provider is set.");
        } else {
            // graph without having to wait for calls to handleNewOrUpdatedAlarm()
            if (reductionsKeysToLookup.size() > 0) {
                final Map<String, AlarmWrapper> lookup = m_alarmProvider.lookup(reductionsKeysToLookup);
                for (Entry<String, AlarmWrapper> eachEntry : lookup.entrySet()) {
                    updateAndPropagateVertex(g, g.getVertexByReductionKey(eachEntry.getKey()), eachEntry.getValue().getStatus());
                }
            }
        }
        m_g = g;
    } finally {
        m_rwLock.writeLock().unlock();
    }
}
Also used : GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceGraphImpl(org.opennms.netmgt.bsm.service.model.graph.internal.BusinessServiceGraphImpl) AlarmWrapper(org.opennms.netmgt.bsm.service.model.AlarmWrapper) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)

Aggregations

AlarmWrapper (org.opennms.netmgt.bsm.service.model.AlarmWrapper)1 BusinessServiceGraph (org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)1 GraphVertex (org.opennms.netmgt.bsm.service.model.graph.GraphVertex)1 BusinessServiceGraphImpl (org.opennms.netmgt.bsm.service.model.graph.internal.BusinessServiceGraphImpl)1