Migrate users of Optional.get() 16/105616/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 11:24:38 +0000 (13:24 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 12:20:05 +0000 (14:20 +0200)
Modernizer is flaggin callers, use better alternatives.

Change-Id: I79b3a5c64e28b2fd5a8de5b6010cfe7b1d38719b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
55 files changed:
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundUtil.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/reconciliation/configuration/HwvtepReconciliationTask.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependentJob.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UnMetDependencyGetter.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepGlobalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepManagerUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalLocatorUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalSwitchUpdateCommand.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/StalePassiveConnectionService.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundUtil.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeOperationalState.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/DataChangesManagedByOvsdbNodeEvent.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointDeleteCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTask.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbManagersUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueUpdateCommand.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeOperationalStateTest.java
utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/MdsalUtils.java
utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/MdsalUtilsAsyncTest.java

index 21ead14ef898f912e74d62abc9c916bd2a77c906..041efecc8e37318313102c2441a7dbeced8824ae 100644 (file)
@@ -317,7 +317,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
     public HwvtepConnectionInstance getConnectionInstance(final HwvtepPhysicalSwitchAttributes node) {
         Optional<HwvtepGlobalAugmentation> optional = HwvtepSouthboundUtil.getManagingNode(db, node);
         if (optional.isPresent()) {
-            return getConnectionInstance(optional.get().getConnectionInfo());
+            return getConnectionInstance(optional.orElseThrow().getConnectionInfo());
         } else {
             return null;
         }
@@ -431,7 +431,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         java.util.Optional<EntityOwnershipState> ownershipStateOpt =
                 entityOwnershipService.getOwnershipState(candidateEntity);
         if (ownershipStateOpt.isPresent()) {
-            EntityOwnershipState ownershipState = ownershipStateOpt.get();
+            EntityOwnershipState ownershipState = ownershipStateOpt.orElseThrow();
             putConnectionInstance(hwvtepConnectionInstance.getMDConnectionInfo(), hwvtepConnectionInstance);
             if (ownershipState != EntityOwnershipState.NO_OWNER) {
                 hwvtepConnectionInstance.setHasDeviceOwnership(ownershipState == EntityOwnershipState.IS_OWNER);
@@ -561,7 +561,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
                     @Override
                     public void onSuccess(final Optional<Node> node) {
                         if (node.isPresent()) {
-                            HwvtepGlobalAugmentation augmentation = node.get()
+                            HwvtepGlobalAugmentation augmentation = node.orElseThrow()
                                     .augmentation(HwvtepGlobalAugmentation.class);
                             if (augmentation == null || augmentation.getConnectionInfo() == null) {
                                 return;
index 27e2435d10069df94259e603e0fe149bf29de34a..54a75049f43c07fe0b3f52dfb3a00eb24e082e2f 100644 (file)
@@ -174,7 +174,7 @@ public final class HwvtepSouthboundUtil {
             Optional<Node> optional = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, path);
             if (optional != null && optional.isPresent()) {
                 HwvtepGlobalAugmentation hwvtepNode = null;
-                Node node = optional.get();
+                Node node = optional.orElseThrow();
                 if (node instanceof HwvtepGlobalAugmentation) {
                     hwvtepNode = (HwvtepGlobalAugmentation) node;
                 } else if (node != null) {
index 46bb1bfe729e6ed5ff31b5599fd6c83a35aae819..a93ff20ebe24fda92f96e1247b466b72f10f473e 100644 (file)
@@ -189,10 +189,9 @@ public class HwvtepTableReader {
     public UUID getLsUuid(InstanceIdentifier lsIid) {
         UUID lsUUID = connectionInstance.getDeviceInfo().getUUID(LogicalSwitches.class, lsIid);
         if (lsUUID == null) {
-            Optional<TypedBaseTable> optional =
-                    getHwvtepTableEntryUUID(LogicalSwitches.class, lsIid, null);
+            Optional<TypedBaseTable> optional = getHwvtepTableEntryUUID(LogicalSwitches.class, lsIid, null);
             if (optional.isPresent()) {
-                lsUUID = optional.get().getUuid();
+                return optional.orElseThrow().getUuid();
             }
         }
         return lsUUID;
index 00580fafa13a1e735f88682402f690f07c5e2f39..1327564251a2216aa9cc55775d5b0688c8b39c2b 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
-import java.util.Optional;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.binding.api.ReadTransaction;
@@ -106,10 +105,6 @@ public class HwvtepReconciliationTask extends ReconciliationTask {
 
     private static Node readNode(ReadTransaction transaction,
                                  LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<Node> iid) {
-        Optional<Node> optional = HwvtepSouthboundUtil.readNode(transaction, logicalDatastoreType, iid);
-        if (optional.isPresent()) {
-            return optional.get();
-        }
-        return null;
+        return HwvtepSouthboundUtil.readNode(transaction, logicalDatastoreType, iid).orElse(null);
     }
 }
index 2422712b61f25d30d9fb396551921c6bac0d4ed4..c5b014da60e76295e169ca09a6ff916907b111cc 100644 (file)
@@ -18,6 +18,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 import org.eclipse.jdt.annotation.NonNull;
@@ -443,11 +444,11 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I> & DataOb
         HwvtepDeviceInfo.DeviceData deviceData  = getDeviceOpData(cls, key);
         if (deviceData == null) {
             LOG.debug("Could not find data for key {}", getNodeKeyStr(key));
-            java.util.Optional<TypedBaseTable> optional =
-                    getTableReader().getHwvtepTableEntryUUID(cls, key, null);
+            Optional<TypedBaseTable> optional = getTableReader().getHwvtepTableEntryUUID(cls, key, null);
             if (optional.isPresent()) {
+                TypedBaseTable table = optional.orElseThrow();
                 LOG.debug("Found the data for key from device {} ", getNodeKeyStr(key));
-                getDeviceInfo().updateDeviceOperData(cls, key, optional.get().getUuid(), optional.get());
+                getDeviceInfo().updateDeviceOperData(cls, key, table.getUuid(), table);
                 return getDeviceOpData(cls, key);
             } else {
                 LOG.info("Could not Find the data for key from device {} ", getNodeKeyStr(key));
index e35bed005d81082bd2c5b33624d48754b1812c77..4f7f6e7242c4c46636d30c2fee067d43f43ba40a 100644 (file)
@@ -171,11 +171,11 @@ public abstract class DependentJob<T extends Identifiable> {
                 Optional<TypedBaseTable> latestDeviceStatus = deviceInfo.getConnectionInstance()
                         .getHwvtepTableReader().getHwvtepTableEntryUUID(cls, iid, controllerData.getUuid());
 
-                TypedBaseTable latestDeviceData = latestDeviceStatus.isPresent() ? latestDeviceStatus.get() : null;
+                TypedBaseTable latestDeviceData = latestDeviceStatus.orElse(null);
 
                 if (INTRANSIT_DATA_CREATED.test(controllerData, latestDeviceStatus)) {
                     LOG.info("Intransit expired key is actually created but update is missed/delayed {}", iid);
-                    deviceInfo.updateDeviceOperData(cls, iid, latestDeviceStatus.get().getUuid(), latestDeviceData);
+                    deviceInfo.updateDeviceOperData(cls, iid, latestDeviceData.getUuid(), latestDeviceData);
 
                 } else if (INTRANSIT_DATA_NOT_CREATED.test(controllerData, latestDeviceStatus)) {
                     LOG.info("Intransit expired key is actually not created but update is missed/delayed {}", iid);
@@ -189,7 +189,7 @@ public abstract class DependentJob<T extends Identifiable> {
                 } else if (INTRANSIT_DATA_NOT_DELETED.test(controllerData, latestDeviceStatus)) {
                     //not deleted from device we will reuse existing uuid
                     LOG.info("Intransit expired key is actually not deleted but update is missed/delayed {}", iid);
-                    deviceInfo.updateDeviceOperData(cls, iid, latestDeviceStatus.get().getUuid(), latestDeviceData);
+                    deviceInfo.updateDeviceOperData(cls, iid, latestDeviceData.getUuid(), latestDeviceData);
                 }
             } else if (DATA_INTRANSIT.test(controllerData)) {
                 //device status is still in transit
index afe4c7a40df8836d165a7d272e8ee3f5e9519576..8bb0626cf6233a8f38f2f62f2af09fa1afa268a3 100644 (file)
@@ -105,7 +105,7 @@ public class HwvtepOperationalState {
         Optional<Node> readNode = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL,
                 connectionInstance.getInstanceIdentifier());
         if (readNode.isPresent()) {
-            operationalNodes.put(connectionInstance.getInstanceIdentifier(), readNode.get());
+            operationalNodes.put(connectionInstance.getInstanceIdentifier(), readNode.orElseThrow());
         }
     }
 
@@ -145,20 +145,19 @@ public class HwvtepOperationalState {
                 //for example, when creating physical port, logical switch is needed
                 //but logical switch is in HwvtepGlobalAugmentation rather than PhysicalSwitchAugmentation
                 if (readNode.isPresent()) {
-                    operationalNodes.put(entry.getKey(), readNode.get());
-                    HwvtepGlobalAugmentation hgAugmentation =
-                            readNode.get().augmentation(HwvtepGlobalAugmentation.class);
-                    PhysicalSwitchAugmentation psAugmentation =
-                            readNode.get().augmentation(PhysicalSwitchAugmentation.class);
-                    if (hgAugmentation != null && hgAugmentation.getSwitches() != null) {
-                        for (Switches pswitch : hgAugmentation.getSwitches().values()) {
+                    Node rdNode = readNode.orElseThrow();
+                    operationalNodes.put(entry.getKey(), rdNode);
+                    HwvtepGlobalAugmentation hgAugmentation = rdNode.augmentation(HwvtepGlobalAugmentation.class);
+                    PhysicalSwitchAugmentation psAugmentation = rdNode.augmentation(PhysicalSwitchAugmentation.class);
+                    if (hgAugmentation != null) {
+                        for (Switches pswitch : hgAugmentation.nonnullSwitches().values()) {
                             @SuppressWarnings("unchecked")
                             InstanceIdentifier<Node> psNodeIid =
                                     (InstanceIdentifier<Node>) pswitch.getSwitchRef().getValue();
                             Optional<Node> psNode =
                                 new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, psNodeIid);
                             if (psNode.isPresent()) {
-                                operationalNodes.put(psNodeIid, psNode.get());
+                                operationalNodes.put(psNodeIid, psNode.orElseThrow());
                             }
                         }
                     }
@@ -169,7 +168,7 @@ public class HwvtepOperationalState {
                         Optional<Node> hgNode = new MdsalUtils(db).readOptional(
                                 LogicalDatastoreType.OPERATIONAL, hgNodeIid);
                         if (hgNode.isPresent()) {
-                            operationalNodes.put(hgNodeIid, hgNode.get());
+                            operationalNodes.put(hgNodeIid, hgNode.orElseThrow());
                         }
                     }
                 }
@@ -183,40 +182,25 @@ public class HwvtepOperationalState {
     }
 
     public Optional<HwvtepGlobalAugmentation> getHwvtepGlobalAugmentation(final InstanceIdentifier<?> iid) {
-        Optional<Node> nodeOptional = getGlobalNode(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            return Optional.ofNullable(nodeOptional.get().augmentation(HwvtepGlobalAugmentation.class));
-        }
-        return Optional.empty();
+        return getGlobalNode(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.augmentation(HwvtepGlobalAugmentation.class)));
     }
 
     public Optional<PhysicalSwitchAugmentation> getPhysicalSwitchAugmentation(final InstanceIdentifier<?> iid) {
-        Optional<Node> nodeOptional = getGlobalNode(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            return Optional.ofNullable(nodeOptional.get().augmentation(PhysicalSwitchAugmentation.class));
-        }
-        return Optional.empty();
+        return getGlobalNode(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.augmentation(PhysicalSwitchAugmentation.class)));
     }
 
     public Optional<Map<TerminationPointKey, TerminationPoint>> getTerminationPointList(
             final InstanceIdentifier<?> iid) {
-        Optional<Node> nodeOptional = getGlobalNode(requireNonNull(iid));
-        if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
-            return Optional.ofNullable(nodeOptional.get().getTerminationPoint());
-        }
-        return Optional.empty();
+        return getGlobalNode(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.getTerminationPoint()));
     }
 
     public Optional<LogicalSwitches> getLogicalSwitches(final InstanceIdentifier<?> iid,
             final LogicalSwitchesKey logicalSwitchesKey) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            LogicalSwitches lswitch = nodeOptional.get().nonnullLogicalSwitches().get(logicalSwitchesKey);
-            if (lswitch != null) {
-                return Optional.of(lswitch);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullLogicalSwitches().get(logicalSwitchesKey)));
     }
 
     public Optional<LogicalSwitches> getLogicalSwitches(final InstanceIdentifier<LogicalSwitches> iid) {
@@ -224,14 +208,8 @@ public class HwvtepOperationalState {
     }
 
     public Optional<Tunnels> getTunnels(final InstanceIdentifier<?> iid, final TunnelsKey tunnelsKey) {
-        Optional<PhysicalSwitchAugmentation> psOptional = getPhysicalSwitchAugmentation(requireNonNull(iid));
-        if (psOptional.isPresent()) {
-            Tunnels tunnel = psOptional.get().nonnullTunnels().get(tunnelsKey);
-            if (tunnel != null) {
-                return Optional.of(tunnel);
-            }
-        }
-        return Optional.empty();
+        return getPhysicalSwitchAugmentation(requireNonNull(iid))
+            .flatMap(ps -> Optional.ofNullable(ps.nonnullTunnels().get(tunnelsKey)));
     }
 
     public Optional<Tunnels> getTunnels(final InstanceIdentifier<Tunnels> iid) {
@@ -244,11 +222,11 @@ public class HwvtepOperationalState {
         Optional<Map<TerminationPointKey, TerminationPoint>> nodeOptional =
                 getTerminationPointList(requireNonNull(iid));
         if (nodeOptional.isPresent()) {
-            for (TerminationPoint tp : nodeOptional.get().values()) {
+            for (TerminationPoint tp : nodeOptional.orElseThrow().values()) {
                 HwvtepPhysicalPortAugmentation hppAugmentation =
                         tp.augmentation(HwvtepPhysicalPortAugmentation.class);
                 if (hppAugmentation != null && hppAugmentation.getHwvtepNodeName().equals(hwvtepNodeName)) {
-                    return Optional.ofNullable(hppAugmentation);
+                    return Optional.of(hppAugmentation);
                 }
             }
         }
@@ -260,7 +238,7 @@ public class HwvtepOperationalState {
         Optional<Map<TerminationPointKey, TerminationPoint>> nodeOptional =
                 getTerminationPointList(requireNonNull(iid));
         if (nodeOptional.isPresent()) {
-            for (TerminationPoint tp : nodeOptional.get().values()) {
+            for (TerminationPoint tp : nodeOptional.orElseThrow().values()) {
                 HwvtepPhysicalLocatorAugmentation hppAugmentation =
                         tp.augmentation(HwvtepPhysicalLocatorAugmentation.class);
                 if (hppAugmentation != null && hppAugmentation.getDstIp().equals(dstIp)
@@ -274,73 +252,38 @@ public class HwvtepOperationalState {
 
     public Optional<HwvtepPhysicalLocatorAugmentation>
             getPhysicalLocatorAugmentation(final InstanceIdentifier<TerminationPoint> iid) {
-        Optional<TerminationPoint> tp =
-            new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
-        if (tp.isPresent()) {
-            return Optional.ofNullable(tp.get().augmentation(HwvtepPhysicalLocatorAugmentation.class));
-        }
-        return Optional.empty();
+        Optional<TerminationPoint> optTp = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
+        return optTp.flatMap(tp -> Optional.ofNullable(tp.augmentation(HwvtepPhysicalLocatorAugmentation.class)));
     }
 
     public Optional<LocalMcastMacs> getLocalMcastMacs(final InstanceIdentifier<?> iid, final LocalMcastMacsKey key) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            LocalMcastMacs mac = nodeOptional.get().nonnullLocalMcastMacs().get(key);
-            if (mac != null) {
-                return Optional.of(mac);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullLocalMcastMacs().get(key)));
     }
 
     public Optional<RemoteMcastMacs> getRemoteMcastMacs(final InstanceIdentifier<?> iid, final RemoteMcastMacsKey key) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            RemoteMcastMacs mac = nodeOptional.get().nonnullRemoteMcastMacs().get(key);
-            if (mac != null) {
-                return Optional.of(mac);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullRemoteMcastMacs().get(key)));
     }
 
     public Optional<LocalUcastMacs> getLocalUcastMacs(final InstanceIdentifier<?> iid, final LocalUcastMacsKey key) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            LocalUcastMacs mac = nodeOptional.get().nonnullLocalUcastMacs().get(key);
-            if (mac != null) {
-                return Optional.of(mac);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullLocalUcastMacs().get(key)));
     }
 
     public Optional<RemoteUcastMacs> getRemoteUcastMacs(final InstanceIdentifier<?> iid, final RemoteUcastMacsKey key) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            RemoteUcastMacs mac = nodeOptional.get().nonnullRemoteUcastMacs().get(key);
-            if (mac != null) {
-                return Optional.of(mac);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullRemoteUcastMacs().get(key)));
     }
 
     public Optional<LogicalRouters> getLogicalRouters(final InstanceIdentifier<?> iid,
             final LogicalRoutersKey logicalRoutersKey) {
-        Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(requireNonNull(iid));
-        if (nodeOptional.isPresent()) {
-            LogicalRouters lrouter = nodeOptional.get().nonnullLogicalRouters().get(logicalRoutersKey);
-            if (lrouter != null) {
-                return Optional.of(lrouter);
-            }
-        }
-        return Optional.empty();
+        return getHwvtepGlobalAugmentation(requireNonNull(iid))
+            .flatMap(node -> Optional.ofNullable(node.nonnullLogicalRouters().get(logicalRoutersKey)));
     }
 
     public Optional<Acls> getAcls(final InstanceIdentifier<Acls> iid) {
-        Optional<Acls> acl = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
-        return acl;
+        return new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
     }
 
     public ReadWriteTransaction getReadWriteTransaction() {
index 10907bd08cf13a6a4d93af899bf103cfd5eb309b..abd99c9e39240cd7b51223b07dca33227ac7904c 100644 (file)
@@ -81,9 +81,10 @@ public class LogicalRouterRemoveCommand
                     getOperationalState().getLogicalRouters(instanceIdentifier, lrouter.key());
 
             if (operationalRouterOptional.isPresent()
-                    && operationalRouterOptional.get().getLogicalRouterUuid() != null) {
+                    && operationalRouterOptional.orElseThrow().getLogicalRouterUuid() != null) {
                 LogicalRouter logicalRouter = transaction.getTypedRowSchema(LogicalRouter.class);
-                UUID logicalRouterUuid = new UUID(operationalRouterOptional.get().getLogicalRouterUuid().getValue());
+                UUID logicalRouterUuid = new UUID(
+                    operationalRouterOptional.orElseThrow().getLogicalRouterUuid().getValue());
                 transaction.add(op.delete(logicalRouter.getSchema())
                         .where(logicalRouter.getUuidColumn().getSchema().opEqual(logicalRouterUuid)).build());
                 transaction.add(op.comment("Logical Router: Deleting " + lrouter.getHwvtepNodeName().getValue()));
index be348667fbd5e9fb4245dd9433540351bebf8b56..194ced57cf71864f29a834333637d26261fb33d3 100644 (file)
@@ -80,7 +80,7 @@ public class LogicalRouterUpdateCommand
                 updateCurrentTxData(LogicalRouters.class, routerKey, lrUuid, lrouter);
                 updateControllerTxHistory(TransactionType.ADD, logicalRouter);
             } else {
-                LogicalRouters updatedLRouter = operationalRouterOptional.get();
+                LogicalRouters updatedLRouter = operationalRouterOptional.orElseThrow();
                 String existingLogicalRouterName = updatedLRouter.getHwvtepNodeName().getValue();
                 LogicalRouter extraLogicalRouter = transaction.getTypedRowWrapper(LogicalRouter.class);
                 extraLogicalRouter.setName("");
@@ -107,8 +107,8 @@ public class LogicalRouterUpdateCommand
             final Optional<LogicalRouters> inputRouterOptional) {
         if (inputRouter.getHwvtepNodeName() != null) {
             logicalRouter.setName(inputRouter.getHwvtepNodeName().getValue());
-        } else if (inputRouterOptional.isPresent() && inputRouterOptional.get().getHwvtepNodeName() != null) {
-            logicalRouter.setName(inputRouterOptional.get().getHwvtepNodeName().getValue());
+        } else if (inputRouterOptional.isPresent() && inputRouterOptional.orElseThrow().getHwvtepNodeName() != null) {
+            logicalRouter.setName(inputRouterOptional.orElseThrow().getHwvtepNodeName().getValue());
         }
     }
 
@@ -123,7 +123,7 @@ public class LogicalRouterUpdateCommand
                 Optional<LogicalSwitches> operationalSwitchOptional =
                         getOperationalState().getLogicalSwitches(lswitchIid);
                 if (operationalSwitchOptional.isPresent()) {
-                    Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid();
+                    Uuid logicalSwitchUuid = operationalSwitchOptional.orElseThrow().getLogicalSwitchUuid();
                     bindingMap.put(switchBinding.getDestinationAddress().getIpv4Prefix().getValue(),
                             new UUID(logicalSwitchUuid.getValue()));
                 } else {
@@ -145,12 +145,10 @@ public class LogicalRouterUpdateCommand
                 Optional<Acls> operationalAclOptional =
                         getOperationalState().getAcls(aclIid);
                 if (operationalAclOptional.isPresent()) {
-                    Uuid aclUuid = operationalAclOptional.get().getAclUuid();
-                    bindingMap.put(aclBinding.getRouterInterface().stringValue(),
-                            new UUID(aclUuid.getValue()));
+                    Uuid aclUuid = operationalAclOptional.orElseThrow().getAclUuid();
+                    bindingMap.put(aclBinding.getRouterInterface().stringValue(), new UUID(aclUuid.getValue()));
                 } else {
-                    bindingMap.put(aclBinding.getRouterInterface().stringValue(),
-                            TransactUtils.getAclUUID(aclIid));
+                    bindingMap.put(aclBinding.getRouterInterface().stringValue(), TransactUtils.getAclUUID(aclIid));
                 }
             }
             logicalRouter.setAclBinding(bindingMap);
index 4380efe3da8f129f699edbb7614365048582f537..5e65c775435fc3552fc597d7cb9b22278b605465 100644 (file)
@@ -54,10 +54,10 @@ public class McastMacsLocalRemoveCommand
             Optional<LocalMcastMacs> operationalMacOptional =
                     getOperationalState().getLocalMcastMacs(instanceIdentifier, mac.key());
             McastMacsLocal mcastMacsLocal = transaction.getTypedRowSchema(McastMacsLocal.class);
-            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.orElseThrow().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locator set and locators are deleted automatically.
                 //TODO: locator in config DS is not deleted
-                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                UUID macEntryUUID = new UUID(operationalMacOptional.orElseThrow().getMacEntryUuid().getValue());
                 mcastMacsLocal.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(mcastMacsLocal.getSchema())
                         .where(mcastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
index dd345879c99728794b3ed5adf29fbd6bcdaf13c5..862fce0c2be18b4e9103cc73df22831e5f4fe55c 100644 (file)
@@ -66,8 +66,8 @@ public class McastMacsLocalUpdateCommand
                 LOG.trace("execute: create LocalMcastMac entry: {}", mcastMacsLocal);
                 transaction.add(op.insert(mcastMacsLocal));
                 transaction.add(op.comment("McastMacLocal: Creating " + localMcastMac.getMacEntryKey().getValue()));
-            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
-                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+            } else if (operationalMacOptional.orElseThrow().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.orElseThrow().getMacEntryUuid().getValue());
                 McastMacsLocal extraMac = transaction.getTypedRowSchema(McastMacsLocal.class);
                 extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: update LocalMcastMac entry: {}", mcastMacsLocal);
@@ -90,7 +90,7 @@ public class McastMacsLocalUpdateCommand
             Optional<LogicalSwitches> operationalSwitchOptional =
                     getOperationalState().getLogicalSwitches(lswitchIid);
             if (operationalSwitchOptional.isPresent()) {
-                Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid();
+                Uuid logicalSwitchUuid = operationalSwitchOptional.orElseThrow().getLogicalSwitchUuid();
                 UUID logicalSwitchUUID = new UUID(logicalSwitchUuid.getValue());
                 mcastMacsLocal.setLogicalSwitch(logicalSwitchUUID);
             } else {
@@ -124,8 +124,8 @@ public class McastMacsLocalUpdateCommand
             } else {
                 mcastMacsLocal.setMac(inputMac.getMacEntryKey().getValue());
             }
-        } else if (inputSwitchOptional.isPresent() && inputSwitchOptional.get().getMacEntryKey() != null) {
-            mcastMacsLocal.setMac(inputSwitchOptional.get().getMacEntryKey().getValue());
+        } else if (inputSwitchOptional.isPresent() && inputSwitchOptional.orElseThrow().getMacEntryKey() != null) {
+            mcastMacsLocal.setMac(inputSwitchOptional.orElseThrow().getMacEntryKey().getValue());
         }
     }
 
index 8cbf865e5f6a87049e26ce679c9cd88b870635e6..7764e4d15ae3fea7e0ed0257242aebb7b58fb670 100644 (file)
@@ -59,7 +59,7 @@ public class PhysicalPortRemoveCommand extends AbstractTransactCommand {
             if (operationalPhysicalPortOptional.isPresent()) {
                 PhysicalPort physicalPort = transaction.getTypedRowWrapper(PhysicalPort.class);
                 physicalPort.setVlanBindings(new HashMap<>());
-                HwvtepPhysicalPortAugmentation updatedPhysicalPort = operationalPhysicalPortOptional.get();
+                HwvtepPhysicalPortAugmentation updatedPhysicalPort = operationalPhysicalPortOptional.orElseThrow();
                 String existingPhysicalPortName = updatedPhysicalPort.getHwvtepNodeName().getValue();
                 PhysicalPort extraPhyscialPort = transaction.getTypedRowWrapper(PhysicalPort.class);
                 extraPhyscialPort.setName("");
index 20c59afe8d6802542b375815c23095dcee0cb8ae..45ddde080c0d7ed968af81854f255f7cc78bb41e 100644 (file)
@@ -55,8 +55,8 @@ public class PhysicalSwitchRemoveCommand extends AbstractTransactCommand {
                 getOperationalState().getPhysicalSwitchAugmentation(iid);
         PhysicalSwitch physicalSwitch = transaction.getTypedRowSchema(PhysicalSwitch.class);
         if (operationalPhysicalSwitchOptional.isPresent()
-                && operationalPhysicalSwitchOptional.get().getPhysicalSwitchUuid() != null) {
-            UUID physicalSwitchUuid = new UUID(operationalPhysicalSwitchOptional.get()
+                && operationalPhysicalSwitchOptional.orElseThrow().getPhysicalSwitchUuid() != null) {
+            UUID physicalSwitchUuid = new UUID(operationalPhysicalSwitchOptional.orElseThrow()
                     .getPhysicalSwitchUuid().getValue());
             Global global = transaction.getTypedRowSchema(Global.class);
             transaction.add(op.delete(physicalSwitch.getSchema())
index f0aebff57d4f73e3bdd38f960511ffecb8a0a7bc..2b22dd078614018b7a025575c197f9660282e72f 100644 (file)
@@ -88,7 +88,7 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         PhysicalSwitch physicalSwitch = transaction.getTypedRowWrapper(PhysicalSwitch.class);
         setDescription(physicalSwitch, physicalSwitchAugmentation);
         setManagementIps(physicalSwitch, physicalSwitchAugmentation);
-        setTunnuleIps(physicalSwitch, operationalPhysicalSwitchOptional.get());
+        setTunnuleIps(physicalSwitch, operationalPhysicalSwitchOptional.orElseThrow());
         try {
             setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation,
                             operationalPhysicalSwitchOptional.isPresent());
@@ -113,7 +113,7 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
             transaction.add(op.comment("Global: Mutating "
                             + physicalSwitchAugmentation.getHwvtepNodeName().getValue() + " " + pswitchUuid));
         } else {
-            PhysicalSwitchAugmentation updatedPhysicalSwitch = operationalPhysicalSwitchOptional.get();
+            PhysicalSwitchAugmentation updatedPhysicalSwitch = operationalPhysicalSwitchOptional.orElseThrow();
             String existingPhysicalSwitchName = updatedPhysicalSwitch.getHwvtepNodeName().getValue();
             /* In case TOR devices don't allow creation of PhysicalSwitch name might be null
              * as user is only adding configurable parameters to MDSAL like BFD params
@@ -121,7 +121,8 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
              * TODO Note: Consider handling tunnel udpate/remove in separate command
              */
             if (existingPhysicalSwitchName == null) {
-                existingPhysicalSwitchName = operationalPhysicalSwitchOptional.get().getHwvtepNodeName().getValue();
+                existingPhysicalSwitchName = operationalPhysicalSwitchOptional.orElseThrow()
+                    .getHwvtepNodeName().getValue();
             }
             // Name is immutable, and so we *can't* update it.  So we use extraPhysicalSwitch for the schema stuff
             PhysicalSwitch extraPhysicalSwitch = transaction.getTypedRowWrapper(PhysicalSwitch.class);
@@ -140,8 +141,8 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         if (physicalSwitchAugmentation.getHwvtepNodeName() != null) {
             physicalSwitch.setName(physicalSwitchAugmentation.getHwvtepNodeName().getValue());
         } else if (operationalPhysicalSwitchOptional.isPresent()
-                && operationalPhysicalSwitchOptional.get().getHwvtepNodeName() != null) {
-            physicalSwitch.setName(operationalPhysicalSwitchOptional.get().getHwvtepNodeName().getValue());
+                && operationalPhysicalSwitchOptional.orElseThrow().getHwvtepNodeName() != null) {
+            physicalSwitch.setName(operationalPhysicalSwitchOptional.orElseThrow().getHwvtepNodeName().getValue());
         }
     }
 
@@ -218,7 +219,7 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
                         transaction.add(op.comment("PhysicalSwitch: Mutating " + tunnelUuid));
                     }
                 } else {
-                    UUID uuid = new UUID(opTunnelOpt.get().getTunnelUuid().getValue());
+                    UUID uuid = new UUID(opTunnelOpt.orElseThrow().getTunnelUuid().getValue());
                     Tunnel extraTunnel = transaction.getTypedRowSchema(Tunnel.class);
                     extraTunnel.getUuidColumn().setData(uuid);
                     transaction.add(op.update(newTunnel)
@@ -270,7 +271,7 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
                         getOperationalState().getPhysicalLocatorAugmentation(iid);
         if (opLocOptional.isPresent()) {
             // Get Locator UUID from operational
-            HwvtepPhysicalLocatorAugmentation locatorAug = opLocOptional.get();
+            HwvtepPhysicalLocatorAugmentation locatorAug = opLocOptional.orElseThrow();
             locatorUUID = new UUID(locatorAug.getPhysicalLocatorUuid().getValue());
         } else {
             // TODO/FIXME: Not in operational, do we create a new one?
index 3f2ca6aec8d808af62d413cea7b0319f74fd37b4..b5b69ea128cd6ef0b6ca2ac28f2a0a001684fc6a 100644 (file)
@@ -54,10 +54,10 @@ public class UcastMacsLocalRemoveCommand
             Optional<LocalUcastMacs> operationalMacOptional =
                     getOperationalState().getLocalUcastMacs(instanceIdentifier, mac.key());
             UcastMacsLocal ucastMacsLocal = transaction.getTypedRowSchema(UcastMacsLocal.class);
-            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.orElseThrow().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locators are deleted automatically.
                 //locators in config DS is not deleted and user need to be removed explicitly by user.
-                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                UUID macEntryUUID = new UUID(operationalMacOptional.orElseThrow().getMacEntryUuid().getValue());
                 ucastMacsLocal.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(ucastMacsLocal.getSchema())
                         .where(ucastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
index abf421214badbbce636827004610c6986d29178c..b3417df7bb5e92772e6ad384d8c34d7829e48e59 100644 (file)
@@ -63,13 +63,13 @@ public class UcastMacsLocalUpdateCommand
             setIpAddress(ucastMacsLocal, localUcastMac);
             setLocator(transaction, ucastMacsLocal, localUcastMac);
             setLogicalSwitch(ucastMacsLocal, localUcastMac);
-            if (!operationalMacOptional.isPresent()) {
+            if (operationalMacOptional.isEmpty()) {
                 setMac(ucastMacsLocal, localUcastMac, operationalMacOptional);
                 LOG.trace("execute: creating LocalUcastMac entry: {}", ucastMacsLocal);
                 transaction.add(op.insert(ucastMacsLocal));
                 transaction.add(op.comment("UcastMacLocal: Creating " + localUcastMac.getMacEntryKey().getValue()));
-            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
-                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+            } else if (operationalMacOptional.orElseThrow().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.orElseThrow().getMacEntryUuid().getValue());
                 UcastMacsLocal extraMac = transaction.getTypedRowSchema(UcastMacsLocal.class);
                 extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: updating LocalUcastMac entry: {}", ucastMacsLocal);
@@ -92,7 +92,7 @@ public class UcastMacsLocalUpdateCommand
             Optional<LogicalSwitches> operationalSwitchOptional =
                     getOperationalState().getLogicalSwitches(lswitchIid);
             if (operationalSwitchOptional.isPresent()) {
-                Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid();
+                Uuid logicalSwitchUuid = operationalSwitchOptional.orElseThrow().getLogicalSwitchUuid();
                 UUID logicalSwitchUUID = new UUID(logicalSwitchUuid.getValue());
                 ucastMacsLocal.setLogicalSwitch(logicalSwitchUUID);
             } else {
@@ -116,7 +116,7 @@ public class UcastMacsLocalUpdateCommand
                     getOperationalState().getPhysicalLocatorAugmentation(iid);
             if (operationalLocatorOptional.isPresent()) {
                 //if exist, get uuid
-                HwvtepPhysicalLocatorAugmentation locatorAugmentation = operationalLocatorOptional.get();
+                HwvtepPhysicalLocatorAugmentation locatorAugmentation = operationalLocatorOptional.orElseThrow();
                 locatorUuid = new UUID(locatorAugmentation.getPhysicalLocatorUuid().getValue());
             } else {
                 //if no, get it from config DS and create id
@@ -124,7 +124,7 @@ public class UcastMacsLocalUpdateCommand
                         getOperationalState().getDataBroker()).readOptional(LogicalDatastoreType.CONFIGURATION, iid);
                 if (configLocatorOptional.isPresent()) {
                     HwvtepPhysicalLocatorAugmentation locatorAugmentation =
-                            configLocatorOptional.get().augmentation(HwvtepPhysicalLocatorAugmentation.class);
+                            configLocatorOptional.orElseThrow().augmentation(HwvtepPhysicalLocatorAugmentation.class);
                     locatorUuid = TransactUtils.createPhysicalLocator(transaction, locatorAugmentation,
                             getOperationalState());
                 } else {
@@ -148,8 +148,8 @@ public class UcastMacsLocalUpdateCommand
             final Optional<LocalUcastMacs> inputSwitchOptional) {
         if (inputMac.getMacEntryKey() != null) {
             ucastMacsLocal.setMac(inputMac.getMacEntryKey().getValue());
-        } else if (inputSwitchOptional.isPresent() && inputSwitchOptional.get().getMacEntryKey() != null) {
-            ucastMacsLocal.setMac(inputSwitchOptional.get().getMacEntryKey().getValue());
+        } else if (inputSwitchOptional.isPresent() && inputSwitchOptional.orElseThrow().getMacEntryKey() != null) {
+            ucastMacsLocal.setMac(inputSwitchOptional.orElseThrow().getMacEntryKey().getValue());
         }
     }
 
index 54c9c69acc837390b87f1e4b7bc6c9aa445a8911..3200f9e1bf875b83cbee44f23420985af7db99d6 100644 (file)
@@ -109,7 +109,7 @@ public abstract class UnMetDependencyGetter<T extends Identifiable> {
             DataBroker db = opState.getConnectionInstance().getDataBroker();
             Optional data = HwvtepSouthboundUtil.readNode(db, LogicalDatastoreType.CONFIGURATION, key);
             if (data.isPresent()) {
-                opState.getDeviceInfo().updateConfigData(cls, key, data.get());
+                opState.getDeviceInfo().updateConfigData(cls, key, data.orElseThrow());
                 return true;
             }
             return false;
index 99cbcfa98c985980b928d9a608c631e516d95abe..27d8e8a6bdbabfcf967523b52cca756f80ec54a5 100644 (file)
@@ -50,7 +50,7 @@ public class HwvtepGlobalRemoveCommand extends AbstractTransactionCommand {
         try {
             Optional<Node> hwvtepGlobalOptional = hwvtepGlobalFuture.get();
             if (hwvtepGlobalOptional.isPresent()) {
-                Node hwvtepNode = hwvtepGlobalOptional.get();
+                Node hwvtepNode = hwvtepGlobalOptional.orElseThrow();
                 HwvtepGlobalAugmentation hgAugmentation = hwvtepNode.augmentation(HwvtepGlobalAugmentation.class);
                 if (checkIfOnlyConnectedManager(hgAugmentation)) {
                     if (hgAugmentation != null) {
index bee29bb32ef297606d264dcc2d6837421ecebaf5..c91d2edacff9872e5c0748ba0429c9b8290000be 100644 (file)
@@ -58,7 +58,7 @@ public final class HwvtepManagerUpdateCommand extends AbstractTransactionCommand
         final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
         Optional<Node> connection = HwvtepSouthboundUtil.readNode(transaction, connectionIId);
         if (connection.isPresent()) {
-            LOG.debug("Connection {} is present", connection.get());
+            LOG.debug("Connection {} is present", connection.orElseThrow());
             Node connectionNode = buildConnectionNode(manager);
             transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
             addToDeviceUpdate(TransactionType.ADD, manager);
index f212b395b9ff17bed98a97281ff8dd6ac8a5e95c..48d92dd8d42d2081838d977b07c159460d2a5af4 100644 (file)
@@ -48,7 +48,7 @@ public final class HwvtepPhysicalLocatorUpdateCommand extends AbstractTransactio
         }
         Optional<Node> node = HwvtepSouthboundUtil.readNode(transaction, connectionIId);
         if (node.isPresent()) {
-            updateTerminationPoints(transaction, node.get());
+            updateTerminationPoints(transaction, node.orElseThrow());
         }
     }
 
index 7a768d9313f622537f87bce2326e4df7ed75e8af..505a8a91c15353287dc2c06fd441938fb270320c 100644 (file)
@@ -86,7 +86,7 @@ public final class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCo
         for (Entry<UUID, PhysicalPort> portUpdateEntry : updatedPPRows.entrySet()) {
             Optional<InstanceIdentifier<Node>> switchIid = getTerminationPointSwitch(portUpdateEntry.getKey());
             if (switchIid.isPresent()) {
-                if (getDeviceInfo().getDeviceOperData(Node.class, switchIid.get()) == null) {
+                if (getDeviceInfo().getDeviceOperData(Node.class, switchIid.orElseThrow()) == null) {
                     //This is the first update from switch do not have to do reconciliation of this port
                     //it is taken care by switch reconciliation
                     skipReconciliationPorts.add(portUpdateEntry.getKey());
@@ -105,7 +105,7 @@ public final class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCo
         LOG.trace("PhysicalPortTable updated: {}", updatedPPRows);
         Optional<Node> node = HwvtepSouthboundUtil.readNode(transaction, connectionIId);
         if (node.isPresent()) {
-            updateTerminationPoints(transaction, node.get());
+            updateTerminationPoints(transaction, node.orElseThrow());
             // TODO: Handle Deletion of VLAN Bindings
         }
     }
@@ -128,7 +128,8 @@ public final class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCo
                 TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
                 tpBuilder.withKey(tpKey);
                 tpBuilder.setTpId(tpKey.getTpId());
-                InstanceIdentifier<TerminationPoint> tpPath = getInstanceIdentifier(switchIid.get(), portUpdate);
+                InstanceIdentifier<TerminationPoint> tpPath =
+                    getInstanceIdentifier(switchIid.orElseThrow(), portUpdate);
                 HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder =
                         new HwvtepPhysicalPortAugmentationBuilder();
                 buildTerminationPoint(tpAugmentationBuilder, portUpdate);
@@ -301,7 +302,7 @@ public final class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCo
             for (Switches managedNodeEntry : switchNodes.values()) {
                 @SuppressWarnings("unchecked")
                 Node switchNode = HwvtepSouthboundUtil.readNode(transaction,
-                                (InstanceIdentifier<Node>) managedNodeEntry.getSwitchRef().getValue()).get();
+                                (InstanceIdentifier<Node>) managedNodeEntry.getSwitchRef().getValue()).orElseThrow();
                 TerminationPointKey tpKey = new TerminationPointKey(new TpId(tpName));
                 TerminationPoint terminationPoint = switchNode.nonnullTerminationPoint().get(tpKey);
                 if (terminationPoint != null) {
index 2bd4898dac3268fcb726d712adf9cb4e08c66ece..0478beb68444e68c9179d1a22510bc16f99938d1 100644 (file)
@@ -97,7 +97,7 @@ public final class HwvtepPhysicalSwitchUpdateCommand extends AbstractTransaction
 
             // Update the Physical Switch with whatever data we are getting
             InstanceIdentifier<Node> psIid = getInstanceIdentifier(phySwitch);
-            Node psNode = buildPhysicalSwitchNode(connection.get(), phySwitch);
+            Node psNode = buildPhysicalSwitchNode(connection.orElseThrow(), phySwitch);
             transaction.merge(LogicalDatastoreType.OPERATIONAL, psIid, psNode);
             addToDeviceUpdate(TransactionType.ADD, phySwitch);
             LOG.info("DEVICE - {} {}", TransactionType.ADD, phySwitch);
index b04ca6ecf2a1afb898aa5adfe562485e6a29f236..004f54634d63036d13d2b19d51259ec6b5a8e674 100644 (file)
@@ -105,9 +105,10 @@ public class StalePassiveConnectionService implements AutoCloseable {
                 .map(entry -> entry.getKey())
                 .findFirst();
         if (clientOptional.isPresent()) {
-            LOG.info("Sending notification for client {}", clientOptional.get().getConnectionInfo());
-            pendingClients.remove(clientOptional.get());
-            clientNotificationCallback.apply(clientOptional.get());
+            OvsdbClient client = clientOptional.orElseThrow();
+            LOG.info("Sending notification for client {}", client.getConnectionInfo());
+            pendingClients.remove(client);
+            clientNotificationCallback.apply(client);
         }
     }
 
index 90151624fbc9aa081fadf84c464d50ead25d81c1..0e700be34e4ece784e974f2a48386a4ba9d0ecea 100644 (file)
@@ -335,7 +335,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     public OvsdbConnectionInstance getConnectionInstance(final OvsdbBridgeAttributes mn) {
         Optional<OvsdbNodeAugmentation> optional = SouthboundUtil.getManagingNode(db, mn);
         if (optional.isPresent()) {
-            return getConnectionInstance(optional.get().getConnectionInfo());
+            return getConnectionInstance(optional.orElseThrow().getConnectionInfo());
         } else {
             return null;
         }
@@ -366,7 +366,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
             transaction.close();
             Optional<Node> optional = nodeFuture.get();
             if (optional.isPresent()) {
-                return this.getConnectionInstance(optional.get());
+                return this.getConnectionInstance(optional.orElseThrow());
             } else {
                 LOG.debug("Node was not found on the path in the operational DS: {}", nodePath);
                 return null;
@@ -500,7 +500,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         txInvoker.invoke(transaction -> {
             Optional<Node> ovsdbNodeOpt = SouthboundUtil.readNode(transaction, nodeIid);
             if (ovsdbNodeOpt.isPresent()) {
-                Node ovsdbNode = ovsdbNodeOpt.get();
+                Node ovsdbNode = ovsdbNodeOpt.orElseThrow();
                 OvsdbNodeAugmentation nodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
                 if (nodeAugmentation != null) {
                     Map<ManagedNodeEntryKey, ManagedNodeEntry> entries = nodeAugmentation.getManagedNodeEntry();
@@ -598,7 +598,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         java.util.Optional<EntityOwnershipState> ownershipStateOpt =
                 entityOwnershipService.getOwnershipState(candidateEntity);
         if (ownershipStateOpt.isPresent()) {
-            EntityOwnershipState ownershipState = ownershipStateOpt.get();
+            EntityOwnershipState ownershipState = ownershipStateOpt.orElseThrow();
             if (ownershipState == EntityOwnershipState.OWNED_BY_OTHER) {
                 ovsdbConnectionInstance.setHasDeviceOwnership(false);
             } else if (ownershipState == EntityOwnershipState.IS_OWNER) {
index ced4324926d7f70c57bef948bdc3d9d762ff9d0b..5a2641cd6f7aac4333a1e06d4f223fedf8602ce8 100644 (file)
@@ -54,17 +54,18 @@ public final class SouthboundUtil {
         try {
             OvsdbNodeRef ref = mn.getManagedBy();
             if (ref != null && ref.getValue() != null) {
-                ReadTransaction transaction = db.newReadOnlyTransaction();
-                @SuppressWarnings("unchecked")
-                // Note: erasure makes this safe in combination with the typecheck below
-                InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue();
+                FluentFuture<Optional<Node>> nf;
+                try (ReadTransaction transaction = db.newReadOnlyTransaction()) {
+                    @SuppressWarnings("unchecked")
+                    // Note: erasure makes this safe in combination with the typecheck below
+                    InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue();
+                    nf = transaction.read(LogicalDatastoreType.OPERATIONAL, path);
+                }
 
-                FluentFuture<Optional<Node>> nf = transaction.read(LogicalDatastoreType.OPERATIONAL, path);
-                transaction.close();
                 Optional<Node> optional = nf.get();
                 if (optional != null && optional.isPresent()) {
                     OvsdbNodeAugmentation ovsdbNode = null;
-                    Node node = optional.get();
+                    Node node = optional.orElseThrow();
                     if (node instanceof OvsdbNodeAugmentation) {
                         ovsdbNode = (OvsdbNodeAugmentation) node;
                     } else if (node != null) {
index 07a4a4fb9a6ebd3b428cab1119ea38b05d23557d..9d0bb1a8ad5ec340290f590bcab686688ef2671a 100644 (file)
@@ -82,7 +82,7 @@ public class AutoAttachRemovedCommand implements TransactCommand {
                         return;
                     }
                     final OvsdbNodeAugmentation currentOvsdbNode =
-                            state.getBridgeNode(ovsdbNodeIid).get().augmentation(OvsdbNodeAugmentation.class);
+                            state.getBridgeNode(ovsdbNodeIid).orElseThrow().augmentation(OvsdbNodeAugmentation.class);
                     final Map<AutoattachKey, Autoattach> currentAutoAttach = currentOvsdbNode.getAutoattach();
                     for (final Autoattach origAutoattach : origAutoattachList.values()) {
                         deleteAutoAttach(transaction, ovsdbNodeIid, getAutoAttachUuid(currentAutoAttach,
@@ -145,14 +145,14 @@ public class AutoAttachRemovedCommand implements TransactCommand {
             final Optional<Node> nodeOptional = SouthboundUtil.readNode(transaction, nodeIid);
             if (nodeOptional.isPresent()) {
                 final Map<ManagedNodeEntryKey, ManagedNodeEntry> managedNodes =
-                        nodeOptional.get().augmentation(OvsdbNodeAugmentation.class).getManagedNodeEntry();
+                        nodeOptional.orElseThrow().augmentation(OvsdbNodeAugmentation.class).getManagedNodeEntry();
                 for (final ManagedNodeEntry managedNode : managedNodes.values()) {
                     final OvsdbBridgeRef ovsdbBridgeRef = managedNode.getBridgeRef();
                     final InstanceIdentifier<OvsdbBridgeAugmentation> brIid = ovsdbBridgeRef.getValue()
                             .firstIdentifierOf(Node.class).augmentation(OvsdbBridgeAugmentation.class);
                     final Optional<OvsdbBridgeAugmentation> optionalBridge =
                             transaction.read(LogicalDatastoreType.OPERATIONAL, brIid).get();
-                    bridge = optionalBridge.get();
+                    bridge = optionalBridge.orElseThrow();
                     if (bridge != null && bridge.getAutoAttach() != null
                             && bridge.getAutoAttach().equals(aaUuid)) {
                         return bridge;
index a7e0f6f8b9321d585795a1fd8ac3b4bda0b379fa..d753b46169f4940cb0be17c4c9553e73b3ca324b 100644 (file)
@@ -92,7 +92,7 @@ public class AutoAttachUpdateCommand implements TransactCommand {
             }
 
             final OvsdbNodeAugmentation currentOvsdbNode =
-                    state.getBridgeNode(iid).get().augmentation(OvsdbNodeAugmentation.class);
+                    state.getBridgeNode(iid).orElseThrow().augmentation(OvsdbNodeAugmentation.class);
             final Map<AutoattachKey, Autoattach> currentAutoAttach = currentOvsdbNode.getAutoattach();
             for (final Autoattach autoAttach : autoAttachList.values()) {
                 final AutoAttach autoAttachWrapper = transaction.getTypedRowWrapper(AutoAttach.class);
@@ -177,7 +177,7 @@ public class AutoAttachUpdateCommand implements TransactCommand {
             final Optional<OvsdbBridgeAugmentation> bridgeOptional =
                     transaction.read(LogicalDatastoreType.OPERATIONAL, bridgeIid).get();
             if (bridgeOptional.isPresent()) {
-                bridge = bridgeOptional.get();
+                bridge = bridgeOptional.orElseThrow();
             }
         } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Error reading from datastore", e);
index 79a45766f0cb56165ddd540a97689a9dbde56d95..2c3703006bc40936a85f8c1db5db315934c7d92e 100644 (file)
@@ -52,20 +52,18 @@ public class BridgeOperationalState {
     }
 
     public Optional<OvsdbBridgeAugmentation> getOvsdbBridgeAugmentation(InstanceIdentifier<?> iid) {
-        Optional<Node> nodeOptional = getBridgeNode(iid);
-        if (nodeOptional.isPresent()) {
-            return Optional.ofNullable(nodeOptional.get().augmentation(OvsdbBridgeAugmentation.class));
-        }
-        return Optional.empty();
+        return getBridgeNode(iid)
+            .flatMap(node -> Optional.ofNullable(node.augmentation(OvsdbBridgeAugmentation.class)));
     }
 
     public Optional<TerminationPoint> getBridgeTerminationPoint(InstanceIdentifier<?> iid) {
         if (iid != null) {
             Optional<Node> nodeOptional = getBridgeNode(iid);
-            if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
+            if (nodeOptional.isPresent()) {
+                Node node = nodeOptional.orElseThrow();
                 TerminationPointKey key = iid.firstKeyOf(TerminationPoint.class);
                 if (key != null) {
-                    final TerminationPoint tp = nodeOptional.get().nonnullTerminationPoint().get(key);
+                    final TerminationPoint tp = node.nonnullTerminationPoint().get(key);
                     if (tp != null) {
                         return Optional.of(tp);
                     }
@@ -78,18 +76,16 @@ public class BridgeOperationalState {
     }
 
     public Optional<OvsdbTerminationPointAugmentation> getOvsdbTerminationPointAugmentation(InstanceIdentifier<?> iid) {
-        Optional<TerminationPoint> tpOptional = getBridgeTerminationPoint(iid);
-        if (tpOptional.isPresent()) {
-            return Optional.ofNullable(tpOptional.get().augmentation(OvsdbTerminationPointAugmentation.class));
-        }
-        return Optional.empty();
+        return getBridgeTerminationPoint(iid)
+            .flatMap(tp -> Optional.ofNullable(tp.augmentation(OvsdbTerminationPointAugmentation.class)));
     }
 
     public Optional<ControllerEntry> getControllerEntry(InstanceIdentifier<?> iid) {
         if (iid != null) {
             Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
             if (ovsdbBridgeOptional.isPresent()) {
-                Map<ControllerEntryKey, ControllerEntry> entries = ovsdbBridgeOptional.get().getControllerEntry();
+                Map<ControllerEntryKey, ControllerEntry> entries =
+                    ovsdbBridgeOptional.orElseThrow().getControllerEntry();
                 if (entries != null) {
                     ControllerEntryKey key = iid.firstKeyOf(ControllerEntry.class);
                     if (key != null) {
@@ -108,7 +104,7 @@ public class BridgeOperationalState {
         if (iid != null) {
             Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
             if (ovsdbBridgeOptional.isPresent()) {
-                Map<ProtocolEntryKey, ProtocolEntry> entries = ovsdbBridgeOptional.get().getProtocolEntry();
+                Map<ProtocolEntryKey, ProtocolEntry> entries = ovsdbBridgeOptional.orElseThrow().getProtocolEntry();
                 if (entries != null) {
                     ProtocolEntryKey key = iid.firstKeyOf(ProtocolEntry.class);
                     if (key != null) {
index 032c79311cb17f226b68da4fda00bc6f9781f69c..77c215e61dbfe4f8c5d74dd3549c62eb65f5e731 100644 (file)
@@ -55,8 +55,9 @@ public class BridgeRemovedCommand implements TransactCommand {
             Bridge bridge = transaction.getTypedRowSchema(Bridge.class);
             Optional<OvsdbBridgeAugmentation> ovsdbAugmentationOptional = state
                     .getOvsdbBridgeAugmentation(ovsdbManagedNodeIid);
-            if (ovsdbAugmentationOptional.isPresent() && ovsdbAugmentationOptional.get().getBridgeUuid() != null) {
-                UUID bridgeUuid = new UUID(ovsdbAugmentationOptional.get().getBridgeUuid().getValue());
+            if (ovsdbAugmentationOptional.isPresent()
+                && ovsdbAugmentationOptional.orElseThrow().getBridgeUuid() != null) {
+                UUID bridgeUuid = new UUID(ovsdbAugmentationOptional.orElseThrow().getBridgeUuid().getValue());
                 OpenVSwitch ovs = transaction.getTypedRowSchema(OpenVSwitch.class);
                 transaction.add(op.delete(bridge.getSchema())
                         .where(bridge.getUuidColumn().getSchema().opEqual(bridgeUuid)).build());
index af5bf9e162704c83bfea85132063ead6f186f6c8..478c0e15b598c55741b07e5f026c03ba938234ad 100644 (file)
@@ -91,7 +91,7 @@ public class BridgeUpdateCommand implements TransactCommand {
                     ovsdbManagedNode.getBridgeName(),
                     ovsdbManagedNode.getBridgeUuid());
         } else {
-            String existingBridgeName = operationalBridgeOptional.get().getBridgeName().getValue();
+            String existingBridgeName = operationalBridgeOptional.orElseThrow().getBridgeName().getValue();
             LOG.debug("Bridge {} already exists in device updating {}", existingBridgeName, iid);
             // Name is immutable, and so we *can't* update it.  So we use extraBridge for the schema stuff
             Bridge extraBridge = transaction.getTypedRowWrapper(Bridge.class);
@@ -120,8 +120,9 @@ public class BridgeUpdateCommand implements TransactCommand {
             final Optional<OvsdbBridgeAugmentation> operationalBridgeOptional) {
         if (ovsdbManagedNode.getBridgeName() != null) {
             bridge.setName(ovsdbManagedNode.getBridgeName().getValue());
-        } else if (operationalBridgeOptional.isPresent() && operationalBridgeOptional.get().getBridgeName() != null) {
-            bridge.setName(operationalBridgeOptional.get().getBridgeName().getValue());
+        } else if (operationalBridgeOptional.isPresent()
+            && operationalBridgeOptional.orElseThrow().getBridgeName() != null) {
+            bridge.setName(operationalBridgeOptional.orElseThrow().getBridgeName().getValue());
         }
     }
 
index 46b825360c3c3346079398c53471ee195a81e47c..8347f91c773bfade623c767537530a5ed7f91b00 100644 (file)
@@ -56,7 +56,7 @@ public class ControllerRemovedCommand implements TransactCommand {
             OvsdbBridgeAugmentation ovsdbBridge = modifiedBridges.get(bridgeIid);
             Optional<ControllerEntry> controllerEntryOptional = state.getControllerEntry(controllerIid);
             if (ovsdbBridge != null && controllerEntryOptional.isPresent()) {
-                ControllerEntry controllerEntry = controllerEntryOptional.get();
+                ControllerEntry controllerEntry = controllerEntryOptional.orElseThrow();
                 Bridge bridge = transaction.getTypedRowWrapper(Bridge.class);
                 bridge.setController(Collections.singleton(new UUID(controllerEntry.getControllerUuid().getValue())));
                 transaction.add(op.mutate(bridge).addMutation(bridge.getControllerColumn().getSchema(),
index aa22a291b7c0e8c2aff7f1c088845cd63f323ad4..98e62de3c5881ea72c194e4ad81eba0ae4ac94b3 100644 (file)
@@ -61,7 +61,7 @@ public class ControllerUpdateCommand implements TransactCommand {
                 Optional<OvsdbBridgeAugmentation> bridgeOptional =
                         state.getOvsdbBridgeAugmentation(bridgeIid);
                 OvsdbBridgeAugmentation ovsdbBridge = bridgeOptional.isPresent()
-                    ? bridgeOptional.get() : bridges.get(bridgeIid);
+                    ? bridgeOptional.orElseThrow() : bridges.get(bridgeIid);
                 if (ovsdbBridge != null
                         && ovsdbBridge.getBridgeName() != null
                         && entry.getValue() != null
index 0f8ce3cdcb3de3cf98eb1a196183280c4e36a2d3..fdb84acc4320e36c8d83bfb6b78b2e7ed7109d63 100644 (file)
@@ -121,8 +121,7 @@ public class DataChangesManagedByOvsdbNodeEvent implements DataChangeEvent {
         InstanceIdentifier<Node> nodeEntryIid = bridgeIid.firstIdentifierOf(Node.class);
 
         Optional<?> bridgeNode =  SouthboundUtil.readNode(db.newReadWriteTransaction(),nodeEntryIid);
-        if (bridgeNode.isPresent() && bridgeNode.get() instanceof Node) {
-            Node node = (Node)bridgeNode.get();
+        if (bridgeNode.isPresent() && bridgeNode.orElseThrow() instanceof Node node) {
             OvsdbBridgeAugmentation bridge = node.augmentation(OvsdbBridgeAugmentation.class);
             if (bridge != null && bridge.getManagedBy() != null) {
                 return bridge.getManagedBy().getValue();
index 6f1af1e6831bfc062500a409e1de95e6a2ff7710..946af1b45df5618578669fa1e5ce253a28982bf4 100644 (file)
@@ -58,7 +58,7 @@ public class ProtocolRemovedCommand implements TransactCommand {
             Optional<ProtocolEntry> protocolEntryOptional = state.getProtocolEntry(protocolIid);
             if (ovsdbBridge != null
                     && protocolEntryOptional.isPresent()) {
-                ProtocolEntry protocolEntry = protocolEntryOptional.get();
+                ProtocolEntry protocolEntry = protocolEntryOptional.orElseThrow();
                 if (protocolEntry != null && protocolEntry.getProtocol() != null) {
                     Bridge bridge = transaction.getTypedRowWrapper(Bridge.class);
                     String protocolString = SouthboundConstants.OVSDB_PROTOCOL_MAP.get(protocolEntry.getProtocol());
index abede5ed2169593821d042fffd59abb4062ce89b..16451e9546572ff976e2635cfdf583c572112946 100644 (file)
@@ -62,7 +62,7 @@ public class ProtocolUpdateCommand implements TransactCommand {
                         state.getOvsdbBridgeAugmentation(bridgeIid);
                 OvsdbBridgeAugmentation ovsdbBridge;
                 if (bridgeOptional.isPresent()) {
-                    ovsdbBridge = bridgeOptional.get();
+                    ovsdbBridge = bridgeOptional.orElseThrow();
                 } else {
                     ovsdbBridge = bridges.get(bridgeIid);
                 }
index bbcb58d335aaaeca0a4717ac65d150f1ac36e329..e46b7cac9ab1fbd0f37c73d22adc21bae622cb61 100644 (file)
@@ -59,8 +59,8 @@ public class QosRemovedCommand implements TransactCommand {
                 Map<QosEntriesKey, QosEntries> updatedQosEntries = update.getQosEntries();
                 if (origQosEntries != null && !origQosEntries.isEmpty()) {
                     for (QosEntries origQosEntry : origQosEntries.values()) {
-                        OvsdbNodeAugmentation operNode =
-                                state.getBridgeNode(ovsdbNodeIid).get().augmentation(OvsdbNodeAugmentation.class);
+                        OvsdbNodeAugmentation operNode = state.getBridgeNode(ovsdbNodeIid).orElseThrow()
+                                .augmentation(OvsdbNodeAugmentation.class);
                         if (updatedQosEntries == null || !updatedQosEntries.containsKey(origQosEntry.key())) {
                             LOG.debug("Received request to delete QoS entry {}", origQosEntry.getQosId());
                             Uuid qosUuid = getQosEntryUuid(operNode.getQosEntries(), origQosEntry.key());
index d2d49f7016fec47eddfa4e1f00fe15818c17af40..339506416605c33ea6e71b0ee7637f119fb2050a 100644 (file)
@@ -68,7 +68,7 @@ public class QosUpdateCommand implements TransactCommand {
                 return;
             }
             OvsdbNodeAugmentation operNode =
-                state.getBridgeNode(iid).get().augmentation(OvsdbNodeAugmentation.class);
+                state.getBridgeNode(iid).orElseThrow().augmentation(OvsdbNodeAugmentation.class);
 
             QosEntries qosEntry = qosMapEntry.getValue();
             Qos qos = transaction.getTypedRowWrapper(Qos.class);
index 48f026ca216347b55ec6572327f765f5e0c0ceed..2cee3c1d23d3b743291f74ea73276f71cfea1bfa 100644 (file)
@@ -58,7 +58,7 @@ public class QueueRemovedCommand implements TransactCommand {
                 if (origQueues != null && !origQueues.isEmpty()) {
                     for (Queues origQueue : origQueues.values()) {
                         OvsdbNodeAugmentation operNode =
-                                state.getBridgeNode(ovsdbNodeIid).get().augmentation(
+                                state.getBridgeNode(ovsdbNodeIid).orElseThrow().augmentation(
                                         OvsdbNodeAugmentation.class);
                         if (updatedQueues == null || !updatedQueues.containsKey(origQueue.key())) {
                             LOG.debug("Received request to delete Queue entry {}", origQueue.getQueueId());
index ef16402e60e660d7b0f5da3b7a161f2a0f2ba19b..4d40bc02f7c181b38d02596a1a0f9514ddd90de2 100644 (file)
@@ -101,7 +101,7 @@ public class QueueUpdateCommand implements TransactCommand {
             }
 
             OvsdbNodeAugmentation operNode =
-                state.getBridgeNode(iid).get().augmentation(OvsdbNodeAugmentation.class);
+                state.getBridgeNode(iid).orElseThrow().augmentation(OvsdbNodeAugmentation.class);
             Uuid operQueueUuid = getQueueEntryUuid(operNode.getQueues(), queueEntry.key());
             if (operQueueUuid == null) {
                 UUID namedUuid = new UUID(SouthboundConstants.QUEUE_NAMED_UUID_PREFIX
index c9d96610c4d23659cc68c4dd717441656a9eed47..71e84853bcdf9d40fb873f5341b38204c2a4864e 100644 (file)
@@ -73,7 +73,7 @@ public class TerminationPointDeleteCommand implements TransactCommand {
             Optional<OvsdbTerminationPointAugmentation> tpAugmentation =
                     state.getOvsdbTerminationPointAugmentation(removedTpIid);
             if (tpAugmentation.isPresent()) {
-                OvsdbTerminationPointAugmentation tp = tpAugmentation.get();
+                OvsdbTerminationPointAugmentation tp = tpAugmentation.orElseThrow();
                 if (tp.getPortUuid() != null) {
                     UUID portUuid = new UUID(tp.getPortUuid().getValue());
                     Bridge bridge = transaction.getTypedRowSchema(Bridge.class);
index 5667cc6f9ce035fa442715971fed18160669f209..883b3833f85b66f45e41158aadd7b069435487fd 100644 (file)
@@ -119,7 +119,7 @@ public class TerminationPointUpdateCommand implements TransactCommand {
             // Bug#6136
             Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = state.getOvsdbBridgeAugmentation(iid);
             if (ovsdbBridgeOptional != null && ovsdbBridgeOptional.isPresent()) {
-                OvsdbBridgeAugmentation operBridge = ovsdbBridgeOptional.get();
+                OvsdbBridgeAugmentation operBridge = ovsdbBridgeOptional.orElseThrow();
                 if (operBridge != null) {
                     Port port = transaction.getTypedRowWrapper(Port.class);
                     updatePort(terminationPoint, port, operBridge, opendaylightIid);
@@ -194,7 +194,7 @@ public class TerminationPointUpdateCommand implements TransactCommand {
         try (ReadTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction()) {
             Optional<Node> nodeOptional = SouthboundUtil.readNode(transaction, iidNode);
             if (nodeOptional.isPresent()) {
-                operNode = nodeOptional.get().augmentation(OvsdbNodeAugmentation.class);
+                operNode = nodeOptional.orElseThrow().augmentation(OvsdbNodeAugmentation.class);
             }
         } catch (Exception exp) {
             LOG.error("Error in getting the brideNode for {}", iidNode, exp);
index f4d7faa3ed0f9f1d8d04241c73a2eae1daa2861d..d970699c7adbe88d4556e389c605a9ccc539dcf6 100644 (file)
@@ -122,7 +122,7 @@ public class BridgeConfigReconciliationTask extends ReconciliationTask {
                 @Override
                 public void onSuccess(@Nullable final Optional<Topology> optionalTopology) {
                     if (optionalTopology != null && optionalTopology.isPresent()) {
-                        Map<NodeKey, Node> nodes = optionalTopology.get().getNode();
+                        Map<NodeKey, Node> nodes = optionalTopology.orElseThrow().getNode();
                         if (nodes != null) {
                             for (Node node : nodes.values()) {
                                 String bridgeNodeIid = node.getNodeId().getValue();
@@ -160,7 +160,7 @@ public class BridgeConfigReconciliationTask extends ReconciliationTask {
                     @Override
                     public void onSuccess(@Nullable final Optional<Node> optionalTopology) {
                         if (optionalTopology != null && optionalTopology.isPresent()) {
-                            Node node = optionalTopology.get();
+                            Node node = optionalTopology.orElseThrow();
                             if (node != null) {
                                 bridgeNodeList.add(node);
                             }
index 196a6b7cb394d1a0fd98411e1ebb26bb611295e8..ad86bc6a3cbd7eb9c5fd90b97327b4ae215ffe77 100644 (file)
@@ -54,17 +54,17 @@ public class OvsdbAutoAttachRemovedCommand extends AbstractTransactionCommand {
                     SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance().getNodeId());
             // FIXME: Iterate on external_ids instead of uuid when Open vSwitch supports external_ids column
             for (final UUID autoAttachUuid : removedAutoAttachRows.keySet()) {
-                final AutoattachKey autoAttachKey = getAutoAttachKeyToRemove(ovsdbNode.get(), autoAttachUuid);
+                final AutoattachKey autoAttachKey = getAutoAttachKeyToRemove(ovsdbNode.orElseThrow(), autoAttachUuid);
                 if (autoAttachKey != null) {
                     final InstanceIdentifier<Autoattach> iid = ovsdbNodeIid
                             .augmentation(OvsdbNodeAugmentation.class)
                             .child(Autoattach.class, autoAttachKey);
                     transaction.delete(LogicalDatastoreType.OPERATIONAL, iid);
                     LOG.debug("AutoAttach table {} for Ovsdb Node {} is deleted", autoAttachUuid,
-                            ovsdbNode.get().getNodeId());
+                            ovsdbNode.orElseThrow().getNodeId());
                 } else {
                     LOG.warn("AutoAttach table {} not found for Ovsdb Node {} to delete", autoAttachUuid,
-                            ovsdbNode.get().getNodeId());
+                            ovsdbNode.orElseThrow().getNodeId());
                 }
             }
         }
index 6ec778e09f1f58317f4103a7fff58d1bd8d36c1d..30d7158eaf50ee5a5fc5065a4ebe748affeba00c 100644 (file)
@@ -91,7 +91,7 @@ public class OvsdbAutoAttachUpdateCommand extends AbstractTransactionCommand {
                         final Optional<Autoattach> optionalAutoattach =
                                 transaction.read(LogicalDatastoreType.OPERATIONAL, currentIid).get();
                         if (optionalAutoattach.isPresent()) {
-                            currentAutoattach = optionalAutoattach.get();
+                            currentAutoattach = optionalAutoattach.orElseThrow();
                         }
                     } catch (final InterruptedException | ExecutionException e) {
                         LOG.debug("AutoAttach table entries not found in operational datastore, need to create it.", e);
@@ -125,7 +125,7 @@ public class OvsdbAutoAttachUpdateCommand extends AbstractTransactionCommand {
 
                 final Autoattach autoAttachEntry = autoAttachBuilder.build();
                 LOG.trace("Update Ovsdb Node {} with AutoAttach table entries {}",
-                        ovsdbNode.get().getNodeId(), autoAttachEntry);
+                        ovsdbNode.orElseThrow().getNodeId(), autoAttachEntry);
                 final InstanceIdentifier<Autoattach> iid = nodeIId
                         .augmentation(OvsdbNodeAugmentation.class)
                         .child(Autoattach.class, autoAttachEntry.key());
index a4adc7667451d8cb24c403a14a483bac85206efa..83174cdaf45f92579bab65252da6c249d7e30e37 100644 (file)
@@ -143,16 +143,17 @@ public class OvsdbControllerUpdateCommand extends AbstractTransactionCommand {
         final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
         final Optional<Node> ovsdbNode = SouthboundUtil.readNode(transaction, connectionIId);
         if (ovsdbNode.isPresent()) {
-            OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.get().augmentation(OvsdbNodeAugmentation.class);
+            OvsdbNodeAugmentation ovsdbNodeAugmentation =
+                ovsdbNode.orElseThrow().augmentation(OvsdbNodeAugmentation.class);
             if (ovsdbNodeAugmentation != null) {
-                final Map<ManagedNodeEntryKey, ManagedNodeEntry> managedNodeEntries
-                    ovsdbNodeAugmentation.getManagedNodeEntry();
+                final Map<ManagedNodeEntryKey, ManagedNodeEntry> managedNodeEntries =
+                    ovsdbNodeAugmentation.getManagedNodeEntry();
                 for (ManagedNodeEntry managedNodeEntry : managedNodeEntries.values()) {
                     final InstanceIdentifier<Node> bridgeIid =
                             (InstanceIdentifier<Node>) managedNodeEntry.getBridgeRef().getValue();
                     final Optional<Node> bridgeNode = SouthboundUtil.readNode(transaction, bridgeIid);
                     if (bridgeNode.isPresent()) {
-                        bridgeNodes.put(bridgeIid, bridgeNode.get());
+                        bridgeNodes.put(bridgeIid, bridgeNode.orElseThrow());
                     } else {
                         LOG.warn("OVSDB bridge node was not found: {}", bridgeIid);
                     }
index 2d56395cffebb98534455a1dcdb940f1a341ce05..eb208327cb903a9d377575c09bd540850c036b84 100644 (file)
@@ -117,10 +117,9 @@ public class OvsdbManagersUpdateCommand extends AbstractTransactionCommand {
         final Optional<Node> ovsdbNode = SouthboundUtil.readNode(transaction, connectionIId);
         if (ovsdbNode.isPresent()) {
             final List<ManagerEntry> managerEntries =
-                    SouthboundMapper.createManagerEntries(ovsdbNode.get(), newUpdatedManagerRows);
+                    SouthboundMapper.createManagerEntries(ovsdbNode.orElseThrow(), newUpdatedManagerRows);
 
-            LOG.debug("Update Ovsdb Node : {} with manager entries : {}",
-                    ovsdbNode.get(), managerEntries);
+            LOG.debug("Update Ovsdb Node : {} with manager entries : {}", ovsdbNode.orElseThrow(), managerEntries);
             for (ManagerEntry managerEntry : managerEntries) {
                 InstanceIdentifier<ManagerEntry> iid = connectionIId
                         .augmentation(OvsdbNodeAugmentation.class)
index aa194b5f3c9d0817d197693401259421ef2c6ab5..7d5362f0523c7e9004dc07d254c77d8212549502 100644 (file)
@@ -44,7 +44,7 @@ public class OvsdbNodeRemoveCommand extends AbstractTransactionCommand {
         try {
             ovsdbNodeOptional = ovsdbNodeFuture.get();
             if (ovsdbNodeOptional.isPresent()) {
-                Node ovsdbNode = ovsdbNodeOptional.get();
+                Node ovsdbNode = ovsdbNodeOptional.orElseThrow();
                 OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
                 if (checkIfOnlyConnectedManager(ovsdbNodeAugmentation)) {
                     if (ovsdbNodeAugmentation != null) {
index 17d5f2ceab9adb040c2d207019124e6ac47d92c6..da833983fd7b9757b8cfdffd47f3839a35151964 100644 (file)
@@ -128,7 +128,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         }
         Optional<Node> node = readNode(transaction, connectionIId);
         if (node.isPresent()) {
-            updateTerminationPoints(transaction, node.get());
+            updateTerminationPoints(transaction, node.orElseThrow());
         }
     }
 
@@ -137,19 +137,20 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         for (Entry<UUID, Port> portUpdate : portUpdatedRows.entrySet()) {
             String portName = null;
             portName = portUpdate.getValue().getNameColumn().getData();
-            Optional<InstanceIdentifier<Node>> bridgeIid = getTerminationPointBridge(portUpdate.getKey());
-            if (!bridgeIid.isPresent()) {
-                bridgeIid = getTerminationPointBridge(transaction, node, portName);
+            Optional<InstanceIdentifier<Node>> optBridgeIid = getTerminationPointBridge(portUpdate.getKey());
+            if (optBridgeIid.isEmpty()) {
+                optBridgeIid = getTerminationPointBridge(transaction, node, portName);
             }
-            if (bridgeIid.isPresent()) {
-                NodeId bridgeId = SouthboundMapper.createManagedNodeId(bridgeIid.get());
+            if (optBridgeIid.isPresent()) {
+                InstanceIdentifier<Node> bridgeIid = optBridgeIid.orElseThrow();
+                NodeId bridgeId = SouthboundMapper.createManagedNodeId(bridgeIid);
                 TerminationPointKey tpKey = new TerminationPointKey(new TpId(portName));
-                getOvsdbConnectionInstance().updatePortInterface(portName, bridgeIid.get());
+                getOvsdbConnectionInstance().updatePortInterface(portName, bridgeIid);
                 TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
                 tpBuilder.withKey(tpKey);
                 tpBuilder.setTpId(tpKey.getTpId());
                 InstanceIdentifier<TerminationPoint> tpPath =
-                        getInstanceIdentifier(bridgeIid.get(), portUpdate.getValue());
+                        getInstanceIdentifier(bridgeIid, portUpdate.getValue());
                 OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
                         new OvsdbTerminationPointAugmentationBuilder();
                 buildTerminationPoint(transaction, tpPath, tpAugmentationBuilder, node, portUpdate);
@@ -178,7 +179,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
             if (getOvsdbConnectionInstance().getPortInterface(interfaceName) != null) {
                 bridgeIid = Optional.of(getOvsdbConnectionInstance().getPortInterface(interfaceName));
             }
-            if (!bridgeIid.isPresent()) {
+            if (bridgeIid.isEmpty()) {
                 bridgeIid = getTerminationPointBridge(transaction, node, interfaceName);
             }
             if (bridgeIid.isPresent()) {
@@ -190,7 +191,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
                         new OvsdbTerminationPointAugmentationBuilder();
                 buildTerminationPoint(tpAugmentationBuilder, interfaceUpdate.getValue());
                 tpBuilder.addAugmentation(tpAugmentationBuilder.build());
-                NodeId bridgeId = SouthboundMapper.createManagedNodeId(bridgeIid.get());
+                NodeId bridgeId = SouthboundMapper.createManagedNodeId(bridgeIid.orElseThrow());
                 InstanceIdentifier<TerminationPoint> tpPath = InstanceIdentifier
                         .create(NetworkTopology.class)
                         .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
@@ -205,11 +206,9 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
     protected void updateToDataStore(ReadWriteTransaction transaction, TerminationPointBuilder tpBuilder,
                                      InstanceIdentifier<TerminationPoint> tpPath, boolean merge) {
         if (merge) {
-            transaction.merge(LogicalDatastoreType.OPERATIONAL,
-                    tpPath, tpBuilder.build());
+            transaction.merge(LogicalDatastoreType.OPERATIONAL, tpPath, tpBuilder.build());
         } else {
-            transaction.put(LogicalDatastoreType.OPERATIONAL,
-                    tpPath, tpBuilder.build());
+            transaction.put(LogicalDatastoreType.OPERATIONAL, tpPath, tpBuilder.build());
         }
     }
 
@@ -280,7 +279,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
             Optional<Node> optManagedNode = SouthboundUtil.readNode(transaction,
                     (InstanceIdentifier<Node>)managedNodeEntry.getBridgeRef().getValue());
             if (optManagedNode.isPresent()) {
-                Node managedNode = optManagedNode.get();
+                Node managedNode = optManagedNode.orElseThrow();
                 Map<TerminationPointKey, TerminationPoint> tpEntrys = managedNode.getTerminationPoint();
                 if (tpEntrys != null) {
                     TerminationPoint tpEntry = tpEntrys.get(new TerminationPointKey(tpId));
index 648cb3279c36af2f98034c9dae6be385533b2338..a5851eba33f3bb3df9b11772f13f445d422cbf03 100644 (file)
@@ -57,7 +57,7 @@ public class OvsdbQosRemovedCommand extends AbstractTransactionCommand {
             InstanceIdentifier<Node> ovsdbNodeIid =
                     SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance().getNodeId());
             for (UUID qosUuid : removedQosRows.keySet()) {
-                QosEntriesKey qosKey = getQosEntriesKey(ovsdbNode.get(), qosUuid);
+                QosEntriesKey qosKey = getQosEntriesKey(ovsdbNode.orElseThrow(), qosUuid);
                 if (qosKey != null) {
                     InstanceIdentifier<QosEntries> iid = ovsdbNodeIid
                         .augmentation(OvsdbNodeAugmentation.class)
index c779ff69a1d008edc70e8c56befb86581398e2ff..0cafa8e7a34bd5ac997a03302d69bc256e8cbf86 100644 (file)
@@ -104,20 +104,18 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
                 QosEntriesBuilder qosEntryBuilder = new QosEntriesBuilder();
                 qosEntryBuilder.setQosId(new Uri(getQosId(qos)));
                 qosEntryBuilder.setQosUuid(new Uuid(entry.getKey().toString()));
-                qosEntryBuilder.setQosType(
-                        SouthboundMapper.createQosType(qos.getTypeColumn().getData()));
+                qosEntryBuilder.setQosType(SouthboundMapper.createQosType(qos.getTypeColumn().getData()));
                 Qos oldQos = oldQosRows.get(entry.getKey());
                 setOtherConfig(transaction, qosEntryBuilder, oldQos, qos, nodeIId);
                 setExternalIds(transaction, qosEntryBuilder, oldQos, qos, nodeIId);
-                setQueueList(transaction, qosEntryBuilder, oldQos, qos, nodeIId, ovsdbNode.get());
+                setQueueList(transaction, qosEntryBuilder, oldQos, qos, nodeIId, ovsdbNode.orElseThrow());
 
                 QosEntries qosEntry = qosEntryBuilder.build();
-                LOG.debug("Update Ovsdb Node {} with qos entries {}",ovsdbNode.get(), qosEntry);
+                LOG.debug("Update Ovsdb Node {} with qos entries {}", ovsdbNode.orElseThrow(), qosEntry);
                 InstanceIdentifier<QosEntries> iid = nodeIId
                         .augmentation(OvsdbNodeAugmentation.class)
                         .child(QosEntries.class, qosEntry.key());
-                transaction.merge(LogicalDatastoreType.OPERATIONAL,
-                        iid, qosEntry);
+                transaction.merge(LogicalDatastoreType.OPERATIONAL, iid, qosEntry);
             }
         }
     }
index 5dd2a20182624ae4ee0c6944ec03de179a610ad4..b53800b045e1be180706845d02581e555e0812f0 100644 (file)
@@ -56,7 +56,7 @@ public class OvsdbQueueRemovedCommand extends AbstractTransactionCommand {
             InstanceIdentifier<Node> ovsdbNodeIid =
                     SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance().getNodeId());
             for (UUID queueUuid : removedQueueRows.keySet()) {
-                QueuesKey queueKey = getQueueKey(ovsdbNode.get(), queueUuid);
+                QueuesKey queueKey = getQueueKey(ovsdbNode.orElseThrow(), queueUuid);
                 if (queueKey != null) {
                     InstanceIdentifier<Queues> iid = ovsdbNodeIid
                         .augmentation(OvsdbNodeAugmentation.class)
index 571256a2181ccbe186082060d74dbba16f4aa72a..082bad34bd40686ed03c309667c4ff0e006dbdbd 100644 (file)
@@ -99,7 +99,7 @@ public class OvsdbQueueUpdateCommand extends AbstractTransactionCommand {
                 setExternalIds(transaction, queuesBuilder, oldQueue, queue, nodeIId);
 
                 Queues queues = queuesBuilder.build();
-                LOG.debug("Update Ovsdb Node {} with queue entries {}",ovsdbNode.get(), queues);
+                LOG.debug("Update Ovsdb Node {} with queue entries {}",ovsdbNode.orElseThrow(), queues);
                 InstanceIdentifier<Queues> iid = nodeIId
                         .augmentation(OvsdbNodeAugmentation.class)
                         .child(Queues.class, queues.key());
index ad0df27cdcd930a9d987eb7efd63b9393a6dc61d..41593d5370652af7e828353b930a889e314c29f6 100644 (file)
@@ -77,8 +77,7 @@ public class BridgeOperationalStateTest {
 
     @Test
     public void testGetBridgeNode() {
-        Optional<Node> optNodes = briOperationState.getBridgeNode(nodeIid);
-        assertEquals(brNode, optNodes.get());
+        assertEquals(Optional.of(brNode), briOperationState.getBridgeNode(nodeIid));
     }
 
     @Test
@@ -96,7 +95,7 @@ public class BridgeOperationalStateTest {
         Optional<OvsdbBridgeAugmentation> ovsdbBriAugOptional = briOperationState.getOvsdbBridgeAugmentation(
             InstanceIdentifier.create(NetworkTopology.class));
         assertNotNull(ovsdbBriAugOptional);
-        assertTrue(ovsdbBriAugOptional.get() instanceof OvsdbBridgeAugmentation);
+        assertTrue(ovsdbBriAugOptional.orElseThrow() instanceof OvsdbBridgeAugmentation);
     }
 
     @Test
@@ -136,7 +135,7 @@ public class BridgeOperationalStateTest {
         Optional<OvsdbTerminationPointAugmentation> ovsdbTermPointOpt = briOperationState
                 .getOvsdbTerminationPointAugmentation(InstanceIdentifier.create(NetworkTopology.class));
         assertNotNull(ovsdbTermPointOpt);
-        assertTrue(ovsdbTermPointOpt.get() instanceof OvsdbTerminationPointAugmentation);
+        assertTrue(ovsdbTermPointOpt.orElseThrow() instanceof OvsdbTerminationPointAugmentation);
     }
 
     @Test
index 1460d8bbbac9262e012931bb30d49101169ee2ae..c512f61fac8aeed5c1263bd1aff289f8beaf321d 100644 (file)
@@ -117,7 +117,7 @@ public class MdsalUtils {
             final LogicalDatastoreType store, final InstanceIdentifier<? extends DataObject> path) {
         Optional<D> optionalDataObject = readOptional(store, path);
         if (optionalDataObject.isPresent()) {
-            return optionalDataObject.get();
+            return optionalDataObject.orElseThrow();
         }
         LOG.debug("{}: Failed to read {}",
                 Thread.currentThread().getStackTrace()[1], path);
index 0cd742b6e9509cb577b39a9f33ec14382aa1b73a..c687b69a7b044e31e3a7d076bfadeceaacd1b6f6 100644 (file)
@@ -170,11 +170,7 @@ public class MdsalUtilsAsyncTest extends AbstractDataBrokerTest {
                 Optional<Node> optNode;
                 try {
                     optNode = future.get();
-                    if (optNode.isPresent()) {
-                        assertEquals(DATA, optNode.get());
-                    } else {
-                        fail("Couldn't read node");
-                    }
+                    assertEquals(Optional.of(DATA), optNode);
                 } catch (InterruptedException | ExecutionException e) {
                     fail(e.getMessage());
                 }
@@ -192,7 +188,7 @@ public class MdsalUtilsAsyncTest extends AbstractDataBrokerTest {
             final Optional<Node> result = databroker.newReadOnlyTransaction().read(
                     LogicalDatastoreType.CONFIGURATION, TEST_IID).get();
             if (result.isPresent()) {
-                return result.get();
+                return result.orElseThrow();
             }
         } catch (InterruptedException | ExecutionException e) {
             fail(e.getMessage());