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;
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) {
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);
@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;
}
}