Search in sources :

Example 1 with BandsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetAllMeterConfigStatistics.

@Test
public void testGetAllMeterConfigStatistics() throws Exception {
    GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder().setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder().setMeterConfig(Collections.singletonList(new MeterConfigBuilder().setFlags(new MeterFlags(true, false, false, false)).setMeterId(METER_ID).setBands(Collections.singletonList(new BandsBuilder().setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().setBurstSize(61L).setRate(62L).setType(MeterBandType.OFPMBTDROP).build()).build()).build())).build())).build()).build()).build())).build();
    final Future<RpcResult<GetAllMeterConfigStatisticsOutput>> resultFuture = meterStatisticsService.getAllMeterConfigStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETERCONFIG, requestInput.getValue().getType());
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) GetAllMeterConfigStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MultipartReplyMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetAllMeterConfigStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder) Test(org.junit.Test)

Example 2 with BandsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertorTest method createMeterConfigList.

private List<MeterConfig> createMeterConfigList() {
    List<MeterConfig> meterConfigs = new ArrayList<>();
    MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
    for (int i = 0; i < PRESET_COUNT; i++) {
        meterConfigBuilder.setMeterId(new MeterId((long) i));
        List<Bands> bandses = new ArrayList<>();
        BandsBuilder bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandDscpRemarkCaseBuilder().setMeterBandDscpRemark(new MeterBandDscpRemarkBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MockMeterBandBuilder());
        bandses.add(bandsBuilder.build());
        bandsBuilder = new BandsBuilder();
        bandsBuilder.setMeterBand(new MeterBandExperimenterCaseBuilder().setMeterBandExperimenter(new MeterBandExperimenterBuilder().build()).build());
        bandses.add(bandsBuilder.build());
        meterConfigBuilder.setBands(bandses);
        meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
        meterConfigs.add(meterConfigBuilder.build());
    }
    return meterConfigs;
}
Also used : MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterBandExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 3 with BandsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder in project openflowplugin by opendaylight.

the class MeterModInputMessageFactory method deserialize.

@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public MeterModInput deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    MeterModInputBuilder builder = new MeterModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setCommand(MeterModCommand.forValue(rawMessage.readUnsignedShort()));
    builder.setFlags(createMeterFlags(rawMessage.readUnsignedShort()));
    builder.setMeterId(new MeterId(rawMessage.readUnsignedInt()));
    List<Bands> bandsList = new ArrayList<>();
    while (rawMessage.readableBytes() > 0) {
        BandsBuilder bandsBuilder = new BandsBuilder();
        int bandStartIndex = rawMessage.readerIndex();
        int bandType = rawMessage.readUnsignedShort();
        switch(bandType) {
            case 1:
                final MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
                MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
                bandDropBuilder.setType(MeterBandType.forValue(bandType));
                rawMessage.readUnsignedShort();
                bandDropBuilder.setRate(rawMessage.readUnsignedInt());
                bandDropBuilder.setBurstSize(rawMessage.readUnsignedInt());
                rawMessage.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
                bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
                break;
            case 2:
                final MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
                MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
                bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
                rawMessage.readUnsignedShort();
                bandDscpRemarkBuilder.setRate(rawMessage.readUnsignedInt());
                bandDscpRemarkBuilder.setBurstSize(rawMessage.readUnsignedInt());
                bandDscpRemarkBuilder.setPrecLevel(rawMessage.readUnsignedByte());
                rawMessage.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
                bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
                break;
            case 0xFFFF:
                long expId = rawMessage.getUnsignedInt(rawMessage.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
                rawMessage.readerIndex(bandStartIndex);
                OFDeserializer<MeterBandExperimenterCase> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
                bandsBuilder.setMeterBand(deserializer.deserialize(rawMessage));
                break;
            default:
                break;
        }
        bandsList.add(bandsBuilder.build());
    }
    builder.setBands(bandsList);
    return builder.build();
}
Also used : MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with BandsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder in project openflowplugin by opendaylight.

the class MeterModInputMessageFactoryTest method createBandsList.

private static List<Bands> createBandsList() {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.OFPMBTDROP);
    dropBand.setRate(1L);
    dropBand.setBurstSize(2L);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
    dscpRemarkBand.setRate(1L);
    dscpRemarkBand.setBurstSize(2L);
    dscpRemarkBand.setPrecLevel((short) 3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)

Example 5 with BandsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method decodeBandsList.

private static List<Bands> decodeBandsList(ByteBuf input) {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dropBand.setRate(input.readUnsignedInt());
    dropBand.setBurstSize(input.readUnsignedInt());
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dscpRemarkBand.setRate(input.readUnsignedInt());
    dscpRemarkBand.setBurstSize(input.readUnsignedInt());
    dscpRemarkBand.setPrecLevel((short) 3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Aggregations

MeterBandDropCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder)10 MeterBandDropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder)10 MeterBandDscpRemarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder)9 MeterBandDscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder)9 ArrayList (java.util.ArrayList)8 BandsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)5 BandsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)5 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands)4 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands)4 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)3 MeterConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder)3 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)2 MeterBandExperimenterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase)2 MeterBandExperimenterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder)2 MeterBandExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder)2 MultipartReplyMeterConfigCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder)2 MultipartReplyMeterConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder)2 MeterConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Test (org.junit.Test)1