2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.api;
10 import com.google.common.util.concurrent.FluentFuture;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 * Write-like operations supported by {@link WriteTransaction} and {@link ReadWriteTransaction}. This interface defines
19 * the operations without a tie-in with lifecycle management.
21 public interface WriteOperations {
23 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that
24 * whole subtree will be replaced by the specified data.
27 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
28 * put, consider using {@link #merge} instead.
30 * @param store the logical data store which should be modified
31 * @param path the data object path
32 * @param data the data object to be written to the specified path
33 * @throws IllegalStateException if the transaction has already been submitted
34 * @throws NullPointerException if any of the arguments is {@code null}
35 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
37 <T extends DataObject> void put(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
41 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
42 * subtree will be replaced by the specified data. Unlike
43 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
44 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
47 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
48 * put, consider using {@link #merge} instead.
51 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
52 * a previous transaction. It also has a significantly higher cost than
53 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)} and should only be used when
54 * absolutely necessary.
56 * @param store the logical data store which should be modified
57 * @param path the data object path
58 * @param data the data object to be written to the specified path
59 * @throws IllegalStateException if the transaction has already been submitted
60 * @throws NullPointerException if any of the arguments is {@code null}
61 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
62 * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
63 * parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
64 * all the cases which do not attach semantics, such as {@code container}s without {@code presence},
65 * {@code augmentation} and {@code list} encapsulation.
66 * This method does not work in the general case, where there are:
68 * <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
69 * boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
70 * to create an invalid structure</li>
71 * <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
72 * can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
75 * Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
76 * relationship with entities responsible for managing such semantic items which are created by this
79 @Deprecated(since = "11.0.3")
80 <T extends DataObject> void mergeParentStructurePut(@NonNull LogicalDatastoreType store,
81 @NonNull InstanceIdentifier<T> path, @NonNull T data);
84 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
85 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
88 * If you require an explicit replace operation, use {@link #put} instead.
90 * @param store the logical data store which should be modified
91 * @param path the data object path
92 * @param data the data object to be merged to the specified path
93 * @throws IllegalStateException if the transaction has already been submitted
94 * @throws NullPointerException if any of the arguments is {@code null}
95 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
97 <T extends DataObject> void merge(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
101 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
102 * overwritten will be preserved. This means that if you store a container, its child lists will be merged. Unlike
103 * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
104 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
107 * If you require an explicit replace operation, use {@link #put} instead.
110 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
111 * a previous transaction. It is not necessary in most scenarios and has a significantly higher cost
112 * than {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}. It should only be used
113 * when absolutely necessary.
115 * @param store the logical data store which should be modified
116 * @param path the data object path
117 * @param data the data object to be merged to the specified path
118 * @throws IllegalStateException if the transaction has already been submitted
119 * @throws NullPointerException if any of the arguments is {@code null}
120 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
121 * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
122 * parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
123 * all the cases which do not attach semantics, such as {@code container}s without {@code presence},
124 * {@code augmentation} and {@code list} encapsulation.
125 * This method does not work in the general case, where there are:
127 * <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
128 * boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
129 * to create an invalid structure</li>
130 * <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
131 * can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
134 * Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
135 * relationship with entities responsible for managing such semantic items which are created by this
138 @Deprecated(since = "11.0.3")
139 <T extends DataObject> void mergeParentStructureMerge(@NonNull LogicalDatastoreType store,
140 @NonNull InstanceIdentifier<T> path, @NonNull T data);
143 * Removes a piece of data from specified path. This operation does not fail if the specified path does not exist.
145 * @param store Logical data store which should be modified
146 * @param path Data object path
147 * @throws IllegalStateException if the transaction was committed or canceled.
148 * @throws NullPointerException if any of the arguments is {@code null}
149 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
151 void delete(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);
154 * Return a {@link FluentFuture} which completes.
156 * @return A future which completes when the requested operations complete.
158 @NonNull FluentFuture<?> completionFuture();