Deprecate all MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / SerializedDOMDataBroker.java
index 3bb5d5f8bfddbc03d2903e9f02bd0420b1045ff9..1d5912cc6a23b917f1844026f650efb1237e56d8 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.base.Supplier;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
@@ -21,7 +21,6 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
 import org.opendaylight.yangtools.util.DurationStatisticsTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory;
  * <p>
  * This executor does not have an upper bound on subtask timeout.
  */
+@Deprecated
 public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
     private static final Logger LOG = LoggerFactory.getLogger(SerializedDOMDataBroker.class);
     private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent();
@@ -63,23 +63,22 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
     }
 
     @Override
-    protected CheckedFuture<Void, TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
-                                                                           final
-                                                                           Collection<DOMStoreThreePhaseCommitCohort>
-                                                                                   cohorts) {
+    protected <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
+            final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
         Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
         Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
         LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
 
-        ListenableFuture<Void> commitFuture = null;
+        ListenableFuture<T> commitFuture;
         try {
-            commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts, commitStatsTracker));
+            commitFuture = executor.submit(new CommitCoordinationTask<>(transaction, cohorts, commitStatsTracker,
+                    futureValueSupplier));
         } catch (RejectedExecutionException e) {
-            LOG.error("The commit executor's queue is full - submit task was rejected. \n" + executor, e);
-            return Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException(
+            LOG.error("The commit executor {} queue is full - submit task was rejected. \n", executor, e);
+            commitFuture = Futures.immediateFailedFuture(new TransactionCommitFailedException(
                     "Could not submit the commit task - the commit queue capacity has been exceeded.", e));
         }
 
-        return MappingCheckedFuture.create(commitFuture, TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER);
+        return commitFuture;
     }
 }