Search in sources :

Example 1 with GetStatsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput in project lispflowmapping by opendaylight.

the class LispSouthboundRPC method createGetStatsOutput.

private static GetStatsOutput createGetStatsOutput(ConcurrentLispSouthboundStats stats) {
    long[] rxStats = stats.getRx();
    long[] txStats = stats.getTx();
    ControlMessageStatsBuilder cmsb = new ControlMessageStatsBuilder();
    cmsb.setRxUnknown(stats.getRxUnknown());
    cmsb.setTxErrors(stats.getTxErrors());
    List<ControlMessage> messages = new ArrayList<ControlMessage>();
    for (int i = 0; i <= ConcurrentLispSouthboundStats.MAX_LISP_TYPES; i++) {
        if (MessageType.forValue(i) == null) {
            continue;
        }
        ControlMessageBuilder cmb = new ControlMessageBuilder();
        cmb.setMsgType(MessageType.forValue(i));
        cmb.setRxCount(rxStats[i]);
        cmb.setTxCount(txStats[i]);
        messages.add(cmb.build());
    }
    cmsb.setControlMessage(messages);
    MapRegisterCacheStatsBuilder mrcsb = new MapRegisterCacheStatsBuilder();
    mrcsb.setHits(stats.getCacheHits());
    mrcsb.setMisses(stats.getCacheMisses());
    return new GetStatsOutputBuilder().setControlMessageStats(cmsb.build()).setMapRegisterCacheStats(mrcsb.build()).build();
}
Also used : ControlMessageStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStatsBuilder) MapRegisterCacheStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.MapRegisterCacheStatsBuilder) ArrayList(java.util.ArrayList) ControlMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessageBuilder) ControlMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessage) GetStatsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutputBuilder)

Example 2 with GetStatsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput in project bgpcep by opendaylight.

the class TopologyStatsRpcServiceImplTest method testGetStatsNoMatch.

@Test
public void testGetStatsNoMatch() throws Exception {
    GetStatsInput in;
    GetStatsOutput out;
    // Non-existing topology
    in = createGetStatsInput(NONEXISTENT_TOPOLOGY, null);
    out = createGetStatsOutput(NONEXISTENT_TOPOLOGY, Collections.emptyList(), null);
    performTest(in, out);
    // Non-existent node
    in = createGetStatsInput(TOPOLOGY_ID1, Collections.singletonList(NONEXISTENT_NODE));
    out = createGetStatsOutput(TOPOLOGY_ID1, Collections.singletonList(NONEXISTENT_NODE), null);
    performTest(in, out);
    // Non-PCEP topology
    in = createGetStatsInput(NONPCEP_TOPOLOGY, Collections.singletonList(NONPCEP_NODE));
    out = createGetStatsOutput(NONPCEP_TOPOLOGY, Collections.singletonList(NONPCEP_NODE), null);
    performTest(in, out);
}
Also used : GetStatsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput) GetStatsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInput) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 3 with GetStatsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput in project bgpcep by opendaylight.

the class TopologyStatsRpcServiceImpl method getStats.

@Override
public ListenableFuture<RpcResult<GetStatsOutput>> getStats(final GetStatsInput input) {
    final var iTopologies = input.getTopology();
    final List<TopologyId> iTopologyIds;
    if (iTopologies != null) {
        iTopologyIds = iTopologies.values().stream().map(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.get.stats.input.Topology::getTopologyId).collect(Collectors.toList());
    } else {
        iTopologyIds = getAvailableTopologyIds();
    }
    return Futures.immediateFuture(SuccessfulRpcResult.create(new GetStatsOutputBuilder().setTopology(iTopologyIds.stream().map(iTopologyId -> {
        final Collection<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.get.stats.input.topology.Node> iNodes;
        if (iTopologies != null) {
            final var nodes = iTopologies.values().stream().filter(t -> iTopologyId.equals(t.getTopologyId())).findFirst().get().getNode();
            iNodes = nodes != null ? nodes.values() : null;
        } else {
            iNodes = null;
        }
        final List<NodeId> iNodeIds;
        if (iNodes != null) {
            iNodeIds = iNodes.stream().map(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.get.stats.input.topology.Node::getNodeId).collect(Collectors.toList());
        } else {
            iNodeIds = getAvailableNodeIds(iTopologyId);
        }
        return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.get.stats.output.TopologyBuilder().setTopologyId(iTopologyId).setNode(iNodeIds.stream().map(iNodeId -> {
            final PcepSessionState state = sessionStateMap.get(InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(iTopologyId)).child(Node.class, new NodeKey(iNodeId)).augmentation(PcepTopologyNodeStatsAug.class).child(PcepSessionState.class).build());
            if (state == null) {
                LOG.debug("Pcep session stats not available for node {} in topology {}", iNodeId.getValue(), iTopologyId.getValue());
            }
            return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.get.stats.output.topology.NodeBuilder().setNodeId(iNodeId).setPcepSessionState(transformStatefulAugmentation(state)).build();
        }).collect(BindingMap.toOrderedMap())).build();
    }).collect(BindingMap.toOrderedMap())).build()));
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetStatsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutputBuilder) StatefulCapabilitiesRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulCapabilitiesRpcAugBuilder) LoggerFactory(org.slf4j.LoggerFactory) DataTreeIdentifier(org.opendaylight.mdsal.binding.api.DataTreeIdentifier) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) GetStatsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInput) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) ConcurrentMap(java.util.concurrent.ConcurrentMap) PeerCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilitiesBuilder) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder) PeerCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilities) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) PcepEntityIdRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdRpcAugBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) StatefulCapabilitiesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulCapabilitiesStatsAug) DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) ClusteredDataTreeChangeListener(org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAug) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) Logger(org.slf4j.Logger) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) BindingMap(org.opendaylight.yangtools.yang.binding.util.BindingMap) Collection(java.util.Collection) SuccessfulRpcResult(org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) Collectors(java.util.stream.Collectors) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) StatefulMessagesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulMessagesStatsAug) PcepTopologyStatsRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.PcepTopologyStatsRpcService) GetStatsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput) PcepEntityIdStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdStatsAug) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) StatefulMessagesRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulMessagesRpcAugBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionState) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionState) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) GetStatsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutputBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAug) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Collection(java.util.Collection) List(java.util.List) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 4 with GetStatsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput in project bgpcep by opendaylight.

the class TopologyStatsRpcServiceImplTest method testGetStatsAllMatch.

@Test
public void testGetStatsAllMatch() throws Exception {
    GetStatsInput in;
    final var ot1 = createGetStatsOutput(TOPOLOGY_ID1, Collections.singletonList(NODE_ID1), createRpcSessionState()).getTopology().values().iterator().next();
    final var ot2 = createGetStatsOutput(TOPOLOGY_ID2, Arrays.asList(NODE_ID2, NODE_ID3), createRpcSessionState()).getTopology().values().iterator().next();
    final GetStatsOutput out = new GetStatsOutputBuilder().setTopology(BindingMap.of(ot1, ot2)).build();
    // Implicitly match all PCEP topologies and nodes
    in = createGetStatsInput(null, null);
    performCountTest(in, out);
    // Explicitly match all PCEP topologies and nodes
    final var it1 = createGetStatsInput(TOPOLOGY_ID1, Collections.singletonList(NODE_ID1)).getTopology().values().iterator().next();
    final var it2 = createGetStatsInput(TOPOLOGY_ID2, Arrays.asList(NODE_ID2, NODE_ID3)).getTopology().values().iterator().next();
    in = new GetStatsInputBuilder().setTopology(BindingMap.of(it1, it2)).build();
    performCountTest(in, out);
}
Also used : GetStatsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput) GetStatsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInputBuilder) GetStatsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInput) GetStatsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutputBuilder) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 5 with GetStatsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput in project bgpcep by opendaylight.

the class TopologyStatsRpcServiceImplTest method testGetStatsPartialMatch.

@Test
public void testGetStatsPartialMatch() throws Exception {
    GetStatsInput in;
    GetStatsOutput out;
    // Match one PCEP topology
    in = createGetStatsInput(TOPOLOGY_ID1, null);
    out = createGetStatsOutput(TOPOLOGY_ID1, Collections.singletonList(NODE_ID1), createRpcSessionState());
    performTest(in, out);
    // Match one PCEP node in one topology
    in = createGetStatsInput(TOPOLOGY_ID2, Collections.singletonList(NODE_ID3));
    out = createGetStatsOutput(TOPOLOGY_ID2, Collections.singletonList(NODE_ID3), createRpcSessionState());
    performTest(in, out);
    // Match two PCEP nodes in one topology
    in = createGetStatsInput(TOPOLOGY_ID2, Arrays.asList(NODE_ID2, NODE_ID3));
    out = createGetStatsOutput(TOPOLOGY_ID2, Arrays.asList(NODE_ID2, NODE_ID3), createRpcSessionState());
    performCountTest(in, out);
}
Also used : GetStatsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput) GetStatsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInput) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Aggregations

GetStatsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsInput)4 GetStatsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutput)4 Test (org.junit.Test)3 AbstractConcurrentDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)3 GetStatsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.GetStatsOutputBuilder)2 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Collectors (java.util.stream.Collectors)1 SuccessfulRpcResult (org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult)1 ClusteredDataTreeChangeListener (org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 DataObjectModification (org.opendaylight.mdsal.binding.api.DataObjectModification)1 DataTreeIdentifier (org.opendaylight.mdsal.binding.api.DataTreeIdentifier)1 DataTreeModification (org.opendaylight.mdsal.binding.api.DataTreeModification)1