use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder in project openflowplugin by opendaylight.
the class OpendaylightMeterStatisticsServiceImplTest method testGetAllMeterConfigStatistics.
@Test
public void testGetAllMeterConfigStatistics() throws Exception {
GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder().setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder().setMeterConfig(Collections.singletonList(new MeterConfigBuilder().setFlags(new MeterFlags(true, false, false, false)).setMeterId(METER_ID).setBands(Collections.singletonList(new BandsBuilder().setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().setBurstSize(61L).setRate(62L).setType(MeterBandType.OFPMBTDROP).build()).build()).build())).build())).build()).build()).build())).build();
final Future<RpcResult<GetAllMeterConfigStatisticsOutput>> resultFuture = meterStatisticsService.getAllMeterConfigStatistics(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPMETERCONFIG, requestInput.getValue().getType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder in project openflowplugin by opendaylight.
the class MeterConfigStatsResponseConvertorTest method createMeterConfigList.
private List<MeterConfig> createMeterConfigList() {
List<MeterConfig> meterConfigs = new ArrayList<>();
MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
for (int i = 0; i < PRESET_COUNT; i++) {
meterConfigBuilder.setMeterId(new MeterId((long) i));
List<Bands> bandses = new ArrayList<>();
BandsBuilder bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().build()).build());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandDscpRemarkCaseBuilder().setMeterBandDscpRemark(new MeterBandDscpRemarkBuilder().build()).build());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MockMeterBandBuilder());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandExperimenterCaseBuilder().setMeterBandExperimenter(new MeterBandExperimenterBuilder().build()).build());
bandses.add(bandsBuilder.build());
meterConfigBuilder.setBands(bandses);
meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
meterConfigs.add(meterConfigBuilder.build());
}
return meterConfigs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder in project openflowplugin by opendaylight.
the class MeterModInputMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public MeterModInput deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
MeterModInputBuilder builder = new MeterModInputBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setCommand(MeterModCommand.forValue(rawMessage.readUnsignedShort()));
builder.setFlags(createMeterFlags(rawMessage.readUnsignedShort()));
builder.setMeterId(new MeterId(rawMessage.readUnsignedInt()));
List<Bands> bandsList = new ArrayList<>();
while (rawMessage.readableBytes() > 0) {
BandsBuilder bandsBuilder = new BandsBuilder();
int bandStartIndex = rawMessage.readerIndex();
int bandType = rawMessage.readUnsignedShort();
switch(bandType) {
case 1:
final MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
bandDropBuilder.setType(MeterBandType.forValue(bandType));
rawMessage.readUnsignedShort();
bandDropBuilder.setRate(rawMessage.readUnsignedInt());
bandDropBuilder.setBurstSize(rawMessage.readUnsignedInt());
rawMessage.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
break;
case 2:
final MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
rawMessage.readUnsignedShort();
bandDscpRemarkBuilder.setRate(rawMessage.readUnsignedInt());
bandDscpRemarkBuilder.setBurstSize(rawMessage.readUnsignedInt());
bandDscpRemarkBuilder.setPrecLevel(rawMessage.readUnsignedByte());
rawMessage.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
break;
case 0xFFFF:
long expId = rawMessage.getUnsignedInt(rawMessage.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
rawMessage.readerIndex(bandStartIndex);
OFDeserializer<MeterBandExperimenterCase> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
bandsBuilder.setMeterBand(deserializer.deserialize(rawMessage));
break;
default:
break;
}
bandsList.add(bandsBuilder.build());
}
builder.setBands(bandsList);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder in project openflowplugin by opendaylight.
the class MeterModInputMessageFactoryTest method createBandsList.
private static List<Bands> createBandsList() {
final List<Bands> bandsList = new ArrayList<>();
final BandsBuilder bandsBuilder = new BandsBuilder();
final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
dropBand.setType(MeterBandType.OFPMBTDROP);
dropBand.setRate(1L);
dropBand.setBurstSize(2L);
dropCaseBuilder.setMeterBandDrop(dropBand.build());
bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
dscpRemarkBand.setRate(1L);
dscpRemarkBand.setBurstSize(2L);
dscpRemarkBand.setPrecLevel((short) 3);
dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
return bandsList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method decodeBandsList.
private static List<Bands> decodeBandsList(ByteBuf input) {
final List<Bands> bandsList = new ArrayList<>();
final BandsBuilder bandsBuilder = new BandsBuilder();
final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
input.skipBytes(Short.SIZE / Byte.SIZE);
dropBand.setRate(input.readUnsignedInt());
dropBand.setBurstSize(input.readUnsignedInt());
dropCaseBuilder.setMeterBandDrop(dropBand.build());
bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
input.skipBytes(Short.SIZE / Byte.SIZE);
dscpRemarkBand.setRate(input.readUnsignedInt());
dscpRemarkBand.setBurstSize(input.readUnsignedInt());
dscpRemarkBand.setPrecLevel((short) 3);
dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
return bandsList;
}
Aggregations