General Sonar clean-up 32/24532/5
authorStephen Kitt <skitt@redhat.com>
Fri, 24 Jul 2015 14:07:50 +0000 (16:07 +0200)
committerSam Hague <shague@redhat.com>
Thu, 6 Aug 2015 15:21:03 +0000 (15:21 +0000)
Return simplification in a number of places:
* drop useless return at the end of void methods (unless it comes before
  commented code)
* simplify return ... ? true : false
* simplify variable declaration immediately followed by return

Drop unused local variables, and move some declarations closer to first
use (in particular when there's a redundant initialisation value).

Drop unused fields where it's safe to do so; in particular,
OvsdbClientImpl's exceptions were never initialised so we can even drop
the corresponding getter.

Drop unnecessary casts and use the Java 7 <> operator as appropriate.

Use primary types instead of wrappers where appropriate (dpid,
openFlowPort).

Drop redundant final modifiers on static methods.

Drop redundant .toString() calls.

Use .parseInt(), .parseShort() etc. instead of .decode().

Drop a few dead methods.

Avoid calling new String() explicitly.

Drive-by cleaning:
* AbstractHandler:
  - switch instead of multiple ifs
* BridgeConfigurationManagerImpl, ConfigurationServiceImpl:
  - rework getControllerIPAddress() to loop over the configuration
    properties
  - in getNormalizedRow(), avoid rebuilding the array every time we go
    through the loop
* ConfigurationServiceImpl:
  - in getTunnelEndPoint(), trace the tunnel endpoint only if we get
    one (avoids a NPE)
* EgressAclService, IngressAclService:
  - srcIpPrefix only makes sense if securityRuleIpPrefix != null, so
    move into the corresponding block

Change-Id: I7ca2a1a37f4795b3c0141b2b3a00977a15ffa5dd
Signed-off-by: Stephen Kitt <skitt@redhat.com>
34 files changed:
library/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbClientImpl.java
library/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java
library/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcServiceBinderHandler.java
library/src/main/java/org/opendaylight/ovsdb/lib/schema/ColumnType.java
library/src/main/java/org/opendaylight/ovsdb/lib/schema/DatabaseSchema.java
library/src/main/java/org/opendaylight/ovsdb/lib/schema/TableSchema.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbNorthboundV2.java
northbound/src/test/java/org/opendaylight/ovsdb/northbound/NodeResourceTest.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.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/ClassifierService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L2ForwardingService.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/FWaasHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSPoolHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/LBaaSPoolMemberHandler.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/PortSecurityHandler.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/api/UuidUtils.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/NodeCacheManagerImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/VlanConfigurationCacheImpl.java
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/internal/Activator.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConnectionServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/InventoryServiceImpl.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java
utils/mdsal-node/src/main/java/org/opendaylight/ovsdb/utils/mdsal/node/NodeUtils.java
utils/mdsal-openflow/src/main/java/org/opendaylight/ovsdb/utils/mdsal/openflow/InstructionUtils.java

index ef58d1e32401f3eac30d5678dcd8861fd7ddd44f..b1855e74b59ff64a4ab3a07fdbdeae728e282562 100644 (file)
@@ -11,11 +11,9 @@ package org.opendaylight.ovsdb.lib.impl;
 
 import io.netty.channel.Channel;
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Queue;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -49,7 +47,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableMap;
@@ -66,12 +63,10 @@ public class OvsdbClientImpl implements OvsdbClient {
     private ExecutorService executorService;
     private OvsdbRPC rpc;
     private Map<String, DatabaseSchema> schema = Maps.newHashMap();
-    private HashMap<String, CallbackContext> monitorCallbacks = Maps.newHashMap();
-    private Queue<Throwable> exceptions;
+    private Map<String, CallbackContext> monitorCallbacks = Maps.newHashMap();
     private OvsdbRPC.Callback rpcCallback;
     private OvsdbConnectionInfo connectionInfo;
     private Channel channel;
-    private static final ObjectMapper objectMapper = new ObjectMapper();
 
     public OvsdbClientImpl(OvsdbRPC rpc, Channel channel, ConnectionType type, ExecutorService executorService) {
         this.rpc = rpc;
@@ -176,8 +171,7 @@ public class OvsdbClientImpl implements OvsdbClient {
         } catch (InterruptedException | ExecutionException e) {
             return null;
         }
-        TableUpdates updates = transformingCallback(result, dbSchema);
-        return updates;
+        return transformingCallback(result, dbSchema);
     }
 
     private void registerCallback(MonitorHandle monitorHandle, MonitorCallBack callback, DatabaseSchema schema) {
@@ -301,10 +295,6 @@ public class OvsdbClientImpl implements OvsdbClient {
         this.rpc = rpc;
     }
 
-    public Queue<Throwable> getExceptions() {
-        return exceptions;
-    }
-
     static class CallbackContext {
         MonitorCallBack monitorCallBack;
         DatabaseSchema schema;
index 56dcb84198242c6029316fa63f360e307f3b5af1..853bdd374bcb506ee90ac223623d70acdf00e871 100644 (file)
@@ -14,7 +14,6 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufInputStream;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
-import io.netty.handler.codec.TooLongFrameException;
 
 import java.io.IOException;
 import java.util.List;
@@ -140,7 +139,6 @@ public class JsonRpcDecoder extends ByteToMessageDecoder {
         // end of stream, save the incomplete record index to avoid reexamining the whole on next run
         if (index >= buf.writerIndex()) {
             lastRecordBytes = buf.readableBytes();
-            return;
         }
     }
 
@@ -159,33 +157,4 @@ public class JsonRpcDecoder extends ByteToMessageDecoder {
         }
     }
 
-
-    private void print(ByteBuf buf, String message) {
-        print(buf, buf.readerIndex(), buf.readableBytes(), message == null ? "buff" : message);
-    }
-
-    private void print(ByteBuf buf, int startPos, int chars, String message) {
-        if (null == message) {
-            message = "";
-        }
-        if (startPos > buf.writerIndex()) {
-            LOG.trace("startPos out of bounds");
-        }
-        byte[] bytes = new byte[startPos + chars <= buf.writerIndex() ? chars : buf.writerIndex() - startPos];
-        buf.getBytes(startPos, bytes);
-        LOG.trace("{} ={}", message, new String(bytes));
-    }
-
-    // copied from Netty decoder
-    private void fail(ChannelHandlerContext ctx, long frameLength) {
-        if (frameLength > 0) {
-            ctx.fireExceptionCaught(
-                    new TooLongFrameException(
-                            "frame length exceeds " + maxFrameLength + ": " + frameLength + " - discarded"));
-        } else {
-            ctx.fireExceptionCaught(
-                    new TooLongFrameException(
-                            "frame length exceeds " + maxFrameLength + " - discarding"));
-        }
-    }
 }
index 7a96757fbae9655077006561bb99f5227eb3cb79..8363dc616a2d74f982f0c189fc2fdf61ff2097d4 100644 (file)
@@ -12,22 +12,14 @@ package org.opendaylight.ovsdb.lib.jsonrpc;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.SettableFuture;
 
 public class JsonRpcServiceBinderHandler extends ChannelInboundHandlerAdapter {
     private static final Logger LOG = LoggerFactory.getLogger(JsonRpcServiceBinderHandler.class);
-    Map<Object, SettableFuture<Object>> waitingForReply = Maps.newHashMap();
-    ExecutorService executorService = Executors.newFixedThreadPool(10);
     JsonRpcEndpoint factory = null;
     Object context = null;
 
index 2f76fdcbcc444fd84442b100f67742b008d8842a..a0d59dc2e972f79214c11aa8f9c041b78935549d 100644 (file)
@@ -180,7 +180,7 @@ public abstract class ColumnType {
 
                 AtomicColumnType atomicColumnType = new AtomicColumnType(baseType);
 
-                JsonNode node = null;
+                JsonNode node;
                 if ((node = json.get("min")) != null) {
                     atomicColumnType.setMin(node.asLong());
                 }
@@ -201,7 +201,7 @@ public abstract class ColumnType {
         @Override
         public Object valueFromJson(JsonNode value) {
             if (isMultiValued()) {
-                OvsdbSet<Object> result = new OvsdbSet<Object>();
+                OvsdbSet<Object> result = new OvsdbSet<>();
                 if (value.isArray()) {
                     if (value.size() == 2) {
                         if (value.get(0).isTextual() && "set".equals(value.get(0).asText())) {
@@ -252,7 +252,7 @@ public abstract class ColumnType {
             BaseType valueType = BaseType.fromJson(json, "value");
 
             KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(keyType, valueType);
-            JsonNode node = null;
+            JsonNode node;
             if ((node = json.get("min")) != null) {
                 keyValueColumnType.setMin(node.asLong());
             }
@@ -273,7 +273,7 @@ public abstract class ColumnType {
             if (node.isArray()) {
                 if (node.size() == 2) {
                     if (node.get(0).isTextual() && "map".equals(node.get(0).asText())) {
-                        OvsdbMap<Object, Object> map = new OvsdbMap<Object, Object>();
+                        OvsdbMap<Object, Object> map = new OvsdbMap<>();
                         for (JsonNode pairNode : node.get(1)) {
                             if (pairNode.isArray() && node.size() == 2) {
                                 Object key = getKeyType().toValue(pairNode.get(0));
index 83f28b70099770761b3f5073bc6f9b17a0b28767..e4943030c3874564fc8fb8e3fced8c16b81c9024 100644 (file)
@@ -64,7 +64,7 @@ public class DatabaseSchema {
     }
 
     protected <E extends TableSchema<E>> E createTableSchema(Class<E> clazz, TableSchema<E> table) {
-        Constructor<E> declaredConstructor = null;
+        Constructor<E> declaredConstructor;
         try {
             declaredConstructor = clazz.getDeclaredConstructor(TableSchema.class);
         } catch (NoSuchMethodException e) {
index 0008de02c4cd19e2de59ed1aa0a3a5f142af1ec2..066756bd78c24487ab8a8c338ce10d47549aafea 100644 (file)
@@ -80,7 +80,7 @@ public abstract class TableSchema<E extends TableSchema<E>> {
     public <D> ColumnSchema<E, Set<D>> multiValuedColumn(String column, Class<D> type) {
         //todo exception handling
 
-        ColumnSchema columnSchema = columns.get(column);
+        ColumnSchema<E, Set<D>> columnSchema = columns.get(column);
         columnSchema.validateType(type);
         return columnSchema;
     }
@@ -88,7 +88,7 @@ public abstract class TableSchema<E extends TableSchema<E>> {
     public <K,V> ColumnSchema<E, Map<K,V>> multiValuedColumn(String column, Class<K> keyType, Class<V> valueType) {
         //todo exception handling
 
-        ColumnSchema columnSchema = columns.get(column);
+        ColumnSchema<E, Map<K, V>> columnSchema = columns.get(column);
         columnSchema.validateType(valueType);
         return columnSchema;
     }
@@ -96,7 +96,7 @@ public abstract class TableSchema<E extends TableSchema<E>> {
     public <D> ColumnSchema<E, D> column(String column, Class<D> type) {
         //todo exception handling
 
-        ColumnSchema columnSchema = columns.get(column);
+        ColumnSchema<E, D> columnSchema = columns.get(column);
         if (columnSchema != null) {
             columnSchema.validateType(type);
         }
index ec7b7b1708cb97d8cffd0cb7572cd98cb184965a..3dfd2ea945b0817d21fb44b6667bdf1c6943d798 100644 (file)
@@ -32,7 +32,6 @@ import org.codehaus.enunciate.jaxrs.StatusCodes;
 import org.codehaus.enunciate.jaxrs.TypeHint;
 import org.opendaylight.controller.northbound.commons.RestMessages;
 import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
@@ -86,18 +85,6 @@ public class OvsdbNorthboundV2 {
         return username;
     }
 
-    private void handleNameMismatch(String name, String nameinURL) {
-        if (name == null || nameinURL == null) {
-            throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Name is null");
-        }
-
-        if (name.equalsIgnoreCase(nameinURL)) {
-            return;
-        }
-        throw new ResourceConflictException(RestMessages.INVALIDDATA.toString()
-                + " : Table Name in URL does not match the row name in request body");
-    }
-
     /**
      * Create a Row for Open_vSwitch schema
      *
@@ -430,7 +417,7 @@ public class OvsdbNorthboundV2 {
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
 
-        Row row = null;
+        Row row;
         try {
             row = ovsdbTable.getRow(node, bckCompatibleTableName, rowUuid);
         } catch (Exception e) {
@@ -512,7 +499,7 @@ public class OvsdbNorthboundV2 {
         Node node = connectionService.getNode(nodeId);
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
-        Map<String, Row> rows = null;
+        Map<String, Row> rows;
         try {
             rows = ovsdbTable.getRows(node, bckCompatibleTableName);
         } catch (Exception e) {
@@ -593,7 +580,7 @@ public class OvsdbNorthboundV2 {
             return Response.status(Response.Status.BAD_REQUEST).build();
         }
 
-        Status status = ovsdbTable.updateRow(node, bckCompatibleTableName, localRow.getParentUuid(), rowUuid, localRow.getRow());
+        ovsdbTable.updateRow(node, bckCompatibleTableName, localRow.getParentUuid(), rowUuid, localRow.getRow());
         return NorthboundUtils.getResponse(
                 new org.opendaylight.controller.sal.utils.Status(
                         org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
index c9b032f3d377ff3f4cd008b099a41149d613cfb7..872a30589b7724e521ac4d7f792c75c2287f9702 100644 (file)
@@ -56,22 +56,21 @@ public class NodeResourceTest {
                 .thenReturn(connectionService)
                 .thenReturn(connectionService);
 
-        Node node = null;
         try {
-            node = NodeResource.getOvsdbNode(IDENTIFIER, this);
+            NodeResource.getOvsdbNode(IDENTIFIER, this);
             fail("Expected an ServiceUnavailableException to be thrown");
         } catch (ServiceUnavailableException e) {
             assertSame(ServiceUnavailableException.class, e.getClass());
         }
 
         try {
-            node = NodeResource.getOvsdbNode(BAD_IDENTIFIER, this);
+            NodeResource.getOvsdbNode(BAD_IDENTIFIER, this);
             fail("Expected an ResourceNotFoundException to be thrown");
         } catch (ResourceNotFoundException e) {
             assertSame(ResourceNotFoundException.class, e.getClass());
         }
 
-        node = NodeResource.getOvsdbNode(OVS_IDENTIFIER, this);
+        Node node = NodeResource.getOvsdbNode(OVS_IDENTIFIER, this);
         assertNotNull("Node " + OVS_IDENTIFIER + " is null", node);
     }
 
@@ -87,22 +86,21 @@ public class NodeResourceTest {
                 .thenReturn(connectionService)
                 .thenReturn(connectionService);
 
-        Connection testConnection = null;
         try {
-            testConnection = NodeResource.getOvsdbConnection(IDENTIFIER, this);
+            NodeResource.getOvsdbConnection(IDENTIFIER, this);
             fail("Expected an ServiceUnavailableException to be thrown");
         } catch (ServiceUnavailableException e) {
             assertSame(ServiceUnavailableException.class, e.getClass());
         }
 
         try {
-            testConnection = NodeResource.getOvsdbConnection(BAD_IDENTIFIER, this);
+            NodeResource.getOvsdbConnection(BAD_IDENTIFIER, this);
             fail("Expected an ResourceNotFoundException to be thrown");
         } catch (ResourceNotFoundException e) {
             assertSame(ResourceNotFoundException.class, e.getClass());
         }
 
-        testConnection = NodeResource.getOvsdbConnection(IDENTIFIER, this);
+        Connection testConnection = NodeResource.getOvsdbConnection(IDENTIFIER, this);
         assertNotNull("Connection " + OVS_IDENTIFIER + " is null", testConnection);
     }
 
@@ -123,7 +121,7 @@ public class NodeResourceTest {
             Response response = nodeResource.getNodes();
             assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
             assertNotNull("entity should not be null", response.getEntity());
-            String id = new String();
+            String id = "";
             List<String> ids = Lists.newArrayList();
             ids.add(id);
             assertEquals("there should be no nodes", ids.toString(), response.getEntity());
@@ -139,7 +137,7 @@ public class NodeResourceTest {
             Response response = nodeResource.getNodes();
             assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
             assertNotNull("entity should not be null", response.getEntity());
-            String id = new String("\"" + OVS_IDENTIFIER + "\"");
+            String id = "\"" + OVS_IDENTIFIER + "\"";
             List<String> ids = Lists.newArrayList();
             ids.add(id);
             assertEquals(OVS_IDENTIFIER + " should be found", ids.toString(), response.getEntity());
@@ -155,8 +153,8 @@ public class NodeResourceTest {
             Response response = nodeResource.getNodes();
             assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
             assertNotNull("entity should not be null", response.getEntity());
-            String id = new String("\"" + OVS_IDENTIFIER + "\"");
-            String id2 = new String("\"" + OVS_IDENTIFIER2 + "\"");
+            String id = "\"" + OVS_IDENTIFIER + "\"";
+            String id2 = "\"" + OVS_IDENTIFIER2 + "\"";
             List<String> ids = Lists.newArrayList();
             ids.add(id);
             ids.add(id2);
index 48f5d5cf3874325ebcd2edb2b56c142c14080a2f..64c0f4075557cfb4bc9c96f1e4cc2a82199c24e6 100644 (file)
@@ -84,10 +84,7 @@ public abstract class AbstractServiceInstance {
 
     public boolean isBridgeInPipeline (Node node){
         String bridgeName = southbound.getBridgeName(node);
-        if (bridgeName != null && Constants.INTEGRATION_BRIDGE.equals(bridgeName)) {
-            return true;
-        }
-        return false;
+        return bridgeName != null && Constants.INTEGRATION_BRIDGE.equals(bridgeName);
     }
 
     public short getTable() {
@@ -109,7 +106,7 @@ public abstract class AbstractServiceInstance {
         return builder;
     }
 
-    private static final InstanceIdentifier<Flow> createFlowPath(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
+    private static InstanceIdentifier<Flow> createFlowPath(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
         return InstanceIdentifier.builder(Nodes.class)
                 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
                         nodeBuilder.getKey())
@@ -118,8 +115,7 @@ public abstract class AbstractServiceInstance {
                 .child(Flow.class, flowBuilder.getKey()).build();
     }
 
-    private static final
-    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
+    private static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node>
     createNodePath(NodeBuilder nodeBuilder) {
         return InstanceIdentifier.builder(Nodes.class)
                 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
@@ -210,9 +206,8 @@ public abstract class AbstractServiceInstance {
         return null;
     }
 
-    private Long getDpid(Node node) {
-        Long dpid = 0L;
-        dpid = southbound.getDataPathId(node);
+    private long getDpid(Node node) {
+        long dpid = southbound.getDataPathId(node);
         if (dpid == 0) {
             LOG.warn("getDpid: dpid not found: {}", node);
         }
@@ -231,7 +226,7 @@ public abstract class AbstractServiceInstance {
         }
         MatchBuilder matchBuilder = new MatchBuilder();
         FlowBuilder flowBuilder = new FlowBuilder();
-        Long dpid = getDpid(node);
+        long dpid = getDpid(node);
         if (dpid == 0L) {
             LOG.info("could not find dpid: {}", node.getNodeId());
             return;
index 1ced2a5f1bb64f292b4b33f7802a63deb88242af..cf73055242ccde70824fd6e3f022f531b1089eb0 100644 (file)
@@ -52,7 +52,7 @@ public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListe
 
     public PipelineOrchestratorImpl() {
         eventHandler = Executors.newSingleThreadExecutor();
-        this.queue = new LinkedBlockingQueue<Node>();
+        this.queue = new LinkedBlockingQueue<>();
         LOG.info("PipelineOrchestratorImpl constructor");
         start();
     }
index 0fe2d306c1ae6dde86c4f740b1e1f97a0563505a..594e08311917c93b731fe03107f6dd21e866e30a 100644 (file)
@@ -362,14 +362,13 @@ public class ClassifierService extends AbstractServiceInstance implements Classi
 
         if (write) {
             // Create the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
 
             // Instructions List Stores Individual Instructions
             List<Instruction> instructions = Lists.newArrayList();
 
             // Append the default pipeline after the first classification
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
index b270afbe3d6a44ffc6304d0f9900d187a3e0970c..bff14d28ab66bf40d549002cf74f386115f8e965 100644 (file)
@@ -10,8 +10,6 @@
 package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.services;
 
 import java.math.BigInteger;
-import java.net.InetAddress;
-import java.util.Iterator;
 import java.util.List;
 
 import org.opendaylight.neutron.spi.NeutronSecurityGroup;
@@ -320,11 +318,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -371,11 +368,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -394,7 +390,6 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                                         boolean write, String securityRuleIpPrefix, Integer protoPortMatchPriority) {
 
         String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
-        Ipv4Prefix srcIpPrefix = new Ipv4Prefix(securityRuleIpPrefix);
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
@@ -402,6 +397,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
         flowBuilder.setMatch(MatchUtils.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId))
                                      .build());
         if (securityRuleIpPrefix != null) {
+            Ipv4Prefix srcIpPrefix = new Ipv4Prefix(securityRuleIpPrefix);
             flowBuilder.setMatch(MatchUtils
                                          .createSmacIpTcpSynMatch(matchBuilder, new MacAddress(attachedMac), null, srcIpPrefix)
                                          .build());
@@ -427,11 +423,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -475,11 +470,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -526,11 +520,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -635,11 +628,10 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
index b70754843cd2084c42ea5c6ac302c56a698b0ef3..6e256811373e51f60957687806fe9d24ea0374e0 100644 (file)
@@ -245,11 +245,10 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -297,11 +296,10 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
 
             List<Instruction> instructionsList = Lists.newArrayList();
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -347,11 +345,10 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(1);
             ib.setKey(new InstructionKey(1));
             instructionsList.add(ib.build());
@@ -420,7 +417,6 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
             boolean write, String securityRuleIpPrefix, Integer protoPortMatchPriority) {
 
         String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
-        Ipv4Prefix srcIpPrefix = new Ipv4Prefix(securityRuleIpPrefix);
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
@@ -428,6 +424,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
         flowBuilder.setMatch(MatchUtils.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId))
                 .build());
         if (securityRuleIpPrefix != null) {
+            Ipv4Prefix srcIpPrefix = new Ipv4Prefix(securityRuleIpPrefix);
             flowBuilder.setMatch(MatchUtils
                     .createDmacIpTcpSynMatch(matchBuilder, new MacAddress(attachedMac), null, srcIpPrefix)
                     .build());
@@ -454,11 +451,10 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(1);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
@@ -507,11 +503,10 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
             List<Instruction> instructionsList = Lists.newArrayList();
 
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructionsList.add(ib.build());
index 0703c6527a0d756dd9fdafb4441406e7966af2e5..f5289eb49e9f87c4020e4853a8c57169fc364171 100644 (file)
@@ -348,7 +348,7 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
 
         List<Instruction> instructions = Lists.newArrayList();
         InstructionBuilder ib = new InstructionBuilder();
-        List<Action> actionList = null;
+        List<Action> actionList;
         if (write) {
             if (existingInstructions == null) {
                 /* First time called there should be no instructions.
@@ -375,7 +375,6 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
                 actionList.add(ab.build());
             } else {
                 /* Subsequent calls require appending any new local ports for this tenant. */
-                ApplyActionsCase aac = (ApplyActionsCase) ib.getInstruction();
                 Instruction in = existingInstructions.get(0);
                 actionList = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
 
@@ -448,7 +447,6 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
         boolean removeFlow = true;
 
         if (instructions != null) {
-            ApplyActionsCase aac = (ApplyActionsCase) ib.getInstruction();
             Instruction in = instructions.get(0);
             List<Action> oldActionList = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
             NodeConnectorId ncid = new NodeConnectorId(OPENFLOW + dpidLong + ":" + localPort);
@@ -464,7 +462,7 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
                     OutputActionCase opAction = (OutputActionCase) action.getAction();
                     if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncidEth))) {
                         actionList.add(action);
-                    } else if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid)) == false) {
+                    } else if (!opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid))) {
                         ab.setAction(action.getAction());
                         ab.setOrder(index);
                         ab.setKey(new ActionKey(index));
@@ -480,7 +478,7 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         }
 
-        if (actionList != null && actionList.size() > 2) {
+        if (actionList.size() > 2) {
             // Add InstructionBuilder to the Instruction(s)Builder List
             InstructionsBuilder isb = new InstructionsBuilder();
             isb.setInstruction(instructions);
@@ -898,14 +896,13 @@ public class L2ForwardingService extends AbstractServiceInstance implements Conf
 
         if (write) {
             // Create the OF Actions and Instructions
-            InstructionBuilder ib = new InstructionBuilder();
             InstructionsBuilder isb = new InstructionsBuilder();
 
             // Instructions List Stores Individual Instructions
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            ib = this.getMutablePipelineInstructionBuilder();
+            InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
index 80ebc43b9101509fd781a6aa2d2b33199ddd965c..94c42f4f02639e06818e1d7bf5704449e851e98a 100644 (file)
@@ -37,28 +37,25 @@ public abstract class AbstractHandler {
      * @param status  manager status
      * @return  An error to be returned to neutron API service.
      */
-    protected static final int getException(Status status) {
-        int result = HttpURLConnection.HTTP_INTERNAL_ERROR;
-
+    protected static int getException(Status status) {
         assert !status.isSuccess();
 
         StatusCode code = status.getCode();
         LOG.debug(" Exception code - {}, description - {}",
                 code, status.getDescription());
 
-        if (code == StatusCode.BADREQUEST) {
-            result = HttpURLConnection.HTTP_BAD_REQUEST;
-        } else if (code == StatusCode.CONFLICT) {
-            result = HttpURLConnection.HTTP_CONFLICT;
-        } else if (code == StatusCode.NOTACCEPTABLE) {
-            result = HttpURLConnection.HTTP_NOT_ACCEPTABLE;
-        } else if (code == StatusCode.NOTFOUND) {
-            result = HttpURLConnection.HTTP_NOT_FOUND;
-        } else {
-            result = HttpURLConnection.HTTP_INTERNAL_ERROR;
+        switch(code) {
+            case BADREQUEST:
+                return HttpURLConnection.HTTP_BAD_REQUEST;
+            case CONFLICT:
+                return HttpURLConnection.HTTP_CONFLICT;
+            case NOTACCEPTABLE:
+                return HttpURLConnection.HTTP_NOT_ACCEPTABLE;
+            case NOTFOUND:
+                return HttpURLConnection.HTTP_NOT_FOUND;
+            default:
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
         }
-
-        return result;
     }
 
     /**
index ed2c004d5079b4c45d2f2c2fd8eaa6bf8c5ec6c8..886bc847408ac393d997817ab584ba3e24d31c2b 100644 (file)
@@ -48,12 +48,10 @@ public class FWaasHandler extends AbstractHandler
     @Override
     public void neutronFirewallCreated(NeutronFirewall neutronFirewall) {
         LOG.debug("Neutron Firewall created by Neutron: {}", neutronFirewall);
-        int result = HttpURLConnection.HTTP_BAD_REQUEST;
 
-        result = canCreateNeutronFirewall(neutronFirewall);
+        int result = canCreateNeutronFirewall(neutronFirewall);
         if (result != HttpURLConnection.HTTP_CREATED) {
             LOG.error("Neutron Firewall creation failed: {} ", result);
-            return;
         }
     }
 
@@ -65,7 +63,6 @@ public class FWaasHandler extends AbstractHandler
     @Override
     public void neutronFirewallUpdated(NeutronFirewall neutronFirewall) {
         LOG.debug("NeutronFirewall updated from Neutron: {}", neutronFirewall);
-        return;
     }
 
     @Override
@@ -79,7 +76,6 @@ public class FWaasHandler extends AbstractHandler
         int result = canDeleteNeutronFirewall(neutronFirewall);
         if  (result != HttpURLConnection.HTTP_OK) {
             LOG.error(" delete Neutron Firewall validation failed for result - {} ", result);
-            return;
         }
     }
 
@@ -99,12 +95,9 @@ public class FWaasHandler extends AbstractHandler
     public void neutronFirewallRuleCreated(NeutronFirewallRule neutronFirewallRule) {
         LOG.debug("NeutronFirewallRule created by Neutron: {}", neutronFirewallRule);
 
-        int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
-        result = canCreateNeutronFirewallRule(neutronFirewallRule);
+        int result = canCreateNeutronFirewallRule(neutronFirewallRule);
         if (result != HttpURLConnection.HTTP_CREATED) {
             LOG.error("Neutron Firewall Rule creation failed {} ", result);
-            return;
         }
     }
 
@@ -116,7 +109,6 @@ public class FWaasHandler extends AbstractHandler
     @Override
     public void neutronFirewallRuleUpdated(NeutronFirewallRule neutronFirewallRule) {
         LOG.debug("Neutron Firewall Rule updated from Neutron: {}", neutronFirewallRule);
-        return;
     }
 
     @Override
@@ -129,7 +121,6 @@ public class FWaasHandler extends AbstractHandler
         int result = canDeleteNeutronFirewallRule(neutronFirewallRule);
         if  (result != HttpURLConnection.HTTP_OK) {
             LOG.error(" delete Neutron Firewall Rule validation failed for result - {} ", result);
-            return;
         }
     }
 
@@ -149,12 +140,9 @@ public class FWaasHandler extends AbstractHandler
     public void neutronFirewallPolicyCreated(NeutronFirewallPolicy neutronFirewallPolicy) {
         LOG.debug("Neutron Firewall Policy created by Neutron: {}", neutronFirewallPolicy);
 
-        int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
-        result = canCreateNeutronFirewallPolicy(neutronFirewallPolicy);
+        int result = canCreateNeutronFirewallPolicy(neutronFirewallPolicy);
         if (result != HttpURLConnection.HTTP_CREATED) {
             LOG.debug("Neutron Firewall Policy creation failed: {} ", result);
-            return;
         }
     }
 
@@ -166,7 +154,6 @@ public class FWaasHandler extends AbstractHandler
     @Override
     public void neutronFirewallPolicyUpdated(NeutronFirewallPolicy neutronFirewallPolicy) {
         LOG.debug("Neutron Firewall Policy updated from Neutron: {}", neutronFirewallPolicy);
-        return;
     }
 
     @Override
@@ -179,7 +166,6 @@ public class FWaasHandler extends AbstractHandler
         int result = canDeleteNeutronFirewallPolicy(neutronFirewallPolicy);
         if  (result != HttpURLConnection.HTTP_OK) {
             LOG.error(" delete Neutron Firewall Policy validation failed for result - {} ", result);
-            return;
         }
     }
 
index f77d6f88b359ae2a8036383bb15eff0db90bdfb5..c7b45694aac0f414e56dbc40ed7a6cda20714525 100644 (file)
@@ -183,13 +183,9 @@ public class LBaaSHandler extends AbstractHandler
         }
         lbConfig.setVmac(NeutronCacheUtils.getMacAddress(neutronPortCache, loadBalancerSubnetID, loadBalancerVip));
 
-        String memberID, memberIP, memberMAC, memberProtocol, memberSubnetID;
-        Integer memberPort;
-        Boolean memberAdminStateIsUp;
-
         for (NeutronLoadBalancerPool neutronLBPool: neutronLBPoolCache.getAllNeutronLoadBalancerPools()) {
             List<NeutronLoadBalancerPoolMember> members = neutronLBPool.getLoadBalancerPoolMembers();
-            memberProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
+            String memberProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
             if (memberProtocol == null) {
                 continue;
             }
@@ -200,20 +196,18 @@ public class LBaaSHandler extends AbstractHandler
                 continue;
             }
             for (NeutronLoadBalancerPoolMember neutronLBPoolMember: members) {
-                memberAdminStateIsUp = neutronLBPoolMember.getPoolMemberAdminStateIsUp();
-                memberSubnetID = neutronLBPoolMember.getPoolMemberSubnetID();
-                if (memberSubnetID == null || memberAdminStateIsUp == null) {
-                    continue;
-                }
-                else if (memberSubnetID.equals(loadBalancerSubnetID) && memberAdminStateIsUp.booleanValue()) {
-                    memberID = neutronLBPoolMember.getPoolMemberID();
-                    memberIP = neutronLBPoolMember.getPoolMemberAddress();
-                    memberPort = neutronLBPoolMember.getPoolMemberProtoPort();
-                    if (memberSubnetID == null || memberID == null || memberIP == null || memberPort == null) {
+                Boolean memberAdminStateIsUp = neutronLBPoolMember.getPoolMemberAdminStateIsUp();
+                String memberSubnetID = neutronLBPoolMember.getPoolMemberSubnetID();
+                if (memberSubnetID != null && memberAdminStateIsUp != null &&
+                        memberSubnetID.equals(loadBalancerSubnetID) && memberAdminStateIsUp) {
+                    String memberID = neutronLBPoolMember.getPoolMemberID();
+                    String memberIP = neutronLBPoolMember.getPoolMemberAddress();
+                    Integer memberPort = neutronLBPoolMember.getPoolMemberProtoPort();
+                    if (memberID == null || memberIP == null || memberPort == null) {
                         LOG.debug("Neutron LB pool member details incomplete: {}", neutronLBPoolMember);
                         continue;
                     }
-                    memberMAC = NeutronCacheUtils.getMacAddress(neutronPortCache, memberSubnetID, memberIP);
+                    String memberMAC = NeutronCacheUtils.getMacAddress(neutronPortCache, memberSubnetID, memberIP);
                     if (memberMAC == null) {
                         continue;
                     }
@@ -249,8 +243,6 @@ public class LBaaSHandler extends AbstractHandler
                 */
 
                  //(type.equals(UpdateType.REMOVED) || type.equals(UpdateType.CHANGED))
-               } else {
-                   continue;
                }
             }
         }
index 9f8c70647919a5fb1cb04e71dc1cacfe33996506..66493fa788d38781474363a3f13416fbd1f144b0 100755 (executable)
@@ -217,11 +217,10 @@ public class LBaaSPoolHandler extends AbstractHandler
 
         /* Iterate over all the Loadbalancers created so far and identify VIP
          */
-        String loadBalancerSubnetID, loadBalancerVip=null, loadBalancerName=null;
         for (NeutronLoadBalancer neutronLB: neutronLBCache.getAllNeutronLoadBalancers()) {
-            loadBalancerSubnetID = neutronLB.getLoadBalancerVipSubnetID();
-            loadBalancerName = neutronLB.getLoadBalancerName();
-            loadBalancerVip = neutronLB.getLoadBalancerVipAddress();
+            String loadBalancerSubnetID = neutronLB.getLoadBalancerVipSubnetID();
+            String loadBalancerName = neutronLB.getLoadBalancerName();
+            String loadBalancerVip = neutronLB.getLoadBalancerVipAddress();
 
             LoadBalancerConfiguration lbConfig = new LoadBalancerConfiguration(loadBalancerName, loadBalancerVip);
             Map.Entry<String,String> providerInfo = NeutronCacheUtils.getProviderInformation(neutronNetworkCache, neutronSubnetCache, loadBalancerSubnetID);
@@ -240,13 +239,12 @@ public class LBaaSPoolHandler extends AbstractHandler
             for (NeutronLoadBalancerPoolMember neutronLBPoolMember: neutronLBPool.getLoadBalancerPoolMembers()) {
                 memberAdminStateIsUp = neutronLBPoolMember.getPoolMemberAdminStateIsUp();
                 memberSubnetID = neutronLBPoolMember.getPoolMemberSubnetID();
-                if (memberSubnetID == null || memberAdminStateIsUp == null) {
-                    continue;
-                } else if (memberSubnetID.equals(loadBalancerSubnetID) && memberAdminStateIsUp.booleanValue()) {
+                if (memberSubnetID != null && memberAdminStateIsUp != null &&
+                        memberSubnetID.equals(loadBalancerSubnetID) && memberAdminStateIsUp) {
                     memberID = neutronLBPoolMember.getPoolMemberID();
                     memberIP = neutronLBPoolMember.getPoolMemberAddress();
                     memberPort = neutronLBPoolMember.getPoolMemberProtoPort();
-                    if (memberSubnetID == null || memberID == null || memberIP == null || memberPort == null) {
+                    if (memberID == null || memberIP == null || memberPort == null) {
                         LOG.debug("Neutron LB pool member details incomplete: {}", neutronLBPoolMember);
                         continue;
                     }
index 8b8752bbed07d82835638e67b918ccb1e758d0a5..bd8ad0d17804849ffc5bbde148e9d313dac8ca41 100755 (executable)
@@ -199,7 +199,6 @@ public class LBaaSPoolMemberHandler extends AbstractHandler
         String memberSubnetID = neutronLBPoolMember.getPoolMemberSubnetID();
         Integer memberPort = neutronLBPoolMember.getPoolMemberProtoPort();
         String memberPoolID = neutronLBPoolMember.getPoolID();
-        String memberProtocol = null;
 
         if (memberSubnetID == null || memberID == null || memberPoolID == null) {
             LOG.debug("Neutron LB pool member details incomplete [id={}, pool_id={},subnet_id={}",
@@ -212,7 +211,7 @@ public class LBaaSPoolMemberHandler extends AbstractHandler
             return null;
         }
         NeutronLoadBalancerPool neutronLBPool = neutronLBPoolCache.getNeutronLoadBalancerPool(memberPoolID);
-        memberProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
+        String memberProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
         if (!(memberProtocol.equalsIgnoreCase(LoadBalancerConfiguration.PROTOCOL_TCP) ||
                 memberProtocol.equalsIgnoreCase(LoadBalancerConfiguration.PROTOCOL_HTTP) ||
                 memberProtocol.equalsIgnoreCase(LoadBalancerConfiguration.PROTOCOL_HTTPS))) {
@@ -259,9 +258,8 @@ public class LBaaSPoolMemberHandler extends AbstractHandler
             otherMemberPort = otherMember.getPoolMemberProtoPort();
             otherMemberProtocol = memberProtocol;
 
-            if (otherMemberIP == null || otherMemberSubnetID == null || otherMemberAdminStateIsUp == null) {
-                continue;
-            } else if (otherMemberAdminStateIsUp.booleanValue()) {
+            if (otherMemberIP != null && otherMemberSubnetID != null && otherMemberAdminStateIsUp != null &&
+                    otherMemberAdminStateIsUp) {
                 otherMemberMAC = NeutronCacheUtils.getMacAddress(neutronPortCache, otherMemberSubnetID, otherMemberIP);
                 if (otherMemberMAC == null) {
                     continue;
index 85fe8ebd759bb9c0bb88fd4fa7eff88c6ce76e00..20c552e43c10b08dcb0039a1c19f14033fb06233 100644 (file)
@@ -38,12 +38,9 @@ public class PortSecurityHandler extends AbstractHandler
 
     @Override
     public void neutronSecurityGroupCreated(NeutronSecurityGroup neutronSecurityGroup) {
-        int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
-        result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
+        int result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
         if (result != HttpURLConnection.HTTP_CREATED) {
             LOG.debug("Neutron Security Group creation failed {} ", result);
-            return;
         }
     }
 
@@ -54,7 +51,7 @@ public class PortSecurityHandler extends AbstractHandler
 
     @Override
     public void neutronSecurityGroupUpdated(NeutronSecurityGroup neutronSecurityGroup) {
-        return;
+        // Nothing to do
     }
 
     @Override
@@ -68,7 +65,6 @@ public class PortSecurityHandler extends AbstractHandler
         int result = canDeleteNeutronSecurityGroup(neutronSecurityGroup);
         if  (result != HttpURLConnection.HTTP_OK) {
             LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
-            return;
         }
     }
 
@@ -87,12 +83,9 @@ public class PortSecurityHandler extends AbstractHandler
 
     @Override
     public void neutronSecurityRuleCreated(NeutronSecurityRule neutronSecurityRule) {
-        int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
-        result = canCreateNeutronSecurityRule(neutronSecurityRule);
+        int result = canCreateNeutronSecurityRule(neutronSecurityRule);
         if (result != HttpURLConnection.HTTP_CREATED) {
             LOG.debug("Neutron Security Group creation failed {} ", result);
-            return;
         }
     }
 
@@ -103,7 +96,7 @@ public class PortSecurityHandler extends AbstractHandler
 
     @Override
     public void neutronSecurityRuleUpdated(NeutronSecurityRule neutronSecurityRule) {
-        return;
+        // Nothing to do
     }
 
     @Override
@@ -116,7 +109,6 @@ public class PortSecurityHandler extends AbstractHandler
         int result = canDeleteNeutronSecurityRule(neutronSecurityRule);
         if  (result != HttpURLConnection.HTTP_OK) {
             LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
-            return;
         }
     }
 
index 9318b3e7c7f624f932522c28b82676a77c100474..71087adfae7b1b40e89b87d4ef800397d21c2e3d 100644 (file)
@@ -127,7 +127,7 @@ public class SouthboundHandler extends AbstractHandler
     private void processPortDelete(Node node, OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation,
                                    Object context) {
         LOG.debug("processPortDelete <{}> <{}>", node, ovsdbTerminationPointAugmentation);
-        NeutronNetwork network = null;
+        NeutronNetwork network;
         if (context == null) {
             network = tenantNetworkManager.getTenantNetwork(ovsdbTerminationPointAugmentation);
         } else {
@@ -336,28 +336,6 @@ public class SouthboundHandler extends AbstractHandler
         }
     }
 
-    private boolean isMainBridge(Node node, OvsdbBridgeAugmentation bridge) {
-        boolean rv = false;
-        String nodeIdStr = node.getNodeId().getValue();
-        String bridgeName = nodeIdStr.substring(nodeIdStr.lastIndexOf('/') + 1);
-        List<TerminationPoint> terminationPoints = southbound.extractTerminationPoints(node);
-        if (terminationPoints != null && terminationPoints.size() == 1) {
-            // TODO: Either do something or remove this if statement.
-            // If there's only one termination point, is it a 1-port bridge?
-        }
-        OvsdbTerminationPointAugmentation port = southbound.extractTerminationPointAugmentation(node, bridgeName);
-        if (port != null) {
-            String datapathId = southbound.getDatapathId(bridge);
-            // Having a datapathId means the ovsdb node has connected to ODL
-            if (datapathId != null) {
-                rv = true;
-            } else {
-                LOG.info("datapathId not found");
-            }
-        }
-        return rv;
-    }
-
     private void processBridgeCreate(Node node, OvsdbBridgeAugmentation bridge) {
         LOG.debug("processBridgeCreate <{}> <{}>", node, bridge);
         String datapathId = southbound.getDatapathId(bridge);
index 2c4415a53971e48db3a4253c5a3021b07280d5f7..63c8fa32b3eeaddbd3c752d1b2d3199ca54ea8d1 100644 (file)
@@ -68,6 +68,13 @@ public final class UuidUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(UuidUtils.class);
 
+    /**
+     * Private constructor (utility class).
+     */
+    private UuidUtils() {
+        // Nothing to do
+    }
+
     /**
      * Convert neutron object id to  key syntax.
      *
index 12e94f2c1605dd31b8fbfe207623636f04ceb57f..2cfcaf3237cb9df979d80b0b8dbbc8e8898a78f2 100644 (file)
@@ -240,7 +240,6 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     @Override
     public List<String> getAllPhysicalInterfaceNames(Node node) {
         List<String> phyIfName = Lists.newArrayList();
-        String phyIf = null;
         String providerMaps = southbound.getOtherConfig(node, OvsdbTables.OPENVSWITCH,
                 configurationService.getProviderMappingsKey());
         if (providerMaps == null) {
@@ -494,12 +493,11 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
     }
 
     private short getControllerOFPort() {
-        Short defaultOpenFlowPort = Constants.OPENFLOW_PORT;
-        Short openFlowPort = defaultOpenFlowPort;
+        short openFlowPort = Constants.OPENFLOW_PORT;
         String portString = ConfigProperties.getProperty(this.getClass(), "of.listenPort");
         if (portString != null) {
             try {
-                openFlowPort = Short.decode(portString).shortValue();
+                openFlowPort = Short.parseShort(portString);
             } catch (NumberFormatException e) {
                 LOG.warn("Invalid port:{}, use default({})", portString,
                         openFlowPort);
@@ -510,13 +508,12 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
 
     private String getControllerTarget(Node node) {
         String setControllerStr = null;
-        String controllerIpStr = null;
         short openflowPort = Constants.OPENFLOW_PORT;
         //Look at user configuration.
         //TODO: In case we move to config subsystem to expose these user facing parameter,
         // we will have to modify this code.
 
-        controllerIpStr = getControllerIPAddress();
+        String controllerIpStr = getControllerIPAddress();
 
         if(controllerIpStr == null){
             // Check if ovsdb node has connection info
@@ -551,10 +548,10 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
         String ipaddress = null;
         try{
             for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();ifaces.hasMoreElements();){
-                NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
+                NetworkInterface iface = ifaces.nextElement();
 
                 for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
-                    InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
+                    InetAddress inetAddr = inetAddrs.nextElement();
                     if (!inetAddr.isLoopbackAddress() && inetAddr.isSiteLocalAddress()) {
                         ipaddress = inetAddr.getHostAddress();
                         break;
index 52c1e7778c6a931c3a4fdf2118c768daa0b05684..10e17b4b69aa700dc2f2af4f9ce534f30b91d491 100644 (file)
@@ -182,9 +182,6 @@ public class NeutronL3Adapter implements ConfigInterface {
      */
     public void handleNeutronSubnetEvent(final NeutronSubnet subnet, Action action) {
         LOG.debug("Neutron subnet {} event : {}", action, subnet.toString());
-        if (!this.enabled) {
-            return;
-        }
     }
 
     /**
@@ -268,9 +265,6 @@ public class NeutronL3Adapter implements ConfigInterface {
      */
     public void handleNeutronRouterEvent(final NeutronRouter neutronRouter, Action action) {
         LOG.debug("Neutron router {} event : {}", action, neutronRouter.toString());
-        if (!this.enabled) {
-            return;
-        }
     }
 
     /**
@@ -489,7 +483,7 @@ public class NeutronL3Adapter implements ConfigInterface {
         }
     }
 
-    private final NeutronPort findNeutronPortForFloatingIp(final String floatingIpUuid) {
+    private NeutronPort findNeutronPortForFloatingIp(final String floatingIpUuid) {
         for (NeutronPort neutronPort : neutronPortCache.getAllPorts()) {
             if (neutronPort.getDeviceOwner().equals(OWNER_FLOATING_IP) &&
                     neutronPort.getDeviceID().equals(floatingIpUuid)) {
@@ -499,7 +493,7 @@ public class NeutronL3Adapter implements ConfigInterface {
         return null;
     }
 
-    private final Long findOFPortForExtPatch(Long dpId) {
+    private Long findOFPortForExtPatch(Long dpId) {
         final String brInt = configurationService.getIntegrationBridgeName();
         final String brExt = configurationService.getExternalBridgeName();
         final String portNameInt = configurationService.getPatchPortName(new ImmutablePair<>(brInt, brExt));
@@ -507,7 +501,7 @@ public class NeutronL3Adapter implements ConfigInterface {
         Preconditions.checkNotNull(dpId);
         Preconditions.checkNotNull(portNameInt);
 
-        final long dpidPrimitive = dpId.longValue();
+        final long dpidPrimitive = dpId;
         for (Node node : nodeCacheManager.getBridgeNodes()) {
             if (dpidPrimitive == southbound.getDataPathId(node)) {
                 final OvsdbTerminationPointAugmentation terminationPointOfBridge =
@@ -526,9 +520,6 @@ public class NeutronL3Adapter implements ConfigInterface {
      */
     public void handleNeutronNetworkEvent(final NeutronNetwork neutronNetwork, Action action) {
         LOG.debug("neutronNetwork {}: network: {}", action, neutronNetwork);
-        if (!this.enabled) {
-            return;
-        }
     }
 
     //
@@ -646,7 +637,7 @@ public class NeutronL3Adapter implements ConfigInterface {
                 programL3ForwardingStage1(node, dpid, providerSegmentationId, tenantMac, tenantIpStr, action);
 
                 // Configure distributed ARP responder
-                if (true == flgDistributedARPEnabled) {
+                if (flgDistributedARPEnabled) {
                     programStaticArpStage1(dpid, providerSegmentationId, tenantMac, tenantIpStr, action);
                 }
             }
@@ -725,7 +716,6 @@ public class NeutronL3Adapter implements ConfigInterface {
                                               neutronNetworkCache.getNetwork(subnet.getNetworkUUID()) : null;
         final String destinationSegmentationId = neutronNetwork != null ?
                                                  neutronNetwork.getProviderSegmentationID() : null;
-        final String gatewayIp = subnet != null ? subnet.getGatewayIP() : null;
         final Boolean isExternal = neutronNetwork != null ? neutronNetwork.getRouterExternal() : Boolean.TRUE;
         final String cidr = subnet != null ? subnet.getCidr() : null;
         final int mask = getMaskLenFromCidr(cidr);
index 1db75d31aaa7250503048b26447c07fc2eb26641..b6b36a57cf1fb0921baf526a3f05407d77905d81 100644 (file)
@@ -135,7 +135,7 @@ public class NodeCacheManagerImpl extends AbstractHandler implements NodeCacheMa
 
     @Override
     public Map<NodeId,Node> getOvsdbNodes() {
-        Map<NodeId,Node> ovsdbNodesMap = new ConcurrentHashMap<NodeId,Node>();
+        Map<NodeId,Node> ovsdbNodesMap = new ConcurrentHashMap<>();
         for (Map.Entry<NodeId, Node> ovsdbNodeEntry : nodeCache.entrySet()) {
             if (southbound.extractOvsdbNode(ovsdbNodeEntry.getValue()) != null) {
                 ovsdbNodesMap.put(ovsdbNodeEntry.getKey(), ovsdbNodeEntry.getValue());
index 1082a8ff5169da681239ea2a62b11d057caff10e..ed6e22fa740453ac3d02a0d15b4533c397ee154c 100644 (file)
@@ -23,8 +23,6 @@ import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
@@ -68,8 +66,6 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
                     neutronPortId);
             return false;
         }
-        String vmPort = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
-                Constants.EXTERNAL_ID_VM_MAC);
         LOG.debug("Security Group Check {} DOES contain a Neutron Security Group", neutronPortId);
         return true;
     }
@@ -98,8 +94,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
 
         List<NeutronSecurityGroup> neutronSecurityGroups = neutronPort.getSecurityGroups();
         if (neutronSecurityGroups != null) {
-            NeutronSecurityGroup neutronSecurityGroup = (NeutronSecurityGroup) neutronSecurityGroups.toArray()[0];
-            return neutronSecurityGroup;
+            return (NeutronSecurityGroup) neutronSecurityGroups.toArray()[0];
         } else {
             return null;
         }
@@ -247,8 +242,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
             return null;
         }
         NeutronPort neutronPort = neutronPortCache.getPort(neutronPortId);
-        List<Neutron_IPs> fixedIps = neutronPort.getFixedIPs();
-        return fixedIps;
+        return neutronPort.getFixedIPs();
     }
 
     @Override
index 70141a20e43273cb3612dcf3d5e761912642139f..a9b97af6e8e7a4b2000ffd0138b0eb0c58b0715e 100644 (file)
@@ -53,12 +53,10 @@ public class VlanConfigurationCacheImpl implements ConfigInterface, VlanConfigur
 
     private void initializeNodeConfiguration(Node node, String nodeUuid) {
         NodeConfiguration nodeConfiguration = new NodeConfiguration();
-        Integer vlan = 0;
-        String networkId = null;
         List<OvsdbTerminationPointAugmentation> ports = southbound.getTerminationPointsOfBridge(node);
         for (OvsdbTerminationPointAugmentation port : ports) {
-            vlan = port.getVlanTag().getValue();
-            networkId = tenantNetworkManager.getTenantNetwork(port).getNetworkUUID();
+            Integer vlan = port.getVlanTag().getValue();
+            String networkId = tenantNetworkManager.getTenantNetwork(port).getNetworkUUID();
             if (vlan != 0 && networkId != null) {
                 internalVlanInUse(nodeConfiguration, vlan);
                 nodeConfiguration.getTenantVlanMap().put(networkId, vlan);
index 5b4f1635ff4411bb09fd735ce2c45cfd3da50d21..bec2632a8d3054abf55d18e0ae4f7d3d53f5ae17 100644 (file)
@@ -50,15 +50,14 @@ public class Activator extends ComponentActivatorAbstractBase {
     }
     @Override
     public Object[] getGlobalImplementations() {
-        Object[] res = { ConnectionServiceImpl.class, ConfigurationServiceImpl.class, InventoryServiceImpl.class };
-        return res;
+        return new Object[]{ ConnectionServiceImpl.class, ConfigurationServiceImpl.class, InventoryServiceImpl.class };
     }
 
     @Override
     public void configureGlobalInstance(Component c, Object imp){
         if (imp.equals(ConfigurationServiceImpl.class)) {
             // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            Dictionary<String, Object> props = new Hashtable<>();
             c.setInterface(new String[] { OvsdbConfigurationService.class.getName()}, props);
             c.add(createServiceDependency()
                     .setService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService.class)
@@ -68,7 +67,7 @@ public class Activator extends ComponentActivatorAbstractBase {
 
         if (imp.equals(ConnectionServiceImpl.class)) {
             // export the service to be used by SAL
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            Dictionary<String, Object> props = new Hashtable<>();
             c.setInterface(
                     new String[] {OvsdbConnectionService.class.getName()}, props);
             c.add(createServiceDependency()
index 8a8c3d5e948e3844e983d79ea4ebad5cf6e07458..f0a887fb7b38c90afb0c3ce7e41a936fc34c2d23 100644 (file)
@@ -253,7 +253,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     @Deprecated
     public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Row row) {
         String databaseName = OvsVswitchdSchemaConstants.DATABASE_NAME;
-        Row<GenericTableSchema> updatedRow = this.updateRow(node, databaseName, tableName, new UUID(rowUUID), row, true);
+        this.updateRow(node, databaseName, tableName, new UUID(rowUUID), row, true);
         return new StatusWithUuid(StatusCode.SUCCESS);
     }
 
@@ -320,8 +320,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     @Override
     @Deprecated
     public ConcurrentMap<String, Row> getRows(Node node, String tableName) {
-        ConcurrentMap<String, Row> ovsTable = ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME,  tableName);
-        return ovsTable;
+        return ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
     }
 
     @Override
@@ -379,12 +378,11 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     }
 
     private short getControllerOFPort() {
-        Short defaultOpenFlowPort = 6633;
-        Short openFlowPort = defaultOpenFlowPort;
+        short openFlowPort = (short) 6633;
         String portString = ConfigProperties.getProperty(this.getClass(), "of.listenPort");
         if (portString != null) {
             try {
-                openFlowPort = Short.decode(portString).shortValue();
+                openFlowPort = Short.parseShort(portString);
             } catch (NumberFormatException e) {
                 LOG.warn("Invalid port:{}, use default({})", portString,
                         openFlowPort);
@@ -445,8 +443,8 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
             return updateOperationStatus.isSuccess();
         }
 
-        Status status = null;
-        UUID currControllerUuid = null;
+        Status status;
+        UUID currControllerUuid;
         InetAddress ofControllerAddr = this.getControllerIPAddress(connection);
         short ofControllerPort = getControllerOFPort();
         String newControllerTarget = "tcp:"+ofControllerAddr.getHostAddress()+":"+ofControllerPort;
@@ -464,11 +462,8 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
             status = this.insertRow(node, controllerTableName, bridgeUUID, newController.getRow());
         }
 
-        if (status != null) {
-            return status.isSuccess();
-        }
+        return status != null && status.isSuccess();
 
-        return false;
     }
 
 
@@ -716,7 +711,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
             }
             for (OperationResult result : operationResults) {
                 if (result.getError() != null) {
-                    throw new OvsdbPluginException("Insert Operation Failed with Error : "+result.getError().toString());
+                    throw new OvsdbPluginException("Insert Operation Failed with Error : " + result.getError());
                 }
             }
             return getNormalizedRow(dbSchema, tableName, row, referencedRows, operationResults, referencedRowsInsertIndex);
@@ -776,14 +771,14 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
                         DatabaseSchema dbSchema = client.getSchema(dbName).get();
                         GenericTableSchema schema = dbSchema.table(refRowObject.getRefTable(), GenericTableSchema.class);
                         Row<GenericTableSchema> refRow = schema.createRow((ObjectNode)refRowObject.getJsonNode());
-                        referencedRows.put(refUuid, new AbstractMap.SimpleEntry<String, Row<GenericTableSchema>>(refRowObject.getRefTable(), refRow));
+                        referencedRows.put(refUuid, new AbstractMap.SimpleEntry<>(refRowObject.getRefTable(), refRow));
                         extractReferencedRows(node, dbName, refRow, referencedRows, namedUuidSuffix);
                     } catch (InterruptedException | ExecutionException e) {
                         LOG.error("Exception while extracting multi-level Row references " + e.getLocalizedMessage());
                     }
                 } else if (column.getData() instanceof OvsdbSet) {
                     OvsdbSet<Object> setObject = (OvsdbSet<Object>)column.getData();
-                    OvsdbSet<Object> modifiedSet = new OvsdbSet<Object>();
+                    OvsdbSet<Object> modifiedSet = new OvsdbSet<>();
                     for (Object obj : setObject) {
                         if (obj instanceof ReferencedRow) {
                             ReferencedRow refRowObject = (ReferencedRow)obj;
@@ -793,7 +788,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
                                 DatabaseSchema dbSchema = client.getSchema(dbName).get();
                                 GenericTableSchema schema = dbSchema.table(refRowObject.getRefTable(), GenericTableSchema.class);
                                 Row<GenericTableSchema> refRow = schema.createRow((ObjectNode)refRowObject.getJsonNode());
-                                referencedRows.put(refUuid, new AbstractMap.SimpleEntry<String, Row<GenericTableSchema>>(refRowObject.getRefTable(), refRow));
+                                referencedRows.put(refUuid, new AbstractMap.SimpleEntry<>(refRowObject.getRefTable(), refRow));
                                 extractReferencedRows(node, dbName, refRow, referencedRows, namedUuidSuffix);
                             } catch (InterruptedException | ExecutionException e) {
                                 LOG.error("Exception while extracting multi-level Row references " + e.getLocalizedMessage());
@@ -829,24 +824,23 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
         TableSchema<GenericTableSchema> primaryRowTableSchema = dbSchema.table(tableName, GenericTableSchema.class);
         ColumnSchema<GenericTableSchema, UUID> uuid = primaryRowTableSchema.column("_uuid", UUID.class);
         if (uuid != null) {
-            Column<GenericTableSchema, UUID> uuidColumn = new Column<GenericTableSchema, UUID>(uuid, primaryRowUuid);
+            Column<GenericTableSchema, UUID> uuidColumn = new Column<>(uuid, primaryRowUuid);
             row.addColumn("_uuid", uuidColumn);
         }
 
         if (referencedRows != null) {
             Collection<Column<GenericTableSchema, ?>> columns = row.getColumns();
-            if (referencedRows != null) {
-                for (int idx=0; idx < referencedRows.keySet().size(); idx++) {
-                    UUID refUuid = (UUID) referencedRows.keySet().toArray()[idx];
-                    for (Column column : columns) {
-                        if (column.getData() != null) {
-                            if ((column.getData() instanceof UUID) && column.getData().equals(refUuid)) {
-                                column.setData(operationResults.get(referencedRowsInsertIndex + idx).getUuid());
-                            } else if ((column.getData() instanceof OvsdbSet) && ((OvsdbSet)column.getData()).contains(refUuid)) {
-                                OvsdbSet<UUID> refSet = (OvsdbSet<UUID>)column.getData();
-                                refSet.remove(refUuid);
-                                refSet.add(operationResults.get(referencedRowsInsertIndex + idx).getUuid());
-                            }
+            Object[] rowKeys = referencedRows.keySet().toArray();
+            for (int idx = 0; idx < rowKeys.length; idx++) {
+                UUID refUuid = (UUID) rowKeys[idx];
+                for (Column column : columns) {
+                    if (column.getData() != null) {
+                        if ((column.getData() instanceof UUID) && column.getData().equals(refUuid)) {
+                            column.setData(operationResults.get(referencedRowsInsertIndex + idx).getUuid());
+                        } else if ((column.getData() instanceof OvsdbSet) && ((OvsdbSet)column.getData()).contains(refUuid)) {
+                            OvsdbSet<UUID> refSet = (OvsdbSet<UUID>)column.getData();
+                            refSet.remove(refUuid);
+                            refSet.add(operationResults.get(referencedRowsInsertIndex + idx).getUuid());
                         }
                     }
                 }
@@ -925,7 +919,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
             }
             for (OperationResult result : operationResults) {
                 if (result.getError() != null) {
-                    throw new OvsdbPluginException("Delete Operation Failed with Error : "+result.getError().toString());
+                    throw new OvsdbPluginException("Delete Operation Failed with Error : " + result.getError());
                 }
             }
         } catch (InterruptedException | ExecutionException e) {
@@ -974,7 +968,7 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
         if (cache == null) {
             return null;
         } else {
-            return new ArrayList<String>(cache.keySet());
+            return new ArrayList<>(cache.keySet());
         }
     }
 }
index 25d5b843ec592e08f33556067e0c8291c1d610ef..a09175824a7d07569c83540993ec566100be1687 100644 (file)
@@ -99,7 +99,7 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
         String portString = ConfigProperties.getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
         int ovsdbListenPort = DEFAULT_OVSDB_PORT;
         if (portString != null) {
-            ovsdbListenPort = Integer.decode(portString).intValue();
+            ovsdbListenPort = Integer.parseInt(portString);
         }
 
         if (!connectionLib.startOvsdbManager(ovsdbListenPort)) {
@@ -204,7 +204,7 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
 
     @Override
     public List<Node> getNodes() {
-        List<Node> nodes = new ArrayList<Node>();
+        List<Node> nodes = new ArrayList<>();
         for (Connection connection : ovsdbConnections.values()) {
             nodes.add(connection.getNode());
         }
index 4766ad45d8a01f7cdbf7208b62435a746095dbd6..0ed62386552e8820614865baf2b506865de4f0f5 100644 (file)
@@ -149,7 +149,7 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
             for (UUID uuid : (Set<UUID>)update.getRows().keySet()) {
 
             if (update.getNew(uuid) != null) {
-                boolean isNewRow = (tCache == null || tCache.get(uuid.toString()) == null) ? true : false;
+                boolean isNewRow = (tCache == null || tCache.get(uuid.toString()) == null);
                 db.updateRow(databaseName, tableName, uuid.toString(), update.getNew(uuid));
                 if (isNewRow) {
                     this.handleOpenVSwitchSpecialCase(n, databaseName, tableName, uuid);
index 084c903ad5a2175cf17ad1def3bfc2b18a7bc07f..dc8bd53c94b9b40627c08cabfcfe6a5a26bed0c6 100644 (file)
@@ -129,7 +129,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
     private void setNewOtherConfigs(OvsdbNodeAugmentationBuilder ovsdbNodeBuilder,
             Map<String, String> otherConfigs) {
         Set<String> otherConfigKeys = otherConfigs.keySet();
-        List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<OpenvswitchOtherConfigs>();
+        List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
         String otherConfigValue;
         for (String otherConfigKey : otherConfigKeys) {
             otherConfigValue = otherConfigs.get(otherConfigKey);
@@ -178,7 +178,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
     private void setNewExternalIds(OvsdbNodeAugmentationBuilder ovsdbNodeBuilder,
             Map<String, String> externalIds) {
         Set<String> externalIdKeys = externalIds.keySet();
-        List<OpenvswitchExternalIds> externalIdsList = new ArrayList<OpenvswitchExternalIds>();
+        List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
         String externalIdValue;
         for (String externalIdKey : externalIdKeys) {
             externalIdValue = externalIds.get(externalIdKey);
@@ -195,7 +195,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
             OpenVSwitch openVSwitch) {
         try {
             Set<String> iftypes = openVSwitch.getIfaceTypesColumn().getData();
-            List<InterfaceTypeEntry> ifEntryList = new ArrayList<InterfaceTypeEntry>();
+            List<InterfaceTypeEntry> ifEntryList = new ArrayList<>();
             for (String ifType : iftypes) {
                 if (SouthboundMapper.createInterfaceType(ifType) != null) {
                     InterfaceTypeEntry ifEntry = new InterfaceTypeEntryBuilder()
@@ -209,7 +209,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
             }
             ovsdbNodeBuilder.setInterfaceTypeEntry(ifEntryList);
         } catch (SchemaVersionMismatchException e) {
-            LOG.debug("Iface types  not supported by this version of ovsdb",e);;
+            LOG.debug("Iface types  not supported by this version of ovsdb",e);
         }
     }
 
@@ -219,7 +219,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
         try {
             Set<String> dptypes = openVSwitch.getDatapathTypesColumn()
                     .getData();
-            List<DatapathTypeEntry> dpEntryList = new ArrayList<DatapathTypeEntry>();
+            List<DatapathTypeEntry> dpEntryList = new ArrayList<>();
             for (String dpType : dptypes) {
                 if (SouthboundMapper.createDatapathType(dpType) != null) {
                     DatapathTypeEntry dpEntry = new DatapathTypeEntryBuilder()
index 11d1f727fb819b519b00b9e422017fccaea66a81..a338487704b5d5bbd3299a6700569701cb434ca9 100644 (file)
@@ -29,11 +29,10 @@ public class NodeUtils {
     public static Node getOpenFlowNode (String identifier) {
         NodeId nodeId = new NodeId(identifier);
         NodeKey nodeKey = new NodeKey(nodeId);
-        Node node = new NodeBuilder()
+
+        return new NodeBuilder()
                 .setId(nodeId)
                 .setKey(nodeKey)
                 .build();
-
-        return node;
     }
 }
index 18d4a9b94c98c7d3724ce0a19c838ae36408fbff..39cef222f42e0929e7418ccc6c83f2e83c677c28 100644 (file)
@@ -316,8 +316,8 @@ public class InstructionUtils {
             // If port we are asked to delete is not found, this implementation will leave actions
             // alone and not remove the flow, as long as a remaining OutputActionCase is found.
             //
-            for (int i = 0; i < actionList.size(); i++) {
-                if (actionList.get(i).getAction() instanceof OutputActionCase) {
+            for (Action action : actionList) {
+                if (action.getAction() instanceof OutputActionCase) {
                     removeFlow = false;
                     break;
                 }