Search in sources :

Example 1 with MeterId

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

the class MeterConvertorTest method testMeterModCommandConvertorNoValidBandData.

@Test
public void testMeterModCommandConvertorNoValidBandData() {
    // / DROP Band
    MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
    MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
    MeterBandType bandFlag = new MeterBandType(true, false, false);
    // _ofpmbtDrop
    meterBandTypesB.setFlags(bandFlag);
    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
    final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
    // DSCP Mark
    MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
    MeterBandType bandFlag1 = new MeterBandType(false, true, false);
    meterBandTypesB1.setFlags(bandFlag1);
    DscpRemarkBuilder dscp = new DscpRemarkBuilder();
    dscp.setDscpRemarkBurstSize(11L);
    dscp.setDscpRemarkRate(21L);
    dscp.setPrecLevel((short) 1);
    DscpRemark dscpRemark = dscp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder1.setBandType(dscpRemark);
    meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
    final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
    // Experimental
    ExperimenterBuilder exp = new ExperimenterBuilder();
    exp.setExperimenterBurstSize(12L);
    exp.setExperimenterRate(22L);
    exp.setExperimenter(23L);
    Experimenter experimenter = exp.build();
    MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
    meterBandHeaderBuilder2.setBandType(experimenter);
    MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
    meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
    MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
    List<MeterBandHeader> meterBandList = new ArrayList<>();
    meterBandList.add(0, meterBH);
    meterBandList.add(1, meterBH1);
    meterBandList.add(2, meterBH2);
    // Constructing List of Bands
    MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
    meterBandHeadersBuilder.setMeterBandHeader(meterBandList);
    MeterBandHeaders meterBandHeaders = meterBandHeadersBuilder.build();
    AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
    // MeterBands
    addMeterFromSAL.setMeterBandHeaders(meterBandHeaders);
    // NodeKey key = new NodeKey(new NodeId("24"));
    // InstanceIdentifier<Node> path =
    // InstanceIdentifier.builder().node(Nodes.class).node(Node.class,
    // key).build();
    addMeterFromSAL.setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(10L));
    MeterFlags flagV = new MeterFlags(true, true, true, true);
    addMeterFromSAL.setFlags(flagV);
    AddMeterInput meterInputCommand = addMeterFromSAL.build();
    MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
    assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
    assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
    assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
    // BandInformation starts here:
    List<Bands> bands = outMeterModInput.getBands();
    for (Bands currentBand : bands) {
        MeterBand meterBand = currentBand.getMeterBand();
        if (meterBand instanceof MeterBandDropCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
            assertEquals((long) 20, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
            assertEquals((long) 10, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
        }
        if (meterBand instanceof MeterBandDscpRemarkCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDSCPREMARK, ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
            assertEquals((long) 11, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
            assertEquals((long) 21, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
            assertEquals((short) 1, (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
        }
        if (meterBand instanceof MeterBandExperimenterCase) {
            assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTEXPERIMENTER, ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
            assertEquals((long) 12, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
            assertEquals((long) 22, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
            ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getAugmentation(ExperimenterIdMeterBand.class);
            assertEquals((long) 23, (long) expBand.getExperimenter().getValue());
        }
    }
}
Also used : MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) DscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark) MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) ArrayList(java.util.ArrayList) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) Experimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) MeterBandHeaders(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeaders) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterBandDropCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) AddMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder) Test(org.junit.Test)

Example 2 with MeterId

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

the class MeterNotificationSupplierImplTest method createTestMeter.

private static Meter createTestMeter() {
    final MeterBuilder builder = new MeterBuilder();
    builder.setMeterId(new MeterId(METER_ID));
    return builder.build();
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)

Example 3 with MeterId

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

the class MeterNotificationSupplierImplTest method createUpdatedTestMeter.

private static Meter createUpdatedTestMeter() {
    final MeterBuilder builder = new MeterBuilder();
    builder.setMeterId(new MeterId(UPDATED_METER_ID));
    return builder.build();
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)

Example 4 with MeterId

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

the class MultipartReplyMeterConfigDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
    final List<MeterConfigStats> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        final MeterConfigStatsBuilder itemBuilder = new MeterConfigStatsBuilder().setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
        final List<MeterBandHeader> subItems = new ArrayList<>();
        int actualLength = METER_CONFIG_LENGTH;
        while (actualLength < itemLength) {
            final int itemStartIndex = message.readerIndex();
            final int itemBandType = message.readUnsignedShort();
            final MeterBandHeaderBuilder subItemBuilder = new MeterBandHeaderBuilder();
            actualLength += message.readUnsignedShort();
            switch(itemBandType) {
                case OFPMBTDROP:
                    subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
                    message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                    break;
                case OFPMBTDSCP:
                    subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
                    message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                    break;
                case OFPMBTEXPERIMENTER:
                    // TODO: Finish meter band experimenter deserialization
                    final long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
                    message.readerIndex(itemStartIndex);
                    final OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
                    subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
                    break;
                default:
            }
            subItems.add(subItemBuilder.build());
        }
        items.add(itemBuilder.setKey(new MeterConfigStatsKey(itemBuilder.getMeterId())).setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(subItems).build()).build());
    }
    return builder.setMeterConfigStats(items).build();
}
Also used : MeterConfigStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) Experimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder) ArrayList(java.util.ArrayList) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) MeterConfigStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey) MeterConfigStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats)

Example 5 with MeterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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)

Aggregations

MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)24 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)23 ByteBuf (io.netty.buffer.ByteBuf)11 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)10 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)9 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)8 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)8 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)8 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)8 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)8 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)8 MeterModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder)8 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)7 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)7 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)6 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)6 MeterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder)6 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder)6