Search in sources :

Example 1 with MultipartReplyMeterStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStats 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 2 with MultipartReplyMeterStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStats in project openflowplugin by opendaylight.

the class MultipartReplyMeterStatsDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    buffer.writeInt(METER_ID);
    buffer.writeShort(ITEM_LENGTH);
    buffer.writeZero(PADDING_IN_METER_STATS_HEADER);
    buffer.writeInt(FLOW_COUNT);
    buffer.writeLong(PACKET_IN_COUNT);
    buffer.writeLong(BYTE_IN_COUNT);
    buffer.writeInt(SECOND);
    buffer.writeInt(NANOSECOND);
    buffer.writeLong(PACKET_BAND_COUNT);
    buffer.writeLong(BYTE_BAND_COUNT);
    final MultipartReplyMeterStats reply = (MultipartReplyMeterStats) deserializeMultipart(buffer);
    final MeterStats meterStats = reply.getMeterStats().get(0);
    assertEquals(METER_ID, meterStats.getMeterId().getValue().intValue());
    assertEquals(FLOW_COUNT, meterStats.getFlowCount().getValue().intValue());
    assertEquals(PACKET_IN_COUNT, meterStats.getPacketInCount().getValue().longValue());
    assertEquals(BYTE_IN_COUNT, meterStats.getByteInCount().getValue().intValue());
    assertEquals(SECOND, meterStats.getDuration().getSecond().getValue().intValue());
    assertEquals(NANOSECOND, meterStats.getDuration().getNanosecond().getValue().intValue());
    assertEquals(PACKET_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0).getPacketBandCount().getValue().longValue());
    assertEquals(BYTE_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0).getByteBandCount().getValue().longValue());
    assertEquals(0, buffer.readableBytes());
}
Also used : MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MultipartReplyMeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStats) MultipartReplyMeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStats) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)1 MultipartReplyMeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStats)1 MultipartReplyMeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder)1 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats)1 MultipartReplyMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase)1 MultipartReplyMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter)1