Fix checkstyle violations in applications 53/67753/3
authorTom Pantelis <tompantelis@gmail.com>
Tue, 30 Jan 2018 23:18:37 +0000 (18:18 -0500)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 15 Feb 2018 10:03:27 +0000 (10:03 +0000)
Change-Id: I1ac5ba94705ffba78d4765185ff6ade5f299a671
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
49 files changed:
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/ForwardingRulesCommitter.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SemaphoreKeeper.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncPlanPushStrategy.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncReactor.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManager.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/GroupForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/MeterForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowDescriptor.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FxChainUtil.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/PathUtil.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/DSInputFactory.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProviderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecoratorTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecoratorTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/DiffInputFactory.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/GroupForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/MeterForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperGuavaImplTest.java
applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java
applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java
applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java
applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtilsTest.java

index 9ad8fab07c0b509fe2a87c6994a66f0143db8b66..cb4b25b12b8f6761445c520db97625e84e041d14 100644 (file)
@@ -14,7 +14,8 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * Represents configuration item contract for device.
  * Combining add/update/remove commiters into single one.
  */
-public interface ForwardingRulesCommitter<D extends DataObject, A extends DataObject, R extends DataObject, U extends DataObject>
-        extends ForwardingRulesAddCommitter<D, A>, ForwardingRulesRemoveCommitter<D, R>, ForwardingRulesUpdateCommitter<D, U> {
+public interface ForwardingRulesCommitter<D extends DataObject, A extends DataObject, R extends DataObject,
+    U extends DataObject> extends ForwardingRulesAddCommitter<D, A>,
+        ForwardingRulesRemoveCommitter<D, R>, ForwardingRulesUpdateCommitter<D, U> {
 }
 
index 9f31ad541796d45ebe3bb7f889c7016753595da0..637e4003321d201e4c610921ad002ad7f45c6a4a 100644 (file)
@@ -24,18 +24,18 @@ public interface SemaphoreKeeper<K> {
      * @param key semaphore identifier
      * @return new or existing semaphore for given key, for one key there is always only one semaphore available
      */
-    Semaphore summonGuard(@Nonnull final K key);
+    Semaphore summonGuard(@Nonnull K key);
 
     /**
      * Get guard and lock for key.
      * @param key for which guard should be created and acquired
      * @return semaphore guard
      */
-    Semaphore summonGuardAndAcquire(@Nonnull final K key);
+    Semaphore summonGuardAndAcquire(@Nonnull K key);
 
     /**
      * Unlock and release guard.
      * @param guard semaphore guard which should be released
      */
-    void releaseGuard(@Nullable final Semaphore guard);
+    void releaseGuard(@Nullable Semaphore guard);
 }
index 5e3838978c9627f577a710020ef79d6eb607eb33..81c3c61a14cbe76e7a1c236a56367d02be4fdeff 100644 (file)
@@ -20,6 +20,8 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 public interface SyncPlanPushStrategy {
 
     /**
+     * Invoked to execute the synchronization strategy.
+     *
      * @param resultVehicle bootstrap future - execution will chain it's async calls to this one
      * @param diffInput     wraps all diff data required for any strategy ({add,remove,update} x {flow,group,meter})
      * @param counters      reference to internal one-shot statistics - summary off successfully pushed items
index c7435f322cae0cd15bfe373938af55c325640ad6..de58c8b7224d1bb98b242caa8c0becd9abce9e44 100644 (file)
@@ -18,10 +18,11 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  */
 public interface SyncReactor {
     /**
+     * Invoked to synchronize a device.
+     *
      * @param flowcapableNodePath path to openflow augmentation of node
      * @param syncupEntry configured node + device reflection
      * @return synchronization outcome
      */
-    ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                     final SyncupEntry syncupEntry);
+    ListenableFuture<Boolean> syncup(InstanceIdentifier<FlowCapableNode> flowcapableNodePath, SyncupEntry syncupEntry);
 }
index 062f1d4299aafe506212b199ef9ea1dfab780a3d..73c25f19be8745a9eb0282c98ae446e89bf1aa35 100644 (file)
@@ -41,8 +41,9 @@ public class FlowCapableNodeOdlDao implements FlowCapableNodeDao {
         this.logicalDatastoreType = logicalDatastoreType;
     }
 
+    @Override
     public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {
-        try (final ReadOnlyTransaction roTx = dataBroker.newReadOnlyTransaction()) {
+        try (ReadOnlyTransaction roTx = dataBroker.newReadOnlyTransaction()) {
             final InstanceIdentifier<FlowCapableNode> path =
                     NODES_IID.child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
             return roTx.read(logicalDatastoreType, path).checkedGet(5000, TimeUnit.MILLISECONDS);
index 835823fba7fe5692a345cfd47076e7591c20a91f..cbf44301cc6a611e8f7af0a1214238a5f434aa6b 100644 (file)
@@ -11,7 +11,9 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -45,14 +47,14 @@ public abstract class AbstractFrmSyncListener<T extends DataObject> implements N
                         LOG.trace("Syncup for {} return from {} listener", nodeId.getValue(), dsType());
                     }
                 }
-            } catch (Exception e) {
+            } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 LOG.error("Error processing inventory node modification: {}, {}", nodeId.getValue(), e);
             }
         }
     }
 
     protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
-            final DataTreeModification<T> modification);
+            DataTreeModification<T> modification);
 
     protected abstract LogicalDatastoreType dsType();
 
index fe4f43b3c6d85123d6bbd052fcf775b5e05b8441..71e2ad07337de4bf616ee59b1050a9b5b0ab2f8d 100644 (file)
@@ -85,13 +85,14 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
         this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
                 "RPC SalFlatBatchService not found.");
 
-        nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
+        nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+                FLOW_CAPABLE_NODE_WC_PATH);
         nodeOperationalDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH);
 
-        final ExecutorService executorService= Executors.newCachedThreadPool(new ThreadFactoryBuilder()
+        final ExecutorService executorService = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
                 .setNameFormat(FRS_EXECUTOR_PREFIX + "%d")
                 .setDaemon(false)
-                .setUncaughtExceptionHandler((thread, e) -> LOG.error("Uncaught exception {}", thread, e))
+                .setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
                 .build());
         syncThreadPool = MoreExecutors.listeningDecorator(executorService);
         broker.registerProvider(this);
@@ -125,8 +126,8 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
         final NodeListener<FlowCapableNode> nodeListenerConfig =
                 new SimplifiedConfigListener(reactor, configSnapshot, operationalDao);
-        final NodeListener<Node> nodeListenerOperational =
-                new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao, reconciliationRegistry, deviceMastershipManager);
+        final NodeListener<Node> nodeListenerOperational = new SimplifiedOperationalListener(reactor,
+                operationalSnapshot, configDao, reconciliationRegistry, deviceMastershipManager);
 
         dataTreeConfigChangeListener =
                 dataService.registerDataTreeChangeListener(nodeConfigDataTreePath, nodeListenerConfig);
@@ -136,6 +137,7 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
         LOG.info("ForwardingRulesSync has started.");
     }
 
+    @Override
     public void close() {
         if (Objects.nonNull(dataTreeConfigChangeListener)) {
             dataTreeConfigChangeListener.close();
index d9f9a361e363981e7f8a9e02763403b0570ca263..daac0a84490e525cf8bfa4972fdf41559e597620 100644 (file)
@@ -53,6 +53,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
      * Update cache. If operational data are present, choose appropriate data and start syncup.
      * Otherwise skip incoming change.
      */
+    @Override
     protected Optional<ListenableFuture<Boolean>> processNodeModification(
             final DataTreeModification<FlowCapableNode> modification) {
         final InstanceIdentifier<FlowCapableNode> nodePath = modification.getRootPath().getRootIdentifier();
@@ -89,7 +90,8 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
                                                   final FlowCapableNode dataAfter,
                                                   final FlowCapableNode operationalNode) {
         LOG.debug("Reconciliation {}: {}", dsType(), PathUtil.digNodeId(nodePath).getValue());
-        final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode, LogicalDatastoreType.OPERATIONAL);
+        final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode,
+                LogicalDatastoreType.OPERATIONAL);
         return reactor.syncup(nodePath, syncupEntry);
     }
 
index b633bb07b71f929362e8928ab45f5c641d5944a1..9e805e2d18b79b645f936b6966cdb88c349a4f58 100644 (file)
@@ -74,6 +74,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      * Update cache, register for device mastership when device connected and start reconciliation if device
      * is registered and actual modification is consistent.Skip the event otherwise.
      */
+    @Override
     protected Optional<ListenableFuture<Boolean>> processNodeModification(
             final DataTreeModification<Node> modification) {
         Optional<ListenableFuture<Boolean>> result;
@@ -85,7 +86,8 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
             deviceMastershipManager.onDeviceDisconnected(nodeId);
             result = skipModification(modification);
         } else {
-            operationalSnapshot.updateCache(nodeId, Optional.fromNullable(ModificationUtil.flowCapableNodeAfter(modification)));
+            operationalSnapshot.updateCache(nodeId, Optional.fromNullable(
+                    ModificationUtil.flowCapableNodeAfter(modification)));
 
             final boolean isAdd = isAdd(nodeModification) || isAddLogical(nodeModification);
 
@@ -93,8 +95,9 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
                 deviceMastershipManager.onDeviceConnected(nodeId);
             }
 
-            // if node is registered for reconcile we need consistent data from operational DS (skip partial collections)
-            // but we can accept first modification since all statistics are intentionally collected in one step on startup
+            // if node is registered for reconcile we need consistent data from operational DS (skip partial
+            // collections) but we can accept first modification since all statistics are intentionally collected in
+            // one step on startup
             if (reconciliationRegistry.isRegistered(nodeId) && (isAdd || isConsistentForReconcile(modification))) {
                 result = reconciliation(modification);
             } else {
@@ -122,7 +125,8 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      * All connectors disappeared from operational store (logical delete).
      */
     private boolean isDeleteLogical(final DataObjectModification<Node> nodeModification) {
-        return !safeConnectorsEmpty(nodeModification.getDataBefore()) && safeConnectorsEmpty(nodeModification.getDataAfter());
+        return !safeConnectorsEmpty(nodeModification.getDataBefore())
+                && safeConnectorsEmpty(nodeModification.getDataAfter());
 
     }
 
@@ -134,7 +138,8 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      * All connectors appeared in operational store (logical add).
      */
     private boolean isAddLogical(final DataObjectModification<Node> nodeModification) {
-        return safeConnectorsEmpty(nodeModification.getDataBefore()) && !safeConnectorsEmpty(nodeModification.getDataAfter());
+        return safeConnectorsEmpty(nodeModification.getDataBefore())
+                && !safeConnectorsEmpty(nodeModification.getDataAfter());
     }
 
     /**
index 015cd8e4554a4ee2e9c809e86f1662476e75ece1..c435140941f26a992f03df2985e57cbeb595cfe9 100644 (file)
@@ -41,6 +41,7 @@ public class SyncReactorGuardDecorator implements SyncReactor {
         this.delegate = delegate;
     }
 
+    @Override
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
                                             final SyncupEntry syncupEntry) {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
@@ -75,14 +76,16 @@ public class SyncReactorGuardDecorator implements SyncReactor {
                 }
                 semaphoreKeeper.releaseGuard(guard);
             }
+
             @Override
-            public void onFailure(final Throwable t) {
+            public void onFailure(final Throwable failure) {
                 final long stampFinished = System.nanoTime();
                 LOG.warn("Syncup failed {} took:{} rpc:{} wait:{}", nodeId.getValue(),
                         formatNanos(stampFinished - stampBeforeGuard), formatNanos(stampFinished - stampAfterGuard),
                         formatNanos(stampAfterGuard - stampBeforeGuard));
                 semaphoreKeeper.releaseGuard(guard);
-            }};
+            }
+        };
     }
 
     private static String formatNanos(final long nanos) {
index b1c73fce825543ec06421d827b988248008fb0e7..7ffea9c8fe3ef76a16beb3d7c0b3d9fb92304d28 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -75,11 +74,14 @@ public class SyncReactorImpl implements SyncReactor {
          *  - flows - meters - groups (reordered)
          **/
 
-        final List<ItemSyncBox<Group>> groupsToAddOrUpdate = extractGroupsToAddOrUpdate(nodeId, configTree, operationalTree);
+        final List<ItemSyncBox<Group>> groupsToAddOrUpdate =
+                extractGroupsToAddOrUpdate(nodeId, configTree, operationalTree);
         final ItemSyncBox<Meter> metersToAddOrUpdate = extractMetersToAddOrUpdate(nodeId, configTree, operationalTree);
-        final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate = extractFlowsToAddOrUpdate(nodeId, configTree, operationalTree);
+        final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate =
+                extractFlowsToAddOrUpdate(nodeId, configTree, operationalTree);
 
-        final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove = extractFlowsToRemove(nodeId, configTree, operationalTree);
+        final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove =
+                extractFlowsToRemove(nodeId, configTree, operationalTree);
         final ItemSyncBox<Meter> metersToRemove = extractMetersToRemove(nodeId, configTree, operationalTree);
         final List<ItemSyncBox<Group>> groupsToRemove = extractGroupsToRemove(nodeId, configTree, operationalTree);
 
@@ -91,32 +93,29 @@ public class SyncReactorImpl implements SyncReactor {
         final ListenableFuture<RpcResult<Void>> resultVehicle = syncPlanPushStrategy.executeSyncStrategy(
                 bootstrapResultFuture, input, counters);
 
-        return Futures.transform(resultVehicle, new Function<RpcResult<Void>, Boolean>() {
-            @Override
-            public Boolean apply(RpcResult<Void> input) {
-                if (input == null) {
-                    return false;
-                }
-                if (LOG.isDebugEnabled()) {
-                    final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
-                    final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
-                    final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
-                    LOG.debug("Syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, " +
-                                    "meter={}/{}/{}, errors={}",
-                            nodeId.getValue(),
-                            flowCrudCounts.getAdded(), flowCrudCounts.getUpdated(), flowCrudCounts.getRemoved(),
-                            groupCrudCounts.getAdded(), groupCrudCounts.getUpdated(), groupCrudCounts.getRemoved(),
-                            meterCrudCounts.getAdded(), meterCrudCounts.getUpdated(), meterCrudCounts.getRemoved(),
-                            Arrays.toString(input.getErrors().toArray()));
-                }
-                return input.isSuccessful();
-            }}, MoreExecutors.directExecutor());
+        return Futures.transform(resultVehicle, input1 -> {
+            if (input1 == null) {
+                return false;
+            }
+            if (LOG.isDebugEnabled()) {
+                final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
+                final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
+                final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
+                LOG.debug("Syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, "
+                                + "meter={}/{}/{}, errors={}",
+                        nodeId.getValue(),
+                        flowCrudCounts.getAdded(), flowCrudCounts.getUpdated(), flowCrudCounts.getRemoved(),
+                        groupCrudCounts.getAdded(), groupCrudCounts.getUpdated(), groupCrudCounts.getRemoved(),
+                        meterCrudCounts.getAdded(), meterCrudCounts.getUpdated(), meterCrudCounts.getRemoved(),
+                        Arrays.toString(input1.getErrors().toArray()));
+            }
+            return input1.isSuccessful();
+        }, MoreExecutors.directExecutor());
     }
 
     @VisibleForTesting
     private static List<ItemSyncBox<Group>> extractGroupsToAddOrUpdate(final NodeId nodeId,
-                                                                       final FlowCapableNode flowCapableNodeConfigured,
-                                                                       final FlowCapableNode flowCapableNodeOperational) {
+            final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
         final List<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
         final List<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
         final Map<Long, Group> groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational);
@@ -140,8 +139,7 @@ public class SyncReactorImpl implements SyncReactor {
 
     @VisibleForTesting
     private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToAddOrUpdate(final NodeId nodeId,
-                                                                              final FlowCapableNode flowCapableNodeConfigured,
-                                                                              final FlowCapableNode flowCapableNodeOperational) {
+            final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
         final List<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
         if (tablesConfigured.isEmpty()) {
             return Collections.emptyMap();
@@ -155,8 +153,7 @@ public class SyncReactorImpl implements SyncReactor {
 
     @VisibleForTesting
     private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToRemove(final NodeId nodeId,
-                                                                         final FlowCapableNode flowCapableNodeConfigured,
-                                                                         final FlowCapableNode flowCapableNodeOperational) {
+            final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
         final List<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
         if (tablesOperational.isEmpty()) {
             return Collections.emptyMap();
index 2d76bf384333e8f1fd2b1356597ffb1850eb4b68..df1f37ea7a8530e33a5201d1082207ed4699cc16 100644 (file)
@@ -61,6 +61,7 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void close() {
         if (clusterSingletonServiceRegistration != null) {
             try {
index 2b9e7ebf42d15416f611d52846230335e4f6d610..405868d6028a7fe9a61fd329d4b3b733095a30c9 100644 (file)
@@ -33,7 +33,8 @@ public class DeviceMastershipManager {
 
     public void onDeviceConnected(final NodeId nodeId) {
         LOG.debug("FRS service registered for: {}", nodeId.getValue());
-        final DeviceMastership mastership = new DeviceMastership(nodeId, reconciliationRegistry, clusterSingletonService);
+        final DeviceMastership mastership = new DeviceMastership(nodeId, reconciliationRegistry,
+                clusterSingletonService);
         deviceMasterships.put(nodeId, mastership);
     }
 
index 2609d576f7c62b2ff0e72cdded3b5617307cbf9c..3381b0ac2cc6212a9edf02da5f1b40610148f370 100644 (file)
@@ -38,7 +38,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Flow}.
  */
-public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutput, RemoveFlowOutput, UpdateFlowOutput> {
+public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutput, RemoveFlowOutput,
+        UpdateFlowOutput> {
 
     private static final Logger LOG = LoggerFactory.getLogger(FlowForwarder.class);
     private static final String TABLE_ID_MISMATCH = "tableId mismatch";
@@ -89,8 +90,8 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
 
             // always needs to set strict flag into update-flow input so that
             // only a flow entry associated with a given flow object is updated.
-            builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).setStrict(Boolean.TRUE).build());
-            builder.setOriginalFlow((new OriginalFlowBuilder(original)).setStrict(Boolean.TRUE).build());
+            builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build());
+            builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build());
 
             output = salFlowService.updateFlow(builder.build());
         } else {
@@ -118,7 +119,8 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
             builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
             output = salFlowService.addFlow(builder.build());
         } else {
-            output = RpcResultBuilder.<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture();
+            output = RpcResultBuilder.<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION,
+                    TABLE_ID_MISMATCH).buildFuture();
         }
         return output;
     }
index 4a43ad1a2b3613a3cdc33a194073d201f69a45ba..be8a93127ed0515e899f697b8ff43ac2fb9e4f3d 100644 (file)
@@ -32,7 +32,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Group}.
  */
-public class GroupForwarder implements ForwardingRulesCommitter<Group, AddGroupOutput, RemoveGroupOutput, UpdateGroupOutput> {
+public class GroupForwarder implements ForwardingRulesCommitter<Group, AddGroupOutput, RemoveGroupOutput,
+        UpdateGroupOutput> {
 
     private static final Logger LOG = LoggerFactory.getLogger(GroupForwarder.class);
     private final SalGroupService salGroupService;
@@ -42,8 +43,8 @@ public class GroupForwarder implements ForwardingRulesCommitter<Group, AddGroupO
     }
 
     @Override
-    public Future<RpcResult<RemoveGroupOutput>> remove(final InstanceIdentifier<Group> identifier, final Group removeDataObj,
-                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+    public Future<RpcResult<RemoveGroupOutput>> remove(final InstanceIdentifier<Group> identifier,
+            final Group removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Forwarding Table REMOVE request [Tbl id, node Id {} {}",
                 identifier, nodeIdent);
 
@@ -67,8 +68,8 @@ public class GroupForwarder implements ForwardingRulesCommitter<Group, AddGroupO
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
         builder.setGroupRef(new GroupRef(identifier));
-        builder.setUpdatedGroup((new UpdatedGroupBuilder(update)).build());
-        builder.setOriginalGroup((new OriginalGroupBuilder(original)).build());
+        builder.setUpdatedGroup(new UpdatedGroupBuilder(update).build());
+        builder.setOriginalGroup(new OriginalGroupBuilder(original).build());
 
         return salGroupService.updateGroup(builder.build());
     }
index 20f1fc8fd8d89190933a51912f1c353557cbed5d..e28725315d1941c9c15ee8a6b20d9a1327a087b0 100644 (file)
@@ -32,7 +32,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Meter}.
  */
-public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterOutput, RemoveMeterOutput, UpdateMeterOutput> {
+public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterOutput, RemoveMeterOutput,
+        UpdateMeterOutput> {
 
     private static final Logger LOG = LoggerFactory.getLogger(MeterForwarder.class);
     private final SalMeterService salMeterService;
@@ -42,8 +43,8 @@ public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterO
     }
 
     @Override
-    public Future<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj,
-                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+    public Future<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier,
+            final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
 
         LOG.trace("Received the Meter REMOVE request [Tbl id, node Id {} {}",
                 identifier, nodeIdent);
@@ -66,8 +67,8 @@ public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterO
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
         builder.setMeterRef(new MeterRef(identifier));
-        builder.setUpdatedMeter((new UpdatedMeterBuilder(update)).build());
-        builder.setOriginalMeter((new OriginalMeterBuilder(original)).build());
+        builder.setUpdatedMeter(new UpdatedMeterBuilder(update).build());
+        builder.setOriginalMeter(new OriginalMeterBuilder(original).build());
 
         return salMeterService.updateMeter(builder.build());
     }
index 2196e3e90a48b43a7fbb176877b8dc97b3155882..a022c282b9e65da672a34cf37dde98261d90d2aa 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.PeekingIterator;
 import com.google.common.collect.Range;
-import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
@@ -107,8 +106,10 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         counters.getGroupCrudCounts().setUpdated(ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
         counters.getGroupCrudCounts().setRemoved(ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
 
-        counters.getFlowCrudCounts().setAdded(ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
-        counters.getFlowCrudCounts().setUpdated(ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
+        counters.getFlowCrudCounts().setAdded(ReconcileUtil.countTotalPushed(
+                diffInput.getFlowsToAddOrUpdate().values()));
+        counters.getFlowCrudCounts().setUpdated(ReconcileUtil.countTotalUpdated(
+                diffInput.getFlowsToAddOrUpdate().values()));
         counters.getFlowCrudCounts().setRemoved(ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
 
         counters.getMeterCrudCounts().setAdded(diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
@@ -119,40 +120,38 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // TODO enable table-update when ready
         //resultVehicle = updateTableFeatures(nodeIdent, configTree);
 
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                final List<Batch> batchBag = new ArrayList<>();
-                int batchOrder = 0;
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            final List<Batch> batchBag = new ArrayList<>();
+            int batchOrder = 0;
 
-                batchOrder = assembleAddOrUpdateGroups(batchBag, batchOrder, diffInput.getGroupsToAddOrUpdate());
-                batchOrder = assembleAddOrUpdateMeters(batchBag, batchOrder, diffInput.getMetersToAddOrUpdate());
-                batchOrder = assembleAddOrUpdateFlows(batchBag, batchOrder, diffInput.getFlowsToAddOrUpdate());
+            batchOrder = assembleAddOrUpdateGroups(batchBag, batchOrder, diffInput.getGroupsToAddOrUpdate());
+            batchOrder = assembleAddOrUpdateMeters(batchBag, batchOrder, diffInput.getMetersToAddOrUpdate());
+            batchOrder = assembleAddOrUpdateFlows(batchBag, batchOrder, diffInput.getFlowsToAddOrUpdate());
 
-                batchOrder = assembleRemoveFlows(batchBag, batchOrder, diffInput.getFlowsToRemove());
-                batchOrder = assembleRemoveMeters(batchBag, batchOrder, diffInput.getMetersToRemove());
-                batchOrder = assembleRemoveGroups(batchBag, batchOrder, diffInput.getGroupsToRemove());
+            batchOrder = assembleRemoveFlows(batchBag, batchOrder, diffInput.getFlowsToRemove());
+            batchOrder = assembleRemoveMeters(batchBag, batchOrder, diffInput.getMetersToRemove());
+            batchOrder = assembleRemoveGroups(batchBag, batchOrder, diffInput.getGroupsToRemove());
 
-                LOG.trace("Index of last batch step: {}", batchOrder);
+            LOG.trace("Index of last batch step: {}", batchOrder);
 
-                final ProcessFlatBatchInput flatBatchInput = new ProcessFlatBatchInputBuilder()
-                        .setNode(new NodeRef(PathUtil.digNodePath(diffInput.getNodeIdent())))
-                        // TODO: propagate from input
-                        .setExitOnFirstError(false)
-                        .setBatch(batchBag)
-                        .build();
+            final ProcessFlatBatchInput flatBatchInput = new ProcessFlatBatchInputBuilder()
+                    .setNode(new NodeRef(PathUtil.digNodePath(diffInput.getNodeIdent())))
+                    // TODO: propagate from input
+                    .setExitOnFirstError(false)
+                    .setBatch(batchBag)
+                    .build();
 
-                final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture = flatBatchService.processFlatBatch(flatBatchInput);
+            final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture =
+                    flatBatchService.processFlatBatch(flatBatchInput);
 
-                if (LOG.isDebugEnabled()) {
-                    Futures.addCallback(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
-                            createCounterCallback(batchBag, batchOrder, counters), MoreExecutors.directExecutor());
-                }
-
-                return Futures.transform(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
-                        ReconcileUtil.<ProcessFlatBatchOutput>createRpcResultToVoidFunction("flat-batch"),
-                        MoreExecutors.directExecutor());
+            if (LOG.isDebugEnabled()) {
+                Futures.addCallback(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
+                        createCounterCallback(batchBag, batchOrder, counters), MoreExecutors.directExecutor());
             }
+
+            return Futures.transform(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
+                    ReconcileUtil.<ProcessFlatBatchOutput>createRpcResultToVoidFunction("flat-batch"),
+                    MoreExecutors.directExecutor());
         }, MoreExecutors.directExecutor());
         return resultVehicle;
     }
@@ -163,14 +162,15 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         return new FutureCallback<RpcResult<ProcessFlatBatchOutput>>() {
             @Override
             public void onSuccess(@Nullable final RpcResult<ProcessFlatBatchOutput> result) {
-                if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) {
+                if (!result.isSuccessful() && result.getResult() != null
+                        && !result.getResult().getBatchFailure().isEmpty()) {
                     Map<Range<Integer>, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit);
                     decrementBatchFailuresCounters(result.getResult().getBatchFailure(), batchMap, counters);
                 }
             }
 
             @Override
-            public void onFailure(final Throwable t) {
+            public void onFailure(final Throwable failure) {
                 counters.resetAll();
             }
         };
@@ -227,7 +227,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleRemoveFlows(final List<Batch> batchBag, int batchOrder, final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
+    static int assembleRemoveFlows(final List<Batch> batchBag, int batchOrder,
+            final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
         // process flow remove
         int order = batchOrder;
         if (flowItemSyncTableMap != null) {
@@ -259,7 +260,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleAddOrUpdateGroups(final List<Batch> batchBag, int batchOrder, final List<ItemSyncBox<Group>> groupsToAddOrUpdate) {
+    static int assembleAddOrUpdateGroups(final List<Batch> batchBag, int batchOrder,
+            final List<ItemSyncBox<Group>> groupsToAddOrUpdate) {
         // process group add+update
         int order = batchOrder;
         if (groupsToAddOrUpdate != null) {
@@ -269,7 +271,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
                             new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size());
                     int itemOrder = 0;
                     for (Group group : groupItemSyncBox.getItemsToPush()) {
-                        flatBatchAddGroupBag.add(new FlatBatchAddGroupBuilder(group).setBatchOrder(itemOrder++).build());
+                        flatBatchAddGroupBag.add(new FlatBatchAddGroupBuilder(group)
+                                .setBatchOrder(itemOrder++).build());
                     }
                     final Batch batch = new BatchBuilder()
                             .setBatchChoice(new FlatBatchAddGroupCaseBuilder()
@@ -287,10 +290,10 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
                     int itemOrder = 0;
                     for (ItemSyncBox.ItemUpdateTuple<Group> groupUpdate : groupItemSyncBox.getItemsToUpdate()) {
                         flatBatchUpdateGroupBag.add(new FlatBatchUpdateGroupBuilder()
-                                .setBatchOrder(itemOrder++)
-                                .setOriginalBatchedGroup(new OriginalBatchedGroupBuilder(groupUpdate.getOriginal()).build())
-                                .setUpdatedBatchedGroup(new UpdatedBatchedGroupBuilder(groupUpdate.getUpdated()).build())
-                                .build());
+                            .setBatchOrder(itemOrder++)
+                            .setOriginalBatchedGroup(new OriginalBatchedGroupBuilder(groupUpdate.getOriginal()).build())
+                            .setUpdatedBatchedGroup(new UpdatedBatchedGroupBuilder(groupUpdate.getUpdated()).build())
+                            .build());
                     }
                     final Batch batch = new BatchBuilder()
                             .setBatchChoice(new FlatBatchUpdateGroupCaseBuilder()
@@ -307,7 +310,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleRemoveGroups(final List<Batch> batchBag, int batchOrder, final List<ItemSyncBox<Group>> groupsToRemoveOrUpdate) {
+    static int assembleRemoveGroups(final List<Batch> batchBag, int batchOrder,
+            final List<ItemSyncBox<Group>> groupsToRemoveOrUpdate) {
         // process group add+update
         int order = batchOrder;
         if (groupsToRemoveOrUpdate != null) {
@@ -317,7 +321,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
                             new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size());
                     int itemOrder = 0;
                     for (Group group : groupItemSyncBox.getItemsToPush()) {
-                        flatBatchRemoveGroupBag.add(new FlatBatchRemoveGroupBuilder(group).setBatchOrder(itemOrder++).build());
+                        flatBatchRemoveGroupBag.add(new FlatBatchRemoveGroupBuilder(group)
+                                .setBatchOrder(itemOrder++).build());
                     }
                     final Batch batch = new BatchBuilder()
                             .setBatchChoice(new FlatBatchRemoveGroupCaseBuilder()
@@ -334,7 +339,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleAddOrUpdateMeters(final List<Batch> batchBag, int batchOrder, final ItemSyncBox<Meter> meterItemSyncBox) {
+    static int assembleAddOrUpdateMeters(final List<Batch> batchBag, int batchOrder,
+            final ItemSyncBox<Meter> meterItemSyncBox) {
         // process meter add+update
         int order = batchOrder;
         if (meterItemSyncBox != null) {
@@ -380,7 +386,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleRemoveMeters(final List<Batch> batchBag, int batchOrder, final ItemSyncBox<Meter> meterItemSyncBox) {
+    static int assembleRemoveMeters(final List<Batch> batchBag, int batchOrder,
+            final ItemSyncBox<Meter> meterItemSyncBox) {
         // process meter remove
         int order = batchOrder;
         if (meterItemSyncBox != null && !meterItemSyncBox.getItemsToPush().isEmpty()) {
@@ -403,7 +410,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     }
 
     @VisibleForTesting
-    static int assembleAddOrUpdateFlows(final List<Batch> batchBag, int batchOrder, final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
+    static int assembleAddOrUpdateFlows(final List<Batch> batchBag, int batchOrder,
+            final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
         // process flow add+update
         int order = batchOrder;
         if (flowItemSyncTableMap != null) {
@@ -436,11 +444,11 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
                     int itemOrder = 0;
                     for (ItemSyncBox.ItemUpdateTuple<Flow> flowUpdate : flowItemSyncBox.getItemsToUpdate()) {
                         flatBatchUpdateFlowBag.add(new FlatBatchUpdateFlowBuilder()
-                                .setBatchOrder(itemOrder++)
-                                .setFlowId(flowUpdate.getUpdated().getId())
-                                .setOriginalBatchedFlow(new OriginalBatchedFlowBuilder(flowUpdate.getOriginal()).build())
-                                .setUpdatedBatchedFlow(new UpdatedBatchedFlowBuilder(flowUpdate.getUpdated()).build())
-                                .build());
+                            .setBatchOrder(itemOrder++)
+                            .setFlowId(flowUpdate.getUpdated().getId())
+                            .setOriginalBatchedFlow(new OriginalBatchedFlowBuilder(flowUpdate.getOriginal()).build())
+                            .setUpdatedBatchedFlow(new UpdatedBatchedFlowBuilder(flowUpdate.getUpdated()).build())
+                            .build());
                     }
                     final Batch batch = new BatchBuilder()
                             .setBatchChoice(new FlatBatchUpdateFlowCaseBuilder()
index 13dc215d60e81bb6aa4e17b64747dc3910189c30..1b2156330d79d3e0fea58d4d74a1e746f1c1cbe1 100644 (file)
@@ -9,11 +9,10 @@
 package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
-import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -80,74 +79,56 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
         // TODO enable table-update when ready
         //resultVehicle = updateTableFeatures(nodeIdent, configTree);
 
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                    //final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(
-                    //        Futures.asList Arrays.asList(input, output),
-                    //        ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("TODO"));
-                }
-                return addMissingGroups(nodeId, nodeIdent, diffInput.getGroupsToAddOrUpdate(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
+                //final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(
+                //        Futures.asList Arrays.asList(input, output),
+                //        ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("TODO"));
             }
+            return addMissingGroups(nodeId, nodeIdent, diffInput.getGroupsToAddOrUpdate(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingGroups"),
                 MoreExecutors.directExecutor());
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                }
-                return addMissingMeters(nodeId, nodeIdent, diffInput.getMetersToAddOrUpdate(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
             }
+            return addMissingMeters(nodeId, nodeIdent, diffInput.getMetersToAddOrUpdate(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingMeters"),
                 MoreExecutors.directExecutor());
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                }
-                return addMissingFlows(nodeId, nodeIdent, diffInput.getFlowsToAddOrUpdate(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
             }
+            return addMissingFlows(nodeId, nodeIdent, diffInput.getFlowsToAddOrUpdate(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingFlows"),
                 MoreExecutors.directExecutor());
 
 
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                }
-                return removeRedundantFlows(nodeId, nodeIdent, diffInput.getFlowsToRemove(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
             }
+            return removeRedundantFlows(nodeId, nodeIdent, diffInput.getFlowsToRemove(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantFlows"),
                 MoreExecutors.directExecutor());
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                }
-                return removeRedundantMeters(nodeId, nodeIdent, diffInput.getMetersToRemove(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
             }
+            return removeRedundantMeters(nodeId, nodeIdent, diffInput.getMetersToRemove(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantMeters"),
                 MoreExecutors.directExecutor());
-        resultVehicle = Futures.transformAsync(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                }
-                return removeRedundantGroups(nodeId, nodeIdent, diffInput.getGroupsToRemove(), counters);
+        resultVehicle = Futures.transformAsync(resultVehicle, input -> {
+            if (!input.isSuccessful()) {
+                //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
             }
+            return removeRedundantGroups(nodeId, nodeIdent, diffInput.getGroupsToRemove(), counters);
         }, MoreExecutors.directExecutor());
         Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantGroups"),
                 MoreExecutors.directExecutor());
@@ -189,7 +170,8 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 final Flow existingFlow = flowUpdate.getOriginal();
                 final Flow updatedFlow = flowUpdate.getUpdated();
 
-                final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, updatedFlow.getKey());
+                final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class,
+                        updatedFlow.getKey());
                 LOG.trace("flow {} in table {} - needs update on device {} match{}",
                         updatedFlow.getId(), tableKey, nodeId, updatedFlow.getMatch());
 
@@ -298,22 +280,17 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
             }
             Collections.reverse(groupsRemovalPlan);
             for (final ItemSyncBox<Group> groupsPortion : groupsRemovalPlan) {
-                chainedResult =
-                        Futures.transformAsync(chainedResult, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-                            @Override
-                            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input)
-                                    throws Exception {
-                                final ListenableFuture<RpcResult<Void>> result;
-                                if (input.isSuccessful()) {
-                                    result = flushRemoveGroupPortionAndBarrier(nodeIdent, groupsPortion);
-                                } else {
-                                    // pass through original unsuccessful rpcResult
-                                    result = Futures.immediateFuture(input);
-                                }
-
-                                return result;
-                            }
-                        }, MoreExecutors.directExecutor());
+                chainedResult = Futures.transformAsync(chainedResult, input -> {
+                    final ListenableFuture<RpcResult<Void>> result;
+                    if (input.isSuccessful()) {
+                        result = flushRemoveGroupPortionAndBarrier(nodeIdent, groupsPortion);
+                    } else {
+                        // pass through original unsuccessful rpcResult
+                        result = Futures.immediateFuture(input);
+                    }
+
+                    return result;
+                }, MoreExecutors.directExecutor());
             }
         } catch (IllegalStateException e) {
             chainedResult = RpcResultBuilder.<Void>failed()
@@ -358,7 +335,8 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 for (TableFeatures tableFeaturesItem : tableFeatures) {
                     // TODO uncomment java.lang.NullPointerException
                     // at
-                    // org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer.serializeHeader(AbstractOxmMatchEntrySerializer.java:31
+                    // org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer
+                    //    .serializeHeader(AbstractOxmMatchEntrySerializer.java:31
                     // allResults.add(JdkFutureAdapters.listenInPoolThread(
                     // tableForwarder.update(tableFeaturesII, null, tableFeaturesItem, nodeIdent)));
                 }
@@ -489,21 +467,17 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 chainedResult = flushAddGroupPortionAndBarrier(nodeIdent, groupsAddPlan.get(0));
                 for (final ItemSyncBox<Group> groupsPortion : Iterables.skip(groupsAddPlan, 1)) {
                     chainedResult =
-                            Futures.transformAsync(chainedResult, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-                                @Override
-                                public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input)
-                                        throws Exception {
-                                    final ListenableFuture<RpcResult<Void>> result;
-                                    if (input.isSuccessful()) {
-                                        result = flushAddGroupPortionAndBarrier(nodeIdent, groupsPortion);
-                                    } else {
-                                        // pass through original unsuccessful rpcResult
-                                        result = Futures.immediateFuture(input);
-                                    }
-
-                                    return result;
-                                }
-                            }, MoreExecutors.directExecutor());
+                        Futures.transformAsync(chainedResult, input -> {
+                            final ListenableFuture<RpcResult<Void>> result;
+                            if (input.isSuccessful()) {
+                                result = flushAddGroupPortionAndBarrier(nodeIdent, groupsPortion);
+                            } else {
+                                // pass through original unsuccessful rpcResult
+                                result = Futures.immediateFuture(input);
+                            }
+
+                            return result;
+                        }, MoreExecutors.directExecutor());
                 }
             } else {
                 chainedResult = RpcResultBuilder.<Void>success().buildFuture();
@@ -538,7 +512,8 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
         return this;
     }
 
-    public SyncPlanPushStrategyIncrementalImpl setTransactionService(final FlowCapableTransactionService transactionService) {
+    public SyncPlanPushStrategyIncrementalImpl setTransactionService(
+            final FlowCapableTransactionService transactionService) {
         this.transactionService = transactionService;
         return this;
     }
index 676cd9221e2a0eaf6f6dd2e0e641d505eb1b30ee..af4aaffbadcfce00512ad8d9c0add151eaf35bc9 100644 (file)
@@ -25,15 +25,15 @@ public class FlowDescriptor {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object obj) {
+        if (this == obj) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
 
-        FlowDescriptor that = (FlowDescriptor) o;
+        FlowDescriptor that = (FlowDescriptor) obj;
         if (flowId != null ? !flowId.equals(that.flowId) : that.flowId != null) {
             return false;
         }
index 5e02d48a39d8aedbfe626282b07aea6dfc6f4d17..18d79bf1b11b6402be6a14d1d8579eaf95ad4844 100644 (file)
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Util methods for {@link com.google.common.util.concurrent.ListenableFuture} chaining.
  */
-public class FxChainUtil {
+public final class FxChainUtil {
 
     private static final Logger LOG = LoggerFactory.getLogger(FxChainUtil.class);
 
@@ -40,7 +40,8 @@ public class FxChainUtil {
                     if (result.isSuccessful()) {
                         LOG.debug(prefix + " finished successfully: {}", nodeId.getValue());
                     } else {
-                        final Collection<RpcError> errors = MoreObjects.firstNonNull(result.getErrors(), ImmutableList.<RpcError>of());
+                        final Collection<RpcError> errors = MoreObjects.firstNonNull(result.getErrors(),
+                                ImmutableList.<RpcError>of());
                         LOG.debug(prefix + " failed: {} -> {}", nodeId.getValue(), Arrays.toString(errors.toArray()));
                     }
                 } else {
@@ -49,8 +50,8 @@ public class FxChainUtil {
             }
 
             @Override
-            public void onFailure(final Throwable t) {
-                LOG.debug(prefix + " reconciliation failed seriously: {}", nodeId.getValue(), t);
+            public void onFailure(final Throwable failure) {
+                LOG.debug(prefix + " reconciliation failed seriously: {}", nodeId.getValue(), failure);
             }
         };
     }
index 0eb7252725f233603d47c387285f51576f782406..3c96f8b1b36524878599922a5c32eb87ef7a943b 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 /**
  * Basic {@link DataTreeModification} related tools.
  */
-public class ModificationUtil {
+public final class ModificationUtil {
 
     private ModificationUtil() {
         throw new IllegalStateException("This class should not be instantiated.");
index 9f84a63851c3090819acc938be983f335cf8a698..b6e984229f5e6a115bb768fff0ce0f3fe0bb52f0 100644 (file)
@@ -17,11 +17,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 /**
  * Basic {@link InstanceIdentifier} related tools.
  */
-public class PathUtil {
+public final class PathUtil {
 
     private PathUtil() {
         throw new IllegalStateException("This class should not be instantiated.");
     }
+
     public static NodeId digNodeId(final InstanceIdentifier<?> nodeIdent) {
         return nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId();
     }
index 9bc5fb7dcf90dbfc696e403e97cc9496d5fcbbb8..ab0ad75f2d45a1f6f4de91970409d75e703d3f5d 100644 (file)
@@ -58,11 +58,14 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Creates a single rpc result of type Void honoring all partial rpc results.
+     *
      * @param previousItemAction description for case when the triggering future contains failure
      * @param <D>                type of rpc output (gathered in list)
      * @return single rpc result of type Void honoring all partial rpc results
      */
-    public static <D> Function<List<RpcResult<D>>, RpcResult<Void>> createRpcResultCondenser(final String previousItemAction) {
+    public static <D> Function<List<RpcResult<D>>, RpcResult<Void>> createRpcResultCondenser(
+            final String previousItemAction) {
         return input -> {
             final RpcResultBuilder<Void> resultSink;
             if (input != null) {
@@ -86,11 +89,14 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Creates a single rpc result of type Void honoring all partial rpc results.
+     *
      * @param actionDescription description for case when the triggering future contains failure
      * @param <D>               type of rpc output (gathered in list)
      * @return single rpc result of type Void honoring all partial rpc results
      */
-    public static <D> Function<RpcResult<D>, RpcResult<Void>> createRpcResultToVoidFunction(final String actionDescription) {
+    public static <D> Function<RpcResult<D>, RpcResult<Void>> createRpcResultToVoidFunction(
+            final String actionDescription) {
         return input -> {
             final RpcResultBuilder<Void> resultSink;
             if (input != null) {
@@ -110,7 +116,9 @@ public final class ReconcileUtil {
     }
 
     /**
-     * @param nodeIdent                     flow capable node path - target device for routed rpc
+     * Flushes a chain barrier.
+     *
+     * @param nodeIdent flow capable node path - target device for routed rpc
      * @param flowCapableTransactionService barrier rpc service
      * @return async barrier result
      */
@@ -126,7 +134,9 @@ public final class ReconcileUtil {
     }
 
     /**
-     * @param nodeId             target node
+     * Returns a list of safe synchronization steps with updates.
+     *
+     * @param nodeId target node
      * @param installedGroupsArg groups resent on device
      * @param pendingGroups      groups configured for device
      * @return list of safe synchronization steps with updates
@@ -138,6 +148,8 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Returns a list of safe synchronization steps.
+     *
      * @param nodeId             target node
      * @param installedGroupsArg groups resent on device
      * @param pendingGroups      groups configured for device
@@ -170,8 +182,10 @@ public final class ReconcileUtil {
                         } else {
                             if (checkGroupPrecondition(installedGroups.keySet(), group)) {
                                 iterator.remove();
-                                LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId);
-                                stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group));
+                                LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(),
+                                        nodeId);
+                                stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup,
+                                        group));
                             }
                         }
                     }
@@ -187,8 +201,8 @@ public final class ReconcileUtil {
                 installedGroups.putAll(installIncrement);
                 plan.add(stepPlan);
             } else if (!pendingGroups.isEmpty()) {
-                LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, " +
-                        "resolving stuck at level {}", nodeId.getValue(), plan.size());
+                LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, "
+                        "resolving stuck at level {}", nodeId.getValue(), plan.size());
                 throw new IllegalStateException("Failed to resolve and divide groups when matching preconditions");
             }
         }
@@ -203,7 +217,7 @@ public final class ReconcileUtil {
             for (Action action : bucket.getAction()) {
                 // if the output action is a group
                 if (GroupActionCase.class.equals(action.getAction().getImplementedInterface())) {
-                    Long groupId = ((GroupActionCase) (action.getAction())).getGroupAction().getGroupId();
+                    Long groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId();
                     // see if that output group is installed
                     if (!installedGroupIds.contains(groupId)) {
                         // if not installed, we have missing dependencies and cannot install this pending group
@@ -236,6 +250,8 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Resolves meter differences.
+     *
      * @param nodeId              target node
      * @param meterOperationalMap meters present on device
      * @param metersConfigured    meters configured for device
@@ -263,6 +279,8 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Resolves flow differences in a table.
+     *
      * @param flowsConfigured    flows resent on device
      * @param flowOperationalMap flows configured for device
      * @param gatherUpdates      check content of pending item if present on device (and create update task eventually)
@@ -289,6 +307,8 @@ public final class ReconcileUtil {
     }
 
     /**
+     * Resolves flow differences in all tables.
+     *
      * @param nodeId              target node
      * @param tableOperationalMap flow-tables resent on device
      * @param tablesConfigured    flow-tables configured for device
@@ -296,9 +316,8 @@ public final class ReconcileUtil {
      * @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps
      */
     public static Map<TableKey, ItemSyncBox<Flow>> resolveFlowDiffsInAllTables(final NodeId nodeId,
-                                                                               final Map<Short, Table> tableOperationalMap,
-                                                                               final List<Table> tablesConfigured,
-                                                                               final boolean gatherUpdates) {
+            final Map<Short, Table> tableOperationalMap, final List<Table> tablesConfigured,
+            final boolean gatherUpdates) {
         LOG.trace("resolving flows in tables for {}", nodeId.getValue());
         final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
         for (final Table tableConfigured : tablesConfigured) {
index 290730e4cc42928c593b4e98890158369ccaf3af..ee76cc9daa34dc4143d3dc4a4b88ba1212c0045f 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 
 /**
- * Data entry of before and after data for syncup in {@link org.opendaylight.openflowplugin.applications.frsync.SyncReactor}.
+ * Data entry of before and after data for syncup in
+ * {@link org.opendaylight.openflowplugin.applications.frsync.SyncReactor}.
  */
 public class SyncupEntry {
     private final FlowCapableNode after;
@@ -49,15 +50,15 @@ public class SyncupEntry {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object obj) {
+        if (this == obj) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
 
-        SyncupEntry that = (SyncupEntry) o;
+        SyncupEntry that = (SyncupEntry) obj;
 
         if (after != null ? !after.equals(that.after) : that.after != null) {
             return false;
index 2d8eb77c7e943d51be3dfed2a67945bef61ba5fd..150dd02040891afa6c578842064c610114acc13b 100644 (file)
@@ -47,7 +47,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter
  * Provides create methods for dataObjects involved in
  * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} by inventory.
  */
-public class DSInputFactory {
+public final class DSInputFactory {
+    private DSInputFactory() {
+    }
+
     public static Group createGroup(final long groupIdValue) {
         final Buckets buckets = new BucketsBuilder()
                 .setBucket(Collections.<Bucket>emptyList())
index 8ae21e2e19030a7bbdf8147ee7be48928d842d45..514784e5be2cec46516af0a52c4b6ad5b49a99d3 100644 (file)
@@ -14,9 +14,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
@@ -50,12 +48,10 @@ public class ForwardingRulesSyncProviderTest {
     @Before
     public void setUp() throws Exception {
         Mockito.when(rpcRegistry.getRpcService(Matchers.<Class<? extends RpcService>>any()))
-                .thenAnswer(new Answer<RpcService>() {
-                    @Override
-                    public RpcService answer(final InvocationOnMock invocation) throws Throwable {
-                        Class<? extends RpcService> serviceType = (Class<? extends RpcService>) invocation.getArguments()[0];
-                        return Mockito.mock(serviceType);
-                    }
+                .thenAnswer(invocation -> {
+                    Class<? extends RpcService> serviceType =
+                            (Class<? extends RpcService>) invocation.getArguments()[0];
+                    return Mockito.mock(serviceType);
                 });
 
         provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry, clusterSingletonService);
@@ -78,4 +74,4 @@ public class ForwardingRulesSyncProviderTest {
         provider.close();
     }
 
-}
\ No newline at end of file
+}
index fa79364664082213324db7e496f0b61bf5fc6e8a..ebea7768eec283848f42696a7c754643fa7455cf 100644 (file)
@@ -92,7 +92,8 @@ public class SimplifiedConfigListenerTest {
     public void testOnDataTreeChangedAdd() {
         Mockito.when(configModification.getDataBefore()).thenReturn(null);
         Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
-        final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
+        final SyncupEntry syncupEntry =
+                loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
@@ -129,8 +130,8 @@ public class SimplifiedConfigListenerTest {
 
     @Test
     public void testOnDataTreeChangedSkip() {
-        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)).
-                thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
@@ -138,8 +139,9 @@ public class SimplifiedConfigListenerTest {
         Mockito.verify(roTx).close();
     }
 
-    private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
-                                                               final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
+    private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after,
+            final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before,
+            final LogicalDatastoreType dsTypeBefore) {
         Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
                 .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
         final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
@@ -148,4 +150,4 @@ public class SimplifiedConfigListenerTest {
         return syncupEntry;
     }
 
-}
\ No newline at end of file
+}
index 32435aa8c1fb339715a1320839d3de3d5d8e4363..15b920d2b8ad56a3802be37233944a8ab96a3409 100644 (file)
@@ -57,7 +57,8 @@ public class SimplifiedOperationalListenerTest {
     private SimplifiedOperationalListener nodeListenerOperational;
     private final LogicalDatastoreType configDS = LogicalDatastoreType.CONFIGURATION;
     private final LogicalDatastoreType operationalDS = LogicalDatastoreType.OPERATIONAL;
-    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(SimplifiedOperationalListener.DATE_AND_TIME_FORMAT);
+    private final SimpleDateFormat simpleDateFormat =
+            new SimpleDateFormat(SimplifiedOperationalListener.DATE_AND_TIME_FORMAT);
 
     @Mock
     private SyncReactor reactor;
@@ -94,8 +95,10 @@ public class SimplifiedOperationalListenerTest {
         final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
 
-        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao, reconciliationRegistry, deviceMastershipManager);
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao,
+                reconciliationRegistry, deviceMastershipManager);
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class,
+                new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
 
         final DataTreeIdentifier<Node> dataTreeIdentifier =
@@ -171,7 +174,8 @@ public class SimplifiedOperationalListenerTest {
     public void testOnDataTreeChangedReconcileButStaticsGatheringNotFinished() {
         Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
         operationalUpdate();
-        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class))
+            .thenReturn(statisticsGatheringStatus);
         Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(null);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
@@ -183,7 +187,8 @@ public class SimplifiedOperationalListenerTest {
     public void testOnDataTreeChangedReconcileButStaticsGatheringNotSuccessful() {
         Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
         operationalUpdate();
-        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class))
+            .thenReturn(statisticsGatheringStatus);
         Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
         Mockito.when(snapshotGatheringStatusEnd.isSucceeded()).thenReturn(false);
 
@@ -208,7 +213,8 @@ public class SimplifiedOperationalListenerTest {
         Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
         operationalUpdate();
         prepareFreshOperational(true);
-        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
+        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(
+                configNode, configDS, fcOperationalNode, operationalDS);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
@@ -222,7 +228,8 @@ public class SimplifiedOperationalListenerTest {
         Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
         operationalAdd();
         prepareFreshOperational(false);
-        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
+        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(
+                configNode, configDS, fcOperationalNode, operationalDS);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
@@ -248,7 +255,8 @@ public class SimplifiedOperationalListenerTest {
     }
 
     private void prepareFreshOperational(final boolean afterRegistration) throws ParseException {
-        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class))
+             .thenReturn(statisticsGatheringStatus);
         Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
         Mockito.when(snapshotGatheringStatusEnd.isSucceeded()).thenReturn(true);
         Mockito.when(snapshotGatheringStatusEnd.getEnd()).thenReturn(Mockito.mock(DateAndTime.class));
@@ -256,10 +264,12 @@ public class SimplifiedOperationalListenerTest {
         final String timestampAfter = "9999-12-12T01:01:01.000-07:00";
         if (afterRegistration) {
             Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampAfter);
-            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampBefore));
+            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID))
+                .thenReturn(simpleDateFormat.parse(timestampBefore));
         } else {
             Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampBefore);
-            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampAfter));
+            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID))
+                .thenReturn(simpleDateFormat.parse(timestampAfter));
         }
     }
 
@@ -273,8 +283,9 @@ public class SimplifiedOperationalListenerTest {
         Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
     }
 
-    private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
-                                                          final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
+    private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after,
+            final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before,
+            final LogicalDatastoreType dsTypeBefore) {
         Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
                 .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
         final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
index 8b95fc009e6eca68a4b3c0cd6df1dc153bfacc56..8f1f52194f5bda1bb6df5e228df1fad1063f464e 100644 (file)
@@ -45,7 +45,8 @@ public class SyncReactorClusterDecoratorTest {
     public void setUp() {
         reactor = new SyncReactorClusterDecorator(delegate, deviceMastershipManager);
 
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
     }
 
@@ -68,4 +69,4 @@ public class SyncReactorClusterDecoratorTest {
         Mockito.verifyZeroInteractions(delegate);
     }
 
-}
\ No newline at end of file
+}
index 6b59c9b3e22474c496d5ecab7ed497377722ce95..77505176d175fa9ba36eb94b1b591a38c009776e 100644 (file)
@@ -27,9 +27,7 @@ import org.mockito.InOrder;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
@@ -66,7 +64,7 @@ public class SyncReactorFutureZipDecoratorTest {
         final ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
                 .setDaemon(false)
                 .setNameFormat("frsync-test-%d")
-                .setUncaughtExceptionHandler((thread, e) -> LOG.error("Uncaught exception {}", thread, e))
+                .setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
                 .build());
         syncThreadPool = MoreExecutors.listeningDecorator(executorService);
         reactor = new SyncReactorFutureZipDecorator(delegate, syncThreadPool);
@@ -90,15 +88,12 @@ public class SyncReactorFutureZipDecoratorTest {
         final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
 
         Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-                    @Override
-                    public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                        LOG.info("unlocking next configs");
-                        latchForNext.countDown();
-                        latchForFirst.await();
-                        LOG.info("unlocking first delegate");
-                        return Futures.immediateFuture(Boolean.TRUE);
-                    }
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking next configs");
+                    latchForNext.countDown();
+                    latchForFirst.await();
+                    LOG.info("unlocking first delegate");
+                    return Futures.immediateFuture(Boolean.TRUE);
                 });
 
         allResults.add(reactor.syncup(fcNodePath, first));
@@ -137,14 +132,11 @@ public class SyncReactorFutureZipDecoratorTest {
         final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
 
         Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-            @Override
-            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                LOG.info("unlocking next config");
-                latchForNext.countDown();
-                return Futures.immediateFuture(Boolean.TRUE);
-            }
-            });
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking next config");
+                    latchForNext.countDown();
+                    return Futures.immediateFuture(Boolean.TRUE);
+                });
 
         reactor.syncup(fcNodePath, first);
         latchForNext.await();
@@ -175,16 +167,13 @@ public class SyncReactorFutureZipDecoratorTest {
         final SyncupEntry second = new SyncupEntry(configActual, configDS, freshOperational, operationalDS);
 
         Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-            @Override
-            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                LOG.info("unlocking for fresh operational");
-                latchForNext.countDown();
-                latchForFirst.await();
-                LOG.info("unlocking first delegate");
-                return Futures.immediateFuture(Boolean.TRUE);
-            }
-        });
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking for fresh operational");
+                    latchForNext.countDown();
+                    latchForFirst.await();
+                    LOG.info("unlocking first delegate");
+                    return Futures.immediateFuture(Boolean.TRUE);
+                });
 
         reactor.syncup(fcNodePath, first);
         latchForNext.await();
@@ -211,4 +200,4 @@ public class SyncReactorFutureZipDecoratorTest {
     public void tearDown() {
         syncThreadPool.shutdownNow();
     }
-}
\ No newline at end of file
+}
index 099d45cc2fc8ada72eb57a00d0c545a54eca29c0..fa0fcbf38da13736ed7d5f421156358072cdf6ba 100644 (file)
@@ -47,7 +47,8 @@ public class SyncReactorGuardDecoratorTest {
     @Before
     public void setUp() throws Exception {
         reactor = new SyncReactorGuardDecorator(delegate);
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
 
         final Node operationalNode = Mockito.mock(Node.class);
@@ -76,4 +77,4 @@ public class SyncReactorGuardDecoratorTest {
         Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
         Mockito.verifyNoMoreInteractions(delegate);
     }
-}
\ No newline at end of file
+}
index 5e6112ee12473aa686eba3d81fde8e7b6f2aeeab..dd0886a793b743f50549287418732c59d424f20a 100644 (file)
@@ -112,32 +112,26 @@ public class SyncReactorImplTest {
                 .thenReturn(RpcResultBuilder.<Void>success().buildFuture());
 
         final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, syncupEntry);
-        try {
-            Assert.assertTrue(syncupResult.isDone());
-            final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
-            Assert.assertTrue(voidRpcResult);
-
-            Mockito.verify(syncPlanPushStrategy).executeSyncStrategy(
-                    Matchers.<ListenableFuture<RpcResult<Void>>>any(),
-                    syncDiffInputCaptor.capture(),
-                    Matchers.<SyncCrudCounters>any()
-            );
-
-            final SynchronizationDiffInput diffInput = syncDiffInputCaptor.getValue();
-            Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
-            Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
-            Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
-
-            Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
-            Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
-            Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
-
-            Assert.assertEquals(1, diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
-            Assert.assertEquals(0, diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
-            Assert.assertEquals(1, diffInput.getMetersToRemove().getItemsToPush().size());
-        } catch (Exception e) {
-            LOG.warn("syncup failed", e);
-            Assert.fail("syncup failed: " + e.getMessage());
-        }
+        Assert.assertTrue(syncupResult.isDone());
+        final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
+        Assert.assertTrue(voidRpcResult);
+
+        Mockito.verify(syncPlanPushStrategy).executeSyncStrategy(
+                Matchers.<ListenableFuture<RpcResult<Void>>>any(),
+                syncDiffInputCaptor.capture(),
+                Matchers.<SyncCrudCounters>any());
+
+        final SynchronizationDiffInput diffInput = syncDiffInputCaptor.getValue();
+        Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
+        Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
+        Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
+
+        Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
+        Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
+        Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
+
+        Assert.assertEquals(1, diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
+        Assert.assertEquals(0, diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
+        Assert.assertEquals(1, diffInput.getMetersToRemove().getItemsToPush().size());
     }
-}
\ No newline at end of file
+}
index 87f686c78a6d741faedd4c6740b5e9466c036e44..70147bc3da12ab7bab748f71c4dca5246eb60d8f 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
- * Test for {@link SyncReactorRetryDecorator}
+ * Test for {@link SyncReactorRetryDecorator}.
  */
 @RunWith(MockitoJUnitRunner.class)
 public class SyncReactorRetryDecoratorTest {
@@ -46,7 +46,8 @@ public class SyncReactorRetryDecoratorTest {
     @Before
     public void setUp() {
         reactor = new SyncReactorRetryDecorator(delegate, reconciliationRegistry);
-        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
     }
 
@@ -84,4 +85,4 @@ public class SyncReactorRetryDecoratorTest {
         Mockito.verifyZeroInteractions(delegate);
     }
 
-}
\ No newline at end of file
+}
index 53005b8f66aa4248296a9426030352b1c0b49ea1..04d2c807d9a8f141f121bfb4e1569b9be9a424cb 100644 (file)
@@ -34,7 +34,8 @@ public class DeviceMastershipTest {
 
     @Before
     public void setUp() throws Exception {
-        deviceMastership = new DeviceMastership(NODE_ID, reconciliationRegistry, Mockito.mock(ClusterSingletonServiceProvider.class));
+        deviceMastership = new DeviceMastership(NODE_ID, reconciliationRegistry,
+                Mockito.mock(ClusterSingletonServiceProvider.class));
     }
 
     @Test
@@ -51,4 +52,4 @@ public class DeviceMastershipTest {
         Assert.assertFalse(deviceMastership.isDeviceMastered());
     }
 
-}
\ No newline at end of file
+}
index 0eadaef2304f7a106a96f14236ae1358035fb9de..39e1dc251e2092b7d2229db417e72dbbaae769c1 100644 (file)
@@ -22,7 +22,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 /**
  * Provides create methods for data involved in {@link SynchronizationDiffInput}.
  */
-public class DiffInputFactory {
+public final class DiffInputFactory {
+    private DiffInputFactory() {
+    }
+
     static ItemSyncBox<Group> createGroupSyncBox(final long... groupIDs) {
         final ItemSyncBox<Group> groupBox = new ItemSyncBox<>();
 
index 90c7a70986327bed553065d23e20226c526627aa..61ce84ee9dd36d7b867bef68e1e98c68703dc639 100644 (file)
@@ -152,7 +152,8 @@ public class FlowForwarderTest {
                 .setMatch(new MatchBuilder().build())
                 .build();
 
-        final Future<RpcResult<UpdateFlowOutput>> updateResult = flowForwarder.update(flowPath, flow, flowUpdated, flowCapableNodePath);
+        final Future<RpcResult<UpdateFlowOutput>> updateResult = flowForwarder.update(flowPath, flow,
+                flowUpdated, flowCapableNodePath);
 
         Mockito.verify(salFlowService).updateFlow(Matchers.<UpdateFlowInput>any());
         final UpdateFlowInput updateFlowInput = updateFlowInputCpt.getValue();
@@ -188,7 +189,8 @@ public class FlowForwarderTest {
                                 .build()).buildFuture());
 
         final Flow removeFlow = new FlowBuilder(flow).build();
-        final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
+        final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath,
+                removeFlow, flowCapableNodePath);
 
         Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
         final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
index 4dd05c3c77c843af649cc79c82060a5deef40785..1d26c584c9cd5672b782a6d6b9ce1b633d2b41fd 100644 (file)
@@ -97,7 +97,8 @@ public class GroupForwarderTest {
                         .buildFuture()
         );
 
-        final Future<RpcResult<RemoveGroupOutput>> addResult = groupForwarder.remove(groupPath, group, flowCapableNodePath);
+        final Future<RpcResult<RemoveGroupOutput>> addResult =
+                groupForwarder.remove(groupPath, group, flowCapableNodePath);
 
         Mockito.verify(salGroupService).removeGroup(Matchers.<RemoveGroupInput>any());
 
@@ -129,8 +130,8 @@ public class GroupForwarderTest {
                 .setGroupName("another-test")
                 .build();
 
-        final Future<RpcResult<UpdateGroupOutput>> addResult = groupForwarder.update(groupPath, groupOriginal, groupUpdate,
-                flowCapableNodePath);
+        final Future<RpcResult<UpdateGroupOutput>> addResult =
+                groupForwarder.update(groupPath, groupOriginal, groupUpdate, flowCapableNodePath);
 
         Mockito.verify(salGroupService).updateGroup(Matchers.<UpdateGroupInput>any());
 
@@ -176,4 +177,4 @@ public class GroupForwarderTest {
         Assert.assertNotNull(addGroupInput.getBuckets());
         Assert.assertEquals("test-group", addGroupInput.getGroupName());
     }
-}
\ No newline at end of file
+}
index 779ebfccb107e889eef95fb9a50ed4e65d0ea897..0109aa13f3723f6ebbddedc09a75c87d99ffed1a 100644 (file)
@@ -95,7 +95,8 @@ public class MeterForwarderTest {
 
         Meter removeMeter = new MeterBuilder(meter).build();
 
-        final Future<RpcResult<RemoveMeterOutput>> removeResult = meterForwarder.remove(meterPath, removeMeter, flowCapableNodePath);
+        final Future<RpcResult<RemoveMeterOutput>> removeResult =
+                meterForwarder.remove(meterPath, removeMeter, flowCapableNodePath);
         Mockito.verify(salMeterService).removeMeter(Matchers.<RemoveMeterInput>any());
 
         Assert.assertTrue(removeResult.isDone());
@@ -123,7 +124,8 @@ public class MeterForwarderTest {
                 .setMeterName("another-test")
                 .build();
 
-        final Future<RpcResult<UpdateMeterOutput>> updateResult = meterForwarder.update(meterPath, meterOriginal, meterUpdate,
+        final Future<RpcResult<UpdateMeterOutput>> updateResult =
+                meterForwarder.update(meterPath, meterOriginal, meterUpdate,
                 flowCapableNodePath);
         Mockito.verify(salMeterService).updateMeter(Matchers.<UpdateMeterInput>any());
 
@@ -163,4 +165,4 @@ public class MeterForwarderTest {
         Assert.assertEquals(nodePath, addMeterInput.getNode().getValue());
         Assert.assertEquals("test-meter", addMeterInput.getMeterName());
     }
-}
\ No newline at end of file
+}
index 4bea89fd48c2f248841135bbdf2ca90ea001b79a..fef5aa02eb7399d6de6d3d4bf36e944876d72031 100644 (file)
@@ -120,7 +120,8 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
     @Test
     public void testExecuteSyncStrategy() throws Exception {
         final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT,
-                groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
+                groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate,
+                flowsToRemove, metersToRemove, groupsToRemove);
 
         Mockito.when(flatBatchService.processFlatBatch(Matchers.<ProcessFlatBatchInput>any()))
                 .thenReturn(RpcResultBuilder.success(new ProcessFlatBatchOutputBuilder().build()).buildFuture());
@@ -167,7 +168,8 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
 
     @Test
     public void testAssembleAddOrUpdateGroups() throws Exception {
-        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateGroups(batchBag, 0, groupsToAddOrUpdate);
+        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateGroups(
+                batchBag, 0, groupsToAddOrUpdate);
 
         Assert.assertEquals(9, lastOrder);
         Assert.assertEquals(3, batchBag.size());
@@ -198,7 +200,8 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
 
     @Test
     public void testAssembleAddOrUpdateMeters() throws Exception {
-        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateMeters(batchBag, 0, metersToAddOrUpdate);
+        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateMeters(
+                batchBag, 0, metersToAddOrUpdate);
 
         Assert.assertEquals(6, lastOrder);
         Assert.assertEquals(2, batchBag.size());
@@ -223,7 +226,8 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
 
     @Test
     public void testAssembleAddOrUpdateFlows() throws Exception {
-        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateFlows(batchBag, 0, flowsToAddOrUpdate);
+        final int lastOrder = SyncPlanPushStrategyFlatBatchImpl.assembleAddOrUpdateFlows(
+                batchBag, 0, flowsToAddOrUpdate);
 
         Assert.assertEquals(9, lastOrder);
         Assert.assertEquals(3, batchBag.size());
@@ -286,7 +290,8 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
                 new BatchBuilder().setBatchOrder(9).build(),
                 new BatchBuilder().setBatchOrder(15).build()
         );
-        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42);
+        final Map<Range<Integer>, Batch> rangeBatchMap =
+                SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42);
 
         Assert.assertEquals(4, rangeBatchMap.size());
         int idx = 0;
@@ -299,4 +304,4 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
             idx++;
         }
     }
-}
\ No newline at end of file
+}
index a0d84c429f229fa4ab4663141c57859ef68d9509..99cef391dfdddbec01b753eca5157a5d0874986d 100644 (file)
@@ -130,45 +130,46 @@ public class SyncPlanPushStrategyIncrementalImplTest {
     @Test
     public void testExecuteSyncStrategy() throws Exception {
         final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT,
-                groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
+                groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove,
+                metersToRemove, groupsToRemove);
 
-        final SyncCrudCounters counters = new SyncCrudCounters();
+        final SyncCrudCounters syncCounters = new SyncCrudCounters();
         final ListenableFuture<RpcResult<Void>> rpcResult = syncPlanPushStrategy.executeSyncStrategy(
-                RpcResultBuilder.<Void>success().buildFuture(), diffInput, counters);
-
-        Mockito.verify(groupCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Group>>any(),Matchers.<Group>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(groupCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Group>>any(),Matchers.<Group>any(),
-               Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(groupCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Group>>any(),Matchers.<Group>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(flowCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Flow>>any(),Matchers.<Flow>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(flowCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Flow>>any(),Matchers.<Flow>any(),
-               Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(flowCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Flow>>any(),Matchers.<Flow>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(meterCommitter, Mockito.times(3)).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(meterCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(),
+                RpcResultBuilder.<Void>success().buildFuture(), diffInput, syncCounters);
+
+        Mockito.verify(groupCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Group>>any(),
+                Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(groupCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Group>>any(),
+                Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(groupCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Group>>any(),
+                Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(flowCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Flow>>any(),
+                Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(flowCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Flow>>any(),
+                Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(flowCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Flow>>any(),
+                Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(meterCommitter, Mockito.times(3)).add(Matchers.<InstanceIdentifier<Meter>>any(),
+                Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(meterCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Meter>>any(),
+                Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+        Mockito.verify(meterCommitter, Mockito.times(3)).remove(Matchers.<InstanceIdentifier<Meter>>any(),
                 Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
-        Mockito.verify(meterCommitter, Mockito.times(3)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
 
         Assert.assertTrue(rpcResult.isDone());
         Assert.assertTrue(rpcResult.get().isSuccessful());
 
-        Assert.assertEquals(6, counters.getFlowCrudCounts().getAdded());
-        Assert.assertEquals(3, counters.getFlowCrudCounts().getUpdated());
-        Assert.assertEquals(6, counters.getFlowCrudCounts().getRemoved());
+        Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getAdded());
+        Assert.assertEquals(3, syncCounters.getFlowCrudCounts().getUpdated());
+        Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getRemoved());
 
-        Assert.assertEquals(6, counters.getGroupCrudCounts().getAdded());
-        Assert.assertEquals(3, counters.getGroupCrudCounts().getUpdated());
-        Assert.assertEquals(6, counters.getGroupCrudCounts().getRemoved());
+        Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getAdded());
+        Assert.assertEquals(3, syncCounters.getGroupCrudCounts().getUpdated());
+        Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getRemoved());
 
-        Assert.assertEquals(3, counters.getMeterCrudCounts().getAdded());
-        Assert.assertEquals(3, counters.getMeterCrudCounts().getUpdated());
-        Assert.assertEquals(3, counters.getMeterCrudCounts().getRemoved());
+        Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getAdded());
+        Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getUpdated());
+        Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getRemoved());
     }
 
     @Before
@@ -207,8 +208,8 @@ public class SyncPlanPushStrategyIncrementalImplTest {
                 Matchers.<InstanceIdentifier<FlowCapableNode>>any());
 
         Mockito.doAnswer(createSalServiceFutureAnswer()).when(tableCommitter).update(
-                Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.<TableFeatures>any(), Matchers.<TableFeatures>any(),
-                Matchers.<InstanceIdentifier<FlowCapableNode>>any());
+                Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.<TableFeatures>any(),
+                Matchers.<TableFeatures>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
 
         syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl()
                 .setMeterForwarder(meterCommitter)
@@ -634,4 +635,4 @@ public class SyncPlanPushStrategyIncrementalImplTest {
 
         Mockito.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
     }
-}
\ No newline at end of file
+}
index f4dcfc97f0ef8761075bb33ce4aca86f36926d05..eb605bdc7c68669eab7bd71fefc3a32c422cd467 100644 (file)
@@ -62,7 +62,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 public class ReconcileUtilTest {
 
     private static final NodeId NODE_ID = new NodeId("unit-node-id");
-    private final InstanceIdentifier<Node> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
+    private static final InstanceIdentifier<Node> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(NODE_ID));
     private static final Splitter COMMA_SPLITTER = Splitter.on(",");
 
@@ -92,9 +92,7 @@ public class ReconcileUtilTest {
     }
 
     /**
-     * add one missing group
-     *
-     * @throws Exception
+     * add one missing group.
      */
     @Test
     public void testResolveAndDivideGroupDiffs1() throws Exception {
@@ -114,14 +112,13 @@ public class ReconcileUtilTest {
         Assert.assertEquals(1, plan.size());
 
         Assert.assertEquals(1, plan.get(0).getItemsToPush().size());
-        Assert.assertEquals(4L, plan.get(0).getItemsToPush().iterator().next().getKey().getGroupId().getValue().longValue());
+        Assert.assertEquals(4L, plan.get(0).getItemsToPush().iterator().next().getKey()
+                .getGroupId().getValue().longValue());
         Assert.assertEquals(0, plan.get(0).getItemsToUpdate().size());
     }
 
     /**
-     * add 3 groups with dependencies - 3 steps involved
-     *
-     * @throws Exception
+     * add 3 groups with dependencies - 3 steps involved.
      */
     @Test
     public void testResolveAndDivideGroupDiffs2() throws Exception {
@@ -139,22 +136,23 @@ public class ReconcileUtilTest {
         Assert.assertEquals(3, plan.size());
 
         Assert.assertEquals(1, plan.get(0).getItemsToPush().size());
-        Assert.assertEquals(2L, plan.get(0).getItemsToPush().iterator().next().getKey().getGroupId().getValue().longValue());
+        Assert.assertEquals(2L, plan.get(0).getItemsToPush().iterator().next().getKey()
+                .getGroupId().getValue().longValue());
         Assert.assertEquals(0, plan.get(0).getItemsToUpdate().size());
 
         Assert.assertEquals(1, plan.get(1).getItemsToPush().size());
-        Assert.assertEquals(4L, plan.get(1).getItemsToPush().iterator().next().getKey().getGroupId().getValue().longValue());
+        Assert.assertEquals(4L, plan.get(1).getItemsToPush().iterator().next().getKey()
+                .getGroupId().getValue().longValue());
         Assert.assertEquals(0, plan.get(1).getItemsToUpdate().size());
 
         Assert.assertEquals(1, plan.get(2).getItemsToPush().size());
-        Assert.assertEquals(3L, plan.get(2).getItemsToPush().iterator().next().getKey().getGroupId().getValue().longValue());
+        Assert.assertEquals(3L, plan.get(2).getItemsToPush().iterator().next().getKey()
+                .getGroupId().getValue().longValue());
         Assert.assertEquals(0, plan.get(2).getItemsToUpdate().size());
     }
 
     /**
-     * no actions taken - installed and pending groups are the same
-     *
-     * @throws Exception
+     * no actions taken - installed and pending groups are the same.
      */
     @Test
     public void testResolveAndDivideGroupDiffs3() throws Exception {
@@ -173,9 +171,7 @@ public class ReconcileUtilTest {
     }
 
     /**
-     * update 1 group
-     *
-     * @throws Exception
+     * update 1 group.
      */
     @Test
     public void testResolveAndDivideGroupDiffs4() throws Exception {
@@ -193,15 +189,14 @@ public class ReconcileUtilTest {
         Assert.assertEquals(1, plan.size());
         Assert.assertEquals(0, plan.get(0).getItemsToPush().size());
         Assert.assertEquals(1, plan.get(0).getItemsToUpdate().size());
-        final ItemSyncBox.ItemUpdateTuple<Group> firstItemUpdateTuple = plan.get(0).getItemsToUpdate().iterator().next();
+        final ItemSyncBox.ItemUpdateTuple<Group> firstItemUpdateTuple =
+                plan.get(0).getItemsToUpdate().iterator().next();
         Assert.assertEquals(1L, firstItemUpdateTuple.getOriginal().getGroupId().getValue().longValue());
         Assert.assertEquals(1L, firstItemUpdateTuple.getUpdated().getGroupId().getValue().longValue());
     }
 
     /**
-     * no action taken - update 1 group will be ignored
-     *
-     * @throws Exception
+     * no action taken - update 1 group will be ignored.
      */
     @Test
     public void testResolveAndDivideGroupDiffs5() throws Exception {
@@ -220,9 +215,7 @@ public class ReconcileUtilTest {
     }
 
     /**
-     * should add 1 group but preconditions are not met
-     *
-     * @throws Exception
+     * should add 1 group but preconditions are not met.
      */
     @Test
     public void testResolveAndDivideGroupDiffs_negative1() throws Exception {
@@ -239,9 +232,7 @@ public class ReconcileUtilTest {
     }
 
     /**
-     * should update 1 group but preconditions are not met
-     *
-     * @throws Exception
+     * should update 1 group but preconditions are not met.
      */
     @Test
     public void testResolveAndDivideGroupDiffs_negative2() throws Exception {
@@ -310,9 +301,7 @@ public class ReconcileUtilTest {
     }
 
     /**
-     * covers {@link ReconcileUtil#countTotalUpdated(Iterable)} too
-     *
-     * @throws Exception
+     * covers {@link ReconcileUtil#countTotalUpdated(Iterable)} too.
      */
     @Test
     public void testCountTotalAdds() throws Exception {
@@ -332,4 +321,4 @@ public class ReconcileUtilTest {
         }
         return syncBox1;
     }
-}
\ No newline at end of file
+}
index efcaa3de41159066bc5777647ac27032c217d112..c900344b72178baba08f870a127a2dc05464e92f 100644 (file)
@@ -72,10 +72,10 @@ public class SemaphoreKeeperGuavaImplTest {
                     0L, TimeUnit.MILLISECONDS,
                     new LinkedBlockingQueue<Runnable>()) {
                 @Override
-                protected void afterExecute(final Runnable r, final Throwable t) {
-                    super.afterExecute(r, t);
-                    if (t != null) {
-                        LOG.error("pool thread crashed", t);
+                protected void afterExecute(final Runnable task, final Throwable failure) {
+                    super.afterExecute(task, failure);
+                    if (failure != null) {
+                        LOG.error("pool thread crashed", failure);
                     }
                 }
             };
@@ -114,12 +114,13 @@ public class SemaphoreKeeperGuavaImplTest {
         private final ConcurrentMap<Integer, Integer> counter = new ConcurrentHashMap<>();
         private volatile int index = 0;
 
-        public Worker(SemaphoreKeeper<String> keeper, final String key) {
+        Worker(SemaphoreKeeper<String> keeper, final String key) {
             this.keeper = keeper;
             this.key = key;
         }
 
         @Override
+        @SuppressWarnings("checkstyle:IllegalCatch")
         public void run() {
             try {
                 final Semaphore guard = keeper.summonGuard(key);
@@ -139,4 +140,4 @@ public class SemaphoreKeeperGuavaImplTest {
             return counter.size();
         }
     }
-}
\ No newline at end of file
+}
index 72544ae50d24263c23c1a1138a6e182e6ada838d..cb4be50cc4f40c5e8eefd16629ffb7c5d571ccc8 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.openflow.ofswitch.config;
 
 import java.util.Collection;
-import java.util.concurrent.Callable;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
@@ -44,17 +43,16 @@ public class DefaultConfigPusher implements AutoCloseable, DataTreeChangeListene
         this.dataBroker = dataBroker;
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void start() {
         try {
-            final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-            final DataTreeIdentifier<FlowCapableNode> identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, path);
+            final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
+                    .augmentation(FlowCapableNode.class);
+            final DataTreeIdentifier<FlowCapableNode> identifier = new DataTreeIdentifier<>(
+                    LogicalDatastoreType.OPERATIONAL, path);
             final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-            listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataTreeChangeListener>>() {
-                @Override
-                public ListenerRegistration<DataTreeChangeListener> call() throws Exception {
-                    return dataBroker.registerDataTreeChangeListener(identifier, DefaultConfigPusher.this);
-                }
-            });
+            listenerRegistration = looper.loopUntilNoException(
+                () -> dataBroker.registerDataTreeChangeListener(identifier, DefaultConfigPusher.this));
         } catch (Exception e) {
             LOG.error("DataTreeChangeListener registration failed: {}", e);
             throw new IllegalStateException("DefaultConfigPusher startup failed!", e);
@@ -64,19 +62,20 @@ public class DefaultConfigPusher implements AutoCloseable, DataTreeChangeListene
 
     @Override
     public void close() {
-        if(listenerRegistration != null) {
+        if (listenerRegistration != null) {
             listenerRegistration.close();
         }
     }
 
     @Override
     public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) {
-        for (DataTreeModification modification : modifications) {
+        for (DataTreeModification<FlowCapableNode> modification : modifications) {
             if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
                 SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
                 setConfigInputBuilder.setFlag(SwitchConfigFlag.FRAGNORMAL.toString());
                 setConfigInputBuilder.setMissSearchLength(OFConstants.OFPCML_NO_BUFFER);
-                setConfigInputBuilder.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)));
+                setConfigInputBuilder.setNode(new NodeRef(modification.getRootPath()
+                        .getRootIdentifier().firstIdentifierOf(Node.class)));
                 nodeConfigService.setConfig(setConfigInputBuilder.build());
             }
         }
index 6079ed0f1c17cf215213cfcc5f17dfd748cf1ccc..c035592026868e5f427a271ac1960acbb54d3a1a 100644 (file)
@@ -42,7 +42,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 @RunWith(MockitoJUnitRunner.class)
 public class DefaultConfigPusherTest {
     private DefaultConfigPusher defaultConfigPusher;
-    private final static InstanceIdentifier<Node> nodeIID = InstanceIdentifier.create(Nodes.class)
+    private static final InstanceIdentifier<Node> NODE_IID = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(new NodeId("testnode:1")));
     @Mock
     private NodeConfigService nodeConfigService;
@@ -54,7 +54,8 @@ public class DefaultConfigPusherTest {
     @Before
     public void setUp() throws Exception {
         defaultConfigPusher = new DefaultConfigPusher(nodeConfigService, Mockito.mock(DataBroker.class));
-        final DataTreeIdentifier<FlowCapableNode> identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, nodeIID);
+        final DataTreeIdentifier<FlowCapableNode> identifier =
+                new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, NODE_IID);
         Mockito.when(dataTreeModification.getRootPath()).thenReturn(identifier);
         Mockito.when(dataTreeModification.getRootNode()).thenReturn(Mockito.mock(DataObjectModification.class));
         Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.WRITE);
@@ -67,7 +68,7 @@ public class DefaultConfigPusherTest {
         final SetConfigInput captured = setConfigInputCaptor.getValue();
         Assert.assertEquals(SwitchConfigFlag.FRAGNORMAL.toString(), captured.getFlag());
         Assert.assertEquals(OFConstants.OFPCML_NO_BUFFER, captured.getMissSearchLength());
-        Assert.assertEquals(nodeIID, captured.getNode().getValue());
+        Assert.assertEquals(NODE_IID, captured.getNode().getValue());
     }
 
     @After
@@ -75,4 +76,4 @@ public class DefaultConfigPusherTest {
         defaultConfigPusher.close();
     }
 
-}
\ No newline at end of file
+}
index 43225b987028b82f20baf4416a71dd9d3fbd1425..0205c4761e97f0dd656f124dc41639115e329f3c 100644 (file)
@@ -27,7 +27,7 @@ public class LLDPDiscoveryListener implements PacketProcessingListener {
     @Override
     public void onPacketReceived(PacketReceived lldp) {
         NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true);
-        if(src != null) {
+        if (src != null) {
             LinkDiscoveredBuilder ldb = new LinkDiscoveredBuilder();
             ldb.setDestination(lldp.getIngress());
             ldb.setSource(new NodeConnectorRef(src));
@@ -37,4 +37,4 @@ public class LLDPDiscoveryListener implements PacketProcessingListener {
             lldpLinkAger.put(ld);
         }
     }
-}
\ No newline at end of file
+}
index 1ec666cc7601fb606277af21dd4fb9294b9b47ce..75f0f26825be959808d8d08670e163efb34f08a6 100644 (file)
@@ -34,7 +34,7 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable {
     private final AutoCloseable configurationServiceRegistration;
 
     /**
-     * default ctor - start timer
+     * default ctor - start timer.
      */
     public LLDPLinkAger(final TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig,
                         final NotificationProviderService notificationService,
@@ -68,7 +68,7 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable {
                 LinkDiscovered link = entry.getKey();
                 Date expires = entry.getValue();
                 Date now = new Date();
-                if(now.after(expires)) {
+                if (now.after(expires)) {
                     if (notificationService != null) {
                         LinkRemovedBuilder lrb = new LinkRemovedBuilder(link);
                         notificationService.publish(lrb.build());
@@ -105,4 +105,4 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable {
             }
         });
     }
-}
\ No newline at end of file
+}
index 67fd2eb2cc42e31ed089f6a2096249e8c73e8f52..b90698a25c2d8841d798dbbd8b17e72fd4a66e2b 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.openflowplugin.libraries.liblldp.Ethernet;
 import org.opendaylight.openflowplugin.libraries.liblldp.LLDP;
 import org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV;
 import org.opendaylight.openflowplugin.libraries.liblldp.NetUtils;
+import org.opendaylight.openflowplugin.libraries.liblldp.PacketException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -37,8 +38,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-public class LLDPDiscoveryUtils {
+public final class LLDPDiscoveryUtils {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
 
     private static final short MINIMUM_LLDP_SIZE = 61;
@@ -47,17 +47,22 @@ public class LLDPDiscoveryUtils {
     private static final short ETHERNET_TYPE_OFFSET = 12;
     private static final short ETHERNET_VLAN_OFFSET = ETHERNET_TYPE_OFFSET + 4;
 
+    private LLDPDiscoveryUtils() {
+    }
+
     public static String macToString(byte[] mac) {
-        StringBuilder b = new StringBuilder();
+        StringBuilder builder = new StringBuilder();
         for (int i = 0; i < mac.length; i++) {
-            b.append(String.format("%02X%s", mac[i], i < mac.length - 1 ? ":" : ""));
+            builder.append(String.format("%02X%s", mac[i], i < mac.length - 1 ? ":" : ""));
         }
 
-        return b.toString();
+        return builder.toString();
     }
 
     /**
-     * @param payload
+     * Returns the encoded in custom TLV for the given lldp.
+     *
+     * @param payload lldp payload
      * @return nodeConnectorId - encoded in custom TLV of given lldp
      * @see LLDPDiscoveryUtils#lldpToNodeConnectorRef(byte[], boolean)
      */
@@ -66,10 +71,13 @@ public class LLDPDiscoveryUtils {
     }
 
     /**
-     * @param payload
+     * Returns the encoded in custom TLV for the given lldp.
+     *
+     * @param payload lldp payload
      * @param useExtraAuthenticatorCheck make it more secure (CVE-2015-1611 CVE-2015-1612)
      * @return nodeConnectorId - encoded in custom TLV of given lldp
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public static NodeConnectorRef lldpToNodeConnectorRef(byte[] payload, boolean useExtraAuthenticatorCheck)  {
         NodeConnectorRef nodeConnectorRef = null;
 
@@ -77,7 +85,7 @@ public class LLDPDiscoveryUtils {
             Ethernet ethPkt = new Ethernet();
             try {
                 ethPkt.deserialize(payload, 0, payload.length * NetUtils.NUM_BITS_IN_A_BYTE);
-            } catch (Exception e) {
+            } catch (PacketException e) {
                 LOG.warn("Failed to decode LLDP packet {}", e);
                 return nodeConnectorRef;
             }
@@ -96,8 +104,8 @@ public class LLDPDiscoveryUtils {
                     throw new Exception("Node id wasn't specified via systemNameId in LLDP packet.");
                 }
 
-                final LLDPTLV nodeConnectorIdLldptlv = lldp.getCustomTLV(
-                        new CustomTLVKey(BitBufferHelper.getInt(LLDPTLV.OFOUI), LLDPTLV.CUSTOM_TLV_SUB_TYPE_NODE_CONNECTOR_ID[0]));
+                final LLDPTLV nodeConnectorIdLldptlv = lldp.getCustomTLV(new CustomTLVKey(
+                        BitBufferHelper.getInt(LLDPTLV.OFOUI), LLDPTLV.CUSTOM_TLV_SUB_TYPE_NODE_CONNECTOR_ID[0]));
                 if (nodeConnectorIdLldptlv != null) {
                     srcNodeConnectorId = new NodeConnectorId(LLDPTLV.getCustomString(
                             nodeConnectorIdLldptlv.getValue(), nodeConnectorIdLldptlv.getLength()));
@@ -109,7 +117,8 @@ public class LLDPDiscoveryUtils {
                     boolean secure = checkExtraAuthenticator(lldp, srcNodeConnectorId);
                     if (!secure) {
                         LOG.warn("SECURITY ALERT: there is probably a LLDP spoofing attack in progress.");
-                        throw new Exception("Attack. LLDP packet with inconsistent extra authenticator field was received.");
+                        throw new Exception(
+                                "Attack. LLDP packet with inconsistent extra authenticator field was received.");
                     }
                 }
 
@@ -119,20 +128,22 @@ public class LLDPDiscoveryUtils {
                         .toInstance();
                 nodeConnectorRef = new NodeConnectorRef(srcInstanceId);
             } catch (Exception e) {
-                LOG.debug("Caught exception while parsing out lldp optional and custom fields: {}", e.getMessage(), e);
+                LOG.debug("Caught exception while parsing out lldp optional and custom fields", e);
             }
         }
         return nodeConnectorRef;
     }
 
     /**
-     * @param nodeConnectorId
+     * Gets an extra authenticator for lldp security.
+     *
+     * @param nodeConnectorId the NodeConnectorId
      * @return extra authenticator for lldp security
-     * @throws NoSuchAlgorithmException
      */
-    public static byte[] getValueForLLDPPacketIntegrityEnsuring(final NodeConnectorId nodeConnectorId) throws NoSuchAlgorithmException {
+    public static byte[] getValueForLLDPPacketIntegrityEnsuring(final NodeConnectorId nodeConnectorId)
+            throws NoSuchAlgorithmException {
         String finalKey;
-        if(LLDPActivator.getLldpSecureKey() !=null && !LLDPActivator.getLldpSecureKey().isEmpty()) {
+        if (LLDPActivator.getLldpSecureKey() != null && !LLDPActivator.getLldpSecureKey().isEmpty()) {
             finalKey = LLDPActivator.getLldpSecureKey();
         } else {
             finalKey = ManagementFactory.getRuntimeMXBean().getName();
@@ -146,12 +157,8 @@ public class LLDPDiscoveryUtils {
         return hashedValue.asBytes();
     }
 
-    /**
-     * @param lldp
-     * @param srcNodeConnectorId
-     * @throws NoSuchAlgorithmException
-     */
-    private static boolean checkExtraAuthenticator(LLDP lldp, NodeConnectorId srcNodeConnectorId) throws NoSuchAlgorithmException {
+    private static boolean checkExtraAuthenticator(LLDP lldp, NodeConnectorId srcNodeConnectorId)
+            throws NoSuchAlgorithmException {
         final LLDPTLV hashLldptlv = lldp.getCustomTLV(
                 new CustomTLVKey(BitBufferHelper.getInt(LLDPTLV.OFOUI), LLDPTLV.CUSTOM_TLV_SUB_TYPE_CUSTOM_SEC[0]));
         boolean secAuthenticatorOk = false;
index 8b107b82a08ff4f553e43653aac3f658f5cce55a..cb4c489e710c7c91881d043c78cf982580bfc81a 100644 (file)
@@ -37,14 +37,15 @@ public class LLDPLinkAgerTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(LLDPLinkAgerTest.class);
 
-    private LLDPLinkAger lldpLinkAger;
-    private final long LLDP_INTERVAL = 5L;
-    private final long LINK_EXPIRATION_TIME = 10L;
+    private static final long LLDP_INTERVAL = 5L;
+    private static final long LINK_EXPIRATION_TIME = 10L;
+
     /**
-     * We need to wait while other tasks are finished before we can check anything
-     * in LLDPAgingTask
+     * We need to wait while other tasks are finished before we can check anything in LLDPAgingTask.
      */
-    private final int SLEEP = 100;
+    private static final int SLEEP = 100;
+
+    private LLDPLinkAger lldpLinkAger;
 
     @Mock
     private LinkDiscovered link;
@@ -70,7 +71,7 @@ public class LLDPLinkAgerTest {
     }
 
     /**
-     * Inner class LLDPAgingTask removes all expired records from linkToDate if any (in constructor of LLDPLinkAger)
+     * Inner class LLDPAgingTask removes all expired records from linkToDate if any (in constructor of LLDPLinkAger).
      */
     @Test
     public void testLLDPAgingTask() throws InterruptedException {
@@ -101,4 +102,4 @@ public class LLDPLinkAgerTest {
 
         return configurationService;
     }
-}
\ No newline at end of file
+}
index c4878c324ffd093825c89de600d995aac2b9db1c..8b99250f4d02c0f80128c6642f75d2996b4aead3 100644 (file)
@@ -33,17 +33,17 @@ public class LLDPDiscoveryUtilsTest {
     @Test
     public void testLldpToNodeConnectorRefLLDP() throws Exception {
         byte[] packetLLDP = {
-                0x01, 0x23, 0x00, 0x00, 0x00, 0x01, (byte) 0x8a, (byte) 0x8e,
-                (byte) 0xcc, (byte) 0x85, (byte) 0xeb, 0x27,
-                /* ethernet type LLDP 0x88cc */(byte) 0x88, (byte) 0xcc,
-                0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
-                0x02, 0x07, 0x32, 0x06, 0x02, 0x13, 0x37, 0x0a, 0x0a,
-                /* openflow:2 */0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32,
-                (byte) 0xfe, 0x10, 0x00, 0x26, (byte) 0xe1, 0x00,
-                /* openflow:2:2 */0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32, 0x3a, 0x32,
-                (byte) 0xfe, 0x14, 0x00, 0x26, (byte) 0xe1, 0x01, 0x62, (byte) 0xc8, 0x2b, 0x67, (byte) 0xce,
-                (byte) 0xbe, 0x7c, 0x2b, 0x47, (byte) 0xbe, 0x2b, (byte) 0xe7, (byte) 0xbc,
-                (byte) 0xe9, 0x75, 0x3d, 0x00, 0x00
+            0x01, 0x23, 0x00, 0x00, 0x00, 0x01, (byte) 0x8a, (byte) 0x8e,
+            (byte) 0xcc, (byte) 0x85, (byte) 0xeb, 0x27,
+            /* ethernet type LLDP 0x88cc */(byte) 0x88, (byte) 0xcc,
+            0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
+            0x02, 0x07, 0x32, 0x06, 0x02, 0x13, 0x37, 0x0a, 0x0a,
+            /* openflow:2 */0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32,
+            (byte) 0xfe, 0x10, 0x00, 0x26, (byte) 0xe1, 0x00,
+            /* openflow:2:2 */0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32, 0x3a, 0x32,
+            (byte) 0xfe, 0x14, 0x00, 0x26, (byte) 0xe1, 0x01, 0x62, (byte) 0xc8, 0x2b, 0x67, (byte) 0xce,
+            (byte) 0xbe, 0x7c, 0x2b, 0x47, (byte) 0xbe, 0x2b, (byte) 0xe7, (byte) 0xbc,
+            (byte) 0xe9, 0x75, 0x3d, 0x00, 0x00
         };
 
         NodeConnectorRef nodeConnectorRef = LLDPDiscoveryUtils.lldpToNodeConnectorRef(packetLLDP, false);
@@ -59,22 +59,22 @@ public class LLDPDiscoveryUtilsTest {
     @Test
     public void testLldpToNodeConnectorRefNotLLDP() throws Exception {
         byte[] packetNotLLDP = {
-                0x01, 0x23, 0x00, 0x00, 0x00, 0x01, (byte) 0x8a, (byte) 0x8e,
-                (byte) 0xcc, (byte) 0x85, (byte) 0xeb, 0x27,
-                /* ethernet type IPv4 0x0800 */(byte) 0x08, (byte) 0x00,
-                0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
-                0x02, 0x07, 0x32, 0x06, 0x02, 0x13, 0x37, 0x0a,
-                0x0a, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f,
-                0x77, 0x3a, 0x32, (byte) 0xfe, 0x10, 0x00, 0x26, (byte) 0xe1,
-                0x00, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f,
-                0x77, 0x3a, 0x32, 0x3a, 0x32, (byte) 0xfe, 0x14, 0x00,
-                0x26, (byte) 0xe1, 0x01, 0x62, (byte) 0xc8, 0x2b, 0x67, (byte) 0xce,
-                (byte) 0xbe, 0x7c, 0x2b, 0x47, (byte) 0xbe, 0x2b, (byte) 0xe7, (byte) 0xbc,
-                (byte) 0xe9, 0x75, 0x3d, 0x00, 0x00
+            0x01, 0x23, 0x00, 0x00, 0x00, 0x01, (byte) 0x8a, (byte) 0x8e,
+            (byte) 0xcc, (byte) 0x85, (byte) 0xeb, 0x27,
+            /* ethernet type IPv4 0x0800 */(byte) 0x08, (byte) 0x00,
+            0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
+            0x02, 0x07, 0x32, 0x06, 0x02, 0x13, 0x37, 0x0a,
+            0x0a, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f,
+            0x77, 0x3a, 0x32, (byte) 0xfe, 0x10, 0x00, 0x26, (byte) 0xe1,
+            0x00, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f,
+            0x77, 0x3a, 0x32, 0x3a, 0x32, (byte) 0xfe, 0x14, 0x00,
+            0x26, (byte) 0xe1, 0x01, 0x62, (byte) 0xc8, 0x2b, 0x67, (byte) 0xce,
+            (byte) 0xbe, 0x7c, 0x2b, 0x47, (byte) 0xbe, 0x2b, (byte) 0xe7, (byte) 0xbc,
+            (byte) 0xe9, 0x75, 0x3d, 0x00, 0x00
         };
 
         NodeConnectorRef nodeConnectorRef = LLDPDiscoveryUtils.lldpToNodeConnectorRef(packetNotLLDP, false);
 
         assertNull(nodeConnectorRef);
     }
-}
\ No newline at end of file
+}