Bulk merge of l2gw changes
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / recovery / impl / L2GatewayConnectionInstanceRecoveryHandler.java
index 8776226396d659cb327239ebdf481dd85f4d2082..30b66dfa92ff3e36235d1e1ac54561938b7034b6 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.elan.l2gw.recovery.impl;
 
+import static org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION;
+
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
@@ -15,7 +17,6 @@ import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
 import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.util.Datastore;
 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@@ -80,23 +81,17 @@ public class L2GatewayConnectionInstanceRecoveryHandler implements ServiceRecove
         }
         //l2GatewayConnectionUtils.addL2GatewayConnection(l2gatewayConnectionOptional.get());
 
-        if (l2gatewayConnectionOptional.isPresent()) {
-            L2gatewayConnection l2gatewayConnection = l2gatewayConnectionOptional.get();
+        L2gatewayConnection l2gatewayConnection = l2gatewayConnectionOptional.get();
 
-            try {
-                LOG.info("deleting l2 gateway connection {}",l2gatewayConnection.key());
-                txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
-                    tx -> tx.delete(connectionInstanceIdentifier)).get();
-                LOG.info("recreating l2 gateway connection {}, {}",entityId, l2gatewayConnection.key());
-                txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
-                    tx -> tx.put(connectionInstanceIdentifier, l2gatewayConnection)).get();
-            } catch (InterruptedException | ExecutionException e) {
-                LOG.error("Service recovery failed for l2gw connection {}", entityId);
-            }
-        }
+        LOG.info("deleting l2 gateway connection {}",l2gatewayConnection.key());
+        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+            tx -> tx.delete(connectionInstanceIdentifier));
+        LOG.info("recreating l2 gateway connection {}, {}",entityId, l2gatewayConnection.key());
+        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+            tx -> tx.put(connectionInstanceIdentifier,l2gatewayConnection));
     }
 
     public String buildServiceRegistryKey() {
         return NetvirtL2gwConnection.class.toString();
     }
-}
\ No newline at end of file
+}