Update DOMStoreThreePhaseCommitCohort design
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / ChainedTransactionCommitImpl.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.dom.store.inmemory;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.mdsal.common.api.CommitInfo;
14 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
15 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
16
17 final class ChainedTransactionCommitImpl extends InMemoryDOMStoreThreePhaseCommitCohort {
18     private final DOMStoreTransactionChainImpl txChain;
19
20     ChainedTransactionCommitImpl(final InMemoryDOMDataStore store,
21                                  final SnapshotBackedWriteTransaction<String> transaction,
22                                  final DataTreeModification modification,
23                                  final DOMStoreTransactionChainImpl txChain,
24                                  final Exception operationError) {
25         super(store, transaction, modification, operationError);
26         this.txChain = requireNonNull(txChain);
27     }
28
29     @Override
30     public ListenableFuture<CommitInfo> commit() {
31         ListenableFuture<CommitInfo> ret = super.commit();
32         txChain.transactionCommited(getTransaction());
33         return ret;
34     }
35 }