Switch to MD-SAL APIs
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / device / TxFacade.java
1 /*
2  * Copyright (c) 2015 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 package org.opendaylight.openflowplugin.api.openflow.device;
9
10 import org.opendaylight.mdsal.binding.api.ReadTransaction;
11 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14
15 /**
16  * Handles operations with transactions.
17  */
18 public interface TxFacade {
19
20     /**
21      * Method creates put operation using provided data in underlying transaction chain.
22      */
23     <T extends DataObject> void writeToTransaction(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
24
25     /**
26      * Method creates put operation using provided data in underlying transaction
27      * chain and flag to create missing parents.
28      * WARNING: This method is slow because of additional reading cost.
29      * Use it only if you really need to create parents.
30      */
31     <T extends DataObject> void writeToTransactionWithParentsSlow(LogicalDatastoreType store,
32                                                                   InstanceIdentifier<T> path,
33                                                                   T data);
34
35     /**
36      * Method creates delete operation for provided path in underlying transaction chain.
37      */
38     <T extends DataObject> void addDeleteToTxChain(LogicalDatastoreType store, InstanceIdentifier<T> path);
39
40     /**
41      * Method submits Transaction to DataStore.
42      * @return transaction is submitted successfully
43      */
44     boolean submitTransaction();
45
46     /**
47      * Method submits Transaction to DataStore and wait till completes by doing get on tx future.
48      * @return transaction is submitted successfully
49      */
50     boolean syncSubmitTransaction();
51
52     /**
53      * Method exposes transaction created for device
54      * represented by this context. This read only transaction has a fresh dataStore snapshot.
55      * There is a possibility to get different data set from  DataStore
56      * as write transaction in this context.
57      * @return readOnlyTransaction - Don't forget to close it after finish reading
58      */
59     ReadTransaction getReadTransaction();
60
61     /**
62      * Method returns true if transaction chain manager is enabled.
63      * @return is transaction chain manager enabled
64      */
65     boolean isTransactionsEnabled();
66 }