Migrate pcep to MD-SAL APIs
[bgpcep.git] / pcep / topology / cli / src / main / java / org / opendaylight / protocol / pcep / cli / utils / PcepStateUtils.java
index 5a12ae60f71a891a73c4dc4980f894ca6dcaa5bd..75dc3c5f0ccceed61593f9b07ef0f2c41d9519fa 100644 (file)
@@ -12,9 +12,9 @@ import java.util.Arrays;
 import java.util.concurrent.ExecutionException;
 import org.apache.karaf.shell.support.table.ShellTable;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug;
@@ -67,7 +67,7 @@ public final class PcepStateUtils {
             stream.println(String.format("Node [%s] not found", nodeId));
             return;
         }
-        final PcepTopologyNodeStatsAug state = node.getAugmentation(PcepTopologyNodeStatsAug.class);
+        final PcepTopologyNodeStatsAug state = node.augmentation(PcepTopologyNodeStatsAug.class);
         if (state == null) {
             stream.println(String.format("State not found for [%s]", nodeId));
             return;
@@ -90,7 +90,7 @@ public final class PcepStateUtils {
         addHeader(table, "Local preferences");
         final LocalPref localPref = pcepSessionState.getLocalPref();
         showPreferences(table, localPref);
-        final PcepEntityIdStatsAug entAug = localPref.getAugmentation(PcepEntityIdStatsAug.class);
+        final PcepEntityIdStatsAug entAug = localPref.augmentation(PcepEntityIdStatsAug.class);
         if (entAug != null) {
             table.addRow().addContent("Speaker Entity Identifier",
                     Arrays.toString(entAug.getSpeakerEntityIdValue()));
@@ -128,7 +128,7 @@ public final class PcepStateUtils {
         if (capa == null) {
             return;
         }
-        final StatefulCapabilitiesStatsAug stateFulCapa = capa.getAugmentation(StatefulCapabilitiesStatsAug.class);
+        final StatefulCapabilitiesStatsAug stateFulCapa = capa.augmentation(StatefulCapabilitiesStatsAug.class);
         if (stateFulCapa != null) {
             addHeader(table, "Stateful Capabilities");
             table.addRow().addContent("Stateful", stateFulCapa.isStateful());
@@ -148,7 +148,7 @@ public final class PcepStateUtils {
         table.addRow().addContent("Sent Msg Count", messages.getSentMsgCount());
         table.addRow().addContent("Unknown Msg Received", messages.getUnknownMsgReceived());
 
-        final StatefulMessagesStatsAug statefulMessages = messages.getAugmentation(StatefulMessagesStatsAug.class);
+        final StatefulMessagesStatsAug statefulMessages = messages.augmentation(StatefulMessagesStatsAug.class);
         if (statefulMessages == null) {
             return;
         }
@@ -205,10 +205,10 @@ public final class PcepStateUtils {
                 .child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
                 .child(Node.class, new NodeKey(new NodeId(nodeId))).build();
 
-        final ReadOnlyTransaction rot = dataBroker.newReadOnlyTransaction();
+        final ReadTransaction rot = dataBroker.newReadOnlyTransaction();
 
         try {
-            return rot.read(LogicalDatastoreType.OPERATIONAL, topology).get().orNull();
+            return rot.read(LogicalDatastoreType.OPERATIONAL, topology).get().orElse(null);
         } catch (final InterruptedException | ExecutionException e) {
             LOG.warn("Failed to read node {}", nodeId, e);
         }