Merge "SONAR TD - Group actions redundancy"
authorJozef Bacigal <jozef.bacigal@pantheon.tech>
Mon, 15 Aug 2016 13:28:34 +0000 (13:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 15 Aug 2016 13:28:34 +0000 (13:28 +0000)
1  2 
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java

index 9e93ba56d6a115f1e24e5387206c45729399241e,5dc48381823c1ec3bed83ab5ebb097dedee3002e..80dfc7bb8b17b34182be4ca1b83979a1bb016f53
@@@ -16,8 -16,8 +16,9 @@@ import org.opendaylight.openflowplugin.
  import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
  import org.opendaylight.openflowplugin.api.openflow.device.Xid;
  import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 +import org.opendaylight.openflowplugin.impl.services.ServiceException;
  import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+ import org.opendaylight.openflowplugin.impl.util.GroupUtil;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
index 04f94ec3728db9017c42c3adbefcfb8e14ea0949,14f1ecc44302a1d2b0fd482ae53b1f4e76448b86..d572eea2340e986aeab058169b46704f1d64eeda
@@@ -121,9 -122,77 +122,40 @@@ public final class GroupUtil 
      public static <O> Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>> createCumulatingFunction(
              final Iterable<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group> inputBatchGroups,
              final int sizeOfInputBatch) {
 -        return new Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>>() {
 -            @Nullable
 -            @Override
 -            public RpcResult<List<BatchFailedGroupsOutput>> apply(@Nullable final List<RpcResult<O>> innerInput) {
 -                final int sizeOfFutures = innerInput.size();
 -                Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
 -                        "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
 -
 -                final List<BatchFailedGroupsOutput> batchGroups = new ArrayList<>();
 -                final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group>
 -                        batchGroupIterator = inputBatchGroups.iterator();
 -
 -                Collection<RpcError> groupErrors = new ArrayList<>(sizeOfFutures);
 -
 -                int batchOrder = 0;
 -                for (RpcResult<O> groupModOutput : innerInput) {
 -                    final GroupId groupId = batchGroupIterator.next().getGroupId();
 -
 -                    if (!groupModOutput.isSuccessful()) {
 -                        batchGroups.add(new BatchFailedGroupsOutputBuilder()
 -                                .setGroupId(groupId)
 -                                .setBatchOrder(batchOrder)
 -                                .build());
 -                        groupErrors.addAll(groupModOutput.getErrors());
 -                    }
 -                    batchOrder++;
 -                }
 -
 -                final RpcResultBuilder<List<BatchFailedGroupsOutput>> resultBuilder;
 -                if (!groupErrors.isEmpty()) {
 -                    resultBuilder = RpcResultBuilder.<List<BatchFailedGroupsOutput>>failed()
 -                            .withRpcErrors(groupErrors).withResult(batchGroups);
 -                } else {
 -                    resultBuilder = SUCCESSFUL_GROUP_OUTPUT_RPC_RESULT;
 -                }
 -                return resultBuilder.build();
 -            }
 -        };
 +        return new CumulatingFunction<O>(inputBatchGroups, sizeOfInputBatch).invoke();
      }
  
+     /*
+      * Method returns the bitmap of actions supported by each group.
+      *
+      * @param actionsSupported
+      * @return
+      */
+     public static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
+         List<Long> supportActionByGroups = new ArrayList<>();
+         for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
+             long supportActionBitmap = 0;
+             supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1) : 0;
+             supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
+             supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
+             supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
+             supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
+             supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
+             supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
+             supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
+             supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
+             supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
+             supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
+             supportActionByGroups.add(supportActionBitmap);
+         }
+         return supportActionByGroups;
+     }
      /**
       * Factory method: create {@link Function} which attaches barrier response to given {@link RpcResult}&lt;T&gt;
       * and changes success flag if needed.