Search in sources :

Example 1 with ForwardingDOMDataReadWriteTransaction

use of org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction in project controller by opendaylight.

the class PingPongTransactionChain method newReadWriteTransaction.

@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
    final PingPongTransaction tx = allocateTransaction();
    final DOMDataReadWriteTransaction ret = new ForwardingDOMDataReadWriteTransaction() {

        private boolean isOpen = true;

        @Override
        protected DOMDataReadWriteTransaction delegate() {
            return tx.getTransaction();
        }

        @Override
        public CheckedFuture<Void, TransactionCommitFailedException> submit() {
            readyTransaction(tx);
            isOpen = false;
            return tx.getSubmitFuture();
        }

        @Override
        public boolean cancel() {
            if (isOpen) {
                cancelTransaction(tx, this);
                isOpen = false;
                return true;
            } else {
                return false;
            }
        }
    };
    tx.recordFrontendTransaction(ret);
    return ret;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) DOMDataReadWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction) ForwardingDOMDataReadWriteTransaction(org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction) ForwardingDOMDataReadWriteTransaction(org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction)

Aggregations

TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 DOMDataReadWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction)1 ForwardingDOMDataReadWriteTransaction (org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction)1