use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsHelper method addError.
/**
* Adds the error.
*
* @param lstAclPortStats the lst acl port stats
* @param aclStatsBuilder the acl stats builder
* @param errMsg the error message
*/
private static void addError(List<AclPortStats> lstAclPortStats, AclPortStatsBuilder aclStatsBuilder, String errMsg) {
aclStatsBuilder.setError(new ErrorBuilder().setErrorMessage(errMsg).build());
lstAclPortStats.add(aclStatsBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortEgressOnly.
/**
* Test stats for two ports and egress direction only. <br>
* port1 is valid <br>
* port2 is invalid <br>
* Expectation: Error expected for port2. Drop stats should be available for
* egress direction only.
*
* @throws Exception the exception
*/
@Test
public void getStatsTwoPortEgressOnly() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
Direction direction = Direction.Egress;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsTwoPortEgressOnly output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsOnePortBothDirection.
/**
* Test stats for one port and both direction. <br>
* port1 is valid <br>
* Expectation: This is a success case.
*
* @throws Exception the exception
*/
@Test
public void getStatsOnePortBothDirection() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1);
Direction direction = Direction.Both;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsOnePortBothDirection output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method assertStatsOutput.
private void assertStatsOutput(RpcResult<GetAclPortStatisticsOutput> output, Direction inputDirection) {
assertNotNull(output);
GetAclPortStatisticsOutput aclPortStats = output.getResult();
assertNotNull(aclPortStats);
Map<AclPortStatsKey, AclPortStats> aclPortStatsKeyAclPortStatsMap = aclPortStats.getAclPortStats();
assertNotNull(aclPortStatsKeyAclPortStatsMap);
assertFalse(aclPortStatsKeyAclPortStatsMap.isEmpty());
for (AclPortStats stats : aclPortStatsKeyAclPortStatsMap.values()) {
List<AclDropStats> aclDropStats = stats.getAclDropStats();
if (stats.getInterfaceName().equals(PORT_1)) {
assertNotNull(aclDropStats);
assertTrue(!aclDropStats.isEmpty());
if (inputDirection == Direction.Both) {
assertTrue(aclDropStats.size() == 2);
} else {
assertTrue(aclDropStats.size() == 1);
}
for (AclDropStats dropStats : aclDropStats) {
if (inputDirection != Direction.Both) {
Assert.assertEquals(dropStats.getDirection(), inputDirection);
}
assertTrue(dropStats.getBytes().getDropCount().intValue() > 0);
assertTrue(dropStats.getBytes().getInvalidDropCount().intValue() > 0);
assertTrue(dropStats.getPackets().getDropCount().intValue() > 0);
assertTrue(dropStats.getPackets().getInvalidDropCount().intValue() > 0);
}
assertNull(stats.getError());
} else {
// Other than port1, error is returned in the output
assertNull(aclDropStats);
assertNotNull(stats.getError());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats 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()));
}
Aggregations