use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class GroupStatisticsToNotificationTransformer method transformToNotification.
/**
* Transform statistics to notification.
* @param mpReplyList raw multipart response from device
* @param deviceInfo device state
* @param emulatedTxId emulated transaction id
* @param convertorExecutor convertor executor
* @return notification containing flow stats
*/
public static GroupStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
GroupStatisticsUpdatedBuilder notification = new GroupStatisticsUpdatedBuilder();
notification.setId(deviceInfo.getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
notification.setGroupStats(new ArrayList<>());
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(replyBody.getGroupStats(), data);
groupStatsList.ifPresent(groupStats -> notification.getGroupStats().addAll(groupStats));
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class MeterStatisticsToNotificationTransformer method transformToNotification.
/**
* Transform statistics to notification.
*
* @param mpReplyList raw multipart response from device
* @param deviceInfo device state
* @param ofVersion device version
* @param emulatedTxId emulated transaction Id
* @param convertorExecutor convertor executor
* @return notification containing flow stats
*/
public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
MeterStatisticsUpdatedBuilder notification = new MeterStatisticsUpdatedBuilder();
notification.setId(deviceInfo.getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
notification.setMeterStats(new ArrayList<>());
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
final Optional<List<MeterStats>> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data);
meterStatsList.ifPresent(meterStats -> notification.getMeterStats().addAll(meterStats));
}
return notification.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 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, @NonNull List<String> interfaceNames, OpendaylightDirectStatisticsService odlDirectStatsService, DataBroker dataBroker) {
LOG.trace("Get ACL port stats for direction {} and interfaces {}", direction, interfaceNames);
List<AclPortStats> lstAclPortStats = new ArrayList<>();
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();
FlowCookie aclDropFlowCookie = new FlowCookie(AclServiceUtils.getDropFlowCookie(lportTag));
GetFlowStatisticsInputBuilder input = new GetFlowStatisticsInputBuilder().setNode(nodeRef).setCookie(aclDropFlowCookie).setCookieMask(aclDropFlowCookieMask).setStoreStats(false);
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.rev200120.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.rev200120.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());
}
Aggregations