Sonar clean-ups
authorStephen Kitt <skitt@redhat.com>
Thu, 10 Sep 2015 12:40:14 +0000 (14:40 +0200)
committerStephen Kitt <skitt@redhat.com>
Thu, 10 Sep 2015 12:54:25 +0000 (14:54 +0200)
Starting from source files containing collapsible ifs:
* merge collapsible ifs;
* remove unused parameters;
* remove unused exceptions;
* remove unused fields;
* rename shadowing variables;
* add private constructors for utility classes;
* use more specific exceptions than RuntimeException;
* clean up "if () return true; else return false;";
* some Java 7 <> operators;
* add missing "static" for constants;
* remove unused private methods (except in OF13Provider);
* move some inline comments above the corresponding source line;
* used boolean instead of Boolean for Map::contains();
* replace foreach-style constructs examining the first element only
  with explicit "if (...hasNext()) ... = ... next()";
* prohibit overriding methods called from constructors;
* remove useless casts.

Reverse the order of node augmentation handling in SouthboundUtil so
that the augmentation case can actually trigger.

Change-Id: Ie4fc662bdcc0e2133fdd4f57b783723466b1f2a9
Signed-off-by: Stephen Kitt <skitt@redhat.com>
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/GatewayMacResolverService.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java

index 977bbbd9725e4f94f9cba49bd5e53d35399a56d8..ac954bf9efa0f77489aea4d3ea8920809493f642 100644 (file)
@@ -16,12 +16,14 @@ import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
 public class OvsdbRow {
+    private static final Logger LOG = LoggerFactory.getLogger(OvsdbRow.class);
     private static final String PARENTUUID = "parent_uuid";
     private static final String PARENTTABLE = "parent_table";
     private static final String PARENTCOLUMN = "parent_column";
@@ -70,21 +72,21 @@ public class OvsdbRow {
         if (rowNode == null) {
             return null;
         }
-        for(Iterator<String> fieldNames = rowNode.fieldNames(); fieldNames.hasNext();) {
+        Iterator<String> fieldNames = rowNode.fieldNames();
+        if (fieldNames.hasNext()) {
             String tableName = fieldNames.next();
-            Row<GenericTableSchema> row = null;
             try {
-                row = getRow(client, dbName, tableName, rowNode.get(tableName));
+                Row<GenericTableSchema> row = getRow(client, dbName, tableName, rowNode.get(tableName));
+                return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row);
             } catch (InterruptedException | ExecutionException | IOException e) {
-                e.printStackTrace();
+                LOG.error("Error retrieving the row for {}", tableName, e);
                 return null;
             }
-            return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row);
         }
         return null;
     }
 
-    public static Row<GenericTableSchema> getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, JsonParseException, IOException {
+    public static Row<GenericTableSchema> getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, IOException {
         DatabaseSchema dbSchema = client.getSchema(dbName).get();
         GenericTableSchema schema = dbSchema.table(tableName, GenericTableSchema.class);
         return schema.createRow((ObjectNode)rowJson);
index b8a096389b95d024011a9f2566ca88fb4c593c69..12879dadda1c22db175238ea5b35d3002beb1fe8 100644 (file)
@@ -1643,29 +1643,27 @@ public class OF13Provider implements ConfigInterface, NetworkingProvider {
                 }
             }
             LOG.debug("createOutputGroupInstructions: addNew {}", addNew);
-            if (addNew) {
+            if (addNew && !buckets.getBucket().isEmpty()) {
                 /* the new output action is not in the bucket, add to bucket */
-                if (!buckets.getBucket().isEmpty()) {
-                    Bucket bucket = buckets.getBucket().get(0);
-                    List<Action> bucketActionList = Lists.newArrayList();
-                    bucketActionList.addAll(bucket.getAction());
-                    /* set order for new action and add to action list */
-                    ab.setOrder(bucketActionList.size());
-                    ab.setKey(new ActionKey(bucketActionList.size()));
-                    bucketActionList.add(ab.build());
-
-                    /* set bucket and buckets list. Reset groupBuilder with new buckets.*/
-                    BucketsBuilder bucketsBuilder = new BucketsBuilder();
-                    List<Bucket> bucketList = Lists.newArrayList();
-                    BucketBuilder bucketBuilder = new BucketBuilder();
-                    bucketBuilder.setBucketId(new BucketId((long) 1));
-                    bucketBuilder.setKey(new BucketKey(new BucketId((long) 1)));
-                    bucketBuilder.setAction(bucketActionList);
-                    bucketList.add(bucketBuilder.build());
-                    bucketsBuilder.setBucket(bucketList);
-                    groupBuilder.setBuckets(bucketsBuilder.build());
-                    LOG.debug("createOutputGroupInstructions: bucketList {}", bucketList);
-                }
+                Bucket bucket = buckets.getBucket().get(0);
+                List<Action> bucketActionList = Lists.newArrayList();
+                bucketActionList.addAll(bucket.getAction());
+                /* set order for new action and add to action list */
+                ab.setOrder(bucketActionList.size());
+                ab.setKey(new ActionKey(bucketActionList.size()));
+                bucketActionList.add(ab.build());
+
+                /* set bucket and buckets list. Reset groupBuilder with new buckets.*/
+                BucketsBuilder bucketsBuilder = new BucketsBuilder();
+                List<Bucket> bucketList = Lists.newArrayList();
+                BucketBuilder bucketBuilder = new BucketBuilder();
+                bucketBuilder.setBucketId(new BucketId((long) 1));
+                bucketBuilder.setKey(new BucketKey(new BucketId((long) 1)));
+                bucketBuilder.setAction(bucketActionList);
+                bucketList.add(bucketBuilder.build());
+                bucketsBuilder.setBucket(bucketList);
+                groupBuilder.setBuckets(bucketsBuilder.build());
+                LOG.debug("createOutputGroupInstructions: bucketList {}", bucketList);
             }
         } else {
             /* create group */
index 87b3dee1d364fc815c22884b9af81ac0231f06dc..edea48c26cdc122d5e2c6cbd29dd478f62e90075 100644 (file)
@@ -83,7 +83,7 @@ public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListe
         return serviceRegistry.get(service);
     }
 
-    public void start() {
+    public final void start() {
         eventHandler.submit(new Runnable()  {
             @Override
             public void run() {
@@ -93,11 +93,8 @@ public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListe
                         LOG.info(">>>>> dequeue: {}", node);
                         for (Service service : staticPipeline) {
                             AbstractServiceInstance serviceInstance = getServiceInstance(service);
-                            //LOG.info("pipeline: {} - {}", service, serviceInstance);
-                            if (serviceInstance != null) {
-                                if (southbound.getBridge(node) != null) {
-                                    serviceInstance.programDefaultPipelineRule(node);
-                                }
+                            if (serviceInstance != null && southbound.getBridge(node) != null) {
+                                serviceInstance.programDefaultPipelineRule(node);
                             }
                         }
                     }
index d6ce3d8b7c4a5700ae81c087b04db56e82866b43..7c2cfbebae8a3ab589561b4d89ec27bd831f686b 100644 (file)
@@ -21,8 +21,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
-import javax.annotation.Nullable;
-
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.ovsdb.openstack.netvirt.api.GatewayMacResolver;
@@ -30,7 +28,6 @@ import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -100,11 +97,11 @@ public class GatewayMacResolverService extends AbstractServiceInstance
     private SalFlowService flowService;
     private final AtomicLong flowCookie = new AtomicLong();
     private final ConcurrentMap<Ipv4Address, ArpResolverMetadata> gatewayToArpMetadataMap =
-            new ConcurrentHashMap<Ipv4Address, ArpResolverMetadata>();
-    private final int ARP_WATCH_BROTHERS = 10;
-    private final int WAIT_CYCLES = 3;
-    private final int PER_CYCLE_WAIT_DURATION = 1000;
-    private final int REFRESH_INTERVAL = 10;
+            new ConcurrentHashMap<>();
+    private static final int ARP_WATCH_BROTHERS = 10;
+    private static final int WAIT_CYCLES = 3;
+    private static final int PER_CYCLE_WAIT_DURATION = 1000;
+    private static final int REFRESH_INTERVAL = 10;
     private final ListeningExecutorService arpWatcherWall = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(ARP_WATCH_BROTHERS));
     private final ScheduledExecutorService gatewayMacRefresherPool = Executors.newScheduledThreadPool(1);
     private final ScheduledExecutorService refreshRequester = Executors.newSingleThreadScheduledExecutor();
@@ -183,7 +180,6 @@ public class GatewayMacResolverService extends AbstractServiceInstance
      * @param sourceMacAddress Source Mac address for the ARP request packet
      * @param periodicRefresh Enable/Disable periodic refresh of the Gateway Mac address
      * NOTE:Periodic refresh is not supported yet.
-     * @param gatewayIp  Resolve MAC address of this Gateway Ip
      * @return Future object
      */
     @Override
@@ -305,13 +301,6 @@ public class GatewayMacResolverService extends AbstractServiceInstance
         });
     }
 
-    private static @Nullable Ipv4Address getIPv4Addresses(IpAddress ipAddress) {
-        if (ipAddress.getIpv4Address() == null) {
-            return null;
-        }
-        return ipAddress.getIpv4Address();
-    }
-
     private Flow createArpReplyToControllerFlow(final ArpMessageAddress senderAddress, final Ipv4Address ipForRequestedMac) {
         checkNotNull(senderAddress);
         checkNotNull(ipForRequestedMac);
@@ -330,11 +319,11 @@ public class GatewayMacResolverService extends AbstractServiceInstance
         arpFlow.setMatch(match);
         arpFlow.setInstructions(new InstructionsBuilder().setInstruction(
                 ImmutableList.of(SEND_TO_CONTROLLER_INSTRUCTION)).build());
-        arpFlow.setId(createFlowId(senderAddress, ipForRequestedMac));
+        arpFlow.setId(createFlowId(ipForRequestedMac));
         return arpFlow.build();
     }
 
-    private FlowId createFlowId(ArpMessageAddress senderAddress, Ipv4Address ipForRequestedMac) {
+    private FlowId createFlowId(Ipv4Address ipForRequestedMac) {
         String flowId = ARP_REPLY_TO_CONTROLLER_FLOW_NAME + "|" + ipForRequestedMac.getValue();
         return new FlowId(flowId);
     }
index 8f21cb8902070819fbb1aebc0b4718dbe45d13b1..8eaed984f10a106608882576d3d20b789f70b94b 100644 (file)
@@ -295,10 +295,8 @@ public class SouthboundHandler extends AbstractHandler
     private void processPortUpdate(Node node, OvsdbTerminationPointAugmentation port) {
         LOG.debug("processPortUpdate <{}> <{}>", node, port);
         NeutronNetwork network = tenantNetworkManager.getTenantNetwork(port);
-        if (network != null ){
-            if(!network.getRouterExternal()){
-                this.handleInterfaceUpdate(node, port);
-            }
+        if (network != null && !network.getRouterExternal()) {
+            this.handleInterfaceUpdate(node, port);
         }
     }
 
index a9e84bad2dc9f657b07c9c55433393d50818aa49..bc40093955545c17c1e73b8af2728f9f0a016d38 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.openstack.netvirt.impl;
 
 import org.opendaylight.neutron.spi.NeutronNetwork;
 import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
-import org.opendaylight.ovsdb.openstack.netvirt.MdsalHelper;
 import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
@@ -127,19 +126,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
             Preconditions.checkNotNull(portNameExt);
 
             if (southbound.isBridgeOnOvsdbNode(ovsdbNode, brExt)) {
-                //this would look better if used a method like isNetworkPatchCreated()
-                if (isPortOnBridge(bridgeNode, portNameInt)) {
-                    Node extBridgeNode = southbound.readBridgeNode(ovsdbNode, brExt);
-                    if (isPortOnBridge(extBridgeNode, portNameExt)) {
-                        ready = true;
-                    } else {
-                        LOG.trace("isNodeL3Ready: node: {}, {} missing",
-                                bridgeNode, portNameExt);
-                    }
-                } else {
-                    LOG.trace("isNodeL3Ready: node: {}, {} missing",
-                            bridgeNode, portNameInt);
-                }
+                ready = isNetworkPatchCreated(bridgeNode, southbound.readBridgeNode(ovsdbNode, brExt));
             } else {
                 LOG.trace("isNodeL3Ready: node: {}, {} missing",
                         bridgeNode, brExt);
@@ -261,7 +248,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     /**
      * Returns true if a patch port exists between the Integration Bridge and Network Bridge
      */
-    private boolean isNetworkPatchCreated(Node node, Node intBridge, Node netBridge) {
+    private boolean isNetworkPatchCreated(Node intBridge, Node netBridge) {
         Preconditions.checkNotNull(configurationService);
 
         boolean isPatchCreated = false;
@@ -280,7 +267,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     /**
      * Creates the Integration Bridge
      */
-    private boolean createIntegrationBridge(Node ovsdbNode) throws Exception {
+    private boolean createIntegrationBridge(Node ovsdbNode) {
         Preconditions.checkNotNull(configurationService);
 
         if (!addBridge(ovsdbNode, configurationService.getIntegrationBridgeName())) {
@@ -290,7 +277,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
         return true;
     }
 
-    private boolean createExternalBridge(Node ovsdbNode) throws Exception {
+    private boolean createExternalBridge(Node ovsdbNode) {
         Preconditions.checkNotNull(configurationService);
 
         if (!addBridge(ovsdbNode, configurationService.getExternalBridgeName())) {
@@ -355,7 +342,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
                 Interface br-int
                     type: internal
      */
-    private boolean createBridges(Node bridgeNode, Node ovsdbNode, NeutronNetwork network) throws Exception {
+    private boolean createBridges(Node bridgeNode, Node ovsdbNode, NeutronNetwork network) {
         Preconditions.checkNotNull(configurationService);
         Preconditions.checkNotNull(networkingProviderManager);
 
@@ -408,7 +395,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     /**
      * Add a Port to a Bridge
      */
-    private boolean addPortToBridge (Node node, String bridgeName, String portName) throws Exception {
+    private boolean addPortToBridge (Node node, String bridgeName, String portName) {
         boolean rv = true;
 
         if (southbound.extractTerminationPointAugmentation(node, portName) == null) {
@@ -432,7 +419,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     /**
      * Add a Patch Port to a Bridge
      */
-    private boolean addPatchPort (Node node, String bridgeName, String portName, String peerPortName) throws Exception {
+    private boolean addPatchPort (Node node, String bridgeName, String portName, String peerPortName) {
         boolean rv = true;
 
         if (southbound.extractTerminationPointAugmentation(node, portName) == null) {
@@ -456,7 +443,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     /**
      * Add Bridge to a Node
      */
-    private boolean addBridge(Node ovsdbNode, String bridgeName) throws Exception {
+    private boolean addBridge(Node ovsdbNode, String bridgeName) {
         boolean rv = true;
         if ((!southbound.isBridgeOnOvsdbNode(ovsdbNode, bridgeName)) ||
                 (southbound.getBridgeFromConfig(ovsdbNode, bridgeName) == null)) {
@@ -466,13 +453,10 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     }
 
     private String getControllerIPAddress() {
-        InetAddress controllerIP = null;
-
         String addressString = ConfigProperties.getProperty(this.getClass(), "ovsdb.controller.address");
         if (addressString != null) {
             try {
-                controllerIP = InetAddress.getByName(addressString);
-                if (controllerIP != null) {
+                if (InetAddress.getByName(addressString) != null) {
                     return addressString;
                 }
             } catch (UnknownHostException e) {
@@ -483,8 +467,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
         addressString = ConfigProperties.getProperty(this.getClass(), "of.address");
         if (addressString != null) {
             try {
-                controllerIP = InetAddress.getByName(addressString);
-                if (controllerIP != null) {
+                if (InetAddress.getByName(addressString) != null) {
                     return addressString;
                 }
             } catch (UnknownHostException e) {
index f5ef9be5dea61ca7cb7e8af190fc6886699a62cc..b679902d379915abf3bdc006b1efc5cee6cd065a 100644 (file)
@@ -73,12 +73,17 @@ public class NeutronL3Adapter implements ConfigInterface {
     private volatile GatewayMacResolver gatewayMacResolver;
 
     private class FloatIpData {
-        private final Long dpid;          // br-int of node where floating ip is associated with tenant port
-        private final Long ofPort;        // patch port in br-int used to reach br-ex
-        private final String segId;       // segmentation id of the net where fixed ip is instantiated
-        private final String macAddress;  // mac address assigned to neutron port of floating ip
+        // br-int of node where floating ip is associated with tenant port
+        private final Long dpid;
+        // patch port in br-int used to reach br-ex
+        private final Long ofPort;
+        // segmentation id of the net where fixed ip is instantiated
+        private final String segId;
+        // mac address assigned to neutron port of floating ip
+        private final String macAddress;
         private final String floatingIpAddress;
-        private final String fixedIpAddress;  // ip address given to tenant vm
+        // ip address given to tenant vm
+        private final String fixedIpAddress;
         private final String neutronRouterMac;
 
         FloatIpData(final Long dpid, final Long ofPort, final String segId, final String macAddress,
@@ -212,14 +217,12 @@ public class NeutronL3Adapter implements ConfigInterface {
             }else{
                 NeutronNetwork externalNetwork = neutronNetworkCache.getNetwork(neutronPort.getNetworkUUID());
 
-                if(externalNetwork != null){
-                    if(externalNetwork.isRouterExternal()){
-                        final NeutronSubnet externalSubnet = getExternalNetworkSubnet(neutronPort);
-                        // TODO support IPv6
-                        if (externalSubnet != null &&
+                if (externalNetwork != null && externalNetwork.isRouterExternal()) {
+                    final NeutronSubnet externalSubnet = getExternalNetworkSubnet(neutronPort);
+                    // TODO support IPv6
+                    if (externalSubnet != null &&
                             externalSubnet.getIpVersion() == 4) {
-                            gatewayMacResolver.stopPeriodicRefresh(new Ipv4Address(externalSubnet.getGatewayIP()));
-                        }
+                        gatewayMacResolver.stopPeriodicRefresh(new Ipv4Address(externalSubnet.getGatewayIP()));
                     }
                 }
             }
@@ -234,7 +237,8 @@ public class NeutronL3Adapter implements ConfigInterface {
             for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) {
                 NeutronRouter_Interface neutronRouterInterface =
                         new NeutronRouter_Interface(neutronIP.getSubnetUUID(), neutronPort.getPortUUID());
-                neutronRouterInterface.setID(neutronIP.getSubnetUUID());  // id of router interface to be same as subnet
+                // id of router interface to be same as subnet
+                neutronRouterInterface.setID(neutronIP.getSubnetUUID());
                 neutronRouterInterface.setTenantID(neutronPort.getTenantID());
 
                 this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action);
@@ -245,14 +249,12 @@ public class NeutronL3Adapter implements ConfigInterface {
             // need to do this check here because a router interface is not added to a node until tenant becomes needed
             // there.
             //
-            if (!isDelete) {
-                if (neutronPort.getFixedIPs() != null) {
-                    for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) {
-                        NeutronRouter_Interface neutronRouterInterface =
+            if (!isDelete && neutronPort.getFixedIPs() != null) {
+                for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) {
+                    NeutronRouter_Interface neutronRouterInterface =
                             subnetIdToRouterInterfaceCache.get(neutronIP.getSubnetUUID());
-                        if (neutronRouterInterface != null) {
-                            this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action);
-                        }
+                    if (neutronRouterInterface != null) {
+                        this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action);
                     }
                 }
             }
@@ -345,7 +347,8 @@ public class NeutronL3Adapter implements ConfigInterface {
         // this.programFlowsForFloatingIP(neutronFloatingIP, action == Action.DELETE);
 
         if (action != Action.DELETE) {
-            programFlowsForFloatingIPArpAdd(neutronFloatingIP);  // must be first, as it updates floatIpDataMapCache
+            // must be first, as it updates floatIpDataMapCache
+            programFlowsForFloatingIPArpAdd(neutronFloatingIP);
 
             programFlowsForFloatingIPInbound(neutronFloatingIP, Action.ADD);
             programFlowsForFloatingIPOutbound(neutronFloatingIP, Action.ADD);
@@ -353,7 +356,8 @@ public class NeutronL3Adapter implements ConfigInterface {
             programFlowsForFloatingIPOutbound(neutronFloatingIP, Action.DELETE);
             programFlowsForFloatingIPInbound(neutronFloatingIP, Action.DELETE);
 
-            programFlowsForFloatingIPArpDelete(neutronFloatingIP.getID()); // must be last, as it updates floatIpDataMapCache
+            // must be last, as it updates floatIpDataMapCache
+            programFlowsForFloatingIPArpDelete(neutronFloatingIP.getID());
         }
     }
 
@@ -654,14 +658,14 @@ public class NeutronL3Adapter implements ConfigInterface {
         // will look at desired action for node.
 
         final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + ipStr;
-        final Boolean isProgrammed = l3ForwardingCache.contains(cacheKey);
+        final boolean isProgrammed = l3ForwardingCache.contains(cacheKey);
 
-        if (actionForNode == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (actionForNode == Action.DELETE && !isProgrammed) {
             LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done",
                          node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode);
             return;
         }
-        if (actionForNode == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (actionForNode == Action.ADD && isProgrammed) {
             LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done",
                     node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode);
             return;
@@ -914,16 +918,16 @@ public class NeutronL3Adapter implements ConfigInterface {
         final String cacheKey = node.getNodeId().getValue() + ":" +
                                 sourceSegmentationId + ":" + destinationSegmentationId + ":" +
                                 ipStr + "/" + Integer.toString(mask);
-        final Boolean isProgrammed = routerInterfacesCache.contains(cacheKey);
+        final boolean isProgrammed = routerInterfacesCache.contains(cacheKey);
 
-        if (actionForNode == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (actionForNode == Action.DELETE && !isProgrammed) {
             LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
                          " action {} is already done",
                          node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId,
                          macAddress, ipStr, mask, actionForNode);
             return;
         }
-        if (actionForNode == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (actionForNode == Action.ADD && isProgrammed) {
             LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" +
                          " action {} is already done",
                          node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId,
@@ -981,14 +985,14 @@ public class NeutronL3Adapter implements ConfigInterface {
         // will look at desired action for node.
         //
         final String cacheKey = dpid + ":" + segOrOfPort + ":" + ipStr;
-        final Boolean isProgrammed = staticArpEntryCache.contains(cacheKey);
+        final boolean isProgrammed = staticArpEntryCache.contains(cacheKey);
 
-        if (action == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (action == Action.DELETE && !isProgrammed) {
             LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done",
                     dpid, segOrOfPort, macAddress, ipStr, action);
             return true;
         }
-        if (action == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (action == Action.ADD && isProgrammed) {
             LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done",
                     dpid, segOrOfPort, macAddress, ipStr, action);
             return true;
@@ -1041,15 +1045,15 @@ public class NeutronL3Adapter implements ConfigInterface {
         // will look at desired action for node.
         //
         final String cacheKey = dpid + ":" + inboundOFPort + ":" + providerSegmentationId + ":" + matchAddress;
-        final Boolean isProgrammed = inboundIpRewriteCache.contains(cacheKey);
+        final boolean isProgrammed = inboundIpRewriteCache.contains(cacheKey);
 
-        if (action == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (action == Action.DELETE && !isProgrammed) {
             LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
                     " action {} is already done",
                     dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action);
             return true;
         }
-        if (action == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (action == Action.ADD && isProgrammed) {
             LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" +
                     " action is already done",
                     dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action);
@@ -1106,14 +1110,14 @@ public class NeutronL3Adapter implements ConfigInterface {
         // will look at desired action for node.
         //
         final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + cidr;
-        final Boolean isProgrammed = outboundIpRewriteExclusionCache.contains(cacheKey);
+        final boolean isProgrammed = outboundIpRewriteExclusionCache.contains(cacheKey);
 
-        if (actionForRewriteExclusion == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (actionForRewriteExclusion == Action.DELETE && !isProgrammed) {
             LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done",
                          node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion);
             return;
         }
-        if (actionForRewriteExclusion == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (actionForRewriteExclusion == Action.ADD && isProgrammed) {
             LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done",
                          node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion);
             return;
@@ -1153,15 +1157,15 @@ public class NeutronL3Adapter implements ConfigInterface {
         // will look at desired action for node.
         //
         final String cacheKey = fid.dpid + ":" + fid.segId + ":" + fid.fixedIpAddress;
-        final Boolean isProgrammed = outboundIpRewriteCache.contains(cacheKey);
+        final boolean isProgrammed = outboundIpRewriteCache.contains(cacheKey);
 
-        if (action == Action.DELETE && isProgrammed == Boolean.FALSE) {
+        if (action == Action.DELETE && !isProgrammed) {
             LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " +
                          "is already done",
                     fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action);
             return;
         }
-        if (action == Action.ADD && isProgrammed == Boolean.TRUE) {
+        if (action == Action.ADD && isProgrammed) {
             LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " +
                          "is already done",
                     fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action);
index 284074d936f6c66cce757b9ef263f4c918041a28..efad7fca4db2eb449d2b1b27e050dbef2ba69ebe 100644 (file)
@@ -197,18 +197,16 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
                                                                                 Constants.EXTERNAL_ID_INTERFACE_ID);
                         if (null != portId) {
                             NeutronPort port = neutronPortCache.getPort(portId);
-                            if (null != port) {
-                                if (!(port.getID().equals(neutronPort.getID()))
-                                        && port.getDeviceOwner().contains("compute")) {
-                                    List<Neutron_IPs> portFixedIp = port.getFixedIPs();
-                                    if (null == portFixedIp || portFixedIp.isEmpty()) {
-                                        return false;
-                                    }
-                                    if (portFixedIp.iterator().next().getSubnetUUID()
-                                            .equals(neutronPort.getFixedIPs().iterator().next().getSubnetUUID())) {
-                                        LOG.trace("isLastPortinSubnet: Port is not the only port.");
-                                        return false;
-                                    }
+                            if (null != port && !(port.getID().equals(neutronPort.getID()))
+                                    && port.getDeviceOwner().contains("compute")) {
+                                List<Neutron_IPs> portFixedIp = port.getFixedIPs();
+                                if (null == portFixedIp || portFixedIp.isEmpty()) {
+                                    return false;
+                                }
+                                if (portFixedIp.iterator().next().getSubnetUUID()
+                                        .equals(neutronPort.getFixedIPs().iterator().next().getSubnetUUID())) {
+                                    LOG.trace("isLastPortinSubnet: Port is not the only port.");
+                                    return false;
                                 }
                             }
                         }
@@ -231,14 +229,13 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
             for (TerminationPoint tp : terminationPoints) {
                 OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
                         tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
-                if (null != ovsdbTerminationPointAugmentation) {
-                    if (!(ovsdbTerminationPointAugmentation.getName().equals(Constants.INTEGRATION_BRIDGE))
-                            && !(terminationPointAugmentation.getInterfaceUuid()
-                                    .equals(ovsdbTerminationPointAugmentation.getInterfaceUuid()))) {
-                        LOG.debug("isLastPortinBridge: it the last port in bridge {}",
-                                  terminationPointAugmentation.getName());
-                        return false;
-                    }
+                if (null != ovsdbTerminationPointAugmentation
+                        && !(ovsdbTerminationPointAugmentation.getName().equals(Constants.INTEGRATION_BRIDGE))
+                        && !(terminationPointAugmentation.getInterfaceUuid()
+                        .equals(ovsdbTerminationPointAugmentation.getInterfaceUuid()))) {
+                    LOG.debug("isLastPortinBridge: it the last port in bridge {}",
+                            terminationPointAugmentation.getName());
+                    return false;
                 }
             }
         }