use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortBothDirection.
/**
* Test stats for two ports and both direction. <br>
* port1 is valid <br>
* port2 is invalid <br>
* Expectation: Error expected for port2
*
* @throws Exception the exception
*/
@Test
public void getStatsTwoPortBothDirection() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
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("getStatsTwoPortBothDirection output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats in project netvirt by opendaylight.
the class AclLiveStatisticsHelper method getAclPortStats.
/**
* Gets the acl port stats.
*
* @param direction the direction
* @param interfaceNames the interface names
* @param odlDirectStatsService the odl direct stats service
* @param dataBroker the data broker
* @return the acl port stats
*/
public static List<AclPortStats> getAclPortStats(Direction direction, List<String> interfaceNames, OpendaylightDirectStatisticsService odlDirectStatsService, DataBroker dataBroker) {
LOG.trace("Get ACL port stats for direction {} and interfaces {}", direction, interfaceNames);
List<AclPortStats> lstAclPortStats = new ArrayList<>();
Short tableId = getTableId(direction);
FlowCookie aclDropFlowCookie = new FlowCookie(AclConstants.COOKIE_ACL_DROP_FLOW);
FlowCookie aclDropFlowCookieMask = new FlowCookie(COOKIE_ACL_DROP_FLOW_MASK);
for (String interfaceName : interfaceNames) {
AclPortStatsBuilder aclStatsBuilder = new AclPortStatsBuilder().setInterfaceName(interfaceName);
Interface interfaceState = AclServiceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
if (interfaceState == null) {
String errMsg = "Interface not found in datastore.";
addError(lstAclPortStats, aclStatsBuilder, errMsg);
continue;
}
BigInteger dpId = AclServiceUtils.getDpIdFromIterfaceState(interfaceState);
if (dpId == null) {
String errMsg = "Failed to find device for the interface.";
addError(lstAclPortStats, aclStatsBuilder, errMsg);
continue;
}
NodeRef nodeRef = buildNodeRef(dpId);
Integer lportTag = interfaceState.getIfIndex();
Match metadataMatch = buildMetadataMatch(lportTag);
GetFlowStatisticsInputBuilder input = new GetFlowStatisticsInputBuilder().setNode(nodeRef).setCookie(aclDropFlowCookie).setCookieMask(aclDropFlowCookieMask).setMatch(metadataMatch).setStoreStats(false);
if (direction != Direction.Both) {
input.setTableId(tableId);
}
Future<RpcResult<GetFlowStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getFlowStatistics(input.build());
RpcResult<GetFlowStatisticsOutput> rpcResult = null;
try {
rpcResult = rpcResultFuture.get();
} catch (InterruptedException | ExecutionException e) {
String errMsg = "Unable to retrieve drop counts due to error: " + e.getMessage();
addError(lstAclPortStats, aclStatsBuilder, errMsg);
LOG.error("Exception occurred during get flow statistics for interface {}", interfaceName, e);
}
if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
GetFlowStatisticsOutput flowStatsOutput = rpcResult.getResult();
getAclDropStats(direction, aclStatsBuilder, flowStatsOutput);
lstAclPortStats.add(aclStatsBuilder.build());
} else {
handleRpcErrors(lstAclPortStats, aclStatsBuilder, rpcResult);
}
}
return lstAclPortStats;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats in project openflowplugin by opendaylight.
the class GroupStatsResponseConvertorTest method testEmptyGroupStats.
/**
* Test empty GroupStats conversion.
*/
@Test
public void testEmptyGroupStats() {
List<GroupStats> groupStats = new ArrayList<>();
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStats = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
Assert.assertFalse("Group stats response should be not present", salGroupStats.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats in project openflowplugin by opendaylight.
the class GroupStatsResponseConvertorTest method testSingleGroupStat.
/**
* Test single GroupStat conversion.
*/
@Test
public void testSingleGroupStat() {
GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
statsBuilder.setByteCount(new BigInteger("12345"));
statsBuilder.setDurationNsec(1000000L);
statsBuilder.setDurationSec(5000L);
statsBuilder.setGroupId(new GroupId(42L));
statsBuilder.setPacketCount(new BigInteger("54321"));
statsBuilder.setRefCount(24L);
statsBuilder.setBucketStats(new ArrayList<BucketStats>());
List<GroupStats> groupStats = new ArrayList<>();
groupStats.add(statsBuilder.build());
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats 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();
}
Aggregations