BUG-1018 Implement BackwardsCompatible BI broker data notifications
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / DOMDataBrokerImpl.java
index fcf8b40efe52106fb8477897d028dc153c956eee..608ac9bc68d120c39d96b0389bbed324ba01652e 100644 (file)
@@ -120,7 +120,7 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
 
     private ListenableFuture<RpcResult<TransactionStatus>> submit(
             final WriteTransactionImpl<? extends DOMStoreWriteTransaction> transaction) {
-        LOG.debug("Tx: {} is submitted for execution.",transaction.getIdentifier());
+        LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
         return executor.submit(new CommitCoordination(transaction));
     }
 
@@ -190,7 +190,7 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
             this.broker = broker;
         }
 
-        public Iterable<DOMStoreThreePhaseCommitCohort> ready() {
+        public synchronized Iterable<DOMStoreThreePhaseCommitCohort> ready() {
             checkState(cohorts == null, "Transaction was already marked as ready.");
             ImmutableList.Builder<DOMStoreThreePhaseCommitCohort> cohortsBuilder = ImmutableList.builder();
             for (DOMStoreWriteTransaction subTx : getSubtransactions()) {
@@ -217,8 +217,7 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
         @Override
         public void merge(final LogicalDatastoreType store, final InstanceIdentifier path,
                 final NormalizedNode<?, ?> data) {
-            // TODO Auto-generated method stub
-            throw new UnsupportedOperationException("Not implemented yet.");
+            getSubtransaction(store).merge(path,data);
         }
 
         @Override
@@ -251,11 +250,6 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
                 final InstanceIdentifier path) {
             return getSubtransaction(store).read(path);
         }
-
-        @Override
-        public void merge(final LogicalDatastoreType store, final InstanceIdentifier path, final NormalizedNode<?, ?> data) {
-
-        }
     }
 
     private final class CommitCoordination implements Callable<RpcResult<TransactionStatus>> {
@@ -269,15 +263,18 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
         @Override
         public RpcResult<TransactionStatus> call() throws Exception {
 
-            Boolean canCommit = canCommit().get();
             try {
+                Boolean canCommit = canCommit().get();
+
                 if (canCommit) {
                     try {
                         preCommit().get();
                         try {
                             commit().get();
-                            COORDINATOR_LOG.debug("Tx: {} Is commited.",transaction.getIdentifier());
-                            return Rpcs.getRpcResult(true, TransactionStatus.COMMITED, Collections.<RpcError>emptySet());
+                            COORDINATOR_LOG.debug("Tx: {} Is commited.", transaction.getIdentifier());
+                            return Rpcs.getRpcResult(true, TransactionStatus.COMMITED,
+                                    Collections.<RpcError> emptySet());
+
                         } catch (InterruptedException | ExecutionException e) {
                             COORDINATOR_LOG.error("Tx: {} Error during commit", transaction.getIdentifier(), e);
                         }
@@ -287,7 +284,7 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
                                 transaction.getIdentifier(), e);
                     }
                 } else {
-                    COORDINATOR_LOG.info("Tx: {} Did not pass canCommit phase.");
+                    COORDINATOR_LOG.info("Tx: {} Did not pass canCommit phase.", transaction.getIdentifier());
                     abort().get();
                 }
             } catch (InterruptedException | ExecutionException e) {
@@ -299,7 +296,7 @@ public class DOMDataBrokerImpl implements DOMDataBroker, AutoCloseable {
             } catch (InterruptedException | ExecutionException e) {
                 COORDINATOR_LOG.error("Tx: {} Error during abort", transaction.getIdentifier(), e);
             }
-            return Rpcs.getRpcResult(false, TransactionStatus.FAILED, Collections.<RpcError>emptySet());
+            return Rpcs.getRpcResult(false, TransactionStatus.FAILED, Collections.<RpcError> emptySet());
         }
 
         public ListenableFuture<Void> preCommit() {