MRI version bumpup for Aluminium
[netvirt.git] / elanmanager / api / src / main / java / org / opendaylight / netvirt / elan / arp / responder / ArpResponderUtil.java
index b2042eef8b06df69c1d82f5eab151dfa2cc6fdab..63eabadcf4e9f0814cb981126beb4212f2969127 100644 (file)
@@ -12,13 +12,14 @@ import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
-
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
@@ -47,6 +48,7 @@ import org.opendaylight.genius.mdsalutil.matches.MatchMetadata;
 import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
@@ -58,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.I
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -80,7 +83,7 @@ public final class ArpResponderUtil {
      * @param dpnId
      *            DPN on which group flow to be installed
      */
-    public static FlowEntity getArpResponderTableMissFlow(BigInteger dpnId) {
+    public static FlowEntity getArpResponderTableMissFlow(Uint64 dpnId) {
         return MDSALUtil.buildFlowEntity(dpnId, NwConstants.ARP_RESPONDER_TABLE,
                 String.valueOf(NwConstants.ARP_RESPONDER_TABLE), NwConstants.TABLE_MISS_PRIORITY,
                 ArpResponderConstant.DROP_FLOW_NAME.value(), 0, 0, NwConstants.COOKIE_ARP_RESPONDER,
@@ -135,8 +138,8 @@ public final class ArpResponderUtil {
     public static List<MatchInfo> getMatchCriteria(int lportTag, ElanInstance elanInstance,
             String ipAddress) {
 
-        BigInteger metadata = ElanHelper.getElanMetadataLabel(elanInstance.getElanTag(), lportTag);
-        BigInteger metadataMask = ElanHelper.getElanMetadataMask();
+        Uint64 metadata = ElanHelper.getElanMetadataLabel(elanInstance.getElanTag().toJava(), lportTag);
+        Uint64 metadataMask = ElanHelper.getElanMetadataMask();
         return Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REQUEST, new MatchArpTpa(ipAddress, "32"),
                 new MatchMetadata(metadata, metadataMask));
 
@@ -209,7 +212,7 @@ public final class ArpResponderUtil {
                 new ActionMoveSpaToTpa().buildAction(actionCounter.getAndIncrement()),
                 new ActionLoadMacToSha(new MacAddress(mac)).buildAction(actionCounter.getAndIncrement()),
                 new ActionLoadIpToSpa(ip).buildAction(actionCounter.getAndIncrement()),
-                new ActionNxLoadInPort(BigInteger.ZERO).buildAction(actionCounter.getAndIncrement()));
+                new ActionNxLoadInPort(Uint64.valueOf(BigInteger.ZERO)).buildAction(actionCounter.getAndIncrement()));
         return actions;
 
     };
@@ -245,7 +248,7 @@ public final class ArpResponderUtil {
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = v
                     .getAction();
             if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
-                tableId.set(((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable());
+                tableId.set(((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable().toJava());
                 return true;
             } else {
                 return false;
@@ -298,16 +301,15 @@ public final class ArpResponderUtil {
      *            Gateway IP for which ARP Response flow to be installed
      * @return Cookie
      */
-    public static BigInteger generateCookie(int lportTag, String ipAddress) {
+    public static Uint64 generateCookie(int lportTag, String ipAddress) {
         LOG.trace("IPAddress in long {}", ipAddress);
-        BigInteger cookie = NwConstants.COOKIE_ARP_RESPONDER.add(BigInteger.valueOf(255))
-                .add(BigInteger.valueOf(ipTolong(ipAddress)));
-        return cookie.add(BigInteger.valueOf(lportTag));
+        return Uint64.fromLongBits(NwConstants.COOKIE_ARP_RESPONDER.longValue()
+                + 255 + ipTolong(ipAddress) + lportTag);
     }
 
-    private static BigInteger buildCookie(short tableId, int arpOpType) {
-        return NwConstants.COOKIE_ARP_RESPONDER.add(BigInteger.ONE).add(
-                BigInteger.valueOf(tableId).add(BigInteger.valueOf(arpOpType)));
+    private static Uint64 buildCookie(short tableId, int arpOpType) {
+        return Uint64.fromLongBits(NwConstants.COOKIE_ARP_RESPONDER.longValue()
+                + 1 + tableId + arpOpType);
     }
 
     private static String buildFlowRef(short tableId, int arpOpType) {
@@ -317,7 +319,7 @@ public final class ArpResponderUtil {
                 + (arpOpType == NwConstants.ARP_REQUEST ? "arp.request" : "arp.replay");
     }
 
-    public static FlowEntity createArpDefaultFlow(BigInteger dpId, short tableId, int arpOpType,
+    public static FlowEntity createArpDefaultFlow(Uint64 dpId, short tableId, int arpOpType,
             Supplier<List<MatchInfo>> matches, Supplier<List<ActionInfo>> actions) {
 
         List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actions.get()));
@@ -371,14 +373,14 @@ public final class ArpResponderUtil {
             try {
                 RpcResult result = itmRpcService.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder()
                         .setIntfName(ifName).build()).get();
-                List<Action> listActions = new ArrayList<>();
+                Map<ActionKey, Action> listActions = new HashMap<ActionKey, Action>();
                 if (!result.isSuccessful()) {
                     LOG.error("getEgressActionsForInterface: RPC Call to Get egress actions for interface {} "
                             + "returned with Errors {}", ifName, result.getErrors());
                 } else {
                     listActions = ((GetEgressActionsForTunnelOutput) result.getResult()).getAction();
                 }
-                return listActions;
+                return new ArrayList<Action>(listActions.values());
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("getEgressActionsForInterface: Exception when egress actions for interface {}", ifName, e);
             }
@@ -408,7 +410,7 @@ public final class ArpResponderUtil {
             RpcResult<AllocateIdOutput> rpcResult = result.get();
             if (rpcResult.isSuccessful()) {
                 LOG.trace("Retrieved Group Id is {}", rpcResult.getResult().getIdValue());
-                return rpcResult.getResult().getIdValue();
+                return rpcResult.getResult().getIdValue().toJava();
             } else {
                 LOG.warn("RPC Call to Allocate Id returned with Errors {}", rpcResult.getErrors());
             }