use of org.opennms.features.topology.api.topo.VertexProvider in project opennms by OpenNMS.
the class VmwareStatusProvider method getStatusForVertices.
@Override
public Map<VertexRef, Status> getStatusForVertices(VertexProvider vertexProvider, Collection<VertexRef> vertices, Criteria[] criteria) {
final List<AbstractVertex> vmwareVertices = vertices.stream().filter(v -> v.getNamespace().equals(getNamespace())).map(v -> (AbstractVertex) v).collect(Collectors.toList());
// All vertices associated with a node id
final Map<Integer, VertexRef> nodeIdMap = vmwareVertices.stream().filter(v -> v.getNodeID() != null).collect(Collectors.toMap(AbstractVertex::getNodeID, Function.identity()));
// Alarm summary for each node id
final Map<Integer, AlarmSummary> nodeIdToAlarmSummaryMap = getAlarmSummaries(nodeIdMap.keySet());
// Set the result
Map<VertexRef, Status> resultMap = Maps.newHashMap();
for (AbstractVertex eachVertex : vmwareVertices) {
AlarmSummary alarmSummary = nodeIdToAlarmSummaryMap.get(eachVertex.getNodeID());
if (alarmSummary != null) {
resultMap.put(eachVertex, new DefaultStatus(alarmSummary.getMaxSeverity().getLabel(), 0));
}
}
return resultMap;
}
use of org.opennms.features.topology.api.topo.VertexProvider in project opennms by OpenNMS.
the class GraphMLVertexStatusProvider method getStatusForVertices.
@Override
public Map<VertexRef, Status> getStatusForVertices(VertexProvider vertexProvider, Collection<VertexRef> vertices, Criteria[] criteria) {
// All vertices for the current vertexProvider
final List<GraphMLVertex> graphMLVertices = vertices.stream().filter(eachVertex -> contributesTo(eachVertex.getNamespace()) && eachVertex instanceof GraphMLVertex).map(eachVertex -> (GraphMLVertex) eachVertex).collect(Collectors.toList());
// All vertices associated with a node id
final Map<Integer, VertexRef> nodeIdMap = graphMLVertices.stream().filter(eachVertex -> eachVertex.getNodeID() != null).collect(Collectors.toMap(AbstractVertex::getNodeID, Function.identity()));
// Alarm summary for each node id
final Map<Integer, AlarmSummary> nodeIdToAlarmSummaryMap = getAlarmSummaries(nodeIdMap.keySet());
// Set the result
Map<VertexRef, Status> resultMap = Maps.newHashMap();
for (GraphMLVertex eachVertex : graphMLVertices) {
AlarmSummary alarmSummary = nodeIdToAlarmSummaryMap.get(eachVertex.getNodeID());
DefaultStatus status = alarmSummary == null ? new VertexStatus(OnmsSeverity.NORMAL) : new VertexStatus(alarmSummary.getMaxSeverity(), alarmSummary.getAlarmCount());
resultMap.put(eachVertex, status);
}
return resultMap;
}
use of org.opennms.features.topology.api.topo.VertexProvider in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProviderTest method testTopoProviderSetParent.
@Test
public void testTopoProviderSetParent() {
VertexRef vertexId1 = addVertexToTopr();
VertexRef vertexId2 = addVertexToTopr();
final AtomicInteger eventsReceived = new AtomicInteger(0);
m_topologyProvider.addVertexListener(new VertexListener() {
@Override
public void vertexSetChanged(VertexProvider provider, Collection<? extends Vertex> added, Collection<? extends Vertex> update, Collection<String> removedVertexIds) {
eventsReceived.incrementAndGet();
}
@Override
public void vertexSetChanged(VertexProvider provider) {
eventsReceived.incrementAndGet();
}
});
Vertex groupId = m_topologyProvider.addGroup("Test Group", "groupIcon.jpg");
assertEquals(1, eventsReceived.get());
eventsReceived.set(0);
m_topologyProvider.setParent(vertexId1, groupId);
m_topologyProvider.setParent(vertexId2, groupId);
assertEquals(2, eventsReceived.get());
}
Aggregations