use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessageBuilder in project openflowplugin by opendaylight.
the class GroupMessageDeserializer method deserialize.
@Override
public GroupMessage deserialize(ByteBuf message) {
final GroupMessageBuilder builder = new GroupMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(GroupModCommand.forValue(message.readUnsignedShort()));
builder.setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING);
builder.setGroupId(new GroupId(message.readUnsignedInt()));
final List<Bucket> buckets = new ArrayList<>();
while (message.readableBytes() > 0) {
final int length = message.readUnsignedShort();
final BucketBuilder bucket = new BucketBuilder().setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
if (message.readableBytes() > 0) {
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 = length - 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++;
}
bucket.setAction(actions);
}
buckets.add(bucket.build());
}
buckets.sort(COMPARATOR);
return builder.setBuckets(new BucketsBuilder().setBucket(buckets).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessageBuilder in project openflowplugin by opendaylight.
the class SingleLayerGroupService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final Group input) throws ServiceException {
final GroupMessageBuilder groupMessageBuilder = new GroupMessageBuilder(input);
final Class<? extends DataContainer> clazz = input.getImplementedInterface();
if (clazz.equals(AddGroupInput.class)) {
groupMessageBuilder.setCommand(GroupModCommand.OFPGCADD);
} else if (clazz.equals(UpdatedGroup.class)) {
groupMessageBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
} else if (clazz.equals(RemoveGroupInput.class) || clazz.equals(OriginalGroup.class)) {
groupMessageBuilder.setCommand(GroupModCommand.OFPGCDELETE);
}
return groupMessageBuilder.setVersion(getVersion()).setXid(xid.getValue()).build();
}
Aggregations