use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyExperimenterDeserializer method deserialize.
@Override
@SuppressWarnings("unchecked")
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
final long expId = message.readUnsignedInt();
final long expType = message.readUnsignedInt();
try {
final OFDeserializer<ExperimenterMessageOfChoice> deserializer = registry.getDeserializer(new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType, ExperimenterMessageOfChoice.class));
builder.setExperimenterMessageOfChoice(deserializer.deserialize(message));
} catch (ClassCastException | IllegalStateException es) {
final OFDeserializer<ExperimenterDataOfChoice> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
final ExperimenterDataOfChoice data = deserializer.deserialize(message);
final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, (Class<? extends ExperimenterDataOfChoice>) data.getImplementedInterface());
final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> convertor = OFSessionUtil.getExtensionConvertorProvider().getMessageConverter(key);
try {
builder.setExperimenterMessageOfChoice(convertor.convert(data, MessagePath.MPMESSAGE_RPC_OUTPUT));
} catch (ConversionException ce) {
LOG.debug("Failed to deserialize multipart reply experimenter for key: {}", key);
}
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyGroupDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
final List<GroupDescStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder().setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
itemBuilder.setKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
final List<Bucket> subItems = new ArrayList<>();
int actualLength = GROUP_DESC_HEADER_LENGTH;
long bucketKey = 0;
while (actualLength < itemLength) {
final int bucketsLength = message.readUnsignedShort();
final BucketBuilder bucketBuilder = new BucketBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketKey(new BucketId(bucketKey))).setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucketBuilder.setAction(actions);
subItems.add(bucketBuilder.build());
bucketKey++;
actualLength += bucketsLength;
}
items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucket(subItems).build()).build());
}
return builder.setGroupDescStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMeterConfigDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
final List<MeterConfigStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final MeterConfigStatsBuilder itemBuilder = new MeterConfigStatsBuilder().setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> subItems = new ArrayList<>();
int actualLength = METER_CONFIG_LENGTH;
while (actualLength < itemLength) {
final int itemStartIndex = message.readerIndex();
final int itemBandType = message.readUnsignedShort();
final MeterBandHeaderBuilder subItemBuilder = new MeterBandHeaderBuilder();
actualLength += message.readUnsignedShort();
switch(itemBandType) {
case OFPMBTDROP:
subItemBuilder.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:
subItemBuilder.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
final long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(itemStartIndex);
final OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
default:
}
subItems.add(subItemBuilder.build());
}
items.add(itemBuilder.setKey(new MeterConfigStatsKey(itemBuilder.getMeterId())).setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(subItems).build()).build());
}
return builder.setMeterConfigStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody 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.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyPortStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
final List<NodeConnectorStatisticsAndPortNumberMap> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final NodeConnectorStatisticsAndPortNumberMapBuilder itemBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
final long port = message.readUnsignedInt();
itemBuilder.setNodeConnectorId(new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port)));
message.skipBytes(PADDING_IN_PORT_STATS_HEADER);
final byte[] recPack = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recPack);
final byte[] txPack = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txPack);
final byte[] recByt = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recByt);
final byte[] txByt = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txByt);
final byte[] recDrop = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recDrop);
final byte[] txDrop = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txDrop);
final byte[] recError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recError);
final byte[] txError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txError);
final byte[] recFrameError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recFrameError);
final byte[] recOverRunError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recOverRunError);
final byte[] recCrcError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(recCrcError);
final byte[] collisionCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(collisionCount);
items.add(itemBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(itemBuilder.getNodeConnectorId())).setPackets(new PacketsBuilder().setReceived(new BigInteger(1, recPack)).setTransmitted(new BigInteger(1, txPack)).build()).setBytes(new BytesBuilder().setReceived(new BigInteger(1, recByt)).setTransmitted(new BigInteger(1, txByt)).build()).setReceiveDrops(new BigInteger(1, recDrop)).setTransmitDrops(new BigInteger(1, txDrop)).setReceiveErrors(new BigInteger(1, recError)).setTransmitErrors(new BigInteger(1, txError)).setReceiveFrameError(new BigInteger(1, recFrameError)).setReceiveOverRunError(new BigInteger(1, recOverRunError)).setReceiveCrcError(new BigInteger(1, recCrcError)).setCollisionCount(new BigInteger(1, collisionCount)).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build()).build());
}
return builder.setNodeConnectorStatisticsAndPortNumberMap(items).build();
}
Aggregations