Merge "Bug-8187: call home throwing exception on startup" into stable/carbon
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / api / NetconfDOMTransaction.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.netconf.topology.singleton.api;
10
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import scala.concurrent.Future;
16
17 /**
18  * Provides API for all operations of read and write transactions
19  */
20 // TODO we should separate between read tx and write tx
21 public interface NetconfDOMTransaction {
22
23
24     /**
25      * Opens a new transaction. Transactions have to be opened before applying
26      * any operations on them. Previous transaction has to be either submitted
27      * ({@link #submit()} was invoked) or canceled ({@link #cancel()} was
28      * invoked.
29      *
30      * @throws IllegalStateException
31      *             if the previous transaction was not SUBMITTED or CANCELLED.
32      */
33     void openTransaction();
34
35     /**
36      * Read data from particular data-store
37      * @param store data-store type
38      * @param path unique identifier of a particular node instance in the data tree
39      * @return result as future
40      */
41     Future<Optional<NormalizedNodeMessage>> read(LogicalDatastoreType store, YangInstanceIdentifier path);
42
43     /**
44      * Test existence of node in certain data-store
45      * @param store data-store type
46      * @param path unique identifier of a particular node instance in the data tree
47      * @return result as future
48      */
49     Future<Boolean> exists(LogicalDatastoreType store, YangInstanceIdentifier path);
50
51     /**
52      * Put data to particular data-store
53      * @param store data-store type
54      * @param data data for inserting included in NormalizedNodeMessage object
55      */
56     void put(LogicalDatastoreType store, NormalizedNodeMessage data);
57
58     /**
59      * Merge data with existing node in particular data-store
60      * @param store data-store type
61      * @param data data for merging included in NormalizedNodeMessage object
62      */
63     void merge(LogicalDatastoreType store, NormalizedNodeMessage data);
64
65     /**
66      * Delete node in particular data-store in path
67      * @param store data-store type
68      * @param path unique identifier of a particular node instance in the data tree
69      */
70     void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
71
72     /**
73      * Cancel operation
74      * @return success or not
75      */
76     boolean cancel();
77
78     /**
79      * Commit opened transaction.
80      * @return void or raised exception
81      */
82     Future<Void> submit();
83 }