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();
}
}
Aggregations