Search in sources :

Example 1 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class AbstractLinkdTopologyProvider method getVertex.

protected AbstractVertex getVertex(Integer nodeId, String ip, String sysobjectId, String nodeLabel, String tooltipText) {
    AbstractVertex vertex = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_LINKD, nodeId.toString(), 0, 0);
    vertex.setIconKey(getIconName(sysobjectId));
    vertex.setLabel(nodeLabel);
    vertex.setIpAddress(ip);
    vertex.setNodeID(nodeId);
    vertex.setTooltipText(tooltipText);
    return vertex;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) SimpleLeafVertex(org.opennms.features.topology.api.topo.SimpleLeafVertex)

Example 2 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class AlarmStatusProviderTest method createVertex.

private static Vertex createVertex(int nodeId) {
    AbstractVertex v = new AbstractVertex("nodes", Integer.toString(nodeId), Integer.toString(nodeId));
    v.setNodeID(nodeId);
    return v;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex)

Example 3 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex 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;
}
Also used : AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) Collection(java.util.Collection) Set(java.util.Set) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) ArrayList(java.util.ArrayList) Objects(java.util.Objects) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) List(java.util.List) StatusProvider(org.opennms.features.topology.api.topo.StatusProvider) VertexProvider(org.opennms.features.topology.api.topo.VertexProvider) AlarmSummaryWrapper(org.opennms.features.topology.plugins.topo.graphml.internal.AlarmSummaryWrapper) Map(java.util.Map) Criteria(org.opennms.features.topology.api.topo.Criteria) Status(org.opennms.features.topology.api.topo.Status) VertexRef(org.opennms.features.topology.api.topo.VertexRef) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) Status(org.opennms.features.topology.api.topo.Status) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 4 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class BusinessServiceSearchProviderIT method verifyQuery.

@Test
public void verifyQuery() {
    BusinessServiceEntity bs1 = new BusinessServiceEntityBuilder().name("Test Service").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs1.key1", new IdentityEntity(), 1).addReductionKey("bs1.key2", new IdentityEntity(), 1).toEntity();
    BusinessServiceEntity bs2 = new BusinessServiceEntityBuilder().name("Real Service 2").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs2.key1", new IdentityEntity(), 1).addReductionKey("bs2.key2", new IdentityEntity(), 1).toEntity();
    businessServiceDao.save(bs1);
    businessServiceDao.save(bs2);
    businessServiceDao.flush();
    // prepare mocks
    TopologyServiceClient topologyServiceClientMock = EasyMock.createNiceMock(TopologyServiceClient.class);
    EasyMock.expect(topologyServiceClientMock.getVertex(EasyMock.anyObject(BusinessServiceVertex.class))).andReturn(// always return a vertex, it just needs to be not null
    new AbstractVertex("bsm", "0", "Dummy Vertex"));
    GraphContainer graphContainerMock = EasyMock.createNiceMock(GraphContainer.class);
    EasyMock.expect(graphContainerMock.getTopologyServiceClient()).andReturn(topologyServiceClientMock).anyTimes();
    EasyMock.replay(graphContainerMock, topologyServiceClientMock);
    // try searching
    final BusinessServiceSearchProvider provider = new BusinessServiceSearchProvider();
    provider.setBusinessServiceManager(businessServiceManager);
    final SearchQuery query = new AbstractSearchQuery("Test") {

        @Override
        public boolean matches(String label) {
            // always match, it does not matter
            return true;
        }
    };
    final List<SearchResult> result = provider.query(query, graphContainerMock);
    Assert.assertEquals(1, result.size());
    EasyMock.verify(graphContainerMock, topologyServiceClientMock);
}
Also used : SearchQuery(org.opennms.features.topology.api.topo.SearchQuery) AbstractSearchQuery(org.opennms.features.topology.api.topo.AbstractSearchQuery) SearchResult(org.opennms.features.topology.api.topo.SearchResult) HighestSeverityEntity(org.opennms.netmgt.bsm.persistence.api.functions.reduce.HighestSeverityEntity) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) GraphContainer(org.opennms.features.topology.api.GraphContainer) TopologyServiceClient(org.opennms.features.topology.api.TopologyServiceClient) AbstractSearchQuery(org.opennms.features.topology.api.topo.AbstractSearchQuery) BusinessServiceEntity(org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity) BusinessServiceEntityBuilder(org.opennms.netmgt.bsm.test.BusinessServiceEntityBuilder) IdentityEntity(org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity) Test(org.junit.Test)

Example 5 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class GenericInfoPanelItemProvider method createVertexContext.

public Map<String, Object> createVertexContext(final VertexRef vertex) {
    final Map<String, Object> context = Maps.newHashMap();
    if (vertex instanceof AbstractVertex) {
        final AbstractVertex abstractVertex = (AbstractVertex) vertex;
        if (abstractVertex.getNodeID() != null) {
            final OnmsNode node = this.nodeDao.get(abstractVertex.getNodeID());
            if (node != null) {
                context.put("node", node);
            }
        }
    }
    context.put("vertex", vertex);
    return context;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) OnmsNode(org.opennms.netmgt.model.OnmsNode)

Aggregations

AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)20 VertexRef (org.opennms.features.topology.api.topo.VertexRef)9 List (java.util.List)7 Map (java.util.Map)6 Objects (java.util.Objects)6 Function (java.util.function.Function)6 Collectors (java.util.stream.Collectors)6 Collection (java.util.Collection)4 Criteria (org.opennms.features.topology.api.topo.Criteria)4 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 Lists (com.google.common.collect.Lists)3 Maps (com.google.common.collect.Maps)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Test (org.junit.Test)3 Status (org.opennms.features.topology.api.topo.Status)3 StatusProvider (org.opennms.features.topology.api.topo.StatusProvider)3 Vertex (org.opennms.features.topology.api.topo.Vertex)3 VertexProvider (org.opennms.features.topology.api.topo.VertexProvider)3 AlarmSummary (org.opennms.netmgt.model.alarm.AlarmSummary)3