Search in sources :

Example 1 with FlowStatsResponseConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateFlow.

private static MultipartReplyFlowStats translateFlow(final MultipartReply msg, final VersionDatapathIdConvertorData data, final ConvertorExecutor convertorExecutor) {
    FlowStatsResponseConvertorData flowData = new FlowStatsResponseConvertorData(data.getVersion());
    flowData.setDatapathId(data.getDatapathId());
    flowData.setMatchPath(MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
    MultipartReplyFlowStatsBuilder message = new MultipartReplyFlowStatsBuilder();
    MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) msg.getMultipartReplyBody();
    MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
    final Optional<List<FlowAndStatisticsMapList>> flowAndStatisticsMapLists = convertorExecutor.convert(replyBody.getFlowStats(), flowData);
    message.setFlowAndStatisticsMapList(flowAndStatisticsMapLists.orElse(Collections.emptyList()));
    return message.build();
}
Also used : MultipartReplyFlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder) FlowStatsResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) ArrayList(java.util.ArrayList) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)

Example 2 with FlowStatsResponseConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData in project openflowplugin by opendaylight.

the class FlowStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform to notification.
 *
 * @param mpResult      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 FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
    final FlowStatsResponseConvertorData data = new FlowStatsResponseConvertorData(ofVersion.getVersion());
    data.setDatapathId(deviceInfo.getDatapathId());
    data.setMatchPath(MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
    final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
    final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
    notification.setId(deviceInfo.getNodeId());
    notification.setFlowAndStatisticsMapList(statsList);
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    for (MultipartReply mpRawReply : mpResult) {
        Preconditions.checkArgument(MultipartType.OFPMPFLOW.equals(mpRawReply.getType()));
        MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpRawReply.getMultipartReplyBody();
        MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
        final Optional<List<FlowAndStatisticsMapList>> outStatsItem = convertorExecutor.convert(replyBody.getFlowStats(), data);
        outStatsItem.ifPresent(statsList::addAll);
    }
    return notification.build();
}
Also used : FlowStatsResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) FlowsStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder) ArrayList(java.util.ArrayList) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 FlowStatsResponseConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData)2 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)2 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)2 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)2 FlowsStatisticsUpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder)1 MultipartReplyFlowStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1