Search in sources :

Example 1 with MeterStatsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder in project openflowplugin by opendaylight.

the class MeterStatNotificationSupplierImpl method createNotification.

@Override
public MeterStatisticsUpdated createNotification(final MeterStatistics meterStatistics, final InstanceIdentifier<MeterStatistics> path) {
    Preconditions.checkArgument(meterStatistics != null);
    Preconditions.checkArgument(path != null);
    final MeterStatisticsUpdatedBuilder builder = new MeterStatisticsUpdatedBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setMeterStats(Collections.singletonList(new MeterStatsBuilder(meterStatistics).build()));
    return builder.build();
}
Also used : MeterStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)

Example 2 with MeterStatsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder 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 3 with MeterStatsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder in project openflowplugin by opendaylight.

the class MeterDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MultipartReply reply = mock(MultipartReply.class);
    final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
    final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
    final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO)).setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L).setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build();
    final List<MeterStats> meterStats = Collections.singletonList(meterStat);
    final List<MultipartReply> input = Collections.singletonList(reply);
    when(meter.getMeterStats()).thenReturn(meterStats);
    when(MeterCase.getMultipartReplyMeter()).thenReturn(meter);
    when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
    final GetMeterStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getMeterStats().size() > 0);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stats = output.getMeterStats().get(0);
    assertEquals(stats.getMeterId().getValue(), METER_NO);
}
Also used : 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) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats) GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder)

Example 4 with MeterStatsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_meter.

@Test
public void testGatherStatistics_meter() throws Exception {
    final MultipartType type = MultipartType.OFPMPMETER;
    final long meterIdValue = 19L;
    final MeterBandStatsBuilder meterBandStatsBld = new MeterBandStatsBuilder().setByteBandCount(BigInteger.valueOf(91L)).setPacketBandCount(BigInteger.valueOf(92L));
    final MeterStatsBuilder meterStatsBld = new MeterStatsBuilder().setMeterId(new MeterId(meterIdValue)).setByteInCount(BigInteger.valueOf(111L)).setDurationSec(112L).setDurationNsec(113L).setFlowCount(114L).setPacketInCount(BigInteger.valueOf(115L)).setMeterBandStats(Lists.newArrayList(meterBandStatsBld.build()));
    final MultipartReplyMeterBuilder mpReplyMeterBld = new MultipartReplyMeterBuilder();
    mpReplyMeterBld.setMeterStats(Lists.newArrayList(meterStatsBld.build()));
    final MultipartReplyMeterCaseBuilder mpReplyMeterCaseBld = new MultipartReplyMeterCaseBuilder();
    mpReplyMeterCaseBld.setMultipartReplyMeter(mpReplyMeterBld.build());
    final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyMeterCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
    fireAndCheck(type, statsData);
    final InstanceIdentifier<MeterStatistics> meterPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue))).augmentation(NodeMeterStatistics.class).child(MeterStatistics.class);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(MeterStatistics.class));
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) MeterBandStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder) NodeMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics) MeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatistics) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder) MultipartReplyMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder) MultipartReplyMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder) Test(org.junit.Test)

Example 5 with MeterStatsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method createMeterStats.

private static List<MeterStats> createMeterStats() {
    MeterStatsBuilder builder = new MeterStatsBuilder();
    builder.setMeterId(new MeterId(1L));
    builder.setFlowCount(1L);
    builder.setPacketInCount(BigInteger.valueOf(1L));
    builder.setByteInCount(BigInteger.valueOf(1L));
    builder.setDurationSec(1L);
    builder.setDurationNsec(1L);
    builder.setMeterBandStats(createMeterBandStats());
    List<MeterStats> list = new ArrayList<>();
    list.add(builder.build());
    return list;
}
Also used : MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder) ArrayList(java.util.ArrayList) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)

Aggregations

ArrayList (java.util.ArrayList)5 MeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder)5 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)4 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats)4 MeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)4 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)4 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)3 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)3 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)3 MeterBandStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder)3 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats)3 MeterBandStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats)3 MeterBandStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder)3 BigInteger (java.math.BigInteger)2 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)2 MultipartReplyMeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder)2 BandId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId)2 BandStat (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat)2 BandStatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatBuilder)2 BandStatKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatKey)2