X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Fdevice%2FDeviceTransactionManager.java;h=1dbc128c9c274dc37b603ce7ced1a0df22cb31fa;hb=f5a8fe61d265bce36b2fca393d82685a22ac326a;hp=20371356f88f2652e39941dbf33aadc2ec19a4d6;hpb=f8f1b05b6eefd0f5c18e22c22b4d4e023f61faf6;p=transportpce.git diff --git a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManager.java b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManager.java index 20371356f..1dbc128c9 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManager.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManager.java @@ -11,9 +11,8 @@ package org.opendaylight.transportpce.common.device; import java.util.Optional; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; - -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -41,7 +40,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; *

* @@ -61,15 +60,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * {@link DeviceTransactionManager#getDataFromDevice(String, LogicalDatastoreType, InstanceIdentifier, long, TimeUnit)} * method can be used. It will automatically take care of {@link DeviceTransaction} and it will return data. * This method SHOULD NOT BE USED TOGETHER WITH DEVICE TRANSACTION ON THE SAME DEVICE IN THE SAME TIME. - * In case that {@link DeviceTransaction} is created on device and before submitting it + * In case that {@link DeviceTransaction} is created on device and before committing it * {@link DeviceTransactionManager#getDataFromDevice(String, LogicalDatastoreType, InstanceIdentifier, long, TimeUnit)} * method is called then get method will wait (will be blocking current thread) until device will be unlocked. * However device is locked by transaction previously created. So this will result in blocking current thread until - * timeout for submit transaction will run out and cancel transaction. This can lead to incorrect execution of code. + * timeout for commit transaction will run out and cancel transaction. This can lead to incorrect execution of code. *

* *

- * Bellow is simple example how to get {@link DeviceTransaction}, put some data to it and then submit it. + * Bellow is simple example how to get {@link DeviceTransaction}, put some data to it and then commit it. + *

*
  * {@code
  *     // get device transaction future from device transaction manager
@@ -93,24 +93,23 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  *     deviceTx.put(LogicalDatastoreType.CONFIGURATION, someInstanceIdentifier, someData);
  *     deviceTx.delete(LogicalDatastoreType.CONFIGURATION, someOtherInstanceIdentifier, someOtherData);
  *
- *     // submit transaction with 5 seconds timeout
- *     ListenableFuture submit = deviceTx.submit(5, TimeUnit.SECONDS);
+ *     // commit transaction with 5 seconds timeout
+ *     FluentFuture commit = deviceTx.commit(5, TimeUnit.SECONDS);
  *     try {
- *         // wait until transaction is submitted
- *         submit.get();
+ *         // wait until transaction is committed
+ *         commit.get();
  *     } catch (InterruptedException | ExecutionException e) {
  *         throw new IllegalStateException("Failed to post data to device " + deviceId + "!", e);
  *     }
  * }
  * 
- *

*/ public interface DeviceTransactionManager { /** * Gets Future containing {@link DeviceTransaction}. Since only one transaction can be opened per device future will - * return transaction when all previously submitted transaction on device are closed. This method will use default - * timeout for submit transaction. + * return transaction when all previously committed transaction on device are closed. This method will use default + * timeout for commit transaction. * * @param deviceId device identifier on which will be transaction created. * @return Future returning Optional of DeviceTransaction. Optional will be empty if device with specified ID @@ -123,7 +122,7 @@ public interface DeviceTransactionManager { * * @param deviceId device id on which will be transaction created. * @param timeoutToSubmit timeout will start running when transaction is created. If transaction will not be - * closed (submitted or cancelled) when times runs out it will be canceled (so device will + * closed (committed or cancelled) when times runs out it will be canceled (so device will * be unlocked). * @param timeUnit time units for timeout. * @return Future returning Optional of DeviceTransaction. Optional will be empty if device with specified ID @@ -132,14 +131,15 @@ public interface DeviceTransactionManager { Future> getDeviceTransaction(String deviceId, long timeoutToSubmit, TimeUnit timeUnit); // TODO make private in impl - @Deprecated Optional getDeviceMountPoint(String deviceId); /** * Returns data from device from specified path. Creates new device transaction, gets data via it and closes * transaction. * + *

* This method is blocking - it's waiting until it receives {@link DeviceTransaction} and then the data from device. + *

* * @param deviceId Device identifier from which will be data read. * @param logicalDatastoreType Datastore type.