Deprecate DOMDataTreeProducer-related classes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / DistributedShardModificationContext.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, 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
9 package org.opendaylight.controller.cluster.sharding;
10
11 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
12 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
14 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
15
16 /**
17  * The context for a single shards modification, keeps a ClientTransaction so it can route requests correctly.
18  */
19 @Deprecated(forRemoval = true)
20 public class DistributedShardModificationContext {
21
22     private final ClientTransaction transaction;
23     private final DOMDataTreeIdentifier identifier;
24     private DOMDataTreeWriteCursor cursor;
25
26     public DistributedShardModificationContext(final ClientTransaction transaction,
27                                                final DOMDataTreeIdentifier identifier) {
28         this.transaction = transaction;
29         this.identifier = identifier;
30     }
31
32     public DOMDataTreeIdentifier getIdentifier() {
33         return identifier;
34     }
35
36     DOMDataTreeWriteCursor cursor() {
37         if (cursor == null) {
38             cursor = transaction.openCursor();
39         }
40
41         return cursor;
42     }
43
44     DOMStoreThreePhaseCommitCohort ready() {
45         if (cursor != null) {
46             cursor.close();
47             cursor = null;
48         }
49
50         return transaction.ready();
51     }
52
53     void closeCursor() {
54         if (cursor != null) {
55             cursor.close();
56             cursor = null;
57         }
58     }
59
60 }

©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.