use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeMeterConfigBody.
private void serializeMeterConfigBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyMeterConfigCase meterConfigCase = (MultipartReplyMeterConfigCase) body;
MultipartReplyMeterConfig meter = meterConfigCase.getMultipartReplyMeterConfig();
for (MeterConfig meterConfig : meter.getMeterConfig()) {
ByteBuf meterConfigBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
meterConfigBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
writeMeterFlags(meterConfig.getFlags(), meterConfigBuff);
meterConfigBuff.writeInt(meterConfig.getMeterId().getValue().intValue());
for (Bands currentBand : meterConfig.getBands()) {
MeterBand meterBand = currentBand.getMeterBand();
if (meterBand instanceof MeterBandDropCase) {
MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand;
MeterBandDrop dropBand = dropBandCase.getMeterBandDrop();
writeBandCommonFields(dropBand, meterConfigBuff);
} else if (meterBand instanceof MeterBandDscpRemarkCase) {
MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand;
MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark();
writeBandCommonFields(dscpRemarkBand, meterConfigBuff);
} else if (meterBand instanceof MeterBandExperimenterCase) {
MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand;
MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter();
writeBandCommonFields(experimenterBand, meterConfigBuff);
}
}
meterConfigBuff.setShort(METER_CONFIG_LENGTH_INDEX, meterConfigBuff.readableBytes());
outBuffer.writeBytes(meterConfigBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter in project openflowplugin by opendaylight.
the class MeterModInputMessageFactory method serializeBands.
private void serializeBands(final List<Bands> bands, final ByteBuf outBuffer) {
if (bands != null) {
for (Bands currentBand : bands) {
MeterBand meterBand = currentBand.getMeterBand();
if (meterBand instanceof MeterBandDropCase) {
MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand;
MeterBandDrop dropBand = dropBandCase.getMeterBandDrop();
writeBandCommonFields(dropBand, outBuffer);
outBuffer.writeZero(PADDING_IN_METER_BAND_DROP);
} else if (meterBand instanceof MeterBandDscpRemarkCase) {
MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand;
MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark();
writeBandCommonFields(dscpRemarkBand, outBuffer);
outBuffer.writeByte(dscpRemarkBand.getPrecLevel());
outBuffer.writeZero(PADDING_IN_METER_BAND_DSCP_REMARK);
} else if (meterBand instanceof MeterBandExperimenterCase) {
MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand;
MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter();
ExperimenterIdMeterBand expIdMeterBand = experimenterBand.getAugmentation(ExperimenterIdMeterBand.class);
if (expIdMeterBand != null) {
long expId = expIdMeterBand.getExperimenter().getValue();
Class<? extends ExperimenterMeterBandSubType> meterBandSubType = expIdMeterBand.getSubType();
try {
OFSerializer<MeterBandExperimenterCase> serializer = registry.getSerializer(ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType));
serializer.serialize(experimenterBandCase, outBuffer);
} catch (final IllegalStateException e) {
LOG.warn("Serializer for key: {} wasn't found, exception {}", ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType), e);
}
}
}
}
}
}
Aggregations