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.actors.dds;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
14 import org.opendaylight.mdsal.common.api.ReadFailedException;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 * Snapshot of the datastore state. Note this snapshot is not consistent across shards because sub-shard snapshots are
22 * @author Robert Varga
25 public class ClientSnapshot extends AbstractClientHandle<AbstractProxyTransaction> {
26 // Hidden to prevent outside instantiation
27 ClientSnapshot(final AbstractClientHistory parent, final TransactionIdentifier transactionId) {
28 super(parent, transactionId);
31 private AbstractProxyTransaction createProxy(final Long shard) {
32 return parent().createSnapshotProxy(getIdentifier(), shard);
35 private AbstractProxyTransaction ensureSnapshotProxy(final YangInstanceIdentifier path) {
36 return ensureProxy(path, this::createProxy);
39 public final CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
40 return ensureSnapshotProxy(path).exists(path);
43 public final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
44 final YangInstanceIdentifier path) {
45 return ensureSnapshotProxy(path).read(path);