Merge "OPNFLWPLUG-1087: ODL controller to provide view of openflow node reconciliatio...
authorArunprakash D <d.arunprakash@ericsson.com>
Thu, 16 Apr 2020 07:15:06 +0000 (07:15 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 16 Apr 2020 07:15:06 +0000 (07:15 +0000)
applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java
extension/openflowplugin-extension-api/src/main/java/org/opendaylight/openflowplugin/extension/api/GroupingResolver.java
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertor.java
openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java
openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/commands.xml
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java

index 7737543a9eaf3d9a43e898ed84287a4ba140ab7a..e3600eafa0f09bcd171981c4e0850ee40ae77ddd 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.applications.arbitratorreconciliation.im
 
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -30,8 +31,8 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.apache.aries.blueprint.annotation.service.Reference;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.applications.reconciliation.NotificationRegistration;
@@ -43,7 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -76,9 +76,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.arbitrator.reconcile.service.rev180227.GetActiveBundleOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.arbitrator.reconcile.service.rev180227.GetActiveBundleOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -101,34 +103,35 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS
 
     private static final BundleRemoveFlowCase DELETE_ALL_FLOW = new BundleRemoveFlowCaseBuilder()
             .setRemoveFlowCaseData(
-                new RemoveFlowCaseDataBuilder(new FlowBuilder().setTableId(OFConstants.OFPTT_ALL).build()).build())
+                    new RemoveFlowCaseDataBuilder(new FlowBuilder().setTableId(OFConstants.OFPTT_ALL).build()).build())
             .build();
     private static final BundleRemoveGroupCase DELETE_ALL_GROUP = new BundleRemoveGroupCaseBuilder()
             .setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(new GroupBuilder()
-                .setGroupType(GroupTypes.GroupAll)
-                .setGroupId(new GroupId(OFConstants.OFPG_ALL))
-                .build()).build())
+                    .setGroupType(GroupTypes.GroupAll)
+                    .setGroupId(new GroupId(OFConstants.OFPG_ALL))
+                    .build()).build())
             .build();
 
     private final SalBundleService salBundleService;
     private final ReconciliationManager reconciliationManager;
-    private final RoutedRpcRegistration routedRpcReg;
+    private final RpcProviderService rpcProviderService;
     private final UpgradeState upgradeState;
     private NotificationRegistration registration;
     private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(
             Executors.newFixedThreadPool(THREAD_POOL_SIZE));
     private final Map<Uint64, BundleDetails> bundleIdMap = new ConcurrentHashMap<>();
+    private  ObjectRegistration<? extends RpcService> rpcRegistration;
 
     @Inject
-    public ArbitratorReconciliationManagerImpl(@Reference RpcProviderRegistry rpcRegistry,
-            @Reference ReconciliationManager reconciliationManager, @Reference UpgradeState upgradeState) {
+    public ArbitratorReconciliationManagerImpl(
+            @Reference ReconciliationManager reconciliationManager, @Reference RpcProviderService rpcProviderService,
+            @Reference final RpcConsumerRegistry rpcRegistry, @Reference UpgradeState upgradeState) {
         Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry cannot be null !");
         this.reconciliationManager = Preconditions.checkNotNull(reconciliationManager,
                 "ReconciliationManager cannot be null!");
         this.salBundleService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalBundleService.class),
-                "RPC SalBundlService not found.");
-        this.routedRpcReg = rpcRegistry.addRoutedRpcImplementation(ArbitratorReconcileService.class,
-                this);
+                "RPC SalBundleService not found.");
+        this.rpcProviderService = rpcProviderService;
         this.upgradeState = Preconditions.checkNotNull(upgradeState, "UpgradeState cannot be null!");
     }
 
@@ -177,7 +180,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS
         return RpcResultBuilder.success(new CommitActiveBundleOutputBuilder()
                 .setResult(null).build())
                 .withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION,
-                null, "No active bundle found for the node" + nodeId.toString()))).buildFuture();
+                        null, "No active bundle found for the node" + nodeId.toString()))).buildFuture();
     }
 
     @Override
@@ -370,14 +373,17 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS
         KeyedInstanceIdentifier<Node, NodeKey> path = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(node.getNodeId()));
         LOG.debug("The path is registered : {}", path);
-        routedRpcReg.registerPath(NodeContext.class, path);
+        rpcRegistration = rpcProviderService.registerRpcImplementation(ArbitratorReconcileService.class,
+                this, ImmutableSet.of(path));
     }
 
     private void deregisterRpc(DeviceInfo node) {
         KeyedInstanceIdentifier<Node, NodeKey> path = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(node.getNodeId()));
         LOG.debug("The path is unregistered : {}", path);
-        routedRpcReg.unregisterPath(NodeContext.class, path);
+        if (rpcRegistration != null) {
+            rpcRegistration.close();
+        }
     }
 
     private static class BundleDetails {
index 7184d6c8ca8c2fcfbe5353734432b1d280b4bc2a..9a238dc03ead7c0f48e72abdfe109f283e8f0e7c 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -27,6 +28,7 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
+
 import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
@@ -108,7 +110,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
                     flowBuilder.build(), createParents);
             createParents = createParentsNextTime;
         }
-        ListenableFuture<?> submitFuture = writeTransaction.commit();
+        FluentFuture<?> submitFuture = writeTransaction.commit();
         return Futures.transform(handleResultFuture(Futures.allAsList(submitFuture)), voidRpcResult -> {
             if (voidRpcResult.isSuccessful()) {
                 return RpcResultBuilder.<AddFlowsDsOutput>success().build();
index 56717f51025d23748482f449207fada0dfa80b0d..e4a8063bd7bab31b6195ebc7b5541e7a543149b6 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.openflowplugin.extension.api;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.HashSet;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
@@ -76,6 +76,6 @@ public class GroupingResolver<G, T extends Augmentable<T>> {
                 return Optional.of((G) potential);
             }
         }
-        return Optional.absent();
+        return Optional.empty();
     }
 }
index 6fa2d28a0a21d87909bea65b22c842ebb1ad0552..525a6f60656d6dd9807b572b756a6b6c22bdaa6f 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
index e1418e16ca9d792646dc64cea403ecad06230f96..f446066d6b2a59ff381462dd56faf0c20b307097 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
index 949290252cbe0a1fd7f6b266acc2ea999a7ba7f9..9230d3582a9511753415ac4240cb88adbac94b30 100755 (executable)
@@ -31,7 +31,6 @@ import org.opendaylight.mdsal.binding.api.TransactionChainListener;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -127,7 +126,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl
         synchronized (txLock) {
             if (TransactionChainManagerStatus.WORKING == transactionChainManagerStatus) {
                 transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
-                future = txChainShuttingDown();
+                future =  txChainShuttingDown();
                 Preconditions.checkState(writeTx == null,
                         "We have some unexpected WriteTransaction.");
                 future.addCallback(new FutureCallback<CommitInfo>() {
@@ -203,7 +202,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl
 
                 @Override
                 public void onFailure(final Throwable throwable) {
-                    if (throwable instanceof TransactionCommitFailedException) {
+                    if (throwable instanceof InterruptedException || throwable instanceof ExecutionException) {
                         LOG.error("Transaction commit failed. ", throwable);
                     } else {
                         if (throwable instanceof CancellationException) {
@@ -309,7 +308,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl
         }
     }
 
-    public ListenableFuture<?> shuttingDown() {
+    public FluentFuture<?> shuttingDown() {
         if (LOG.isDebugEnabled()) {
             LOG.debug("TxManager is going SHUTTING_DOWN for node {}", this.nodeId);
         }
index 8ec9095170ed477a3c5b16ff61896be9fa672968..67be069039d7e02f6e13ec2a8bf3fad866deeea2 100644 (file)
@@ -9,9 +9,6 @@
 
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
-    <reference id="dataBrokerRef"
-               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
-
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
         <command name="ofp/showStats">
             <action class="org.opendaylight.openflowplugin.impl.karaf.ShowStatsCommandProvider"/>
index e2c9571ce52c69010554e00dc882c29f11b3d30b..c657fc7b08420361b04082393fd0e079f3b96a54 100644 (file)
@@ -36,7 +36,6 @@ import org.opendaylight.mdsal.binding.api.TransactionChain;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -162,8 +161,8 @@ public class DeviceManagerImplTest {
 
     @Test(expected = ExecutionException.class)
     public void removeDeviceFromOperationalDSException() throws Exception {
-        final FluentFuture<CommitInfo> failedFuture = FluentFutures.immediateFailedFluentFuture(
-                        new TransactionCommitFailedException("Test failed transaction"));
+        final FluentFuture<?> failedFuture = FluentFutures.immediateFailedFluentFuture(
+                        new ExecutionException(new Throwable("Test failed transaction")));
         Mockito.doReturn(failedFuture).when(writeTransaction).commit();
         final ListenableFuture<?> future = deviceManager.removeDeviceFromOperationalDS(DUMMY_IDENTIFIER);
         future.get();
index 1fdad07299016f268da18e50ad5edbe28af8c20d..8f1d6e173a8ccfab733e4bc455455e2c301b7b6e 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.device;
 
 import static org.mockito.ArgumentMatchers.any;
 
+import java.util.concurrent.ExecutionException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -24,7 +25,6 @@ import org.opendaylight.mdsal.binding.api.TransactionChain;
 import org.opendaylight.mdsal.binding.api.TransactionChainListener;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
 import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
@@ -118,7 +118,7 @@ public class TransactionChainManagerTest {
 
     @Test
     public void testSubmitTransactionFailed() {
-        Mockito.doReturn(FluentFutures.immediateFailedFluentFuture(new TransactionCommitFailedException("mock")))
+        Mockito.doReturn(FluentFutures.immediateFailedFluentFuture(new ExecutionException(new Throwable("mock"))))
             .when(writeTx).commit();
         final Node data = new NodeBuilder().setId(nodeId).build();
         txChainManager.initialSubmitWriteTransaction();
index d6c77c7ad89d88ade1e06831bcc0db2864d0bfa4..5066dcbf08c9701b9c53652fafaa3c544bf8bc86 100644 (file)
@@ -17,10 +17,10 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;