2 * Copyright (c) 2014 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.md.sal.dom.store.impl;
10 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
11 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 import com.google.common.base.Optional;
18 import com.google.common.util.concurrent.Futures;
19 import com.google.common.util.concurrent.ListenableFuture;
22 * Implementation of Read-Write transaction which is backed by {@link DataTreeSnapshot}
23 * and executed according to {@link TransactionReadyPrototype}.
26 class SnapshotBackedReadWriteTransaction extends SnapshotBackedWriteTransaction implements
27 DOMStoreReadWriteTransaction {
29 private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class);
32 * Creates new read-write transaction.
34 * @param identifier transaction Identifier
35 * @param snapshot Snapshot which will be modified.
36 * @param readyImpl Implementation of ready method.
38 protected SnapshotBackedReadWriteTransaction(final Object identifier, final DataTreeSnapshot snapshot,
39 final TransactionReadyPrototype store) {
40 super(identifier, snapshot, store);
44 public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
45 LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
47 return Futures.immediateFuture(getMutatedView().readNode(path));
48 } catch (Exception e) {
49 LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);