Search in sources :

Example 1 with MeterBandHeaderKey

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

Aggregations

ArrayList (java.util.ArrayList)1 BandId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId)1 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)1 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags)1 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)1 DropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder)1 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)1 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder)1 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)1 MeterConfigStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats)1 MeterConfigStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder)1 MeterConfigStatsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey)1 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)1 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)1 MeterBandHeaderKey (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey)1 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)1 MeterBandDropCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase)1 MeterBandDscpRemarkCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase)1 MeterBandExperimenterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase)1 MeterBandDrop (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop)1