X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Fdevice%2FDeviceTransactionManagerImpl.java;h=eaa7773d99c065dc5c7c3edc28d502f8c781243f;hb=f5a8fe61d265bce36b2fca393d82685a22ac326a;hp=ca0e91976260ed811aaea50b063f990af66c0eae;hpb=62777a1d5b1130c3e77c558d5d99efdc688bed5b;p=transportpce.git diff --git a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerImpl.java b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerImpl.java index ca0e91976..eaa7773d9 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerImpl.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerImpl.java @@ -13,7 +13,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -24,11 +23,10 @@ import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.binding.api.MountPointService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.InstanceIdentifiers; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; @@ -48,13 +46,14 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { private static final int NUMBER_OF_THREADS = 4; private static final long GET_DATA_SUBMIT_TIMEOUT = 3000; private static final TimeUnit GET_DATA_SUBMIT_TIME_UNIT = TimeUnit.MILLISECONDS; + private static final TimeUnit MAX_DURATION_TO_SUBMIT_TIMEUNIT = TimeUnit.MILLISECONDS; private final MountPointService mountPointService; private final ScheduledExecutorService checkingExecutor; private final ListeningExecutorService listeningExecutor; private final ConcurrentMap deviceLocks; - private final long maxDurationToSubmitTransaction; // TODO set reasonable value in blueprint - private final TimeUnit maxDurationToSubmitTransactionTimeUnit = TimeUnit.MILLISECONDS; + // TODO set reasonable value in blueprint for maxDurationToSubmitTransaction + private final long maxDurationToSubmitTransaction; public DeviceTransactionManagerImpl(MountPointService mountPointService, long maxDurationToSubmitTransaction) { this.mountPointService = mountPointService; @@ -66,7 +65,7 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { @Override public Future> getDeviceTransaction(String deviceId) { - return getDeviceTransaction(deviceId, maxDurationToSubmitTransaction, maxDurationToSubmitTransactionTimeUnit); + return getDeviceTransaction(deviceId, maxDurationToSubmitTransaction, MAX_DURATION_TO_SUBMIT_TIMEUNIT); } @Override @@ -105,9 +104,9 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { LOG.debug("Timeout to submit transaction run out! Transaction was {} submitted or canceled.", deviceTx.wasSubmittedOrCancelled().get() ? "" : "not"); if (!deviceTx.wasSubmittedOrCancelled().get()) { - LOG.error(String.format("Transaction for node %s was not submitted or canceled after %s" - + " milliseconds! Cancelling transaction!", deviceId, - timeoutToSubmit)); + LOG.error( + "Transaction for node {} not submitted/canceled after {} ms. Cancelling transaction.", + deviceId, timeoutToSubmit); deviceTx.cancel(); } } @@ -132,7 +131,7 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { private Optional getDeviceDataBroker(String deviceId) { Optional netconfNode = getDeviceMountPoint(deviceId); if (netconfNode.isPresent()) { - return netconfNode.get().getService(DataBroker.class).toJavaUtil(); + return netconfNode.get().getService(DataBroker.class); } else { LOG.error("Device mount point not found for : {}", deviceId); return Optional.empty(); @@ -143,7 +142,7 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { public Optional getDeviceMountPoint(String deviceId) { InstanceIdentifier netconfNodeIID = InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class, new NodeKey(new NodeId(deviceId))); - return mountPointService.getMountPoint(netconfNodeIID).toJavaUtil(); + return mountPointService.getMountPoint(netconfNodeIID); } @Override @@ -159,11 +158,11 @@ public class DeviceTransactionManagerImpl implements DeviceTransactionManager { if (deviceTxOpt.isPresent()) { DeviceTransaction deviceTx = deviceTxOpt.get(); try { - return deviceTx.read(logicalDatastoreType, path).get(timeout, timeUnit).toJavaUtil(); + return deviceTx.read(logicalDatastoreType, path).get(timeout, timeUnit); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.error("Exception thrown while reading data from device {}! IID: {}", deviceId, path, e); } finally { - deviceTx.submit(GET_DATA_SUBMIT_TIMEOUT, GET_DATA_SUBMIT_TIME_UNIT); + deviceTx.commit(GET_DATA_SUBMIT_TIMEOUT, GET_DATA_SUBMIT_TIME_UNIT); } } else { LOG.error("Could not obtain transaction for device {}!", deviceId);