Expose completion future from WriteOperations
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / WriteOperations.java
index 12bca936a2c5e04b2b61826ead23e1c3641bbc3a..b054d43f7bd0f14f9e8f19ef2122d9ca4510b4e1 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.mdsal.binding.api;
 
-import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.FluentFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -30,7 +31,8 @@ public interface WriteOperations {
      * @param path the data object path
      * @param data the data object to be written to the specified path
      * @throws IllegalStateException if the transaction has already been submitted
-     * @throws NullPointerException if any of the arguments is null
+     * @throws NullPointerException if any of the arguments is {@code null}
+     * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
      */
     <T extends DataObject> void put(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
             @NonNull T data);
@@ -55,10 +57,26 @@ public interface WriteOperations {
      * @param path the data object path
      * @param data the data object to be written to the specified path
      * @throws IllegalStateException if the transaction has already been submitted
-     * @throws NullPointerException if any of the arguments is null
+     * @throws NullPointerException if any of the arguments is {@code null}
+     * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
+     * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
+     *             parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
+     *             all the cases which do not attach semantics, such as {@code container}s without {@code presence},
+     *             {@code augmentation} and {@code list} encapsulation.
+     *             This method does not work in the general case, where there are:
+     *             <ul>
+     *               <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
+     *                   boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
+     *                   to create an invalid structure</li>
+     *               <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
+     *                   can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
+     *                   requirements.</li>
+     *             </ul>
+     *             Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
+     *             relationship with entities responsible for managing such semantic items which are created by this
+     *             method.
      */
-    // TODO: can we come up with a better name?
-    @Beta
+    @Deprecated(since = "11.0.3")
     <T extends DataObject> void mergeParentStructurePut(@NonNull LogicalDatastoreType store,
             @NonNull InstanceIdentifier<T> path, @NonNull T data);
 
@@ -73,7 +91,8 @@ public interface WriteOperations {
      * @param path the data object path
      * @param data the data object to be merged to the specified path
      * @throws IllegalStateException if the transaction has already been submitted
-     * @throws NullPointerException if any of the arguments is null
+     * @throws NullPointerException if any of the arguments is {@code null}
+     * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
      */
     <T extends DataObject> void merge(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
             @NonNull T data);
@@ -97,10 +116,26 @@ public interface WriteOperations {
      * @param path the data object path
      * @param data the data object to be merged to the specified path
      * @throws IllegalStateException if the transaction has already been submitted
-     * @throws NullPointerException if any of the arguments is null
+     * @throws NullPointerException if any of the arguments is {@code null}
+     * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
+     * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
+     *             parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
+     *             all the cases which do not attach semantics, such as {@code container}s without {@code presence},
+     *             {@code augmentation} and {@code list} encapsulation.
+     *             This method does not work in the general case, where there are:
+     *             <ul>
+     *               <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
+     *                   boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
+     *                   to create an invalid structure</li>
+     *               <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
+     *                   can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
+     *                   requirements.</li>
+     *             </ul>
+     *             Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
+     *             relationship with entities responsible for managing such semantic items which are created by this
+     *             method.
      */
-    // TODO: can we come up with a better name?
-    @Beta
+    @Deprecated(since = "11.0.3")
     <T extends DataObject> void mergeParentStructureMerge(@NonNull LogicalDatastoreType store,
             @NonNull InstanceIdentifier<T> path, @NonNull T data);
 
@@ -110,6 +145,15 @@ public interface WriteOperations {
      * @param store Logical data store which should be modified
      * @param path Data object path
      * @throws IllegalStateException if the transaction was committed or canceled.
+     * @throws NullPointerException if any of the arguments is {@code null}
+     * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
      */
     void delete(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);
+
+    /**
+     * Return a {@link FluentFuture} which completes.
+     *
+     * @return A future which completes when the requested operations complete.
+     */
+    @NonNull FluentFuture<?> completionFuture();
 }