Add case for READY in RemoteProxyTransaction
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / ClientBackedDataStore.java
1 /*
2  * Copyright (c) 2016 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.controller.cluster.databroker;
9
10 import akka.actor.ActorSystem;
11 import com.google.common.annotations.VisibleForTesting;
12 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
13 import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
14 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
15 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
16 import org.opendaylight.controller.cluster.datastore.config.Configuration;
17 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
18 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
19 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
21 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
22 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
23
24 /**
25  * Implements a distributed DOMStore using ClientActor.
26  */
27 public class ClientBackedDataStore extends AbstractDataStore {
28
29     public ClientBackedDataStore(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     }
34
35     @VisibleForTesting
36     ClientBackedDataStore(final ActorContext actorContext, final ClientIdentifier identifier) {
37         super(actorContext, identifier);
38     }
39
40     @Override
41     public DOMStoreTransactionChain createTransactionChain() {
42         return new ClientBackedTransactionChain(getClient().createLocalHistory());
43     }
44
45     @Override
46     public DOMStoreReadTransaction newReadOnlyTransaction() {
47         return new ClientBackedReadTransaction(getClient().createSnapshot(), null);
48     }
49
50     @Override
51     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
52         return new ClientBackedWriteTransaction(getClient().createTransaction());
53     }
54
55     @Override
56     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
57         return new ClientBackedReadWriteTransaction(getClient().createTransaction());
58     }
59 }