Obsolete ask-based protocol
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DistributedDataStore.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
9 package org.opendaylight.controller.cluster.datastore;
10
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.ActorUtils;
17 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
18 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
19 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
20 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
21
22 /**
23  * Implements a distributed DOMStore using Akka {@code Patterns.ask()}.
24  *
25  * @deprecated This implementation is destined for removal,
26  */
27 @Deprecated(since = "7.0.0", forRemoval = true)
28 public class DistributedDataStore extends AbstractDataStore {
29     private final TransactionContextFactory txContextFactory;
30
31     public DistributedDataStore(final ActorSystem actorSystem, final ClusterWrapper cluster,
32             final Configuration configuration, final DatastoreContextFactory datastoreContextFactory,
33             final DatastoreSnapshot restoreFromSnapshot) {
34         super(actorSystem, cluster, configuration, datastoreContextFactory, restoreFromSnapshot);
35         txContextFactory = new TransactionContextFactory(getActorUtils(), getIdentifier());
36     }
37
38     @VisibleForTesting
39     DistributedDataStore(final ActorUtils actorUtils, final ClientIdentifier identifier) {
40         super(actorUtils, identifier);
41         txContextFactory = new TransactionContextFactory(getActorUtils(), getIdentifier());
42     }
43
44
45     @Override
46     public DOMStoreTransactionChain createTransactionChain() {
47         return txContextFactory.createTransactionChain();
48     }
49
50     @Override
51     public DOMStoreReadTransaction newReadOnlyTransaction() {
52         return new TransactionProxy(txContextFactory, TransactionType.READ_ONLY);
53     }
54
55     @Override
56     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
57         getActorUtils().acquireTxCreationPermit();
58         return new TransactionProxy(txContextFactory, TransactionType.WRITE_ONLY);
59     }
60
61     @Override
62     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
63         getActorUtils().acquireTxCreationPermit();
64         return new TransactionProxy(txContextFactory, TransactionType.READ_WRITE);
65     }
66
67     @Override
68     public void close() {
69         txContextFactory.close();
70         super.close();
71     }
72 }