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