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
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.actor.ActorSystem;
12 import com.google.common.annotations.VisibleForTesting;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
14 import org.opendaylight.controller.cluster.datastore.config.Configuration;
15 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
16 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
18 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
19 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
23 * Implements a distributed DOMStore using Akka Patterns.ask().
25 public class DistributedDataStore extends AbstractDataStore {
27 private final TransactionContextFactory txContextFactory;
29 public DistributedDataStore(final ActorSystem actorSystem, final ClusterWrapper cluster,
30 final Configuration configuration, final DatastoreContextFactory datastoreContextFactory,
31 final DatastoreSnapshot restoreFromSnapshot) {
32 super(actorSystem, cluster, configuration, datastoreContextFactory, restoreFromSnapshot);
33 this.txContextFactory = new TransactionContextFactory(getActorContext(), getIdentifier());
37 DistributedDataStore(final ActorContext actorContext, final ClientIdentifier identifier) {
38 super(actorContext, identifier);
39 this.txContextFactory = new TransactionContextFactory(getActorContext(), getIdentifier());
44 public DOMStoreTransactionChain createTransactionChain() {
45 return txContextFactory.createTransactionChain();
49 public DOMStoreReadTransaction newReadOnlyTransaction() {
50 return new TransactionProxy(txContextFactory, TransactionType.READ_ONLY);
54 public DOMStoreWriteTransaction newWriteOnlyTransaction() {
55 getActorContext().acquireTxCreationPermit();
56 return new TransactionProxy(txContextFactory, TransactionType.WRITE_ONLY);
60 public DOMStoreReadWriteTransaction newReadWriteTransaction() {
61 getActorContext().acquireTxCreationPermit();
62 return new TransactionProxy(txContextFactory, TransactionType.READ_WRITE);
67 txContextFactory.close();