Migrate to MD-SAL APIs
[bgpcep.git] / bgp / openconfig-state / src / main / java / org / opendaylight / protocol / bgp / state / StateProviderImpl.java
index 337402387f5b5eb615e52baecea039428e031ada..68e1f8e282a26284bf106469bba050e6d690e493 100644 (file)
@@ -25,14 +25,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
-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.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.Transaction;
+import org.opendaylight.mdsal.binding.api.TransactionChain;
+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.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState;
@@ -68,7 +67,7 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
     @GuardedBy("this")
     private final Map<String, InstanceIdentifier<Bgp>> instanceIdentifiersCache = new HashMap<>();
     @GuardedBy("this")
-    private BindingTransactionChain transactionChain;
+    private TransactionChain transactionChain;
     @GuardedBy("this")
     private ScheduledFuture<?> scheduleTask;
     private final ScheduledExecutorService scheduler;
@@ -95,7 +94,7 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
     }
 
     public synchronized void init() {
-        this.transactionChain = this.dataBroker.createTransactionChain(this);
+        this.transactionChain = this.dataBroker.createMergingTransactionChain(this);
         final TimerTask task = new TimerTask() {
             @Override
             @SuppressWarnings("checkstyle:IllegalCatch")
@@ -107,12 +106,12 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
 
                         wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
                             @Override
-                            public void onSuccess(CommitInfo result) {
+                            public void onSuccess(final CommitInfo result) {
                                 LOG.debug("Successfully committed BGP stats update");
                             }
 
                             @Override
-                            public void onFailure(Throwable ex) {
+                            public void onFailure(final Throwable ex) {
                                 LOG.error("Failed to commit BGP stats update", ex);
                             }
                         }, MoreExecutors.directExecutor());
@@ -190,19 +189,19 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
     }
 
     @Override
-    public synchronized void onTransactionChainFailed(final TransactionChain<?, ?> chain,
-            final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+    public synchronized void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
+            final Throwable cause) {
         LOG.error("Transaction chain {} failed for tx {}",
                 chain, transaction != null ? transaction.getIdentifier() : null, cause);
 
         if (!closed.get()) {
             transactionChain.close();
-            transactionChain = dataBroker.createTransactionChain(this);
+            transactionChain = dataBroker.createMergingTransactionChain(this);
         }
     }
 
     @Override
-    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+    public void onTransactionChainSuccessful(final TransactionChain chain) {
         LOG.debug("Transaction chain {} successful.", chain);
     }
 }