X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fprotocol%2Fserialization%2Fmessages%2FGroupMessageSerializer.java;h=f46b3da8df01059d112ebd7709f6776aba66a43c;hb=05f8db12159673d0e0a95642fe86e62c14b7dc7b;hp=a0286c77fe8d04e8481e5890d8419dcf7e510432;hpb=047d9550bc3a205217b53d0348eba9d304d965eb;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java index a0286c77fe..f46b3da8df 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.messages; import com.google.common.base.MoreObjects; @@ -21,15 +20,18 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Ord import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Translates GroupMod messages. * OF protocol versions: 1.3. */ public class GroupMessageSerializer extends AbstractMessageSerializer implements - SerializerRegistryInjector { + SerializerRegistryInjector { private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1; private static final byte PADDING_IN_BUCKET = 4; + private static final int OFPGC_ADD_OR_MOD = 32768; + private final boolean isGroupAddModEnabled; private static final Comparator COMPARATOR = (bucket1, bucket2) -> { if (bucket1.getBucketId() == null || bucket2.getBucketId() == null) { @@ -40,31 +42,44 @@ public class GroupMessageSerializer extends AbstractMessageSerializer !GroupModCommand.OFPGCDELETE.equals(message.getCommand())) - .flatMap(b -> Optional.ofNullable(b.getBucket())) - .ifPresent(b -> b.stream() + .flatMap(b -> Optional.ofNullable(b.nonnullBucket())) + .ifPresent(b -> b.values().stream() .sorted(COMPARATOR) .forEach(bucket -> { final int bucketIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), 0)); + outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), Uint16.ZERO).toJava()); outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchPort(), OFConstants.OFPG_ANY) .intValue()); outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchGroup(), OFConstants.OFPG_ANY) .intValue()); outBuffer.writeZero(PADDING_IN_BUCKET); - Optional.ofNullable(bucket.getAction()).ifPresent(as -> as + Optional.ofNullable(bucket.nonnullAction()).ifPresent(as -> as.values() .stream() .sorted(OrderComparator.build()) .forEach(a -> ActionUtil.writeAction( @@ -75,7 +90,6 @@ public class GroupMessageSerializer extends AbstractMessageSerializer