use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterMessageDeserializer method deserialize.
@Override
public MeterMessage deserialize(ByteBuf message) {
final MeterMessageBuilder builder = new MeterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(MeterModCommand.forValue(message.readUnsignedShort())).setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> bands = new ArrayList<>();
while (message.readableBytes() > 0) {
final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
final int bandStartIndex = message.readerIndex();
final int bandType = message.readUnsignedShort();
switch(bandType) {
case OFPMBTDROP:
{
bandBuilder.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:
{
bandBuilder.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
long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(bandStartIndex);
OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
}
default:
}
bands.add(bandBuilder.build());
}
return builder.setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(bands).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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.MeterId in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createMeterInstructions.
private static InstructionsBuilder createMeterInstructions() {
MeterBuilder aab = new MeterBuilder();
aab.setMeterId(new MeterId(1L));
InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
// Put our Instruction in a list of Instructions
InstructionsBuilder isb = new InstructionsBuilder();
List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO)).setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L).setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build();
final List<MeterStats> meterStats = Collections.singletonList(meterStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(meter.getMeterStats()).thenReturn(meterStats);
when(MeterCase.getMultipartReplyMeter()).thenReturn(meter);
when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getMeterStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stats = output.getMeterStats().get(0);
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId 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;
}
Aggregations