Search in sources :

Example 1 with MultipartReplyMeterStatsBuilder

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

the class MultipartReplyMeterStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyMeterStatsBuilder builder = new MultipartReplyMeterStatsBuilder();
    final List<MeterStats> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final MeterStatsBuilder itemBuilder = new MeterStatsBuilder().setMeterId(new MeterId(message.readUnsignedInt()));
        final int itemLength = message.readUnsignedShort();
        message.skipBytes(PADDING_IN_METER_STATS_HEADER);
        itemBuilder.setKey(new MeterStatsKey(itemBuilder.getMeterId())).setFlowCount(new Counter32(message.readUnsignedInt()));
        final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(packetCount);
        final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(byteCount);
        itemBuilder.setPacketInCount(new Counter64(new BigInteger(1, packetCount))).setByteInCount(new Counter64(new BigInteger(1, byteCount))).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build());
        final List<BandStat> subItems = new ArrayList<>();
        int actualLength = METER_BODY_LENGTH;
        long bandKey = 0;
        while (actualLength < itemLength) {
            final byte[] packetCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            message.readBytes(packetCountB);
            final byte[] byteCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            message.readBytes(byteCountB);
            subItems.add(new BandStatBuilder().setBandId(new BandId(bandKey)).setKey(new BandStatKey(new BandId(bandKey))).setPacketBandCount(new Counter64(new BigInteger(1, packetCountB))).setByteBandCount(new Counter64(new BigInteger(1, byteCountB))).build());
            bandKey++;
            actualLength += METER_BAND_STATS_LENGTH;
        }
        items.add(itemBuilder.setMeterBandStats(new MeterBandStatsBuilder().setBandStat(subItems).build()).build());
    }
    return builder.setMeterStats(items).build();
}
Also used : ArrayList(java.util.ArrayList) MeterStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey) BandStat(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MeterBandStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) BigInteger(java.math.BigInteger) BandId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId) BandStatKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatKey) BandStatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)

Example 2 with MultipartReplyMeterStatsBuilder

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

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

the class MeterDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new MeterId(METER_NO)).setByteInCount(new Counter64(BigInteger.ONE)).setPacketInCount(new Counter64(BigInteger.ONE)).setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setFlowCount(new Counter32(0L)).setMeterBandStats(new MeterBandStatsBuilder().build()).build();
    final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyMeterStatsBuilder().setMeterStats(Collections.singletonList(meterStat)).build()).build();
    final List<MultipartReply> input = Collections.singletonList(reply);
    final GetMeterStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getMeterStats().size() > 0);
    final MeterStats stats = output.getMeterStats().get(0);
    assertEquals(stats.getMeterId().getValue(), METER_NO);
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartRequestMeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput) MeterBandStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)

Aggregations

MultipartReplyMeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder)3 ArrayList (java.util.ArrayList)2 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)2 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)2 MeterBandStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder)2 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats)2 MeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)2 BigInteger (java.math.BigInteger)1 List (java.util.List)1 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)1 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)1 MultipartRequestMeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats)1 BandId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId)1 BandStat (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat)1 BandStatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatBuilder)1 BandStatKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatKey)1 MeterStatsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply)1