2 * Copyright (c) 2016 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.cluster.datastore;
10 import com.google.common.base.Preconditions;
11 import com.google.common.base.Ticker;
12 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.RequestException;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
19 * Standalone transaction specialization of {@link AbstractFrontendHistory}. There can be multiple open transactions
20 * and they are submitted in any order.
22 * @author Robert Varga
24 final class StandaloneFrontendHistory extends AbstractFrontendHistory {
25 private final LocalHistoryIdentifier identifier;
26 private final ShardDataTree tree;
28 StandaloneFrontendHistory(final String persistenceId, final Ticker ticker, final ClientIdentifier clientId,
29 final ShardDataTree tree) {
30 super(persistenceId, ticker);
31 this.identifier = new LocalHistoryIdentifier(clientId, 0);
32 this.tree = Preconditions.checkNotNull(tree);
36 public LocalHistoryIdentifier getIdentifier() {
41 FrontendTransaction createOpenSnapshot(final TransactionIdentifier id) throws RequestException {
42 return FrontendReadOnlyTransaction.create(this, tree.newReadOnlyTransaction(id));
46 FrontendTransaction createOpenTransaction(final TransactionIdentifier id) throws RequestException {
47 return FrontendReadWriteTransaction.createOpen(this, tree.newReadWriteTransaction(id));
51 FrontendTransaction createReadyTransaction(final TransactionIdentifier id, final DataTreeModification mod)
52 throws RequestException {
53 return FrontendReadWriteTransaction.createReady(this, id, mod);
57 ShardDataTreeCohort createReadyCohort(final TransactionIdentifier id, final DataTreeModification mod) {
58 return tree.createReadyCohort(id, mod);