- node = transaction.read(LogicalDatastoreType.OPERATIONAL, connectionIid).checkedGet();
- } catch (final ReadFailedException e) {
- LOG.warn("Read Operational/DS for Node failed! {}", connectionIid, e);
+ return transaction.read(logicalDatastoreType, connectionIid).get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Read failed from datastore for Node : {}",connectionIid,e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static <D extends org.opendaylight.yangtools.yang.binding.DataObject> Optional<D> readNode(
+ ReadWriteTransaction transaction, final InstanceIdentifier<D> connectionIid) {
+ return readNode(transaction, LogicalDatastoreType.OPERATIONAL, connectionIid);
+ }
+
+ public static <D extends DataObject> Optional<D> readNode(ReadWriteTransaction transaction,
+ LogicalDatastoreType logicalDatastoreType,
+ InstanceIdentifier<D> connectionIid) {
+ if (logicalDatastoreType == LogicalDatastoreType.OPERATIONAL) {
+ Node node = HwvtepOperGlobalListener.getNode((InstanceIdentifier<Node>) connectionIid);
+ if (node != null) {
+ return Optional.of((D)node);
+ } else {
+ LOG.debug("Node not available in cache. Read from datastore - {}", connectionIid);
+ }
+ }
+ try {
+ return transaction.read(logicalDatastoreType, connectionIid).get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Read failed from datastore for Node : {}",connectionIid,e);
+ throw new RuntimeException(e);