Bumping versions by 0.0.1 for next dev cycle
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / InMemoryDOMDataTreeShardThreePhaseCommitCohort.java
index 8c69c59a65d033339fc49f5b0080d4d7cc56e8ff..5f20089c5cbe2475acc410eb9e8aefee2cb1a542 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.mdsal.dom.store.inmemory;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collections;
 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
@@ -29,19 +30,21 @@ class InMemoryDOMDataTreeShardThreePhaseCommitCohort implements DOMStoreThreePha
     private final DataTree dataTree;
     private final DataTreeModification modification;
     private DataTreeCandidate candidate;
+    private final InMemoryDOMDataTreeShardChangePublisher changePublisher;
 
     InMemoryDOMDataTreeShardThreePhaseCommitCohort(final DataTree dataTree,
-                                                   final DataTreeModification modification) {
-        Preconditions.checkNotNull(dataTree);
-        this.dataTree = dataTree;
-        this.modification = modification;
+                                                   final DataTreeModification modification,
+                                                   final InMemoryDOMDataTreeShardChangePublisher changePublisher) {
+        this.dataTree = Preconditions.checkNotNull(dataTree);
+        this.modification = Preconditions.checkNotNull(modification);
+        this.changePublisher = Preconditions.checkNotNull(changePublisher);
     }
 
     @Override
     public ListenableFuture<Boolean> canCommit() {
         try {
             dataTree.validate(modification);
-            LOG.debug("DataTreeModification {} validated");
+            LOG.debug("DataTreeModification {} validated", modification);
 
             return CAN_COMMIT_FUTURE;
         } catch (DataValidationFailedException e) {
@@ -59,6 +62,7 @@ class InMemoryDOMDataTreeShardThreePhaseCommitCohort implements DOMStoreThreePha
     public ListenableFuture<Void> preCommit() {
         try {
             candidate = dataTree.prepare(modification);
+            LOG.debug("DataTreeModification {} prepared", modification);
             return SUCCESSFUL_FUTURE;
         } catch (Exception e) {
             LOG.warn("Unexpected failure in preparation phase", e);
@@ -75,7 +79,10 @@ class InMemoryDOMDataTreeShardThreePhaseCommitCohort implements DOMStoreThreePha
     @Override
     public ListenableFuture<Void> commit() {
         Preconditions.checkState(candidate != null, "Attempted to commit an aborted transaction");
+        LOG.debug("Commiting candidate {}", candidate);
         dataTree.commit(candidate);
+        // publish this change for listeners
+        changePublisher.publishChange(candidate);
         return SUCCESSFUL_FUTURE;
     }
 }