use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId 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.meter.types.rev130918.BandId in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method createTestMeters.
private MeterBuilder createTestMeters(String s1, String s2) {
// Sample data , committing to DataStore
long id = Integer.parseInt(s1);
MeterKey key = new MeterKey(new MeterId(id));
MeterBuilder meter = new MeterBuilder();
meter.setContainerName("abcd");
meter.setKey(key);
meter.setMeterId(new MeterId(9L));
MeterBandHeaderBuilder bandHeader = new MeterBandHeaderBuilder();
if (s2.equalsIgnoreCase("modify")) {
meter.setMeterName(updatedMeterName);
bandHeader.setBandRate((long) 234);
} else {
meter.setMeterName(originalMeterName);
bandHeader.setBandRate((long) 123);
}
meter.setFlags(new MeterFlags(true, false, false, false));
bandHeader.setBandBurstSize((long) 444);
DscpRemarkBuilder dscpRemark = new DscpRemarkBuilder();
dscpRemark.setDscpRemarkBurstSize((long) 5);
dscpRemark.setPrecLevel((short) 1);
dscpRemark.setDscpRemarkRate((long) 12);
bandHeader.setBandType(dscpRemark.build());
MeterBandTypesBuilder bandTypes = new MeterBandTypesBuilder();
MeterBandType bandType = new MeterBandType(false, true, false);
bandTypes.setFlags(bandType);
bandHeader.setMeterBandTypes(bandTypes.build());
bandHeader.setBandId(new BandId(0L));
List<MeterBandHeader> bandHdr = new ArrayList<>();
bandHdr.add(bandHeader.build());
MeterBandHeadersBuilder bandHeaders = new MeterBandHeadersBuilder();
bandHeaders.setMeterBandHeader(bandHdr);
meter.setMeterBandHeaders(bandHeaders.build());
if (Integer.parseInt(s1) == 1) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 2) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 3) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 4) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 5) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 6) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 7) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 8) {
testMeter2 = meter.build();
}
return meter;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method createTestMeter.
private MeterBuilder createTestMeter() {
// Sample data , committing to DataStore
long id = 12;
MeterKey key = new MeterKey(new MeterId(id));
MeterBuilder meter = new MeterBuilder();
meter.setContainerName("abcd");
meter.setKey(key);
meter.setMeterId(new MeterId(9L));
meter.setMeterName(originalMeterName);
meter.setFlags(new MeterFlags(true, false, false, false));
MeterBandHeaderBuilder bandHeader = new MeterBandHeaderBuilder();
bandHeader.setBandRate((long) 234);
bandHeader.setBandBurstSize((long) 444);
DscpRemarkBuilder dscpRemark = new DscpRemarkBuilder();
dscpRemark.setDscpRemarkBurstSize((long) 5);
dscpRemark.setPrecLevel((short) 1);
dscpRemark.setDscpRemarkRate((long) 12);
bandHeader.setBandType(dscpRemark.build());
MeterBandTypesBuilder bandTypes = new MeterBandTypesBuilder();
MeterBandType bandType = new MeterBandType(false, true, false);
bandTypes.setFlags(bandType);
bandHeader.setMeterBandTypes(bandTypes.build());
bandHeader.setBandId(new BandId(0L));
List<MeterBandHeader> bandHdr = new ArrayList<>();
bandHdr.add(bandHeader.build());
MeterBandHeadersBuilder bandHeaders = new MeterBandHeadersBuilder();
bandHeaders.setMeterBandHeader(bandHdr);
meter.setMeterBandHeaders(bandHeaders.build());
testMeter = meter.build();
return meter;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId in project openflowplugin by opendaylight.
the class MeterStatsResponseConvertor method convert.
@Override
public List<MeterStats> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats> source, VersionConvertorData data) {
List<MeterStats> convertedSALMeters = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats meterStats : source) {
// Convert MeterStats message from library to MD SAL defined MeterStats
MeterStatsBuilder salMeterStats = new MeterStatsBuilder();
salMeterStats.setByteInCount(new Counter64(meterStats.getByteInCount()));
DurationBuilder time = new DurationBuilder();
time.setSecond(new Counter32(meterStats.getDurationSec()));
time.setNanosecond(new Counter32(meterStats.getDurationNsec()));
salMeterStats.setDuration(time.build());
salMeterStats.setFlowCount(new Counter32(meterStats.getFlowCount()));
salMeterStats.setMeterId(new MeterId(meterStats.getMeterId().getValue()));
salMeterStats.setPacketInCount(new Counter64(meterStats.getPacketInCount()));
salMeterStats.setKey(new MeterStatsKey(salMeterStats.getMeterId()));
List<MeterBandStats> allMeterBandStats = meterStats.getMeterBandStats();
MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
List<BandStat> listAllBandStats = new ArrayList<>();
int bandKey = 0;
for (MeterBandStats meterBandStats : allMeterBandStats) {
BandStatBuilder bandStatBuilder = new BandStatBuilder();
bandStatBuilder.setByteBandCount(new Counter64(meterBandStats.getByteBandCount()));
bandStatBuilder.setPacketBandCount(new Counter64(meterBandStats.getPacketBandCount()));
BandId bandId = new BandId((long) bandKey);
bandStatBuilder.setKey(new BandStatKey(bandId));
bandStatBuilder.setBandId(bandId);
bandKey++;
listAllBandStats.add(bandStatBuilder.build());
}
meterBandStatsBuilder.setBandStat(listAllBandStats);
salMeterStats.setMeterBandStats(meterBandStatsBuilder.build());
convertedSALMeters.add(salMeterStats.build());
}
return convertedSALMeters;
}
Aggregations