From 13f6c4b60cc2babeaad6a059f83f614bced45c05 Mon Sep 17 00:00:00 2001 From: R P Karthika Date: Tue, 2 Jun 2020 13:28:35 +0530 Subject: [PATCH] Bug fixes after MRI version bump Change-Id: I9fc2351cf37877427c698fdb6a2d38a0ce5b02f4 Signed-off-by: R P Karthika Signed-off-by: Apurba Mukherjee Signed-off-by: R P Karthika --- .../internal/HwVtepTunnelsStateHandler.java | 4 +- .../utilities/FlowBasedServicesUtils.java | 65 ++++++++++--------- .../genius/itm/impl/ItmUtils.java | 12 ++-- .../ovs/utilities/DirectTunnelUtils.java | 10 +-- .../genius/itm/rpc/ItmManagerRpcService.java | 9 ++- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/genius/alivenessmonitor/internal/HwVtepTunnelsStateHandler.java b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/genius/alivenessmonitor/internal/HwVtepTunnelsStateHandler.java index 6ed5dfb32..926170de6 100644 --- a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/genius/alivenessmonitor/internal/HwVtepTunnelsStateHandler.java +++ b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/genius/alivenessmonitor/internal/HwVtepTunnelsStateHandler.java @@ -349,8 +349,8 @@ public class HwVtepTunnelsStateHandler extends AbstractSyncDataTreeChangeListene } private void setBfdParamForEnable(Map bfdParams, boolean isEnabled) { - bfdParams.put(getBfdParams(AlivenessMonitorConstants.BFD_PARAM_ENABLE, Boolean.toString(isEnabled)).key(), - getBfdParams(AlivenessMonitorConstants.BFD_PARAM_ENABLE, Boolean.toString(isEnabled))); + BfdParams getBfdParam = getBfdParams(AlivenessMonitorConstants.BFD_PARAM_ENABLE, Boolean.toString(isEnabled)); + bfdParams.put(getBfdParam.key(), getBfdParam); } private BfdParams getBfdParams(String key, String value) { diff --git a/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java b/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java index aa0d99dd1..9dbb7e933 100644 --- a/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java +++ b/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java @@ -207,9 +207,9 @@ public final class FlowBasedServicesUtils { // incrementing instructionSize and using it as actionKey. Because // it won't clash with any other instructions int actionKey = ++serviceInstructionsSize; - instructionSet.put(MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, - ++serviceInstructionsSize).key(), MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, - ++serviceInstructionsSize)); + Instruction getPopVlanActionInstruction = MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, + ++serviceInstructionsSize); + instructionSet.put(getPopVlanActionInstruction.key(), getPopVlanActionInstruction); } if (lportTag != 0L) { @@ -220,10 +220,9 @@ public final class FlowBasedServicesUtils { Uint64 metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher( MetaDataUtil.METADATA_MASK_SERVICE_INDEX, MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG, metadataValues[1]); - instructionSet.put( - MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, - ++serviceInstructionsSize).key(), - MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++serviceInstructionsSize)); + Instruction writeMetadaInstruction = MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, + ++serviceInstructionsSize); + instructionSet.put(writeMetadaInstruction.key(), writeMetadaInstruction); } if (instructions != null && !instructions.isEmpty()) { @@ -284,9 +283,10 @@ public final class FlowBasedServicesUtils { Uint64 metadataMask = MetaDataUtil.getWriteMetaDataMaskForDispatcherTable(); // build the final instruction for LPort Dispatcher table flow entry - Map instructions = new HashMap<>(); - instructions.put(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize).key(), - MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize)); + Map instructionsMap = new HashMap<>(); + Instruction instruction = MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, + ++instructionSize); + instructionsMap.put(instruction.key(),instruction); if (serviceInstructions != null && !serviceInstructions.isEmpty()) { for (Instruction info : serviceInstructions.values()) { // Skip meta data write as that is handled already @@ -300,7 +300,7 @@ public final class FlowBasedServicesUtils { ((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction())); } //instructions.values().add(info); - instructions.put(info.key(),info); + instructionsMap.put(info.key(),info); } } @@ -308,7 +308,8 @@ public final class FlowBasedServicesUtils { String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex); Flow ingressFlow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, - DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions); + DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), + matches, instructionsMap); LOG.debug("Installing LPort Dispatcher Flow on DPN {}, for interface {}, with flowRef {}", dpId, interfaceName, flowRef); installFlow(dpId, ingressFlow, tx); @@ -348,14 +349,14 @@ public final class FlowBasedServicesUtils { // build the final instruction for LPort Dispatcher table flow entry List finalApplyActions = new ArrayList<>(); - Map instructions = new HashMap<>(); + Map instructionMap = new HashMap<>(); if (boundService.getServicePriority().toJava() != ServiceIndex.getIndex(NwConstants.DEFAULT_EGRESS_SERVICE_NAME, NwConstants.DEFAULT_EGRESS_SERVICE_INDEX)) { Uint64[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions); Uint64 metadataMask = MetaDataUtil.getWriteMetaDataMaskForEgressDispatcherTable(); - instructions.put(MDSALUtil.buildAndGetWriteMetadaInstruction(metadataValues[0], metadataMask, - instructions.size()).key(),MDSALUtil.buildAndGetWriteMetadaInstruction(metadataValues[0], - metadataMask, instructions.size())); + Instruction instruction = MDSALUtil.buildAndGetWriteMetadaInstruction(metadataValues[0], metadataMask, + instructionMap.size()); + instructionMap.put(instruction.key(), instruction); finalApplyActions.add(MDSALUtil.createSetReg6Action(finalApplyActions.size(), 0, 31, MetaDataUtil.getReg6ValueForLPortDispatcher(interfaceTag, nextServiceIndex))); } @@ -365,8 +366,9 @@ public final class FlowBasedServicesUtils { if (info.getInstruction() instanceof WriteActionsCase) { List writeActions = ActionConverterUtil.convertServiceActionToFlowAction( ((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()); - instructions.put(MDSALUtil.buildWriteActionsInstruction(writeActions, instructions.size()).key(), - MDSALUtil.buildWriteActionsInstruction(writeActions, instructions.size())); + Instruction writeActionsInstruction = MDSALUtil.buildWriteActionsInstruction(writeActions, + instructionMap.size()); + instructionMap.put(writeActionsInstruction.key(), writeActionsInstruction); } else if (info.getInstruction() instanceof ApplyActionsCase) { List applyActions = ActionConverterUtil.convertServiceActionToFlowAction( ((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction(), @@ -374,13 +376,14 @@ public final class FlowBasedServicesUtils { finalApplyActions.addAll(applyActions); } else if (!(info.getInstruction() instanceof WriteMetadataCase)) { // Skip meta data write as that is handled already - instructions.put(MDSALUtil.buildInstruction(info, instructions.size()).key(), - MDSALUtil.buildInstruction(info, instructions.size())); + Instruction buildInstruction = MDSALUtil.buildInstruction(info, instructionMap.size()); + instructionMap.put(buildInstruction.key(), buildInstruction); } } if (!finalApplyActions.isEmpty()) { - instructions.put(MDSALUtil.buildApplyActionsInstruction(finalApplyActions, instructions.size()).key(), - MDSALUtil.buildApplyActionsInstruction(finalApplyActions, instructions.size())); + Instruction buildApplyActionsInstruction = MDSALUtil.buildApplyActionsInstruction(finalApplyActions, + instructionMap.size()); + instructionMap.put(buildApplyActionsInstruction.key(), buildApplyActionsInstruction); } // build the flow and install it @@ -391,7 +394,7 @@ public final class FlowBasedServicesUtils { currentServiceIndex); Flow egressFlow = MDSALUtil.buildFlowNew(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, flowRef, boundService.getServicePriority().toJava(), serviceRef, 0, 0, stypeOpenflow.getFlowCookie(), - matches, instructions); + matches, instructionMap); LOG.debug("Installing Egress Dispatcher Flow for interface : {}, with flow-ref : {}", interfaceName, flowRef); installFlow(dpId, egressFlow, tx); } @@ -696,18 +699,20 @@ public final class FlowBasedServicesUtils { actions.add(MDSALUtil.createNxOfInPortAction(++actionKey, 0)); } if (!actions.isEmpty()) { - instructions.put(MDSALUtil.buildApplyActionsInstruction(actions, instructionKey++).key(), - MDSALUtil.buildApplyActionsInstruction(actions, instructionKey++)); + Instruction buildApplyActionsInstruction = MDSALUtil.buildApplyActionsInstruction(actions, + instructionKey++); + instructions.put(buildApplyActionsInstruction.key(), buildApplyActionsInstruction); } Uint64 metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, (short) 0, Uint64.ZERO, isExternal(iface)); Uint64 metadataMask = MetaDataUtil .getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG); - instructions.put(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, instructionKey++).key(), - MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, instructionKey++)); - instructions.put(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.LPORT_DISPATCHER_TABLE, - instructionKey++).key(), - MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.LPORT_DISPATCHER_TABLE, instructionKey++)); + Instruction metadaInstruction = MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, + instructionKey++); + instructions.put(metadaInstruction.key(),metadaInstruction); + Instruction gotoTableInstruction = MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.LPORT_DISPATCHER_TABLE, + instructionKey++); + instructions.put(gotoTableInstruction.key(), gotoTableInstruction); int priority = isVlanTransparent ? 1 : vlanId == 0 ? IfmConstants.FLOW_PRIORITY_FOR_UNTAGGED_VLAN : IfmConstants.FLOW_HIGH_PRIORITY; String flowRef = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, iface.getName()); diff --git a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/impl/ItmUtils.java b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/impl/ItmUtils.java index 03473ea6f..469ded5f9 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/impl/ItmUtils.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/impl/ItmUtils.java @@ -572,16 +572,18 @@ public final class ItmUtils { public static Map getInternalTunnelsFromCache(DataBroker dataBroker) { Collection internalInterfaces = ITM_CACHE.getAllInternalTunnel(); LOG.trace("getInternalTunnelsFromCache - List of InternalTunnels in the Cache: {} ", internalInterfaces); - Map tunnelList = new HashMap<>(); + Map tunnelMap = new HashMap<>(); if (internalInterfaces.isEmpty()) { LOG.trace("ItmUtils.getInternalTunnelsFromCache invoking getAllInternalTunnlInterfacesFromDS"); - tunnelList = getAllInternalTunnels(dataBroker); + tunnelMap = getAllInternalTunnels(dataBroker); } else { LOG.debug("No. of Internal Tunnel Interfaces in cache: {} ", internalInterfaces.size()); - tunnelList.values().addAll(internalInterfaces); + for (InternalTunnel internalTunnel : internalInterfaces) { + tunnelMap.put(internalTunnel.key(), internalTunnel); + } } - LOG.trace("List of Internal Tunnels: {}", tunnelList); - return tunnelList; + LOG.trace("List of Internal Tunnels: {}", tunnelMap); + return tunnelMap; } @SuppressFBWarnings("RV_CHECK_FOR_POSITIVE_INDEXOF") diff --git a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/itmdirecttunnels/renderer/ovs/utilities/DirectTunnelUtils.java b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/itmdirecttunnels/renderer/ovs/utilities/DirectTunnelUtils.java index 6111ec4dd..85018bf2d 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/itmdirecttunnels/renderer/ovs/utilities/DirectTunnelUtils.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/itmdirecttunnels/renderer/ovs/utilities/DirectTunnelUtils.java @@ -13,6 +13,7 @@ import com.google.common.util.concurrent.ListenableFuture; import edu.umd.cs.findbugs.annotations.CheckReturnValue; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -54,7 +55,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput; @@ -418,10 +418,10 @@ public final class DirectTunnelUtils { actions.add(new ActionOutput(0, new Uri(portNo))); } String flowRef = getTunnelInterfaceFlowRef(dpnId, NwConstants.EGRESS_TUNNEL_TABLE, interfaceName); - Flow egressFlow = MDSALUtil.buildFlowNew(NwConstants.EGRESS_TUNNEL_TABLE, flowRef, 5, flowRef, 0, 0, - NwConstants.COOKIE_ITM_EGRESS_TUNNEL_TABLE, matches, - (Map)(MDSALUtil.buildApplyActionsInstruction(MDSALUtil - .buildActions(actions)))); + Instruction instruction = MDSALUtil.buildApplyActionsInstruction(MDSALUtil.buildActions(actions)); + Flow egressFlow = MDSALUtil.buildFlowNew(NwConstants.EGRESS_TUNNEL_TABLE, flowRef, 5, flowRef, + 0, 0, NwConstants.COOKIE_ITM_EGRESS_TUNNEL_TABLE, matches, + Collections.singletonMap(instruction.key(),instruction)); mdsalApiManager.addFlow(tx, dpnId, egressFlow); } diff --git a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/rpc/ItmManagerRpcService.java b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/rpc/ItmManagerRpcService.java index 4232ea0ce..c2ecab9ae 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/rpc/ItmManagerRpcService.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/genius/itm/rpc/ItmManagerRpcService.java @@ -1027,8 +1027,7 @@ public class ItmManagerRpcService implements ItmRpcService { Map dcGatewayIpList = new HashMap<>(); txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, - tx -> dcGatewayIpList.values().addAll(getDcGatewayIpList(tx).values())).isDone(); - + tx -> dcGatewayIpList.putAll(getDcGatewayIpList(tx))).isDone(); String dcgwIpStr = input.getDcgwIp(); IpAddress dcgwIpAddr = IpAddressBuilder.getDefaultInstance(dcgwIpStr); long retVal; @@ -1199,7 +1198,7 @@ public class ItmManagerRpcService implements ItmRpcService { public static Map getDcGatewayIpList(TypedReadWriteTransaction tx) throws ExecutionException, InterruptedException { - Map dcGatewayIpList = new HashMap<>(); + Map dcGatewayIpMap = new HashMap<>(); FluentFuture> future = tx.read(InstanceIdentifier.builder(DcGatewayIpList.class).build()); future.addCallback(new FutureCallback>() { @@ -1211,7 +1210,7 @@ public class ItmManagerRpcService implements ItmRpcService { if (opt.isPresent()) { DcGatewayIpList list = opt.get(); if (list != null) { - dcGatewayIpList.values().addAll(list.getDcGatewayIp().values()); + dcGatewayIpMap.putAll(list.getDcGatewayIp()); } } } catch (ExecutionException | InterruptedException e) { @@ -1224,6 +1223,6 @@ public class ItmManagerRpcService implements ItmRpcService { LOG.error("DcGateway IpList read failed", error); } }, MoreExecutors.directExecutor()); - return dcGatewayIpList; + return dcGatewayIpMap; } } -- 2.36.6