X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Fdevice%2FDeviceTransaction.java;h=574dd6fddeeec6a1f556bf7e8b4aa1cd4f3dc92a;hb=3cc9cc2152696a25177e965a40d63a5c0ab5f73f;hp=5aa093fd89b71420f5f0faeb7a21e7b2c29ba385;hpb=1bf7f298852d03faf47011c75978ce44bee135d7;p=transportpce.git diff --git a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransaction.java b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransaction.java index 5aa093fd8..574dd6fdd 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransaction.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransaction.java @@ -8,20 +8,20 @@ package org.opendaylight.transportpce.common.device; -import com.google.common.base.Optional; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; - +import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nullable; - -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -62,19 +62,10 @@ public class DeviceTransaction { rwTx.put(store, path, data); } - public void put(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents) { - rwTx.put(store, path, data, createMissingParents); - } - public void merge(LogicalDatastoreType store, InstanceIdentifier path, T data) { rwTx.merge(store, path, data); } - public void merge(LogicalDatastoreType store, InstanceIdentifier path, T data, - boolean createMissingParents) { - rwTx.merge(store, path, data, createMissingParents); - } public void delete(LogicalDatastoreType store, InstanceIdentifier path) { rwTx.delete(store, path); @@ -97,36 +88,35 @@ public class DeviceTransaction { } /** - * Submits data changed in transaction to device with defined timeout to submit. If time from timeout runs out then - * submit will be interrupted and device will be unlocked. + * Submits data changed in transaction to device with defined timeout to commit. If time from timeout runs out then + * the commit will be interrupted and the device will be unlocked. * * @param timeout a timeout * @param timeUnit a time unit - * @return ListenableFuture which indicates when is submit completed. + * @return FluentFuture which indicates when the commit is completed. */ - @Deprecated - public ListenableFuture submit(long timeout, TimeUnit timeUnit) { + public FluentFuture commit(long timeout, TimeUnit timeUnit) { if (wasSubmittedOrCancelled.get()) { String msg = "Transaction was already submitted or canceled!"; LOG.error(msg); - return Futures.immediateFailedFuture(new IllegalStateException(msg)); + return FluentFutures.immediateFailedFluentFuture(new IllegalStateException(msg)); } - LOG.debug("Transaction submitted. Lock: {}", deviceLock); + LOG.debug("Transaction committed. Lock: {}", deviceLock); wasSubmittedOrCancelled.set(true); - ListenableFuture future = - Futures.withTimeout(rwTx.submit(), timeout, timeUnit, scheduledExecutorService); + FluentFuture future = + rwTx.commit().withTimeout(timeout, timeUnit, scheduledExecutorService); - Futures.addCallback(future, new FutureCallback() { + future.addCallback(new FutureCallback() { @Override - public void onSuccess(@Nullable Void result) { - LOG.debug("Transaction with lock {} successfully submitted.", deviceLock); + public void onSuccess(CommitInfo result) { + LOG.debug("Transaction with lock {} successfully committed: {}", deviceLock, result); afterClose(); } @Override public void onFailure(Throwable throwable) { - LOG.error("Device transaction submit failed or submit took longer than {} {}! Unlocking device.", + LOG.error("Device transaction commit failed or submit took longer than {} {}! Unlocking device.", timeout, timeUnit, throwable); afterClose(); }