X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FBindingTranslatedTransactionChain.java;h=36b7a0f5f2754cd54be26bd932c99e6e361a9631;hb=6e2f13caf52fe4f4af8aa7c0e8ffd475d4e15fba;hp=d16170ba481d7d1a295a6acdcf33ae83b73b8a7d;hpb=a41c1ca36ad9be6b8e43413e4477623123b62250;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java index d16170ba48..36b7a0f5f2 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java @@ -25,20 +25,24 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.yangtools.concepts.Delegator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -class BindingTranslatedTransactionChain implements BindingTransactionChain, Delegator { +final class BindingTranslatedTransactionChain implements BindingTransactionChain, Delegator { + + private static final Logger LOG = LoggerFactory.getLogger(BindingTranslatedTransactionChain.class); private final DOMTransactionChain delegate; private final BindingToNormalizedNodeCodec codec; - private final DelegateChainListener delegatingListener; - private final TransactionChainListener listener; + private final DelegateChainListener domListener; + private final TransactionChainListener bindingListener; public BindingTranslatedTransactionChain(final DOMDataBroker chainFactory, final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) { Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null"); - this.delegatingListener = new DelegateChainListener(); - this.listener = listener; - this.delegate = chainFactory.createTransactionChain(listener); + this.domListener = new DelegateChainListener(); + this.bindingListener = listener; + this.delegate = chainFactory.createTransactionChain(domListener); this.codec = codec; } @@ -82,7 +86,7 @@ class BindingTranslatedTransactionChain implements BindingTransactionChain, Dele return bindingTx; } - protected CheckedFuture listenForFailure( + private CheckedFuture listenForFailure( final WriteTransaction tx, CheckedFuture future) { Futures.addCallback(future, new FutureCallback() { @Override @@ -99,11 +103,14 @@ class BindingTranslatedTransactionChain implements BindingTransactionChain, Dele return future; } - protected void failTransactionChain(WriteTransaction tx, Throwable t) { - // We asume correct state change for underlaying transaction - // chain, so we are not changing any of our internal state - // to mark that we failed. - this.delegatingListener.onTransactionChainFailed(this, tx, t); + private void failTransactionChain(WriteTransaction tx, Throwable t) { + /* + * We asume correct state change for underlaying transaction + * + * chain, so we are not changing any of our internal state + * to mark that we failed. + */ + this.bindingListener.onTransactionChainFailed(this, tx, t); } @Override @@ -116,21 +123,25 @@ class BindingTranslatedTransactionChain implements BindingTransactionChain, Dele @Override public void onTransactionChainFailed(final TransactionChain chain, final AsyncTransaction transaction, final Throwable cause) { + Preconditions.checkState(delegate.equals(chain), + "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain); /* * Intentionally NOOP, callback for failure, since we - * are also listening on each transaction for failure. + * are also listening on each transaction future for failure, + * in order to have reference to Binding Transaction (which was seen by client + * of this transaction chain), instead of DOM transaction + * which is known only to this chain, binding transaction implementation + * and underlying transaction chain. * - * by listening on submit future for Binding transaction - * in order to provide Binding transaction (which was seen by client - * of this transaction chain, instead of - */ + */ + LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause); } @Override public void onTransactionChainSuccessful(final TransactionChain chain) { Preconditions.checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain); - listener.onTransactionChainSuccessful(BindingTranslatedTransactionChain.this); + bindingListener.onTransactionChainSuccessful(BindingTranslatedTransactionChain.this); } }