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