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 org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
12 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.RequestException;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
18 * Standalone transaction specialization of {@link AbstractFrontendHistory}. There can be multiple open transactions
19 * and they are submitted in any order.
21 * @author Robert Varga
23 final class StandaloneFrontendHistory extends AbstractFrontendHistory {
24 private final LocalHistoryIdentifier identifier;
25 private final ShardDataTree tree;
27 StandaloneFrontendHistory(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree) {
29 this.identifier = new LocalHistoryIdentifier(clientId, 0);
30 this.tree = Preconditions.checkNotNull(tree);
34 public LocalHistoryIdentifier getIdentifier() {
39 FrontendTransaction createOpenTransaction(final TransactionIdentifier id) throws RequestException {
40 return FrontendTransaction.createOpen(this, tree.newReadWriteTransaction(id));
44 FrontendTransaction createReadyTransaction(final TransactionIdentifier id, final DataTreeModification mod)
45 throws RequestException {
46 return FrontendTransaction.createReady(this, id, mod);
50 ShardDataTreeCohort createReadyCohort(final TransactionIdentifier id, final DataTreeModification mod) {
51 return tree.createReadyCohort(id, mod);