Search in sources :

Example 1 with MeterConfigStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats 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 2 with MeterConfigStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertor method convert.

@Override
public List<MeterConfigStats> convert(List<MeterConfig> source, VersionConvertorData data) {
    List<MeterConfigStats> listMeterConfigStats = new ArrayList<>();
    for (MeterConfig meterConfig : source) {
        MeterConfigStatsBuilder meterConfigStatsBuilder = new MeterConfigStatsBuilder();
        meterConfigStatsBuilder.setMeterId(new MeterId(meterConfig.getMeterId().getValue()));
        meterConfigStatsBuilder.setKey(new MeterConfigStatsKey(meterConfigStatsBuilder.getMeterId()));
        MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
        List<Bands> bands = meterConfig.getBands();
        MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(), meterConfig.getFlags().isOFPMFKBPS(), meterConfig.getFlags().isOFPMFPKTPS(), meterConfig.getFlags().isOFPMFSTATS());
        meterConfigStatsBuilder.setFlags(meterFlags);
        List<MeterBandHeader> listBandHeaders = new ArrayList<>();
        int bandKey = 0;
        for (Bands band : bands) {
            MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
            if (band.getMeterBand() instanceof MeterBandDropCase) {
                MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand();
                MeterBandDrop dropBand = dropCaseBand.getMeterBandDrop();
                DropBuilder dropBuilder = new DropBuilder();
                dropBuilder.setDropBurstSize(dropBand.getBurstSize());
                dropBuilder.setDropRate(dropBand.getRate());
                meterBandHeaderBuilder.setBandType(dropBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(dropBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(dropBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(true, false, false));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            } else if (band.getMeterBand() instanceof MeterBandDscpRemarkCase) {
                MeterBandDscpRemarkCase dscpRemarkCaseBand = (MeterBandDscpRemarkCase) band.getMeterBand();
                MeterBandDscpRemark dscpRemarkBand = dscpRemarkCaseBand.getMeterBandDscpRemark();
                DscpRemarkBuilder dscpRemarkBuilder = new DscpRemarkBuilder();
                dscpRemarkBuilder.setDscpRemarkBurstSize(dscpRemarkBand.getBurstSize());
                dscpRemarkBuilder.setDscpRemarkRate(dscpRemarkBand.getRate());
                dscpRemarkBuilder.setPrecLevel(dscpRemarkBand.getPrecLevel());
                meterBandHeaderBuilder.setBandType(dscpRemarkBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(dscpRemarkBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(dscpRemarkBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(false, true, false));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            } else if (band.getMeterBand() instanceof MeterBandExperimenterCase) {
                MeterBandExperimenterCase experimenterCaseBand = (MeterBandExperimenterCase) band.getMeterBand();
                MeterBandExperimenter experimenterBand = experimenterCaseBand.getMeterBandExperimenter();
                ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
                experimenterBuilder.setExperimenterBurstSize(experimenterBand.getBurstSize());
                experimenterBuilder.setExperimenterRate(experimenterBand.getRate());
                meterBandHeaderBuilder.setBandType(experimenterBuilder.build());
                meterBandHeaderBuilder.setBandBurstSize(experimenterBand.getBurstSize());
                meterBandHeaderBuilder.setBandRate(experimenterBand.getRate());
                BandId bandId = new BandId((long) bandKey);
                meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
                meterBandHeaderBuilder.setBandId(bandId);
                MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
                meterBandTypesBuilder.setFlags(new MeterBandType(false, false, true));
                meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
                listBandHeaders.add(meterBandHeaderBuilder.build());
            }
            bandKey++;
        }
        meterBandHeadersBuilder.setMeterBandHeader(listBandHeaders);
        meterConfigStatsBuilder.setMeterBandHeaders(meterBandHeadersBuilder.build());
        listMeterConfigStats.add(meterConfigStatsBuilder.build());
    }
    return listMeterConfigStats;
}
Also used : ArrayList(java.util.ArrayList) 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) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) 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) 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) 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) MeterBandExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter) 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) 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) MeterBandHeaderKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey) 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) 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) 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) MeterBandDrop(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop) BandId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId) MeterBandDscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark)

Example 3 with MeterConfigStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeterConfig.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig translateMeterConfig(final MultipartReply msg, final VersionDatapathIdConvertorData data, final ConvertorExecutor convertorExecutor) {
    MultipartReplyMeterConfigBuilder message = new MultipartReplyMeterConfigBuilder();
    MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) msg.getMultipartReplyBody();
    MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
    final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
    message.setMeterConfigStats(meterConfigStatsList.orElse(Collections.emptyList()));
    return message.build();
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder) 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) MultipartReplyMeterConfigCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig)

Example 4 with MeterConfigStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertorTest method testToSALMeterConfigList.

@Test
public /**
 * Test of basic mapping functionality of {@link MeterConfigStatsResponseConvertor#convert(java.util.List)} }
 */
void testToSALMeterConfigList() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<List<MeterConfigStats>> meterConfigsOptional = convertorManager.convert(createMeterConfigList(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    List<MeterConfigStats> meterConfigs = meterConfigsOptional.orElse(Collections.emptyList());
    assertEquals(PRESET_COUNT, meterConfigs.size());
    int cnt = 0;
    for (MeterConfigStats meterConfigStats : meterConfigs) {
        assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue());
        assertTrue(meterConfigStats.getFlags().isMeterBurst());
        assertFalse(meterConfigStats.getFlags().isMeterKbps());
        assertTrue(meterConfigStats.getFlags().isMeterPktps());
        assertFalse(meterConfigStats.getFlags().isMeterStats());
        cnt++;
    }
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) ArrayList(java.util.ArrayList) List(java.util.List) MeterConfigStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats) Test(org.junit.Test)

Example 5 with MeterConfigStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats in project openflowplugin by opendaylight.

the class AllMeterConfigStatsService method transformToNotification.

@Override
public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
    message.setId(getDeviceInfo().getNodeId());
    message.setMoreReplies(Boolean.FALSE);
    message.setTransactionId(emulatedTxId);
    message.setMeterConfigStats(new ArrayList<>());
    for (MultipartReply mpReply : result) {
        MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
        MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
        final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
        meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats));
    }
    return message.build();
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MeterConfigStatsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder) ArrayList(java.util.ArrayList) List(java.util.List) MultipartReplyMeterConfigCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig)

Aggregations

ArrayList (java.util.ArrayList)5 List (java.util.List)3 MeterConfigStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats)3 MultipartReplyMeterConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder)2 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 DropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder)2 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)2 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)2 MeterConfigStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder)2 MeterConfigStatsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey)2 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)2 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)2 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)2 MultipartReplyMeterConfigCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase)2 MultipartReplyMeterConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig)2 Test (org.junit.Test)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 ExperimenterIdDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1