Search in sources :

Example 1 with FlowsStatisticsUpdateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder in project openflowplugin by opendaylight.

the class FlowStatNotificationSupplierImpl method createNotification.

@Override
public FlowsStatisticsUpdate createNotification(final FlowStatistics flowStatistics, final InstanceIdentifier<FlowStatistics> path) {
    Preconditions.checkArgument(flowStatistics != null);
    Preconditions.checkArgument(path != null);
    final FlowAndStatisticsMapListBuilder fsmlBuilder = new FlowAndStatisticsMapListBuilder(flowStatistics);
    fsmlBuilder.setFlowId(new FlowId(path.firstKeyOf(Flow.class, FlowKey.class).getId().getValue()));
    final FlowsStatisticsUpdateBuilder builder = new FlowsStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setFlowAndStatisticsMapList(Collections.singletonList(fsmlBuilder.build()));
    return builder.build();
}
Also used : FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId) FlowsStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder)

Example 2 with FlowsStatisticsUpdateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method prepareFlowStatisticsData.

private Iterable<FlowsStatisticsUpdate> prepareFlowStatisticsData() {
    final FlowAndStatisticsMapListBuilder flowAndStatsMapListBld = new FlowAndStatisticsMapListBuilder();
    flowAndStatsMapListBld.setTableId((short) 42);
    flowAndStatsMapListBld.setMatch(new MatchBuilder().build());
    final FlowsStatisticsUpdateBuilder flowStatsUpdateBld1 = new FlowsStatisticsUpdateBuilder();
    flowStatsUpdateBld1.setFlowAndStatisticsMapList(Lists.newArrayList(flowAndStatsMapListBld.build()));
    return Lists.newArrayList(flowStatsUpdateBld1.build());
}
Also used : FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) FlowsStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Example 3 with FlowsStatisticsUpdateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder 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

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