Search in sources :

Example 6 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class NodeConnectorDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final NodeConnectorStatisticsAndPortNumberMap portStat = new NodeConnectorStatisticsAndPortNumberMapBuilder().setNodeConnectorId(nodeConnectorId).build();
    final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyPortStatsBuilder().setNodeConnectorStatisticsAndPortNumberMap(Collections.singletonList(portStat)).build()).build();
    final List<MultipartReply> input = Collections.singletonList(reply);
    final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
    final NodeConnectorStatisticsAndPortNumberMap stats = output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
    assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
Also used : NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 7 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeter.

private static MultipartReplyMeterStats translateMeter(final MultipartReply msg, final VersionDatapathIdConvertorData data, final ConvertorExecutor convertorExecutor) {
    MultipartReplyMeterStatsBuilder message = new MultipartReplyMeterStatsBuilder();
    MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) msg.getMultipartReplyBody();
    MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
    final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data);
    message.setMeterStats(meterStatsList.orElse(Collections.emptyList()));
    return message.build();
}
Also used : MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) 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)

Example 8 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateGroup.

private static MultipartReplyGroupStats translateGroup(final MultipartReply msg, final VersionDatapathIdConvertorData data, final ConvertorExecutor convertorExecutor) {
    MultipartReplyGroupStatsBuilder message = new MultipartReplyGroupStatsBuilder();
    MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) msg.getMultipartReplyBody();
    MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
    final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(replyBody.getGroupStats(), data);
    message.setGroupStats(groupStatsList.orElse(Collections.emptyList()));
    return message.build();
}
Also used : MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) 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) MultipartReplyGroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder)

Example 9 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeterConfig.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig translateMeterConfig(final MultipartReply msg, final VersionDatapathIdConvertorData data, final ConvertorExecutor convertorExecutor) {
    MultipartReplyMeterConfigBuilder message = new MultipartReplyMeterConfigBuilder();
    MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) msg.getMultipartReplyBody();
    MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
    final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
    message.setMeterConfigStats(meterConfigStatsList.orElse(Collections.emptyList()));
    return message.build();
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder) 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) MultipartReplyMeterConfigCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig)

Example 10 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translatePortStats.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStats translatePortStats(final MultipartReply msg, final OpenflowVersion ofVersion, final BigInteger datapathId) {
    MultipartReplyPortStatsBuilder message = new MultipartReplyPortStatsBuilder();
    MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) msg.getMultipartReplyBody();
    MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
    List<NodeConnectorStatisticsAndPortNumberMap> statsMap = new ArrayList<>();
    for (PortStats portStats : replyBody.getPortStats()) {
        NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
        statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portStats.getPortNo(), ofVersion));
        BytesBuilder bytesBuilder = new BytesBuilder();
        bytesBuilder.setReceived(portStats.getRxBytes());
        bytesBuilder.setTransmitted(portStats.getTxBytes());
        statsBuilder.setBytes(bytesBuilder.build());
        PacketsBuilder packetsBuilder = new PacketsBuilder();
        packetsBuilder.setReceived(portStats.getRxPackets());
        packetsBuilder.setTransmitted(portStats.getTxPackets());
        statsBuilder.setPackets(packetsBuilder.build());
        DurationBuilder durationBuilder = new DurationBuilder();
        if (portStats.getDurationSec() != null) {
            durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
        }
        if (portStats.getDurationNsec() != null) {
            durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
        }
        statsBuilder.setDuration(durationBuilder.build());
        statsBuilder.setCollisionCount(portStats.getCollisions());
        statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
        statsBuilder.setReceiveCrcError(portStats.getRxCrcErr());
        statsBuilder.setReceiveDrops(portStats.getRxDropped());
        statsBuilder.setReceiveErrors(portStats.getRxErrors());
        statsBuilder.setReceiveFrameError(portStats.getRxFrameErr());
        statsBuilder.setReceiveOverRunError(portStats.getRxOverErr());
        statsBuilder.setTransmitDrops(portStats.getTxDropped());
        statsBuilder.setTransmitErrors(portStats.getTxErrors());
        statsMap.add(statsBuilder.build());
    }
    message.setNodeConnectorStatisticsAndPortNumberMap(statsMap);
    return message.build();
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) ArrayList(java.util.ArrayList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) NodeConnectorStatisticsAndPortNumberMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey) MultipartReplyPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder) NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) PortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Aggregations

MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)52 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)25 List (java.util.List)25 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)13 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)11 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)10 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)10 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)6 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)6 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply)6 MultipartReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)6 ConvertorManager (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager)5 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 TranslatorKey (org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey)4 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)4 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)4 MultipartReplyMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase)4