Migrate deprecated submit() to commit() under PCEP 31/72231/3
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 24 May 2018 12:29:53 +0000 (14:29 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Fri, 25 May 2018 06:48:13 +0000 (08:48 +0200)
Change-Id: Id3136e3bcac708e0c04e35ee2bc673f8dd424d36
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
12 files changed:
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/message/PCEPRequestMessageParser.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPTopologyProvider.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/ServerSessionManager.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyNodeState.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/config/PCEPTopologyProviderBean.java
pcep/topology/topology-stats/src/main/java/org/opendaylight/bgpcep/pcep/topology/stats/provider/TopologyStatsProviderImpl.java
pcep/tunnel/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/NodeChangedListener.java
pcep/tunnel/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/PCEPTunnelClusterSingletonService.java
pcep/tunnel/tunnel-provider/src/test/java/org/opendaylight/bgpcep/pcep/tunnel/provider/NodeChangedListenerTest.java
pcep/tunnel/tunnel-provider/src/test/java/org/opendaylight/bgpcep/pcep/tunnel/provider/TunnelProgrammingTest.java
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/ProgrammingServiceImpl.java

index f12cc1bf4721bb9706faee104fb81689b8ae9481..dffd3d5bec09438a3ac2fc462fd68cc9f615cf59 100644 (file)
@@ -54,7 +54,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.P2p;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRoute;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRouteBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject;
index e4eea25bd3958d1817d644d71186b081c8eab771..dad70f519a65b3bd90057cef808927d41355a21f 100755 (executable)
@@ -33,6 +33,7 @@ import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionState
 import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.TopologySessionStats;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
@@ -186,9 +187,9 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
             this.triggeredResyncInProcess = true;
         }
         // All set, commit the modifications
-        Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
+        ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Pcc Internal state for session {} updated successfully",
                         AbstractTopologySessionListener.this.session);
             }
@@ -278,13 +279,23 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
         if (onMessage(ctx, message)) {
             LOG.warn("Unhandled message {} on session {}", message, psession);
             //cancel not supported, submit empty transaction
-            ctx.trans.submit();
+            ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
+                @Override
+                public void onSuccess(final CommitInfo result) {
+                    LOG.trace("Successful commit");
+                }
+
+                @Override
+                public void onFailure(final Throwable trw) {
+                    LOG.error("Failed commit", trw);
+                }
+            }, MoreExecutors.directExecutor());
             return;
         }
 
-        Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
+        ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Internal state for session {} updated successfully", psession);
                 ctx.notifyRequests();
 
index 8279b469be9a96fa300e1acd7b8f81ed2f626673..61e5707c536a770115da94377bd46c6efcf86241 100755 (executable)
@@ -10,7 +10,7 @@ package org.opendaylight.bgpcep.pcep.topology.provider;
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
@@ -23,6 +23,7 @@ import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev171025.NetworkTopologyPcepProgrammingService;
@@ -89,7 +90,7 @@ public final class PCEPTopologyProvider extends DefaultTopologyReference {
         this.channel = channelFuture.channel();
     }
 
-    public ListenableFuture<Void> closeServiceInstance() {
+    public FluentFuture<? extends CommitInfo> closeServiceInstance() {
         //FIXME return also channelClose once ListenableFuture implements wildcard
         this.channel.close().addListener((ChannelFutureListener) future ->
                 checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause()));
index 56190f935714761a6acaaa046844e2496bf7becc..63a1b1ffa3942f887bc8913453e66d057b268b6f 100755 (executable)
@@ -10,11 +10,10 @@ package org.opendaylight.bgpcep.pcep.topology.provider;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.VisibleForTesting;
+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;
 import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
@@ -29,6 +28,7 @@ import org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProvide
 import org.opendaylight.bgpcep.pcep.topology.spi.stats.TopologySessionStatsRegistry;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.protocol.pcep.PCEPDispatcherDependencies;
 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
@@ -219,11 +219,10 @@ final class ServerSessionManager implements PCEPSessionListenerFactory, Topology
         return listener.tearDownSession(input);
     }
 
-    @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
-    synchronized ListenableFuture<Void> closeServiceInstance() {
+    synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
         if (this.isClosed.getAndSet(true)) {
             LOG.error("Session Manager has already been closed.");
-            return Futures.immediateFuture(null);
+            return CommitInfo.emptyFluentFuture();
         }
         for (final TopologySessionListener node : this.nodes.values()) {
             node.close();
@@ -236,10 +235,10 @@ final class ServerSessionManager implements PCEPSessionListenerFactory, Topology
 
         final WriteTransaction t = this.dependenciesProvider.getDataBroker().newWriteOnlyTransaction();
         t.delete(LogicalDatastoreType.OPERATIONAL, this.topology);
-        final ListenableFuture<Void> future = t.submit();
-        Futures.addCallback(future, new FutureCallback<Void>() {
+        final FluentFuture<? extends CommitInfo> future = t.commit();
+        future.addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.debug("Topology {} removed", ServerSessionManager.this.topology);
             }
 
index 41b9286ab4e7aff2d648e987b19667e32b8a39cc..fdc5c4541bc9d3fede235d692880a7fae86f83c7 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.bgpcep.pcep.topology.provider;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
@@ -28,6 +27,7 @@ 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.common.api.CommitInfo;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.TerminationReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1;
@@ -90,9 +90,9 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
         if (!persist) {
             final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
             trans.delete(LogicalDatastoreType.OPERATIONAL, this.nodeId);
-            Futures.addCallback(trans.submit(), new FutureCallback<Void>() {
+            trans.commit().addCallback(new FutureCallback<CommitInfo>() {
                 @Override
-                public void onSuccess(final Void result) {
+                public void onSuccess(final CommitInfo result) {
                     LOG.trace("Internal state for node {} cleaned up successfully", TopologyNodeState.this.nodeId);
                 }
 
@@ -171,9 +171,9 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
         final WriteTransaction t = this.chain.newWriteOnlyTransaction();
         LOG.trace("Put topology Node {}, value {}", this.nodeId, node);
         t.merge(LogicalDatastoreType.OPERATIONAL, this.nodeId, node);
-        Futures.addCallback(t.submit(), new FutureCallback<Void>() {
+        t.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Topology Node stored {}, value {}", TopologyNodeState.this.nodeId, node);
             }
 
@@ -184,16 +184,16 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
         }, MoreExecutors.directExecutor());
     }
 
-    public synchronized void storeNode(final InstanceIdentifier<Node1> topologyAugment, final Node1 ta,
+    synchronized void storeNode(final InstanceIdentifier<Node1> topologyAugment, final Node1 ta,
             final PCEPSession session) {
         LOG.trace("Peer data {} set to {}", topologyAugment, ta);
         final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
         trans.put(LogicalDatastoreType.OPERATIONAL, topologyAugment, ta);
 
         // All set, commit the modifications
-        Futures.addCallback(trans.submit(), new FutureCallback<Void>() {
+        trans.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Node stored {} for session {} updated successfully", topologyAugment, session);
             }
 
index f1b7609a60dc3faa16dd9305f70da87769ede8a6..2e01e9d5ad725e0b840d48cf73b7bcbd60145c37 100644 (file)
@@ -10,9 +10,7 @@ package org.opendaylight.bgpcep.pcep.topology.provider.config;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.List;
@@ -25,6 +23,7 @@ import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
@@ -74,12 +73,11 @@ public final class PCEPTopologyProviderBean implements PCEPTopologyProviderDepen
         }
     }
 
-    @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
-    synchronized ListenableFuture<Void> closeServiceInstance() {
+    synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
         if (this.pcepTopoProviderCSS != null) {
             return this.pcepTopoProviderCSS.closeServiceInstance();
         }
-        return Futures.immediateFuture(null);
+        return CommitInfo.emptyFluentFuture();
     }
 
     @Override
@@ -164,14 +162,13 @@ public final class PCEPTopologyProviderBean implements PCEPTopologyProviderDepen
         }
 
         @Override
-        @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
-        public synchronized ListenableFuture<Void> closeServiceInstance() {
+        public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
             LOG.info("Close PCEP Topology Provider Singleton Service {}", getIdentifier().getValue());
             if (this.serviceInstantiated) {
                 this.serviceInstantiated = false;
                 return this.pcepTopoProvider.closeServiceInstance();
             }
-            return Futures.immediateFuture(null);
+            return CommitInfo.emptyFluentFuture();
         }
 
         @Nonnull
index 3a5632319dba5e4a90cf9ec75b2dd4bda19df334..d667aaa4772eedcbd598a9fdb8b71ea06f92ec21 100644 (file)
@@ -12,7 +12,6 @@ import static java.util.Objects.requireNonNull;
 import static java.util.concurrent.TimeUnit.SECONDS;
 
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.HashMap;
 import java.util.Map;
@@ -32,6 +31,7 @@ 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.common.api.CommitInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug;
@@ -87,9 +87,9 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
                         entry.getKey().augmentation(PcepTopologyNodeStatsAug.class);
                 tx.put(LogicalDatastoreType.OPERATIONAL, statId, nodeStatsAug);
             }
-            Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+            tx.commit().addCallback(new FutureCallback<CommitInfo>() {
                 @Override
-                public void onSuccess(Void result) {
+                public void onSuccess(CommitInfo result) {
                     LOG.debug("Successfully committed Topology stats update");
                 }
 
@@ -149,7 +149,7 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
         final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, nodeId);
         try {
-            wTx.submit().get();
+            wTx.commit().get();
         } catch (final InterruptedException | ExecutionException e) {
             LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId());
         }
index e7f22b0546648214a464feaccbbccb7f4c202031..78bea0ed16094156ee47bde6c23b6c3599747e77 100644 (file)
@@ -13,8 +13,6 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,6 +28,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.AdministrativeStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1;
@@ -432,9 +431,9 @@ public final class NodeChangedListener implements ClusteredDataTreeChangeListene
         // We now have list of all affected LSPs. Walk them create/remove them
         updateTransaction(trans, lsps, original, updated, created);
 
-        Futures.addCallback(JdkFutureAdapters.listenInPoolThread(trans.submit()), new FutureCallback<Void>() {
+        trans.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Topology change committed successfully");
             }
 
index acf586583df363fbe1ac41afcf2ba7de02408d55..b7901e3205dbc9eaddfb3efd1abf5a8bde1f4fd0 100644 (file)
@@ -9,9 +9,7 @@ package org.opendaylight.bgpcep.pcep.tunnel.provider;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import javax.annotation.Nonnull;
@@ -20,6 +18,7 @@ import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
@@ -98,14 +97,13 @@ public final class PCEPTunnelClusterSingletonService implements ClusterSingleton
     }
 
     @Override
-    @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
-    public synchronized ListenableFuture<Void> closeServiceInstance() {
+    public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
         LOG.info("Close Service Instance PCEP Tunnel Topology Provider Singleton Service {}",
                 getIdentifier().getValue());
         this.reg.close();
         this.tp.close();
         this.ttp.close();
-        return Futures.immediateFuture(null);
+        return CommitInfo.emptyFluentFuture();
     }
 
     @Nonnull
index 06c1412ebe7d47740d877465128c03fe090f3f4c..bce6dadd5952836dba2240ca5f0c9b3e3fbeaf8f 100644 (file)
@@ -14,6 +14,7 @@ import static org.opendaylight.protocol.util.CheckUtil.readDataOperational;
 
 import com.google.common.collect.Lists;
 import java.util.Collections;
+import java.util.concurrent.ExecutionException;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -23,7 +24,6 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
@@ -85,14 +85,14 @@ public class NodeChangedListenerTest extends AbstractConcurrentDataBrokerTest {
     private ListenerRegistration<NodeChangedListener> listenerRegistration;
 
     @Before
-    public void setUp() throws TransactionCommitFailedException {
+    public void setUp() throws InterruptedException, ExecutionException {
         final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID, new TopologyBuilder()
                 .setKey(new TopologyKey(PCEP_TOPOLOGY_ID)).setNode(Lists.newArrayList())
                 .setTopologyId(PCEP_TOPOLOGY_ID).build(), true);
         wTx.put(LogicalDatastoreType.OPERATIONAL, TUNNEL_TOPO_IID, new TopologyBuilder()
                 .setKey(new TopologyKey(TUNNEL_TOPOLOGY_ID)).setTopologyId(TUNNEL_TOPOLOGY_ID).build(), true);
-        wTx.submit().checkedGet();
+        wTx.commit().get();
         final NodeChangedListener nodeListener = new NodeChangedListener(getDataBroker(),
                 PCEP_TOPOLOGY_ID, TUNNEL_TOPO_IID);
         this.listenerRegistration = getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(
@@ -100,7 +100,7 @@ public class NodeChangedListenerTest extends AbstractConcurrentDataBrokerTest {
     }
 
     @Test
-    public void testNodeChangedListener() throws ReadFailedException, TransactionCommitFailedException {
+    public void testNodeChangedListener() throws ReadFailedException, InterruptedException, ExecutionException {
         // add node -> create two nodes with TPs and link
         createNode(NODE1_ID, NODE1_IPV4, LSP1_NAME, LSP1_ID, NODE2_IPV4);
         final Topology tunnelTopo = readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, tunnelTopo1 -> {
@@ -198,7 +198,7 @@ public class NodeChangedListenerTest extends AbstractConcurrentDataBrokerTest {
     }
 
     private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId,
-            final String dstIpv4Address) throws TransactionCommitFailedException {
+            final String dstIpv4Address) throws InterruptedException, ExecutionException {
         final NodeBuilder nodeBuilder = new NodeBuilder();
         nodeBuilder.setKey(new NodeKey(nodeId));
         nodeBuilder.setNodeId(nodeId);
@@ -225,13 +225,13 @@ public class NodeChangedListenerTest extends AbstractConcurrentDataBrokerTest {
         final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class,
                 new NodeKey(nodeId)).build(), nodeBuilder.build());
-        wTx.submit().checkedGet();
+        wTx.commit().get();
     }
 
-    private void removeNode(final NodeId nodeId) throws TransactionCommitFailedException {
+    private void removeNode(final NodeId nodeId) throws InterruptedException, ExecutionException {
         final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder()
                 .child(Node.class, new NodeKey(nodeId)).build());
-        wTx.submit().checkedGet();
+        wTx.commit().get();
     }
 }
index 3a997a780e8ca0debbb883d92cfeb27e4dc23253..32e3d753f1b4733a0911f90235ed2d896dd049f5 100644 (file)
@@ -228,7 +228,7 @@ public class TunnelProgrammingTest extends AbstractConcurrentDataBrokerTest {
     }
 
     @Test
-    public void testTunnelProgramming() throws TransactionCommitFailedException {
+    public void testTunnelProgramming() throws InterruptedException, ExecutionException {
         final Bandwidth bwd = new Bandwidth(new byte[]{0x00, 0x00, 0x00, (byte) 0xff});
         final ClassType classType = new ClassType((short) 1);
         final String tunnelName = "create-tunnel";
@@ -291,7 +291,7 @@ public class TunnelProgrammingTest extends AbstractConcurrentDataBrokerTest {
         Assert.assertEquals(NODE1_ID.getValue(), this.removeLspInput.getNode().getValue());
     }
 
-    private void createInitialTopology() throws TransactionCommitFailedException {
+    private void createInitialTopology() throws InterruptedException, ExecutionException {
         final TopologyBuilder topologyBuilder = new TopologyBuilder();
         topologyBuilder.setKey(new TopologyKey(TOPOLOGY_ID));
         topologyBuilder.setServerProvided(true);
@@ -300,10 +300,10 @@ public class TunnelProgrammingTest extends AbstractConcurrentDataBrokerTest {
                 createNode(NODE2_ID, TP2_ID, NODE2_IPV4)));
         final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL, TOPO_IID, topologyBuilder.build(), true);
-        wTx.submit().checkedGet();
+        wTx.commit().get();
     }
 
-    private void createLink() throws TransactionCommitFailedException {
+    private void createLink() throws InterruptedException, ExecutionException {
         final LinkBuilder linkBuilder = new LinkBuilder();
         linkBuilder.setSource(new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology
                 .rev131021.link.attributes.SourceBuilder().setSourceNode(NODE1_ID).setSourceTp(TP1_ID).build());
@@ -315,7 +315,7 @@ public class TunnelProgrammingTest extends AbstractConcurrentDataBrokerTest {
         final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL, TOPO_IID.builder().child(Link.class, new LinkKey(LINK1_ID)).build(),
                 linkBuilder.build(), true);
-        wTx.submit().checkedGet();
+        wTx.commit().get();
     }
 
 }
index 86ae352a97ee584471d1a093bfd2e8b564eb1663..641f149d36a769118dcd934fff738c4c104ca9c0 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.bgpcep.programming.impl;
 
 import static java.util.Objects.requireNonNull;
 
+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;
@@ -38,6 +39,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
@@ -112,9 +114,9 @@ public final class ProgrammingServiceImpl implements ClusterSingletonService, In
                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming
                                         .rev150720.instruction.queue.Instruction.class,
                                 new InstructionKey(this.builder.getId())), this.builder.build());
-                Futures.addCallback(wt.submit(), new FutureCallback<Void>() {
+                wt.commit().addCallback(new FutureCallback<CommitInfo>() {
                     @Override
-                    public void onSuccess(final Void result) {
+                    public void onSuccess(final CommitInfo result) {
                         LOG.debug("Instruction Queue {} updated", ProgrammingServiceImpl.this.qid);
                     }
 
@@ -140,9 +142,9 @@ public final class ProgrammingServiceImpl implements ClusterSingletonService, In
                     org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction
                             .queue.Instruction.class,
                     new InstructionKey(this.builder.getId())));
-            Futures.addCallback(wt.submit(), new FutureCallback<Void>() {
+            wt.commit().addCallback(new FutureCallback<CommitInfo>() {
                 @Override
-                public void onSuccess(final Void result) {
+                public void onSuccess(final CommitInfo result) {
                     LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
                 }
 
@@ -178,9 +180,9 @@ public final class ProgrammingServiceImpl implements ClusterSingletonService, In
         final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
         wt.put(LogicalDatastoreType.OPERATIONAL, this.qid, new InstructionsQueueBuilder()
                 .setKey(new InstructionsQueueKey(this.instructionId)).setInstruction(Collections.emptyList()).build());
-        Futures.addCallback(wt.submit(), new FutureCallback<Void>() {
+        wt.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.debug("Instruction Queue {} added", ProgrammingServiceImpl.this.qid);
             }
 
@@ -411,7 +413,7 @@ public final class ProgrammingServiceImpl implements ClusterSingletonService, In
     }
 
     @Override
-    public synchronized ListenableFuture<Void> closeServiceInstance() {
+    public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
         LOG.info("Closing Instruction Queue service {}", this.sgi.getValue());
 
         if (this.reg != null) {
@@ -425,10 +427,10 @@ public final class ProgrammingServiceImpl implements ClusterSingletonService, In
         final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
         wt.delete(LogicalDatastoreType.OPERATIONAL, this.qid);
 
-        final ListenableFuture<Void> future = wt.submit();
-        Futures.addCallback(future, new FutureCallback<Void>() {
+        final FluentFuture<? extends CommitInfo> future = wt.commit();
+        future.addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
             }