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