Deprecate old MD-SAL APIs for removal
[controller.git] / opendaylight / md-sal / mdsal-trace / dom-impl / src / main / java / org / opendaylight / controller / md / sal / trace / dom / impl / TracingReadWriteTransaction.java
1 /*
2  * Copyright (c) 2016 Red Hat, 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.md.sal.trace.dom.impl;
9
10 import com.google.common.base.Optional;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.FluentFuture;
13 import java.util.Objects;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
17 import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked;
18 import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
19 import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedTrait;
20 import org.opendaylight.mdsal.common.api.CommitInfo;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
23
24 @Deprecated(forRemoval = true)
25 class TracingReadWriteTransaction
26     extends AbstractTracingWriteTransaction
27         implements DOMDataReadWriteTransaction, CloseTracked<TracingReadWriteTransaction> {
28
29     private final CloseTrackedTrait<TracingReadWriteTransaction> closeTracker;
30     private final DOMDataReadWriteTransaction delegate;
31
32     TracingReadWriteTransaction(DOMDataReadWriteTransaction delegate, TracingBroker tracingBroker,
33             CloseTrackedRegistry<TracingReadWriteTransaction> readWriteTransactionsRegistry) {
34         super(delegate, tracingBroker);
35         this.closeTracker = new CloseTrackedTrait<>(readWriteTransactionsRegistry, this);
36         this.delegate = Objects.requireNonNull(delegate);
37     }
38
39     @Override
40     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
41                                                             LogicalDatastoreType store, YangInstanceIdentifier yiid) {
42         return delegate.read(store, yiid);
43     }
44
45     @Override
46     public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store, YangInstanceIdentifier yiid) {
47         return delegate.exists(store, yiid);
48     }
49
50     @Override
51     public FluentFuture<? extends CommitInfo> commit() {
52         closeTracker.removeFromTrackedRegistry();
53         return super.commit();
54     }
55
56     @Override
57     public boolean cancel() {
58         closeTracker.removeFromTrackedRegistry();
59         return super.cancel();
60     }
61
62     @Override
63     public StackTraceElement[] getAllocationContextStackTrace() {
64         return closeTracker.getAllocationContextStackTrace();
65     }
66
67     @Override
68     public CloseTracked<TracingReadWriteTransaction> getRealCloseTracked() {
69         return this;
70     }
71 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.