Remove deprecated CheckedFuture 93/62993/2
authorDavid Suarez <david.suarez.fuentes@gmail.com>
Thu, 7 Sep 2017 19:40:03 +0000 (21:40 +0200)
committerSam Hague <shague@redhat.com>
Wed, 13 Sep 2017 21:49:57 +0000 (21:49 +0000)
Remove deprecated CheckedFuture.

Change-Id: I69b6378867f68e18d69a23c25e14780ad305370c
Signed-off-by: David Suarez <david.suarez.fuentes@gmail.com>
(cherry picked from commit bbfc50ca13ba5b8db07ef27db3acfb49bcaaed4e)

vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/DpnInVpnChangeListener.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/TransactionUtil.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/TunnelEndPointChangeListener.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnFootprintService.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInstanceListener.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnUtil.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/InterVpnLinkNodeAddTask.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/intervpnlink/tasks/InterVpnLinkRemoverTask.java

index 2c07c759c3ab0d8f18d779376266baa089073edf..12dee08c8a3db5af7c5fae39c0e7d067aa667c77 100644 (file)
@@ -8,16 +8,13 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import java.math.BigInteger;
 import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddDpnEvent;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddInterfaceToDpnOnVpnEvent;
@@ -41,10 +38,12 @@ public class DpnInVpnChangeListener implements OdlL3vpnListener {
         this.mdsalManager = mdsalManager;
     }
 
+    @Override
     public void onAddDpnEvent(AddDpnEvent notification) {
 
     }
 
+    @Override
     public void onRemoveDpnEvent(RemoveDpnEvent notification) {
 
         RemoveEventData eventData = notification.getRemoveEventData();
@@ -72,9 +71,8 @@ public class DpnInVpnChangeListener implements OdlL3vpnListener {
                 if (flushDpnsOnVpn) {
                     WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                     deleteDpn(vpnToDpnList, rd, writeTxn);
-                    CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
                     try {
-                        futures.get();
+                        writeTxn.submit().get();
                     } catch (InterruptedException | ExecutionException e) {
                         LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
                         throw new RuntimeException(e.getMessage());
index fa025fe7b8eaf92febf8a187f9cc913fd7b4ed5e..13418bf3a2dc34eacce70886fdede3a57d3e01eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015 - 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,7 +8,6 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import java.util.concurrent.ExecutionException;
@@ -16,7 +15,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -29,19 +27,19 @@ public class TransactionUtil {
     }
 
     public static final FutureCallback<Void> DEFAULT_CALLBACK = new FutureCallback<Void>() {
+        @Override
         public void onSuccess(Void result) {
             LOG.debug("onSuccess: Success in Datastore operation");
         }
 
+        @Override
         public void onFailure(Throwable error) {
             LOG.error("onFailure: Error in Datastore operation", error);
         }
-
-        ;
     };
 
     public static <T extends DataObject> Optional<T> read(DataBroker dataBroker, LogicalDatastoreType datastoreType,
-        InstanceIdentifier<T> path) {
+            InstanceIdentifier<T> path) {
 
         ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();
 
@@ -52,29 +50,25 @@ public class TransactionUtil {
             LOG.debug("read: Error while reading data from path {}", path);
             throw new RuntimeException(e);
         }
-
         return result;
     }
 
     public static <T extends DataObject> void asyncWrite(DataBroker dataBroker, LogicalDatastoreType datastoreType,
-        InstanceIdentifier<T> path, T data,
-        FutureCallback<Void> callback) {
+            InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(datastoreType, path, data, true);
         Futures.addCallback(tx.submit(), callback);
     }
 
     public static <T extends DataObject> void syncWrite(DataBroker dataBroker, LogicalDatastoreType datastoreType,
-        InstanceIdentifier<T> path,
-        T data, FutureCallback<Void> callback) {
+            InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
-        CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
         try {
-            futures.get();
+            tx.submit().get();
         } catch (InterruptedException | ExecutionException e) {
-            LOG.error("syncWrite: Error writing VPN instance to ID info to datastore (path, data) : ({}, {})",
-                    path, data);
+            LOG.error("syncWrite: Error writing VPN instance to ID info to datastore (path, data) : ({}, {})", path,
+                    data);
             throw new RuntimeException(e.getMessage());
         }
     }
index 9610549fd2d1c1a0fa5c70ce66979de0361c012c..9609f3fbe2777b20e2e680975e76f099612562e8 100644 (file)
@@ -8,16 +8,13 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
 import org.opendaylight.netvirt.vpnmanager.api.VpnHelper;
@@ -110,11 +107,9 @@ public class TunnelEndPointChangeListener
                                 vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd,
                                         vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn,
                                         interfaceState);
-                                List<CheckedFuture<Void, TransactionCommitFailedException>> checkedFutures =
-                                        Arrays.asList(writeOperTxn.submit(),
-                                                writeConfigTxn.submit(),
-                                                writeInvTxn.submit());
-                                futures.addAll(checkedFutures);
+                                futures.add(writeOperTxn.submit());
+                                futures.add(writeConfigTxn.submit());
+                                futures.add(writeInvTxn.submit());
                                 LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}",
                                         tep.getInterfaceName(), vpnName, vpnInterfaceName);
                                 return futures;
index 85b5f741ea0e1bb7fca87fd8753f842dd10ac8f1..a8b8bc03ce816afbd09ae8a4a5c1ffe7ad7a42b8 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -17,13 +16,11 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
 import org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService;
 import org.opendaylight.netvirt.vpnmanager.utilities.InterfaceUtils;
@@ -68,8 +65,8 @@ public class VpnFootprintService implements IVpnFootprintService {
     private final NotificationPublishService notificationPublishService;
 
     public VpnFootprintService(final DataBroker dataBroker, final IFibManager fibManager,
-        final OdlInterfaceRpcService ifaceRpcService, final NotificationPublishService notificationPublishService,
-        final VpnOpDataSyncer vpnOpDataSyncer) {
+            final OdlInterfaceRpcService ifaceRpcService, final NotificationPublishService notificationPublishService,
+            final VpnOpDataSyncer vpnOpDataSyncer) {
         this.dataBroker = dataBroker;
         this.fibManager = fibManager;
         this.vpnOpDataSyncer = vpnOpDataSyncer;
@@ -79,21 +76,21 @@ public class VpnFootprintService implements IVpnFootprintService {
 
     @Override
     public void updateVpnToDpnMapping(BigInteger dpId, String vpnName, String primaryRd, String interfaceName,
-            ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair,
-                                      boolean add) {
+            ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair, boolean add) {
         long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
         if (dpId == null) {
             dpId = InterfaceUtils.getDpnForInterface(ifaceMgrRpcService, interfaceName);
         }
         if (!dpId.equals(BigInteger.ZERO)) {
             if (add) {
-                // Considering the possibility of VpnInstanceOpData not being ready yet cause the VPN is
+                // Considering the possibility of VpnInstanceOpData not being ready yet cause
+                // the VPN is
                 // still in its creation process
                 if (vpnId == VpnConstants.INVALID_ID) {
                     LOG.error("updateVpnToDpnMapping: Operational data  for vpn not ready. Waiting to update vpn"
                             + " footprint for vpn {} on dpn {} interface {}", vpnName, dpId, interfaceName);
                     vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId, vpnName,
-                        VpnConstants.PER_VPN_INSTANCE_OPDATA_MAX_WAIT_TIME_IN_MILLISECONDS);
+                            VpnConstants.PER_VPN_INSTANCE_OPDATA_MAX_WAIT_TIME_IN_MILLISECONDS);
                     vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
                 }
                 if (interfaceName != null) {
@@ -114,7 +111,7 @@ public class VpnFootprintService implements IVpnFootprintService {
     }
 
     private void createOrUpdateVpnToDpnListForInterfaceName(long vpnId, String primaryRd, BigInteger dpnId,
-                                                            String intfName, String vpnName) {
+            String intfName, String vpnName) {
         Boolean newDpnOnVpn = Boolean.FALSE;
 
         synchronized (vpnName.intern()) {
@@ -135,7 +132,8 @@ public class VpnFootprintService implements IVpnFootprintService {
 
                 writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(),
                         WriteTransaction.CREATE_MISSING_PARENTS);
-                /* If earlier state was inactive, it is considered new DPN coming back to the
+                /*
+                 * If earlier state was inactive, it is considered new DPN coming back to the
                  * same VPN
                  */
                 if (vpnToDpnList.getDpnState() == VpnToDpnList.DpnState.Inactive) {
@@ -155,9 +153,8 @@ public class VpnFootprintService implements IVpnFootprintService {
                 LOG.debug("createOrUpdateVpnToDpnList: Creating vpn footprint for vpn {} vpnId {} interface {}"
                         + " on dpn {}", vpnName, vpnId, intfName, dpnId);
             }
-            CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
             try {
-                futures.get();
+                writeTxn.submit().get();
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("createOrUpdateVpnToDpnList: Error adding to dpnToVpnList for vpn {} vpnId {} interface {}"
                         + " dpn {}", vpnName, vpnId, intfName, dpnId, e);
@@ -167,11 +164,11 @@ public class VpnFootprintService implements IVpnFootprintService {
         LOG.info("createOrUpdateVpnToDpnList: Created/Updated vpn footprint for vpn {} vpnId {} interfacName{}"
                 + " on dpn {}", vpnName, vpnId, intfName, dpnId);
         /*
-         * Informing the Fib only after writeTxn is submitted successfuly.
+         * Informing the FIB only after writeTxn is submitted successfully.
          */
         if (newDpnOnVpn) {
-            fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd,
-                true /* entered */));
+            fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd,
+                    new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd, true /* entered */));
             LOG.info("createOrUpdateVpnToDpnList: Sent populateFib event for new dpn {} in VPN {} for interface {}",
                     dpnId, vpnName, intfName);
         }
@@ -201,7 +198,8 @@ public class VpnFootprintService implements IVpnFootprintService {
                 vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setIpAddresses(ipAddresses);
 
                 writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
-                /* If earlier state was inactive, it is considered new DPN coming back to the
+                /*
+                 * If earlier state was inactive, it is considered new DPN coming back to the
                  * same VPN
                  */
                 if (vpnToDpnList.getDpnState() == VpnToDpnList.DpnState.Inactive) {
@@ -216,9 +214,8 @@ public class VpnFootprintService implements IVpnFootprintService {
                 writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
                 newDpnOnVpn = Boolean.TRUE;
             }
-            CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
             try {
-                futures.get();
+                writeTxn.submit().get();
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("Error adding to dpnToVpnList for vpn {} ipAddresses {} dpn {}", vpnName,
                         ipAddressSourceValuePair.getValue(), dpnId, e);
@@ -230,26 +227,26 @@ public class VpnFootprintService implements IVpnFootprintService {
          */
         if (newDpnOnVpn) {
             LOG.debug("Sending populateFib event for new dpn {} in VPN {}", dpnId, vpnName);
-            fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd,
-                    true /* entered */));
+            fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd,
+                    new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd, true /* entered */));
         }
     }
 
     private void removeOrUpdateVpnToDpnListForInterfaceName(long vpnId, String rd, BigInteger dpnId, String intfName,
-                                                            String vpnName) {
+            String vpnName) {
         Boolean lastDpnOnVpn = Boolean.FALSE;
         synchronized (vpnName.intern()) {
             InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(rd, dpnId);
             VpnToDpnList dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id).orNull();
             if (dpnInVpn == null) {
                 LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={} rd={} id={}]"
-                    + " and dpnId={}", vpnName, rd, id, dpnId);
+                        + " and dpnId={}", vpnName, rd, id, dpnId);
                 return;
             }
             List<VpnInterfaces> vpnInterfaces = dpnInVpn.getVpnInterfaces();
             if (vpnInterfaces == null) {
                 LOG.error("Could not find vpnInterfaces for DpnInVpn map for VPN=[name={} rd={} id={}] and dpnId={}",
-                         vpnName, rd, id, dpnId);
+                        vpnName, rd, id, dpnId);
                 return;
             }
 
@@ -272,14 +269,13 @@ public class VpnFootprintService implements IVpnFootprintService {
                             WriteTransaction.CREATE_MISSING_PARENTS);
 
                 } else {
-                    writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(VpnInterfaces.class,
-                                                                               new VpnInterfacesKey(intfName)));
+                    writeTxn.delete(LogicalDatastoreType.OPERATIONAL,
+                            id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
                     LOG.debug("removeOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} interface {},"
                             + " on dpn {}", vpnName, vpnName, intfName, dpnId);
                 }
-                CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
                 try {
-                    futures.get();
+                    writeTxn.submit().get();
                 } catch (InterruptedException | ExecutionException e) {
                     LOG.error("removeOrUpdateVpnToDpnList: Error removing from dpnToVpnList for vpn {} vpnId {}"
                             + " interface {} dpn {}", vpnName, vpnId, intfName, dpnId, e);
@@ -291,10 +287,10 @@ public class VpnFootprintService implements IVpnFootprintService {
                 + " on dpn {}", vpnName, vpnName, intfName, dpnId);
 
         if (lastDpnOnVpn) {
-            fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd,
-                false /* exited */));
-            LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}",
-                    dpnId, vpnName, vpnId, intfName);
+            fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd,
+                    new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false /* exited */));
+            LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}", dpnId,
+                    vpnName, vpnId, intfName);
         }
     }
 
@@ -318,8 +314,7 @@ public class VpnFootprintService implements IVpnFootprintService {
 
             IpAddresses currIpAddress = new IpAddressesBuilder()
                     .setKey(new IpAddressesKey(ipAddressSourceValuePair.getValue()))
-                    .setIpAddressSource(ipAddressSourceValuePair.getKey())
-                    .build();
+                    .setIpAddressSource(ipAddressSourceValuePair.getKey()).build();
             if (ipAddresses.remove(currIpAddress)) {
                 WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                 if (ipAddresses.isEmpty()) {
@@ -335,15 +330,14 @@ public class VpnFootprintService implements IVpnFootprintService {
                     writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(), true);
 
                 } else {
-                    writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(IpAddresses.class,
-                            new IpAddressesKey(ipAddressSourceValuePair.getValue())));
+                    writeTxn.delete(LogicalDatastoreType.OPERATIONAL,
+                            id.child(IpAddresses.class, new IpAddressesKey(ipAddressSourceValuePair.getValue())));
                 }
-                CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
                 try {
-                    futures.get();
+                    writeTxn.submit().get();
                 } catch (InterruptedException | ExecutionException e) {
-                    LOG.error("Error removing from dpnToVpnList for vpn {} Ipaddress {} dpn {}",
-                            vpnName, ipAddressSourceValuePair.getValue(), dpnId, e);
+                    LOG.error("Error removing from dpnToVpnList for vpn {} Ipaddress {} dpn {}", vpnName,
+                            ipAddressSourceValuePair.getValue(), dpnId, e);
                     throw new RuntimeException(e.getMessage());
                 }
             }
@@ -351,8 +345,8 @@ public class VpnFootprintService implements IVpnFootprintService {
 
         if (lastDpnOnVpn) {
             LOG.debug("Sending cleanup event for dpn {} in VPN {}", dpnId, vpnName);
-            fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd,
-                    false /* exited */));
+            fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd,
+                    new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false /* exited */));
         }
     }
 
@@ -399,13 +393,13 @@ public class VpnFootprintService implements IVpnFootprintService {
     }
 
     private void publishInterfaceAddedToVpnNotification(String interfaceName, BigInteger dpnId, String vpnName,
-                                                        Long vpnId) {
+            Long vpnId) {
         LOG.debug("publishInterfaceAddedToVpnNotification: Sending notification for addition of interface {} on dpn {}"
                 + " for vpn {}", interfaceName, dpnId, vpnName);
-        AddInterfaceEventData data = new AddInterfaceEventDataBuilder().setInterfaceName(interfaceName)
-                .setVpnId(vpnId).setDpnId(dpnId).build();
-        AddInterfaceToDpnOnVpnEvent event = new AddInterfaceToDpnOnVpnEventBuilder()
-                .setAddInterfaceEventData(data).build();
+        AddInterfaceEventData data = new AddInterfaceEventDataBuilder().setInterfaceName(interfaceName).setVpnId(vpnId)
+                .setDpnId(dpnId).build();
+        AddInterfaceToDpnOnVpnEvent event = new AddInterfaceToDpnOnVpnEventBuilder().setAddInterfaceEventData(data)
+                .build();
         final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
         Futures.addCallback(eventFuture, new FutureCallback<Object>() {
             @Override
@@ -423,7 +417,7 @@ public class VpnFootprintService implements IVpnFootprintService {
     }
 
     private void publishInterfaceRemovedFromVpnNotification(String interfaceName, BigInteger dpnId, String vpnName,
-                                                            Long vpnId) {
+            Long vpnId) {
         LOG.debug("publishInterfaceAddedToVpnNotification: Sending notification for removal of interface {}"
                 + " from dpn {} for vpn {}", interfaceName, dpnId, vpnName);
         RemoveInterfaceEventData data = new RemoveInterfaceEventDataBuilder().setInterfaceName(interfaceName)
@@ -434,9 +428,10 @@ public class VpnFootprintService implements IVpnFootprintService {
         Futures.addCallback(eventFuture, new FutureCallback<Object>() {
             @Override
             public void onFailure(Throwable error) {
-                LOG.warn("publishInterfaceAddedToVpnNotification: Error in notifying listeners"
-                        + " for removing interface {} from dpn {} in vpn {} event ", interfaceName, dpnId, vpnName,
-                        error);
+                LOG.warn(
+                        "publishInterfaceAddedToVpnNotification: Error in notifying listeners"
+                                + " for removing interface {} from dpn {} in vpn {} event ",
+                        interfaceName, dpnId, vpnName, error);
             }
 
             @Override
@@ -447,10 +442,9 @@ public class VpnFootprintService implements IVpnFootprintService {
         });
     }
 
-
     /**
-     * JobCallback class is used as a future callback for
-     * main and rollback workers to handle success and failure.
+     * JobCallback class is used as a future callback for main and rollback workers
+     * to handle success and failure.
      */
     private class DpnEnterExitVpnWorker implements FutureCallback<List<Void>> {
         private final Logger log = LoggerFactory.getLogger(DpnEnterExitVpnWorker.class);
@@ -467,31 +461,30 @@ public class VpnFootprintService implements IVpnFootprintService {
         }
 
         /**
-         * This implies that all the future instances have returned success. -- TODO: Confirm this
+         * This implies that all the future instances have returned success. -- TODO:
+         * Confirm this
          */
         @Override
         public void onSuccess(List<Void> voids) {
             if (entered) {
                 publishAddNotification(dpnId, vpnName, rd);
-                log.info("onSuccess: FootPrint established for vpn {} rd {} on dpn {}", vpnName,
-                        rd, dpnId);
+                log.info("onSuccess: FootPrint established for vpn {} rd {} on dpn {}", vpnName, rd, dpnId);
             } else {
                 publishRemoveNotification(dpnId, vpnName, rd);
-                log.info("onSuccess: FootPrint cleared for vpn {} rd {} on dpn {}", vpnName,
-                        rd, dpnId);
+                log.info("onSuccess: FootPrint cleared for vpn {} rd {} on dpn {}", vpnName, rd, dpnId);
             }
         }
 
         /**
-         * This method is used to handle failure callbacks.
-         * If more retry needed, the retrycount is decremented and mainworker is executed again.
-         * After retries completed, rollbackworker is executed.
-         * If rollbackworker fails, this is a double-fault. Double fault is logged and ignored.
+         * This method is used to handle failure callbacks. If more retry needed, the
+         * retrycount is decremented and mainworker is executed again. After retries
+         * completed, rollbackworker is executed. If rollbackworker fails, this is a
+         * double-fault. Double fault is logged and ignored.
          */
         @Override
         public void onFailure(Throwable throwable) {
-            log.error("onFailure: Failed to establish/clear footprint for vpn {} rd {} on dpn {} ",
-                    vpnName, rd, dpnId, throwable);
+            log.error("onFailure: Failed to establish/clear footprint for vpn {} rd {} on dpn {} ", vpnName, rd, dpnId,
+                    throwable);
         }
     }
 
index a0a7211ca7fd348aaef1f59df5c73a6b5056897b..e3a08cf937d38c19f6d184ce2ea419a4a538af2c 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -16,6 +15,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -24,7 +24,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
@@ -133,11 +132,10 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
                 InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd);
                 WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                 writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
-                List<ListenableFuture<Void>> futures = new ArrayList<>();
-                futures.add(writeTxn.submit());
+
                 LOG.info("{} call: Operational status set to PENDING_DELETE for vpn {} with rd {}",
                         LOGGING_PREFIX_DELETE, vpnName, primaryRd);
-                return futures;
+                return Collections.singletonList(writeTxn.submit());
             }, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
         }
     }
@@ -184,9 +182,9 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
             WriteTransaction writeConfigTxn = broker.newWriteOnlyTransaction();
             WriteTransaction writeOperTxn = broker.newWriteOnlyTransaction();
             addVpnInstance(vpnInstance, writeConfigTxn, writeOperTxn);
-            CheckedFuture<Void, TransactionCommitFailedException> checkFutures = writeOperTxn.submit();
+
             try {
-                checkFutures.get();
+                writeOperTxn.submit().get();
             } catch (InterruptedException | ExecutionException e) {
                 log.error("{} call: Error creating vpn {} ", LOGGING_PREFIX_ADD, vpnInstance.getVpnInstanceName());
                 throw new RuntimeException(e.getMessage());
@@ -327,7 +325,7 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
              */
             VpnAfConfig config = vpnInstance.getIpv4Family();
             List<String> rd = config.getRouteDistinguisher();
-            if ((rd == null) || addBgpVrf(voids)) {
+            if (rd == null || addBgpVrf(voids)) {
                 notifyTask();
                 vpnInterfaceManager.vpnInstanceIsReady(vpnName);
             }
@@ -398,7 +396,7 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
             //Advertise all the rds and check if primary Rd advertisement fails
             long primaryRdAddFailed = rds.parallelStream().filter(rd -> {
                 try {
-                    LayerType layerType = (vpnInstance.getType() == VpnInstance.Type.L2) ? LayerType.LAYER2 :
+                    LayerType layerType = vpnInstance.getType() == VpnInstance.Type.L2 ? LayerType.LAYER2 :
                             LayerType.LAYER3;
                     bgpManager.addVrf(rd, irtList, ertList, layerType);
                 } catch (Exception e) {
@@ -511,7 +509,6 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
             }
 
         }
-
         return tunnelInterfaceNameList;
     }
 
@@ -519,5 +516,4 @@ public class VpnInstanceListener extends AsyncDataTreeChangeListenerBase<VpnInst
         return VpnConstants.FLOWID_PREFIX + dpnId + NwConstants.FLOWID_SEPARATOR + tableId
                 + NwConstants.FLOWID_SEPARATOR + vpnName + NwConstants.FLOWID_SEPARATOR + priority;
     }
-
 }
index 93fd59ca234e6783994e91dc25bdbc42ad550aaf..cd7ffd1ca62814decab6644541184456c8190cdc 100755 (executable)
@@ -9,7 +9,6 @@
 package org.opendaylight.netvirt.vpnmanager;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -28,7 +27,6 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.FlowEntityBuilder;
@@ -180,11 +178,14 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFai
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class VpnUtil {
+public final class VpnUtil {
     private static final Logger LOG = LoggerFactory.getLogger(VpnUtil.class);
     private static final int DEFAULT_PREFIX_LENGTH = 32;
     private static final String PREFIX_SEPARATOR = "/";
 
+    private VpnUtil() {
+    }
+
     static InstanceIdentifier<VpnInterface> getVpnInterfaceIdentifier(String vpnInterfaceName) {
         return InstanceIdentifier.builder(VpnInterfaces.class)
             .child(VpnInterface.class, new VpnInterfaceKey(vpnInterfaceName)).build();
@@ -371,10 +372,8 @@ public class VpnUtil {
         if (rpcResult == null) {
             return null;
         }
-
         interfaceFromIfIndexOutput = rpcResult.getResult();
-        String interfaceName = interfaceFromIfIndexOutput.getInterfaceName();
-        return interfaceName;
+        return interfaceFromIfIndexOutput.getInterfaceName();
     }
 
     static AllocatedRdsBuilder getRdsBuilder(String nexthop, String rd) {
@@ -388,8 +387,7 @@ public class VpnUtil {
     public static InstanceIdentifier<IdPool> getPoolId(String poolName) {
         InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idBuilder =
             InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(poolName));
-        InstanceIdentifier<IdPool> id = idBuilder.build();
-        return id;
+        return idBuilder.build();
     }
 
     static InstanceIdentifier<VpnInterfaces> getVpnInterfacesIdentifier() {
@@ -827,9 +825,9 @@ public class VpnUtil {
         InstanceIdentifier<T> path, T data) {
         WriteTransaction tx = broker.newWriteOnlyTransaction();
         tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
-        CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
+
         try {
-            futures.get();
+            tx.submit().get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("syncWrite: Error writing to datastore (path, data) : ({}, {})", path, data);
             throw new RuntimeException(e.getMessage());
@@ -840,9 +838,9 @@ public class VpnUtil {
         InstanceIdentifier<T> path, T data) {
         WriteTransaction tx = broker.newWriteOnlyTransaction();
         tx.merge(datastoreType, path, data, true);
-        CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
+
         try {
-            futures.get();
+            tx.submit().get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("syncUpdate: Error writing to datastore (path, data) : ({}, {})", path, data);
             throw new RuntimeException(e.getMessage());
@@ -1087,22 +1085,18 @@ public class VpnUtil {
     }
 
     static InstanceIdentifier<NetworkMap> buildNetworkMapIdentifier(Uuid networkId) {
-        InstanceIdentifier<NetworkMap> id = InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
+        return InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
                 NetworkMapKey(networkId)).build();
-        return id;
     }
 
     static InstanceIdentifier<SubnetOpDataEntry> buildSubnetOpDataEntryInstanceIdentifier(Uuid subnetId) {
-        InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class)
+        return InstanceIdentifier.builder(SubnetOpData.class)
                 .child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
-        return subOpIdentifier;
     }
 
     static InstanceIdentifier<VpnPortipToPort> buildVpnPortipToPortIdentifier(String vpnName, String fixedIp) {
-        InstanceIdentifier<VpnPortipToPort> id =
-            InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class,
+        return InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class,
                 new VpnPortipToPortKey(fixedIp, vpnName)).build();
-        return id;
     }
 
     public static VpnPortipToPort getNeutronPortFromVpnPortFixedIp(DataBroker broker, String vpnName, String fixedIp) {
@@ -1179,9 +1173,7 @@ public class VpnUtil {
     }
 
     static InstanceIdentifier<Routers> buildRouterIdentifier(String routerId) {
-        InstanceIdentifier<Routers> routerInstanceIndentifier =
-            InstanceIdentifier.builder(ExtRouters.class).child(Routers.class, new RoutersKey(routerId)).build();
-        return routerInstanceIndentifier;
+        return InstanceIdentifier.builder(ExtRouters.class).child(Routers.class, new RoutersKey(routerId)).build();
     }
 
     static Networks getExternalNetwork(DataBroker dataBroker, Uuid networkId) {
@@ -1277,9 +1269,9 @@ public class VpnUtil {
         }
 
         String flowId = getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, gwMacAddress);
-        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE,
-            flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
-        return flowEntity;
+
+        return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE,
+                flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
     }
 
     private static String getL3VpnGatewayFlowRef(short l3GwMacTable, BigInteger dpId, long vpnId, String gwMacAddress) {
@@ -1742,13 +1734,13 @@ public class VpnUtil {
 
     public static boolean isEligibleForBgp(String rd, String vpnName, BigInteger dpnId, String networkName) {
         if (rd != null) {
-            if ((vpnName != null) && (rd.equals(vpnName))) {
+            if (vpnName != null && rd.equals(vpnName)) {
                 return false;
             }
-            if ((dpnId != null) && (rd.equals(dpnId.toString()))) {
+            if (dpnId != null && rd.equals(dpnId.toString())) {
                 return false;
             }
-            if ((networkName != null) && (rd.equals(networkName))) {
+            if (networkName != null && rd.equals(networkName)) {
                 return false;
             }
             return true;
index 4022299495b94532f0d79ddfa55e18354b570148..9b4bbb203903cec2d1ff98cc6fa5d932981e67b6 100755 (executable)
@@ -8,7 +8,6 @@
 package org.opendaylight.netvirt.vpnmanager.intervpnlink;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -18,7 +17,6 @@ import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.netvirt.vpnmanager.VpnFootprintService;
 import org.opendaylight.netvirt.vpnmanager.VpnUtil;
@@ -78,21 +76,21 @@ public class InterVpnLinkNodeAddTask implements Callable<List<ListenableFuture<V
 
     private boolean shouldConfigureLinkIntoDpn(InterVpnLinkState interVpnLinkState, int numberOfDpns) {
 
-        if ((interVpnLinkState.getFirstEndpointState().getDpId() == null
-                 || interVpnLinkState.getFirstEndpointState().getDpId().isEmpty())
-            || (interVpnLinkState.getSecondEndpointState().getDpId() == null
-                    || interVpnLinkState.getSecondEndpointState().getDpId().isEmpty())) {
+        if (interVpnLinkState.getFirstEndpointState().getDpId() == null
+                 || interVpnLinkState.getFirstEndpointState().getDpId().isEmpty()
+            || interVpnLinkState.getSecondEndpointState().getDpId() == null
+                    || interVpnLinkState.getSecondEndpointState().getDpId().isEmpty()) {
             return true;
         } else if (!interVpnLinkState.getFirstEndpointState().getDpId().contains(dpnId)
             && !interVpnLinkState.getSecondEndpointState().getDpId().contains(dpnId)
-            && (interVpnLinkState.getFirstEndpointState().getDpId().size() < numberOfDpns)) {
+            && interVpnLinkState.getFirstEndpointState().getDpId().size() < numberOfDpns) {
             return true;
         } else {
             return false;
         }
     }
 
-    private CheckedFuture<Void, TransactionCommitFailedException>
+    private ListenableFuture<Void>
         updateInterVpnLinkState(InterVpnLinkState interVpnLinkState, List<BigInteger> firstDpnList,
                                 List<BigInteger> secondDpnList, int numberOfDpns) {
 
@@ -157,5 +155,4 @@ public class InterVpnLinkNodeAddTask implements Callable<List<ListenableFuture<V
                     secondDpnList);
         }
     }
-
 }
index da64701f35ef1158e5a2317cb9f7f5994970e807..db7b268ca921f69b35d97dda9462e7c3866b2d7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,22 +7,19 @@
  */
 package org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks;
 
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class InterVpnLinkRemoverTask implements Callable<List<ListenableFuture<Void>>> {
-
     private static final Logger LOG = LoggerFactory.getLogger(InterVpnLinkRemoverTask.class);
 
     private final InstanceIdentifier<InterVpnLink> interVpnLinkIid;
@@ -38,12 +35,9 @@ public class InterVpnLinkRemoverTask implements Callable<List<ListenableFuture<V
     @Override
     public List<ListenableFuture<Void>> call() throws Exception {
         LOG.debug("Removing InterVpnLink {} from storage", interVpnLinkName);
-        List<ListenableFuture<Void>> result = new ArrayList<>();
         WriteTransaction removeTx = dataBroker.newWriteOnlyTransaction();
         removeTx.delete(LogicalDatastoreType.CONFIGURATION, this.interVpnLinkIid);
-        CheckedFuture<Void, TransactionCommitFailedException> removalFuture = removeTx.submit();
-        result.add(removalFuture);
-        return result;
-    }
 
+        return Collections.singletonList(removeTx.submit());
+    }
 }