Search in sources :

Example 31 with Stats

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 testGroupStatsWithBuckets.

/**
 * Test GroupStats with buckets conversion.
 */
@Test
public void testGroupStatsWithBuckets() {
    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);
    List<BucketStats> bucketStats = new ArrayList<>();
    BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("987"));
    bucketStatsBuilder.setPacketCount(new BigInteger("654"));
    bucketStats.add(bucketStatsBuilder.build());
    bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("123"));
    bucketStatsBuilder.setPacketCount(new BigInteger("456"));
    bucketStats.add(bucketStatsBuilder.build());
    statsBuilder.setBucketStats(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", 2, stat.getBuckets().getBucketCounter().size());
    List<BucketCounter> list = stat.getBuckets().getBucketCounter();
    Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
}
Also used : ArrayList(java.util.ArrayList) BucketStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) BucketCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 32 with Stats

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 MultipartReplyFlowTest method testEmptyMultipartReplyFlowBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testEmptyMultipartReplyFlowBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
    Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 33 with Stats

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 MultipartReplyFlowTest method testMultipartReplyFlowBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyFlowBody() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 01 00 01 00 00 00 00 " + // first flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 1F " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00 " + // second flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 00 " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
    Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size());
    FlowStats flowStats1 = message.getFlowStats().get(0);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
    flowStats1 = message.getFlowStats().get(1);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) BigInteger(java.math.BigInteger) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 34 with Stats

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 NodeConnectorStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device basic info
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @return notification containing flow stats
 */
public static NodeConnectorStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
    NodeConnectorStatisticsUpdateBuilder notification = new NodeConnectorStatisticsUpdateBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setNodeConnectorStatisticsAndPortNumberMap(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) mpReply.getMultipartReplyBody();
        MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
        for (PortStats portStats : replyBody.getPortStats()) {
            NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = processSingleNodeConnectorStats(deviceInfo, ofVersion, portStats);
            notification.getNodeConnectorStatisticsAndPortNumberMap().add(statsBuilder.build());
        }
    }
    return notification.build();
}
Also used : NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) 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) NodeConnectorStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder)

Example 35 with Stats

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 GroupDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MultipartReply reply = mock(MultipartReply.class);
    final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
    final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
    final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setBucketStats(Collections.emptyList()).setDurationSec(1L).setDurationNsec(1L).setRefCount(0L).build();
    final List<GroupStats> groupStats = Collections.singletonList(groupStat);
    final List<MultipartReply> input = Collections.singletonList(reply);
    when(group.getGroupStats()).thenReturn(groupStats);
    when(groupCase.getMultipartReplyGroup()).thenReturn(group);
    when(reply.getMultipartReplyBody()).thenReturn(groupCase);
    final GetGroupStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getGroupStats().size() > 0);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
    assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) GetGroupStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput) 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) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)

Aggregations

ArrayList (java.util.ArrayList)14 Test (org.junit.Test)14 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)10 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)10 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)10 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)9 BigInteger (java.math.BigInteger)7 List (java.util.List)7 GroupStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)6 GetFlowStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput)5 GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)5 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)5 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 GetGroupStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput)4 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)4 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)4