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 com.google.common.util.concurrent.FluentFuture;
11 import java.util.Optional;
12 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
15 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 * An implementation of {@link DOMStoreReadTransaction} backed by a {@link ClientSnapshot}. Used for standalone
23 * @author Robert Varga
25 final class ClientBackedReadTransaction extends ClientBackedTransaction<ClientSnapshot>
26 implements DOMStoreReadTransaction {
27 private static final AtomicReferenceFieldUpdater<ClientBackedReadTransaction, ClientBackedTransactionChain>
28 PARENT_UPDATER = AtomicReferenceFieldUpdater.newUpdater(ClientBackedReadTransaction.class,
29 ClientBackedTransactionChain.class, "parent");
31 @SuppressWarnings("unused")
32 private volatile ClientBackedTransactionChain parent;
34 ClientBackedReadTransaction(final ClientSnapshot delegate, final @Nullable ClientBackedTransactionChain parent,
35 final @Nullable Throwable allocationContext) {
36 super(delegate, allocationContext);
41 public FluentFuture<Optional<NormalizedNode>> read(final YangInstanceIdentifier path) {
42 return delegate().read(path);
46 public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
47 return delegate().exists(path);
54 final ClientBackedTransactionChain local = PARENT_UPDATER.getAndSet(this, null);
56 local.snapshotClosed(delegate());