Fix issues related to checkstyle compliance in module mdsalutil-impl 83/52683/4
authorDavid <david.suarez.fuentes@ericsson.com>
Thu, 2 Mar 2017 23:33:46 +0000 (00:33 +0100)
committerDavid <david.suarez.fuentes@ericsson.com>
Mon, 6 Mar 2017 19:09:08 +0000 (20:09 +0100)
Fix issues related to checkstyle compliance in module
mdsalutil-impl:
- Copyright sections
- Line lengths
- Order imports
- Formatting
- Declaration of constants: name, modifiers
- Rename variables
- Exception catching
- Move declaration of variables closer to their use
- Remove unused variables
- Enforcement in pom.xml

There is more cleanup to be done, apart from checkstyle, I'll rise a
separate commit.

Change-Id: I91848d2ca07e404787489c15040dfa8983594692
Signed-off-by: David <david.suarez.fuentes@ericsson.com>
mdsalutil/mdsalutil-impl/pom.xml
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/genius/mdsalutil/internal/FlowBatchingUtils.java
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/genius/mdsalutil/internal/MDSALManager.java
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/genius/mdsalutil/internal/MdSalUtilBatchHandler.java
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/genius/mdsalutil/internal/NotifyTask.java
mdsalutil/mdsalutil-impl/src/test/java/org/opendaylight/genius/test/AbstractMockForwardingRulesManager.java
mdsalutil/mdsalutil-impl/src/test/java/org/opendaylight/genius/test/MdSalUtilTest.java
mdsalutil/mdsalutil-impl/src/test/java/org/opendaylight/genius/test/MockFlowForwarder.java
mdsalutil/mdsalutil-impl/src/test/java/org/opendaylight/genius/test/MockGroupForwarder.java

index 2bee0d3d28794b9cb7dcc8ad5e92df4bc02ca3f9..0c8658322bf6d9d1481b805fccce81028411ad5b 100644 (file)
@@ -81,6 +81,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <groupId>org.apache.aries.blueprint</groupId>
         <artifactId>blueprint-maven-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>
index 197089b6e56a7c3de68ecaed0b246940e4911617..3a5fce9054877773342babc65f342da0f48a5575 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.genius.mdsalutil.internal;
 
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.utils.batching.ActionableResource;
 import org.opendaylight.genius.utils.batching.ActionableResourceImpl;
@@ -17,11 +19,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
 public class FlowBatchingUtils {
-    private static final Logger LOG = LoggerFactory.getLogger((Class)FlowBatchingUtils.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FlowBatchingUtils.class);
     public static final int BATCH_SIZE = 1000;
     public static final int PERIODICITY = 500;
     public static Integer batchSize;
@@ -48,7 +47,8 @@ public class FlowBatchingUtils {
             batchInterval = Integer.getInteger("batch.wait.time");
         }
         ResourceBatchingManager resBatchingManager = ResourceBatchingManager.getInstance();
-        resBatchingManager.registerBatchableResource("MDSALUTIL-INVENTORY-CONFIG", inventoryConfigShardBufferQ, resourceHandler);
+        resBatchingManager.registerBatchableResource("MDSALUTIL-INVENTORY-CONFIG", inventoryConfigShardBufferQ,
+                resourceHandler);
     }
 
     static <T extends DataObject> void update(InstanceIdentifier<T> path, T data) {
index a02224175dc8a5157c2e50173ca7d4aaa87f1083..c56645a23973c60f49f4669d44d61be2d8cab539 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -63,97 +63,104 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Singleton
-public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
+@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
+public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager {
 
     private static final long FIXED_DELAY_IN_MILLISECONDS = 5000;
-    private static final Logger s_logger = LoggerFactory.getLogger(MDSALManager.class);
+    private static final Logger LOG = LoggerFactory.getLogger(MDSALManager.class);
 
-    private final DataBroker m_dataBroker;
+    private final DataBroker dataBroker;
 
-    private final PacketProcessingService m_packetProcessingService;
+    private final PacketProcessingService packetProcessingService;
     private final ConcurrentMap<FlowInfoKey, Runnable> flowMap = new ConcurrentHashMap<>();
     private final ConcurrentMap<GroupInfoKey, Runnable> groupMap = new ConcurrentHashMap<>();
     private final ExecutorService executorService = Executors.newSingleThreadExecutor();
 
     /**
-     * Writes the flows and Groups to the MD SAL DataStore
-     * which will be sent to the openflowplugin for installing flows/groups on the switch.
-     * Other modules of VPN service that wants to install flows / groups on the switch
+     * Writes the flows and Groups to the MD SAL DataStore which will be sent to
+     * the openflowplugin for installing flows/groups on the switch. Other
+     * modules of VPN service that wants to install flows / groups on the switch
      * uses this utility
      *
-     * @param db - dataBroker reference
-     * @param pktProcService- PacketProcessingService for sending the packet outs
+     * @param db
+     *            dataBroker reference
+     * @param pktProcService
+     *            PacketProcessingService for sending the packet outs
      */
     @Inject
     public MDSALManager(DataBroker db, PacketProcessingService pktProcService) {
-        m_dataBroker = db;
-        m_packetProcessingService = pktProcService;
-        s_logger.info( "MDSAL Manager Initialized ") ;
+        this.dataBroker = db;
+        this.packetProcessingService = pktProcService;
+        LOG.info("MDSAL Manager Initialized ");
     }
 
     @Override
     protected void start() throws Exception {
-        s_logger.info("{} start", getClass().getSimpleName());
-        registerListener(m_dataBroker);
+        LOG.info("{} start", getClass().getSimpleName());
+        registerListener(dataBroker);
     }
 
     @Override
     protected void stop() throws Exception {
-        s_logger.info("{} stop", getClass().getSimpleName());
+        LOG.info("{} stop", getClass().getSimpleName());
     }
 
     private void registerListener(DataBroker db) {
-        try {
-            FlowListener flowListener = new FlowListener();
-            GroupListener groupListener = new GroupListener();
-            FlowBatchingUtils.registerWithBatchManager(new MdSalUtilBatchHandler(), db);
-            flowListener.registerListener(LogicalDatastoreType.OPERATIONAL, db);
-            groupListener.registerListener(LogicalDatastoreType.OPERATIONAL, db);
-        } catch (final Exception e) {
-            s_logger.error("GroupEventHandler: DataChange listener registration fail!", e);
-            throw new IllegalStateException("GroupEventHandler: registration Listener failed.", e);
-        }
+        FlowListener flowListener = new FlowListener();
+        GroupListener groupListener = new GroupListener();
+        FlowBatchingUtils.registerWithBatchManager(new MdSalUtilBatchHandler(), db);
+        flowListener.registerListener(LogicalDatastoreType.OPERATIONAL, db);
+        groupListener.registerListener(LogicalDatastoreType.OPERATIONAL, db);
     }
 
     private InstanceIdentifier<Group> getWildCardGroupPath() {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).child(Group.class);
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                .child(Group.class);
     }
 
     private InstanceIdentifier<Flow> getWildCardFlowPath() {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                .child(Table.class).child(Flow.class);
     }
 
     public CheckedFuture<Void, TransactionCommitFailedException> installFlowInternal(FlowEntity flowEntity) {
-            WriteTransaction tx = m_dataBroker.newWriteOnlyTransaction();
-            s_logger.trace("InstallFlow for flowEntity {} ", flowEntity);
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        LOG.trace("InstallFlow for flowEntity {} ", flowEntity);
 
-            writeFlowEntityInternal(flowEntity, tx);
+        writeFlowEntityInternal(flowEntity, tx);
 
-            CheckedFuture<Void,TransactionCommitFailedException> submitFuture  = tx.submit();
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
 
-            Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
 
-                @Override
-                public void onSuccess(final Void result) {
-                    // Commited successfully
-                    s_logger.debug( "Install Flow -- Committedsuccessfully ") ;
-                }
+            @Override
+            public void onSuccess(final Void result) {
+                // Committed successfully
+                LOG.debug("Install Flow -- Committedsuccessfully ");
+            }
 
-                @Override
-                public void onFailure(final Throwable t) {
-                    // Transaction failed
-
-                    if(t instanceof OptimisticLockFailedException) {
-                        // Failed because of concurrent transaction modifying same data
-                        s_logger.error( "Install Flow -- Failed because of concurrent transaction modifying same data ") ;
-                    } else {
-                        // Some other type of TransactionCommitFailedException
-                        s_logger.error( "Install Flow -- Some other type of TransactionCommitFailedException " + t) ;
-                    }
+            @Override
+            public void onFailure(final Throwable throwable) {
+                // Transaction failed
+
+                if (throwable instanceof OptimisticLockFailedException) {
+                    // Failed because of concurrent transaction modifying same
+                    // data
+                    LOG.error("Install Flow -- Failed because of concurrent transaction modifying same data");
+                } else {
+                    // Some other type of TransactionCommitFailedException
+                    LOG.error("Install Flow -- Some other type of TransactionCommitFailedException", throwable);
                 }
-            });
+            }
+        });
 
-            return submitFuture;
+        return submitFuture;
+    }
+
+    public CheckedFuture<Void, TransactionCommitFailedException> installFlowInternal(BigInteger dpId, Flow flow) {
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        writeFlowInternal(dpId, flow, tx);
+        return tx.submit();
     }
 
     public void writeFlowEntityInternal(FlowEntity flowEntity, WriteTransaction tx) {
@@ -161,79 +168,74 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
             flowEntity.setCookie(new BigInteger("0110000", 16));
         }
 
-        FlowKey flowKey = new FlowKey( new FlowId(flowEntity.getFlowId()) );
+        FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
 
         FlowBuilder flowbld = flowEntity.getFlowBuilder();
 
         Node nodeDpn = buildDpnNode(flowEntity.getDpnId());
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class,flowKey).build();
-
-        tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flowbld.build(),true );
-    }
+                .child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
 
-    public CheckedFuture<Void,TransactionCommitFailedException> installFlowInternal(BigInteger dpId, Flow flow) {
-        WriteTransaction tx = m_dataBroker.newWriteOnlyTransaction();
-        writeFlowInternal(dpId, flow, tx);
-        return tx.submit();
+        tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flowbld.build(), true);
     }
 
     public void writeFlowInternal(BigInteger dpId, Flow flow, WriteTransaction tx) {
-        FlowKey flowKey = new FlowKey( new FlowId(flow.getId()) );
+        FlowKey flowKey = new FlowKey(new FlowId(flow.getId()));
         Node nodeDpn = buildDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class,flowKey).build();
+                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
         tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true);
     }
 
     public void batchedAddFlowInternal(BigInteger dpId, Flow flow) {
-        FlowKey flowKey = new FlowKey( new FlowId(flow.getId()) );
+        FlowKey flowKey = new FlowKey(new FlowId(flow.getId()));
         Node nodeDpn = buildDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class,flowKey).build();
+                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
         FlowBatchingUtils.write(flowInstanceId, flow);
     }
 
     public void batchedRemoveFlowInternal(BigInteger dpId, Flow flow) {
-        FlowKey flowKey = new FlowKey( new FlowId(flow.getId()) );
+        FlowKey flowKey = new FlowKey(new FlowId(flow.getId()));
         Node nodeDpn = buildDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class,flowKey).build();
+                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
         FlowBatchingUtils.delete(flowInstanceId);
     }
 
     public CheckedFuture<Void, TransactionCommitFailedException> installGroupInternal(GroupEntity groupEntity) {
-            WriteTransaction tx = m_dataBroker.newWriteOnlyTransaction();
-            writeGroupEntityInternal(groupEntity, tx);
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        writeGroupEntityInternal(groupEntity, tx);
 
-            CheckedFuture<Void,TransactionCommitFailedException> submitFuture  = tx.submit();
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
 
-            Futures.addCallback(submitFuture, new FutureCallback<Void>() {
-                @Override
-                public void onSuccess(final Void result) {
-                    // Commited successfully
-                    s_logger.debug( "Install Group -- Committedsuccessfully ") ;
-                }
+        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                // Committed successfully
+                LOG.debug("Install Group -- Committedsuccessfully ");
+            }
 
-                @Override
-                public void onFailure(final Throwable t) {
-                    // Transaction failed
-
-                    if(t instanceof OptimisticLockFailedException) {
-                        // Failed because of concurrent transaction modifying same data
-                        s_logger.error( "Install Group -- Failed because of concurrent transaction modifying same data ") ;
-                    } else {
-                        // Some other type of TransactionCommitFailedException
-                        s_logger.error( "Install Group -- Some other type of TransactionCommitFailedException " + t) ;
-                    }
+            @Override
+            public void onFailure(final Throwable throwable) {
+                // Transaction failed
+
+                if (throwable instanceof OptimisticLockFailedException) {
+                    // Failed because of concurrent transaction modifying same
+                    // data
+                    LOG.error("Install Group -- Failed because of concurrent transaction modifying same data");
+                } else {
+                    // Some other type of TransactionCommitFailedException
+                    LOG.error("Install Group -- Some other type of TransactionCommitFailedException", throwable);
                 }
-            });
+            }
+        });
 
-            return submitFuture;
+        return submitFuture;
     }
 
     public void writeGroupEntityInternal(GroupEntity groupEntity, WriteTransaction tx) {
@@ -271,33 +273,34 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
     }
 
     public CheckedFuture<Void, TransactionCommitFailedException> removeFlowInternal(FlowEntity flowEntity) {
-            WriteTransaction tx = m_dataBroker.newWriteOnlyTransaction();
-            deleteFlowEntityInternal(flowEntity, tx);
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        deleteFlowEntityInternal(flowEntity, tx);
 
-            CheckedFuture<Void,TransactionCommitFailedException> submitFuture  = tx.submit();
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
 
-            Futures.addCallback(submitFuture, new FutureCallback<Void>() {
-                @Override
-                public void onSuccess(final Void result) {
-                    // Commited successfully
-                    s_logger.debug( "Delete Flow -- Committedsuccessfully ") ;
-                }
+        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                // Committed successfully
+                LOG.debug("Delete Flow -- Committedsuccessfully ");
+            }
 
-                @Override
-                public void onFailure(final Throwable t) {
-                    // Transaction failed
-                    if(t instanceof OptimisticLockFailedException) {
-                        // Failed because of concurrent transaction modifying same data
-                        s_logger.error( "Delete Flow -- Failed because of concurrent transaction modifying same data ") ;
-                    } else {
-                        // Some other type of TransactionCommitFailedException
-                        s_logger.error( "Delete Flow -- Some other type of TransactionCommitFailedException " + t) ;
-                    }
+            @Override
+            public void onFailure(final Throwable throwable) {
+                // Transaction failed
+                if (throwable instanceof OptimisticLockFailedException) {
+                    // Failed because of concurrent transaction modifying same
+                    // data
+                    LOG.error("Delete Flow -- Failed because of concurrent transaction modifying same data");
+                } else {
+                    // Some other type of TransactionCommitFailedException
+                    LOG.error("Delete Flow -- Some other type of TransactionCommitFailedException", throwable);
                 }
+            }
 
-            });
+        });
 
-            return submitFuture;
+        return submitFuture;
     }
 
     public void deleteFlowEntityInternal(FlowEntity flowEntity, WriteTransaction tx) {
@@ -307,13 +310,13 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
 
-
-        tx.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId);
+        tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
     }
 
-    public CheckedFuture<Void,TransactionCommitFailedException> removeFlowNewInternal(BigInteger dpnId, Flow flowEntity) {
-        s_logger.debug("Remove flow {}",flowEntity);
-        WriteTransaction  tx = m_dataBroker.newWriteOnlyTransaction();
+    public CheckedFuture<Void, TransactionCommitFailedException> removeFlowNewInternal(BigInteger dpnId,
+            Flow flowEntity) {
+        LOG.debug("Remove flow {}", flowEntity);
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         deleteFlowInternal(dpnId, flowEntity, tx);
         return tx.submit();
     }
@@ -324,36 +327,37 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
-        tx.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId );
+        tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
     }
 
     public CheckedFuture<Void, TransactionCommitFailedException> removeGroupInternal(GroupEntity groupEntity) {
-            WriteTransaction tx = m_dataBroker.newWriteOnlyTransaction();
-            removeGroupEntityInternal(groupEntity, tx);
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        removeGroupEntityInternal(groupEntity, tx);
 
-            CheckedFuture<Void,TransactionCommitFailedException> submitFuture  = tx.submit();
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
 
-            Futures.addCallback(submitFuture, new FutureCallback<Void>() {
-                @Override
-                public void onSuccess(final Void result) {
-                    // Commited successfully
-                    s_logger.debug( "Install Group -- Committedsuccessfully ") ;
-                }
+        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                // Committed successfully
+                LOG.debug("Install Group -- Committedsuccessfully ");
+            }
 
-                @Override
-                public void onFailure(final Throwable t) {
-                    // Transaction failed
-                    if(t instanceof OptimisticLockFailedException) {
-                        // Failed because of concurrent transaction modifying same data
-                        s_logger.error( "Install Group -- Failed because of concurrent transaction modifying same data ") ;
-                    } else {
-                        // Some other type of TransactionCommitFailedException
-                        s_logger.error( "Install Group -- Some other type of TransactionCommitFailedException " + t) ;
-                    }
+            @Override
+            public void onFailure(final Throwable throwable) {
+                // Transaction failed
+                if (throwable instanceof OptimisticLockFailedException) {
+                    // Failed because of concurrent transaction modifying same
+                    // data
+                    LOG.error("Install Group -- Failed because of concurrent transaction modifying same data");
+                } else {
+                    // Some other type of TransactionCommitFailedException
+                    LOG.error("Install Group -- Some other type of TransactionCommitFailedException", throwable);
                 }
-            });
+            }
+        });
 
-            return submitFuture;
+        return submitFuture;
     }
 
     public void removeGroupEntityInternal(GroupEntity groupEntity, WriteTransaction tx) {
@@ -362,7 +366,7 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
                 .child(Group.class, new GroupKey(new GroupId(groupEntity.getGroupId()))).build();
 
-        tx.delete(LogicalDatastoreType.CONFIGURATION,groupInstanceId );
+        tx.delete(LogicalDatastoreType.CONFIGURATION, groupInstanceId);
     }
 
     public void modifyGroupInternal(GroupEntity groupEntity) {
@@ -378,15 +382,16 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         sendPacketOutWithActions(dpnId, groupId, payload, actionInfos);
     }
 
-    public void sendPacketOutWithActionsInternal(BigInteger dpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos) {
+    public void sendPacketOutWithActionsInternal(BigInteger dpnId, long groupId, byte[] payload,
+            List<ActionInfo> actionInfos) {
 
-        m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actionInfos, payload, dpnId,
-                getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
+        packetProcessingService.transmitPacket(
+                MDSALUtil.getPacketOut(actionInfos, payload, dpnId, getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
     }
 
     public void sendARPPacketOutWithActionsInternal(BigInteger dpnId, byte[] payload, List<ActionInfo> actions) {
-        m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actions, payload, dpnId,
-                getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
+        packetProcessingService.transmitPacket(
+                MDSALUtil.getPacketOut(actions, payload, dpnId, getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
     }
 
     protected InstanceIdentifier<Node> nodeToInstanceId(Node node) {
@@ -394,22 +399,21 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
     }
 
     protected static NodeConnectorRef getNodeConnRef(final String nodeId, final String port) {
-        StringBuilder _stringBuilder = new StringBuilder(nodeId);
-        StringBuilder _append = _stringBuilder.append(":");
-        StringBuilder sBuild = _append.append(port);
-        String _string = sBuild.toString();
-        NodeConnectorId _nodeConnectorId = new NodeConnectorId(_string);
-        NodeConnectorKey _nodeConnectorKey = new NodeConnectorKey(_nodeConnectorId);
-        NodeConnectorKey nConKey = _nodeConnectorKey;
-        InstanceIdentifierBuilder<Nodes> _builder = InstanceIdentifier.builder(Nodes.class);
-        NodeId _nodeId = new NodeId(nodeId);
-        NodeKey _nodeKey = new NodeKey(_nodeId);
-        InstanceIdentifierBuilder<Node> _child = _builder.child(Node.class, _nodeKey);
-        InstanceIdentifierBuilder<NodeConnector> _child_1 = _child.child(
-                NodeConnector.class, nConKey);
-        InstanceIdentifier<NodeConnector> path = _child_1.toInstance();
-        NodeConnectorRef _nodeConnectorRef = new NodeConnectorRef(path);
-        return _nodeConnectorRef;
+        StringBuilder stringBuilder = new StringBuilder(nodeId);
+        StringBuilder append = stringBuilder.append(":");
+        StringBuilder build = append.append(port);
+        String string = build.toString();
+        NodeConnectorId nodeConnectorId = new NodeConnectorId(string);
+        NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
+        NodeConnectorKey connectorKey = nodeConnectorKey;
+        InstanceIdentifierBuilder<Nodes> builder = InstanceIdentifier.builder(Nodes.class);
+
+        NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
+        InstanceIdentifierBuilder<Node> child = builder.child(Node.class, nodeKey);
+        InstanceIdentifierBuilder<NodeConnector> anotherChild = child.child(NodeConnector.class, connectorKey);
+        InstanceIdentifier<NodeConnector> path = anotherChild.toInstance();
+        NodeConnectorRef nodeConnectorRef = new NodeConnectorRef(path);
+        return nodeConnectorRef;
     }
 
     protected Node buildDpnNode(BigInteger dpnId) {
@@ -420,8 +424,8 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
     }
 
     public void syncSetUpFlowInternal(FlowEntity flowEntity, long delay, boolean isRemove) {
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("syncSetUpFlow for flowEntity {} ", flowEntity);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("syncSetUpFlow for flowEntity {} ", flowEntity);
         }
         if (flowEntity.getCookie() == null) {
             flowEntity.setCookie(new BigInteger("0110000", 16));
@@ -429,21 +433,21 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         Flow flow = flowEntity.getFlowBuilder().build();
         String flowId = flowEntity.getFlowId();
         BigInteger dpId = flowEntity.getDpnId();
-        FlowKey flowKey = new FlowKey( new FlowId(flowId));
+        FlowKey flowKey = new FlowKey(new FlowId(flowId));
         Node nodeDpn = buildDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
         if (isRemove) {
-            MDSALUtil.syncDelete(m_dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId);
+            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId);
         } else {
-            MDSALUtil.syncWrite(m_dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
+            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
         }
     }
 
     public void syncSetUpGroupInternal(GroupEntity groupEntity, long delayTime, boolean isRemove) {
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("syncSetUpGroup for groupEntity {} ", groupEntity);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("syncSetUpGroup for groupEntity {} ", groupEntity);
         }
         Group group = groupEntity.getGroupBuilder().build();
         BigInteger dpId = groupEntity.getDpnId();
@@ -451,34 +455,34 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         long groupId = groupEntity.getGroupId();
         GroupKey groupKey = new GroupKey(new GroupId(groupId));
         InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Group.class, groupKey).build();
+                .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Group.class, groupKey)
+                .build();
         if (isRemove) {
-            MDSALUtil.syncDelete(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
+            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
         } else {
-            MDSALUtil.syncWrite(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
+            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
         }
     }
 
     public void syncSetUpGroupInternal(BigInteger dpId, Group group, long delayTime, boolean isRemove) {
-        s_logger.trace("syncSetUpGroup for group {} ", group);
+        LOG.trace("syncSetUpGroup for group {} ", group);
         Node nodeDpn = buildDpnNode(dpId);
         long groupId = group.getGroupId().getValue();
         GroupKey groupKey = new GroupKey(new GroupId(groupId));
         InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
-                .child(Group.class, groupKey).build();
+                .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Group.class, groupKey)
+                .build();
         if (isRemove) {
-            MDSALUtil.syncDelete(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
+            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
         } else {
-            MDSALUtil.syncWrite(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
+            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
         }
     }
 
-    class GroupListener extends AsyncClusteredDataChangeListenerBase<Group,GroupListener> {
+    class GroupListener extends AsyncClusteredDataChangeListenerBase<Group, GroupListener> {
 
-        public GroupListener() {
-            super(Group.class,GroupListener.class);
+        GroupListener() {
+            super(Group.class, GroupListener.class);
         }
 
         @Override
@@ -510,7 +514,8 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
 
         @Override
         protected InstanceIdentifier<Group> getWildCardPath() {
-            return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).child(Group.class);
+            return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                    .child(Group.class);
         }
 
         @Override
@@ -524,9 +529,9 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         }
     }
 
-    class FlowListener extends AsyncClusteredDataChangeListenerBase<Flow,FlowListener> {
+    class FlowListener extends AsyncClusteredDataChangeListenerBase<Flow, FlowListener> {
 
-        public FlowListener() {
+        FlowListener() {
             super(Flow.class, FlowListener.class);
         }
 
@@ -557,7 +562,8 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
 
         @Override
         protected InstanceIdentifier<Flow> getWildCardPath() {
-            return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
+            return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                    .child(Table.class).child(Flow.class);
         }
 
         @Override
@@ -616,7 +622,6 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         modifyGroupInternal(groupEntity);
     }
 
-
     @Override
     public void removeGroup(GroupEntity groupEntity) {
         removeGroupInternal(groupEntity);
@@ -627,23 +632,19 @@ public class MDSALManager extends AbstractLifecycle implements IMdsalApiManager{
         sendPacketOutInternal(dpnId, groupId, payload);
     }
 
-
     @Override
-    public void sendPacketOutWithActions(BigInteger dpnId, long groupId,
-                                         byte[] payload, List<ActionInfo> actionInfos) {
+    public void sendPacketOutWithActions(BigInteger dpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos) {
         sendPacketOutWithActionsInternal(dpnId, groupId, payload, actionInfos);
     }
 
-
     @Override
-    public void sendARPPacketOutWithActions(BigInteger dpnId, byte[] payload,
-                                            List<ActionInfo> actionInfo) {
+    public void sendARPPacketOutWithActions(BigInteger dpnId, byte[] payload, List<ActionInfo> actionInfo) {
         sendARPPacketOutWithActionsInternal(dpnId, payload, actionInfo);
     }
 
     @Override
     public void syncRemoveFlow(FlowEntity flowEntity, long delayTime) {
-        syncSetUpFlowInternal(flowEntity,  delayTime, true);
+        syncSetUpFlowInternal(flowEntity, delayTime, true);
     }
 
     @Override
index 4a5a8b7b0816817bebbb4a1142d3be51d771f373..85fc7f2ec8f9156b2d6cf247cd36e92d63761cc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,6 +8,7 @@
 
 package org.opendaylight.genius.mdsalutil.internal;
 
+import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -17,34 +18,38 @@ import org.opendaylight.genius.utils.batching.SubTransactionImpl;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.List;
-
 public class MdSalUtilBatchHandler implements ResourceHandler {
-    public void update(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier, Object original, Object update,List<SubTransaction> transactionObjects) {
+    @Override
+    public void update(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier,
+            Object original, Object update, List<SubTransaction> transactionObjects) {
         if (update != null && !(update instanceof DataObject)) {
             return;
         }
         if (datastoreType != this.getDatastoreType()) {
             return;
         }
-        tx.merge(datastoreType, identifier, (DataObject)update, true);
+        tx.merge(datastoreType, identifier, (DataObject) update, true);
 
         buildSubTransactions(transactionObjects, identifier, update, SubTransaction.UPDATE);
     }
 
-    public void create(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier, Object data,List<SubTransaction> transactionObjects) {
+    @Override
+    public void create(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier,
+            Object data, List<SubTransaction> transactionObjects) {
         if (data != null && !(data instanceof DataObject)) {
             return;
         }
         if (datastoreType != this.getDatastoreType()) {
             return;
         }
-        tx.put(datastoreType, identifier, (DataObject)data, true);
+        tx.put(datastoreType, identifier, (DataObject) data, true);
 
         buildSubTransactions(transactionObjects, identifier, data, SubTransaction.CREATE);
     }
 
-    public void delete(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier, Object data,List<SubTransaction> transactionObjects) {
+    @Override
+    public void delete(WriteTransaction tx, LogicalDatastoreType datastoreType, InstanceIdentifier identifier,
+            Object data, List<SubTransaction> transactionObjects) {
         if (data != null && !(data instanceof DataObject)) {
             return;
         }
@@ -56,24 +61,28 @@ public class MdSalUtilBatchHandler implements ResourceHandler {
         buildSubTransactions(transactionObjects, identifier, data, SubTransaction.DELETE);
     }
 
+    @Override
     public DataBroker getResourceBroker() {
         return FlowBatchingUtils.getBroker();
     }
 
+    @Override
     public int getBatchSize() {
         return FlowBatchingUtils.batchSize;
     }
 
+    @Override
     public int getBatchInterval() {
         return FlowBatchingUtils.batchInterval;
     }
 
+    @Override
     public LogicalDatastoreType getDatastoreType() {
         return LogicalDatastoreType.CONFIGURATION;
     }
 
     private void buildSubTransactions(List<SubTransaction> transactionObjects, InstanceIdentifier identifier,
-                                              Object data, short subTransactionType) {
+            Object data, short subTransactionType) {
         // enable retries
         SubTransaction subTransaction = new SubTransactionImpl();
         subTransaction.setInstanceIdentifier(identifier);
index 80e628516720afb0e0a4f16c2068cd60d13107d6..02a553d7f1aaa9f54c04b1598b9784de211c9d8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -11,14 +11,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 class NotifyTask implements Runnable {
-    private static final Logger logger = LoggerFactory.getLogger(NotifyTask.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NotifyTask.class);
 
     @Override
     public void run() {
-        logger.debug("Notify Task is running for the task {}", this);
+        LOG.debug("Notify Task is running for the task {}", this);
         synchronized (this) {
             notifyAll();
         }
     }
-
 }
index 2cc871e12d680ba92ee95eca3ed55867b8916386..c906a8f566a15a85254502d8ec2d55507750e648 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,14 +9,9 @@ package org.opendaylight.genius.test;
 
 import java.util.Collection;
 
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import com.google.common.base.Preconditions;
 
 public abstract class AbstractMockForwardingRulesManager<D extends DataObject> implements DataTreeChangeListener<D> {
 
@@ -24,9 +19,8 @@ public abstract class AbstractMockForwardingRulesManager<D extends DataObject> i
         // Do Nothing
     }
 
-
+    @Override
     public void onDataTreeChanged(Collection<DataTreeModification<D>> changes) {
         // TODO Auto-generated method stub
     }
-
 }
index 0e1d3bc47dac3d09bb514c34055e3733970933a2..932a5d201a6a3bba07b57d70dde731b354617d63 100644 (file)
  */
 package org.opendaylight.genius.test;
 
+import static org.junit.Assert.assertEquals;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Collections;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
-
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
-import org.opendaylight.genius.mdsalutil.actions.ActionPuntToController;
-import org.opendaylight.genius.mdsalutil.actions.ActionPushVlan;
-import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid;
-import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteActions;
-import org.opendaylight.genius.mdsalutil.matches.MatchTunnelId;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.GroupEntity;
-import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.mdsalutil.MatchInfo;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
+import org.opendaylight.genius.mdsalutil.actions.ActionPuntToController;
+import org.opendaylight.genius.mdsalutil.actions.ActionPushVlan;
+import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid;
+import org.opendaylight.genius.mdsalutil.instructions.InstructionWriteActions;
 import org.opendaylight.genius.mdsalutil.internal.MDSALManager;
+import org.opendaylight.genius.mdsalutil.matches.MatchTunnelId;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import static org.junit.Assert.assertEquals;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
 
 @RunWith(MockitoJUnitRunner.class)
 @PrepareForTest(MDSALUtil.class)
 public class MdSalUtilTest extends AbstractConcurrentDataBrokerTest {
 
-     DataBroker dataBroker;
-     @Mock PacketProcessingService ppS ;
-     MDSALManager mdSalMgr = null ;
-     MockFlowForwarder flowFwder = null ;
-     MockGroupForwarder grpFwder = null ;
-     private static final String Nodeid = "openflow:1";
-
-     @Before
-        public void setUp() throws Exception {
-            dataBroker = getDataBroker() ;
-            mdSalMgr = new MDSALManager( dataBroker, ppS);
-            flowFwder = new MockFlowForwarder( dataBroker );
-            grpFwder = new MockGroupForwarder( dataBroker ) ;
-
-            PowerMockito.mockStatic(MDSALUtil.class) ;
-
-            NodeKey s1Key = new NodeKey(new NodeId("openflow:1"));
-            addFlowCapableNode(s1Key);
-        }
-
-        @Test
-        public void testInstallFlow() throws Exception {
-            String dpnId = "openflow:1";
-            String tableId1 = "12";
-
-            //Install Flow 1
-            FlowEntity testFlow1 = createFlowEntity(dpnId, tableId1) ;
-            mdSalMgr.installFlowInternal(testFlow1).get();
-            assertEquals(1, flowFwder.getDataChgCount());
-
-            // Install FLow 2
-            String tableId2 = "13" ;
-             FlowEntity testFlow2 = createFlowEntity(dpnId, tableId2) ;
-             mdSalMgr.installFlowInternal(testFlow2).get();
-             assertEquals(2, flowFwder.getDataChgCount());
-        }
+    DataBroker dataBroker;
+    @Mock
+    PacketProcessingService ppS;
+    MDSALManager mdSalMgr = null;
+    MockFlowForwarder flowFwder = null;
+    MockGroupForwarder grpFwder = null;
+    private static final String NODE_ID = "openflow:1";
+
+    @Before
+    public void setUp() throws Exception {
+        dataBroker = getDataBroker();
+        mdSalMgr = new MDSALManager(dataBroker, ppS);
+        flowFwder = new MockFlowForwarder(dataBroker);
+        grpFwder = new MockGroupForwarder(dataBroker);
+
+        PowerMockito.mockStatic(MDSALUtil.class);
+
+        NodeKey s1Key = new NodeKey(new NodeId("openflow:1"));
+        addFlowCapableNode(s1Key);
+    }
 
-        @Test
-        public void testRemoveFlow() throws Exception {
-            String dpnId = "openflow:1";
-            String tableId = "13" ;
-            FlowEntity testFlow = createFlowEntity(dpnId, tableId) ;
-
-            // To test RemoveFlow add and then delete Flows
-            mdSalMgr.installFlowInternal(testFlow).get();
-            assertEquals(1, flowFwder.getDataChgCount());
-            mdSalMgr.removeFlowInternal(testFlow).get();
-            assertEquals(0, flowFwder.getDataChgCount());
-        }
+    @Test
+    public void testInstallFlow() throws Exception {
+        String dpnId = "openflow:1";
+        String tableId1 = "12";
+
+        // Install Flow 1
+        FlowEntity testFlow1 = createFlowEntity(dpnId, tableId1);
+        mdSalMgr.installFlowInternal(testFlow1).get();
+        assertEquals(1, flowFwder.getDataChgCount());
+
+        // Install FLow 2
+        String tableId2 = "13";
+        FlowEntity testFlow2 = createFlowEntity(dpnId, tableId2);
+        mdSalMgr.installFlowInternal(testFlow2).get();
+        assertEquals(2, flowFwder.getDataChgCount());
+    }
 
-        @Test
-        public void testInstallGroup() throws Exception {
-            // Install Group 1
-            String inport = "2" ;
-            int vlanid = 100 ;
-            GroupEntity grpEntity1 = createGroupEntity(Nodeid, inport, vlanid) ;
-
-             mdSalMgr.installGroupInternal(grpEntity1).get();
-             assertEquals(1, grpFwder.getDataChgCount());
-
-             // Install Group 2
-                inport = "3" ;
-                vlanid = 100 ;
-                GroupEntity grpEntity2 = createGroupEntity(Nodeid, inport, vlanid) ;
-                mdSalMgr.installGroupInternal(grpEntity2).get();
-                assertEquals(2, grpFwder.getDataChgCount());
-        }
+    @Test
+    public void testRemoveFlow() throws Exception {
+        String dpnId = "openflow:1";
+        String tableId = "13";
+        FlowEntity testFlow = createFlowEntity(dpnId, tableId);
+
+        // To test RemoveFlow add and then delete Flows
+        mdSalMgr.installFlowInternal(testFlow).get();
+        assertEquals(1, flowFwder.getDataChgCount());
+        mdSalMgr.removeFlowInternal(testFlow).get();
+        assertEquals(0, flowFwder.getDataChgCount());
+    }
 
-        @Test
-        public void testRemoveGroup() throws Exception {
-            String inport = "2" ;
-            int vlanid = 100 ;
-            GroupEntity grpEntity = createGroupEntity(Nodeid, inport, vlanid) ;
-            // To test RemoveGroup  add and then delete Group
-            mdSalMgr.installGroupInternal(grpEntity).get();
-            assertEquals(1, grpFwder.getDataChgCount());
-            mdSalMgr.removeGroupInternal(grpEntity).get();
-            assertEquals(0, grpFwder.getDataChgCount());
-        }
+    @Test
+    public void testInstallGroup() throws Exception {
+        // Install Group 1
+        String inport = "2";
+        int vlanid = 100;
+        GroupEntity grpEntity1 = createGroupEntity(NODE_ID, inport, vlanid);
+
+        mdSalMgr.installGroupInternal(grpEntity1).get();
+        assertEquals(1, grpFwder.getDataChgCount());
+
+        // Install Group 2
+        inport = "3";
+        vlanid = 100;
+        GroupEntity grpEntity2 = createGroupEntity(NODE_ID, inport, vlanid);
+        mdSalMgr.installGroupInternal(grpEntity2).get();
+        assertEquals(2, grpFwder.getDataChgCount());
+    }
 
-        public void addFlowCapableNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
-            Nodes nodes = new NodesBuilder().setNode(Collections.emptyList()).build();
-            InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class)
-                    .child(Node.class, nodeKey);
-
-            FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
-            NodeBuilder nodeBuilder = new NodeBuilder();
-            nodeBuilder.setKey(nodeKey);
-            nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
-
-            WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
-            writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
-            writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
-            writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
-            writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
-            assertCommit(writeTx.submit());
-        }
+    @Test
+    public void testRemoveGroup() throws Exception {
+        String inport = "2";
+        int vlanid = 100;
+        GroupEntity grpEntity = createGroupEntity(NODE_ID, inport, vlanid);
+        // To test RemoveGroup add and then delete Group
+        mdSalMgr.installGroupInternal(grpEntity).get();
+        assertEquals(1, grpFwder.getDataChgCount());
+        mdSalMgr.removeGroupInternal(grpEntity).get();
+        assertEquals(0, grpFwder.getDataChgCount());
+    }
 
-         // Methods to test the install Flow and Group
+    public void addFlowCapableNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
+        Nodes nodes = new NodesBuilder().setNode(Collections.emptyList()).build();
+        final InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class,
+                nodeKey);
+
+        FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
+        NodeBuilder nodeBuilder = new NodeBuilder();
+        nodeBuilder.setKey(nodeKey);
+        nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
+
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
+        assertCommit(writeTx.submit());
+    }
 
-        public FlowEntity createFlowEntity(String dpnId, String tableId) {
+    // Methods to test the install Flow and Group
+    public FlowEntity createFlowEntity(String dpnId, String tableId) {
+        BigInteger dpId;
+        final int serviceId = 0;
 
-            BigInteger dpId;
-            int SERVICE_ID = 0;
-            FlowEntity terminatingServiceTableFlowEntity = null;
+        List<ActionInfo> listActionInfo = new ArrayList<>();
+        listActionInfo.add(new ActionPuntToController());
 
-            List<ActionInfo> listActionInfo = new ArrayList<>();
-            listActionInfo.add(new ActionPuntToController());
+        dpId = new BigInteger(dpnId.split(":")[1]);
 
-            try {
-                dpId = new BigInteger(dpnId.split(":")[1]);
+        List<MatchInfo> mkMatches = new ArrayList<>();
+        final BigInteger cookie = new BigInteger("9000000", 16);
 
-                List<MatchInfo> mkMatches = new ArrayList<>();
-                BigInteger COOKIE = new BigInteger("9000000", 16);
+        short shortTableId = Short.parseShort(tableId);
 
-                short s_tableId = Short.parseShort(tableId) ;
+        mkMatches.add(new MatchTunnelId(new BigInteger("0000000000000000", 16)));
 
-                mkMatches.add(new MatchTunnelId(new BigInteger("0000000000000000", 16)));
+        List<InstructionInfo> mkInstructions = new ArrayList<>();
+        mkInstructions.add(new InstructionWriteActions(listActionInfo));
 
-                List<InstructionInfo> mkInstructions = new ArrayList<>();
-                mkInstructions.add(new InstructionWriteActions(listActionInfo));
+        FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(dpId, shortTableId,
+                getFlowRef(shortTableId, serviceId), 5, "Terminating Service Flow Entry: " + serviceId, 0, 0,
+                cookie.add(BigInteger.valueOf(serviceId)), null, null);
 
-                terminatingServiceTableFlowEntity = MDSALUtil
-                        .buildFlowEntity(
-                                dpId,
-                                s_tableId,
-                                getFlowRef(s_tableId,
-                                        SERVICE_ID), 5, "Terminating Service Flow Entry: " + SERVICE_ID,
-                                0, 0, COOKIE
-                                        .add(BigInteger.valueOf(SERVICE_ID)),
-                                        null, null);
-                } catch (Exception e) {
-                    //throw new Exception(e) ;
-              }
+        return terminatingServiceTableFlowEntity;
+    }
 
-            return terminatingServiceTableFlowEntity;
-        }
+    private String getFlowRef(short termSvcTable, int svcId) {
+        return String.valueOf(termSvcTable) + svcId;
+    }
 
-        private String getFlowRef(short termSvcTable, int svcId) {
-            return String.valueOf(termSvcTable) + svcId;
+    public GroupEntity createGroupEntity(String nodeid, String inport, int vlanid) {
+        List<BucketInfo> listBucketInfo = new ArrayList<>();
+        List<ActionInfo> listActionInfo = new ArrayList<>();
+        if (vlanid > 0) {
+            listActionInfo.add(new ActionPushVlan());
+            listActionInfo.add(new ActionSetFieldVlanVid(vlanid));
         }
+        listActionInfo.add(new ActionOutput(new Uri(inport), 65535));
+        listBucketInfo.add(new BucketInfo(listActionInfo));
 
-        public GroupEntity createGroupEntity(String Nodeid, String inport, int vlanid) {
-            GroupEntity groupEntity;
-            long id = getUniqueValue(Nodeid, inport);
-            List<BucketInfo> listBucketInfo = new ArrayList<>();
-            List<ActionInfo> listActionInfo = new ArrayList<>();
-            if (vlanid > 0) {
-                listActionInfo.add(new ActionPushVlan());
-                listActionInfo.add(new ActionSetFieldVlanVid(vlanid));
-            }
-            listActionInfo.add(new ActionOutput(new Uri(inport), 65535));
-            listBucketInfo.add(new BucketInfo(listActionInfo));
-
-            String groupName = "Test Group";
-            BigInteger dpnId = new BigInteger(Nodeid.split(":")[1]);
-            groupEntity = MDSALUtil.buildGroupEntity(dpnId, id, groupName, GroupTypes.GroupIndirect,
-                    listBucketInfo);
-
-            return groupEntity;
-        }
+        String groupName = "Test Group";
+        BigInteger dpnId = new BigInteger(nodeid.split(":")[1]);
 
-        private static long getUniqueValue(String nodeId, String inport) {
+        long id = getUniqueValue(nodeid, inport);
+        return MDSALUtil.buildGroupEntity(dpnId, id, groupName, GroupTypes.GroupIndirect, listBucketInfo);
+    }
 
-            Long nodeIdL = Long.valueOf(nodeId.split(":")[1]);
-            Long inportL = Long.valueOf(inport);
-                long sd_set;
-                sd_set = nodeIdL * 10 + inportL;
+    private static long getUniqueValue(String nodeId, String inport) {
+        Long nodeIdL = Long.valueOf(nodeId.split(":")[1]);
+        Long inportL = Long.valueOf(inport);
+        long sdSet = nodeIdL * 10 + inportL;
 
-                return sd_set;
+        return sdSet;
     }
-
 }
index 14daef2cddbc5ec26d570ccfdf17757d4be0630a..61b1b8dc24c90b76421c341dd9aa14a1d27d640d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,7 +8,6 @@
 package org.opendaylight.genius.test;
 
 import java.util.Collection;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
@@ -24,28 +23,25 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class MockFlowForwarder extends AbstractMockForwardingRulesManager<Flow> {
 
-    private int nFlowCount = 0;
+    private int flowCount = 0;
 
     private ListenerRegistration<MockFlowForwarder> listenerRegistration;
 
-    public MockFlowForwarder( final DataBroker db) {
-        super() ;
-        registerListener(db) ;
+    public MockFlowForwarder(final DataBroker db) {
+        super();
+        registerListener(db);
     }
 
     private void registerListener(final DataBroker db) {
-        final DataTreeIdentifier<Flow> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
-        try {
-            listenerRegistration = db.registerDataTreeChangeListener(treeId, MockFlowForwarder.this);
-        } catch (final Exception e) {
-            throw new IllegalStateException("FlowForwarder registration Listener fail! System needs restart.", e);
-        }
+        final DataTreeIdentifier<Flow> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+                getWildCardPath());
+        listenerRegistration = db.registerDataTreeChangeListener(treeId, MockFlowForwarder.this);
     }
 
     private InstanceIdentifier<Flow> getWildCardPath() {
-            return InstanceIdentifier.create(Nodes.class).child(Node.class)
-                    .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
-     }
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                .child(Table.class).child(Flow.class);
+    }
 
     @Override
     public void onDataTreeChanged(Collection<DataTreeModification<Flow>> changes) {
@@ -53,27 +49,27 @@ public class MockFlowForwarder extends AbstractMockForwardingRulesManager<Flow>
             final InstanceIdentifier<Flow> key = change.getRootPath().getRootIdentifier();
             final DataObjectModification<Flow> mod = change.getRootNode();
 
-                switch (mod.getModificationType()) {
+            switch (mod.getModificationType()) {
                 case DELETE:
-                    nFlowCount -= 1;
+                    flowCount -= 1;
                     break;
                 case SUBTREE_MODIFIED:
                     // CHECK IF RQD
                     break;
                 case WRITE:
                     if (mod.getDataBefore() == null) {
-                        nFlowCount += 1;
+                        flowCount += 1;
                     } else {
                         // UPDATE COUNT UNCHANGED
                     }
                     break;
                 default:
                     throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
-                }
             }
-     }
+        }
+    }
 
     public int getDataChgCount() {
-        return nFlowCount;
+        return flowCount;
     }
 }
index ff76618885ed9d4eb1c4d3fd5a97e9fa5cd07f88..988eb00bcaab5b6071771709372a277394c7cac9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,40 +8,37 @@
 package org.opendaylight.genius.test;
 
 import java.util.Collection;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
-public class MockGroupForwarder extends AbstractMockForwardingRulesManager<Group>{
+public class MockGroupForwarder extends AbstractMockForwardingRulesManager<Group> {
 
-    private int nGroupCount = 0;
-    private ListenerRegistration<MockGroupForwarder> listenerRegistration ;
+    private int groupCount = 0;
+    private ListenerRegistration<MockGroupForwarder> listenerRegistration;
 
-    public MockGroupForwarder( final DataBroker db) {
-        super() ;
-        registerListener(db) ;
+    public MockGroupForwarder(final DataBroker db) {
+        super();
+        registerListener(db);
     }
 
     private void registerListener(final DataBroker db) {
-       final DataTreeIdentifier<Group> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
-       try {
-           listenerRegistration = db.registerDataTreeChangeListener(treeId, MockGroupForwarder.this);
-       } catch (final Exception e) {
-           throw new IllegalStateException("GroupForwarder registration Listener fail! System needs restart.", e);
-       }
+        final DataTreeIdentifier<Group> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+                getWildCardPath());
+        listenerRegistration = db.registerDataTreeChangeListener(treeId, MockGroupForwarder.this);
     }
 
     private InstanceIdentifier<Group> getWildCardPath() {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class).
-                augmentation(FlowCapableNode.class).child(Group.class);
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+                .child(Group.class);
     }
 
     @Override
@@ -50,27 +47,27 @@ public class MockGroupForwarder extends AbstractMockForwardingRulesManager<Group
             final InstanceIdentifier<Group> key = change.getRootPath().getRootIdentifier();
             final DataObjectModification<Group> mod = change.getRootNode();
 
-                switch (mod.getModificationType()) {
+            switch (mod.getModificationType()) {
                 case DELETE:
-                    nGroupCount -= 1;
+                    groupCount -= 1;
                     break;
                 case SUBTREE_MODIFIED:
                     // CHECK IF RQD
                     break;
                 case WRITE:
                     if (mod.getDataBefore() == null) {
-                        nGroupCount += 1;
+                        groupCount += 1;
                     } else {
                         // UPDATE COUNT UNCHANGED
                     }
                     break;
                 default:
                     throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
-                }
             }
-     }
+        }
+    }
 
     public int getDataChgCount() {
-        return nGroupCount;
+        return groupCount;
     }
 }