2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import com.google.common.base.Preconditions;
11 import com.google.common.util.concurrent.FutureCallback;
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
15 import org.opendaylight.controller.sal.core.spi.data.ForwardingDOMStoreThreePhaseCommitCohort;
17 final class ChainedTransactionCommitImpl extends ForwardingDOMStoreThreePhaseCommitCohort {
18 private final SnapshotBackedWriteTransaction transaction;
19 private final DOMStoreThreePhaseCommitCohort delegate;
20 private final DOMStoreTransactionChainImpl txChain;
22 ChainedTransactionCommitImpl(final SnapshotBackedWriteTransaction transaction,
23 final DOMStoreThreePhaseCommitCohort delegate, final DOMStoreTransactionChainImpl txChain) {
24 this.transaction = Preconditions.checkNotNull(transaction);
25 this.delegate = Preconditions.checkNotNull(delegate);
26 this.txChain = Preconditions.checkNotNull(txChain);
30 protected DOMStoreThreePhaseCommitCohort delegate() {
35 public ListenableFuture<Void> commit() {
36 ListenableFuture<Void> commitFuture = super.commit();
37 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
39 public void onFailure(final Throwable t) {
40 txChain.onTransactionFailed(transaction, t);
44 public void onSuccess(final Void result) {
45 txChain.onTransactionCommited(transaction);