use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.
the class MultipartReplyMeterFeaturesDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeInt(MAX_METER);
int bitMaskBands = ByteBufUtils.fillBitMask(0, BANDS_SUPPORTED.contains(MeterBandDrop.class), BANDS_SUPPORTED.contains(MeterBandDscpRemark.class));
buffer.writeInt(bitMaskBands);
int bitMaskCapabilities = ByteBufUtils.fillBitMask(0, CAPABILITIES_SUPPORTED.contains(MeterKbps.class), CAPABILITIES_SUPPORTED.contains(MeterPktps.class), CAPABILITIES_SUPPORTED.contains(MeterBurst.class), CAPABILITIES_SUPPORTED.contains(MeterStats.class));
buffer.writeInt(bitMaskCapabilities);
buffer.writeByte(MAX_BANDS);
buffer.writeByte(MAX_COLOR);
final MultipartReplyMeterFeatures reply = (MultipartReplyMeterFeatures) deserializeMultipart(buffer);
assertEquals(MAX_METER, reply.getMaxMeter().getValue().intValue());
assertTrue(reply.getMeterBandSupported().containsAll(BANDS_SUPPORTED));
assertTrue(reply.getMeterCapabilitiesSupported().containsAll(CAPABILITIES_SUPPORTED));
assertEquals(MAX_BANDS, reply.getMaxBands().byteValue());
assertEquals(MAX_COLOR, reply.getMaxColor().byteValue());
assertEquals(0, buffer.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.
the class MeterFeaturesService method transformToNotification.
@Override
public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
final int mpSize = result.size();
Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
notification.setMaxBands(replyBody.getMaxBands());
notification.setMaxColor(replyBody.getMaxColor());
notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
return notification.build();
}
Aggregations