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.databroker;
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;
25 * Implements a distributed DOMStore using ClientActor.
27 public class ClientBackedDataStore extends AbstractDataStore {
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);
36 ClientBackedDataStore(final ActorContext actorContext, final ClientIdentifier identifier) {
37 super(actorContext, identifier);
41 public DOMStoreTransactionChain createTransactionChain() {
42 return new ClientBackedTransactionChain(getClient().createLocalHistory());
46 public DOMStoreReadTransaction newReadOnlyTransaction() {
47 return new ClientBackedReadTransaction(getClient().createSnapshot(), null);
51 public DOMStoreWriteTransaction newWriteOnlyTransaction() {
52 return new ClientBackedWriteTransaction(getClient().createTransaction());
56 public DOMStoreReadWriteTransaction newReadWriteTransaction() {
57 return new ClientBackedReadWriteTransaction(getClient().createTransaction());