Merge "Bug 6374 topology-manager - DTCL instead of DTL"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / GroupFeaturesService.java
index 192208d8318b704ac5940e2289046b4c0a8b00ce..80dfc7bb8b17b34182be4ca1b83979a1bb016f53 100644 (file)
@@ -16,7 +16,9 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 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;
@@ -33,7 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
@@ -56,7 +57,7 @@ final class GroupFeaturesService
     }
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final GetGroupFeaturesInput input) {
+    protected OfHeader buildRequest(final Xid xid, final GetGroupFeaturesInput input) throws ServiceException {
         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                 MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
         mprInput.setMultipartRequestBody(GROUP_FEAT_CASE);
@@ -74,7 +75,7 @@ final class GroupFeaturesService
         Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
 
         GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceInfo().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
@@ -84,7 +85,7 @@ final class GroupFeaturesService
         notification.setGroupTypesSupported(extractSupportedGroupTypes(replyBody.getTypes()));
         notification.setMaxGroups(replyBody.getMaxGroups());
         notification.setGroupCapabilitiesSupported(extractSupportedCapabilities(replyBody.getCapabilities()));
-        notification.setActions(extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
+        notification.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
 
         return notification.build();
     }
@@ -126,30 +127,4 @@ final class GroupFeaturesService
         }
         return supportedGroups;
     }
-
-    @VisibleForTesting
-    static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
-        List<Long> supportActionByGroups = new ArrayList<>();
-        for (ActionType supportedActions : actionsSupported) {
-            long supportActionBitmap = 0;
-            supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1 << 0) : 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(Long.valueOf(supportActionBitmap));
-        }
-        return supportActionByGroups;
-    }
 }