MD-SAL API integration
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / transactions / md / OvsdbQosUpdateCommand.java
index 916874f59af6f0a2e7e9130051d67e132a03c217..190153c580fc30552f15682063177b62abe20873 100644 (file)
@@ -8,15 +8,15 @@
 
 package org.opendaylight.ovsdb.southbound.transactions.md;
 
-import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
@@ -57,9 +57,9 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
 
     private final InstanceIdentifierCodec instanceIdentifierCodec;
 
-    private Map<UUID, Qos> updatedQosRows;
-    private Map<UUID, Qos> oldQosRows;
-    private Map<UUID, Queue> updatedQueueRows;
+    private final Map<UUID, Qos> updatedQosRows;
+    private final Map<UUID, Qos> oldQosRows;
+    private final Map<UUID, Queue> updatedQueueRows;
 
     public OvsdbQosUpdateCommand(InstanceIdentifierCodec instanceIdentifierCodec, OvsdbConnectionInstance key,
             TableUpdates updates, DatabaseSchema dbSchema) {
@@ -114,7 +114,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
                 LOG.debug("Update Ovsdb Node {} with qos entries {}",ovsdbNode.get(), qosEntry);
                 InstanceIdentifier<QosEntries> iid = nodeIId
                         .augmentation(OvsdbNodeAugmentation.class)
-                        .child(QosEntries.class, qosEntry.getKey());
+                        .child(QosEntries.class, qosEntry.key());
                 transaction.merge(LogicalDatastoreType.OPERATIONAL,
                         iid, qosEntry);
             }
@@ -160,7 +160,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
             return (InstanceIdentifier<Queues>) instanceIdentifierCodec.bindingDeserializerOrNull(
                     queue.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY));
         } else {
-            OvsdbNodeAugmentation node = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+            OvsdbNodeAugmentation node = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
             if (node.getQueues() != null && !node.getQueues().isEmpty()) {
                 for (Queues q : node.getQueues()) {
                     if (q.getQueueUuid().equals(new Uuid(queueUuid.toString()))) {
@@ -190,7 +190,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
         if (oldQos != null && oldQos.getOtherConfigColumn() != null) {
             oldOtherConfigs = oldQos.getOtherConfigColumn().getData();
         }
-        if ((oldOtherConfigs != null) && !oldOtherConfigs.isEmpty()) {
+        if (oldOtherConfigs != null && !oldOtherConfigs.isEmpty()) {
             removeOldConfigs(transaction, qosEntryBuilder, oldOtherConfigs, qos, nodeIId);
         }
         if (otherConfigs != null && !otherConfigs.isEmpty()) {
@@ -203,7 +203,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
             Qos qos, InstanceIdentifier<Node> nodeIId) {
         InstanceIdentifier<QosEntries> qosIId = nodeIId
                 .augmentation(OvsdbNodeAugmentation.class)
-                .child(QosEntries.class, qosEntryBuilder.build().getKey());
+                .child(QosEntries.class, qosEntryBuilder.build().key());
         Set<String> otherConfigKeys = oldOtherConfigs.keySet();
         for (String otherConfigKey : otherConfigKeys) {
             KeyedInstanceIdentifier<QosOtherConfig, QosOtherConfigKey> otherIId =
@@ -215,11 +215,10 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
 
     private void setNewOtherConfigs(QosEntriesBuilder qosEntryBuilder,
             Map<String, String> otherConfig) {
-        Set<String> otherConfigKeys = otherConfig.keySet();
         List<QosOtherConfig> otherConfigList = new ArrayList<>();
-        String otherConfigValue;
-        for (String otherConfigKey : otherConfigKeys) {
-            otherConfigValue = otherConfig.get(otherConfigKey);
+        for (Entry<String, String> entry : otherConfig.entrySet()) {
+            String otherConfigKey = entry.getKey();
+            String otherConfigValue = entry.getValue();
             if (otherConfigKey != null && otherConfigValue != null) {
                 otherConfigList.add(new QosOtherConfigBuilder().setOtherConfigKey(otherConfigKey)
                         .setOtherConfigValue(otherConfigValue).build());
@@ -240,7 +239,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
         if (oldQos != null && oldQos.getExternalIdsColumn() != null) {
             oldExternalIds = oldQos.getExternalIdsColumn().getData();
         }
-        if ((oldExternalIds != null) && !oldExternalIds.isEmpty()) {
+        if (oldExternalIds != null && !oldExternalIds.isEmpty()) {
             removeOldExternalIds(transaction, qosEntryBuilder, oldExternalIds, qos, nodeIId);
         }
         if (externalIds != null && !externalIds.isEmpty()) {
@@ -253,7 +252,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
             Qos qos, InstanceIdentifier<Node> nodeIId) {
         InstanceIdentifier<QosEntries> qosIId = nodeIId
                 .augmentation(OvsdbNodeAugmentation.class)
-                .child(QosEntries.class, qosEntryBuilder.build().getKey());
+                .child(QosEntries.class, qosEntryBuilder.build().key());
         Set<String> externalIdsKeys = oldExternalIds.keySet();
         for (String extIdKey : externalIdsKeys) {
             KeyedInstanceIdentifier<QosExternalIds, QosExternalIdsKey> externalIId =
@@ -265,11 +264,10 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
 
     private void setNewExternalIds(QosEntriesBuilder qosEntryBuilder,
             Map<String, String> externalIds) {
-        Set<String> externalIdsKeys = externalIds.keySet();
         List<QosExternalIds> externalIdsList = new ArrayList<>();
-        String extIdValue;
-        for (String extIdKey : externalIdsKeys) {
-            extIdValue = externalIds.get(extIdKey);
+        for (Entry<String, String> entry : externalIds.entrySet()) {
+            String extIdKey = entry.getKey();
+            String extIdValue = entry.getValue();
             if (extIdKey != null && extIdValue != null) {
                 externalIdsList.add(new QosExternalIdsBuilder().setQosExternalIdKey(extIdKey)
                         .setQosExternalIdValue(extIdValue).build());
@@ -290,7 +288,7 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
         if (oldQos != null && oldQos.getQueuesColumn() != null) {
             oldQueueList = oldQos.getQueuesColumn().getData();
         }
-        if ((oldQueueList != null) && !oldQueueList.isEmpty()) {
+        if (oldQueueList != null && !oldQueueList.isEmpty()) {
             removeOldQueues(transaction, qosEntryBuilder, oldQueueList, qos, nodeIId);
         }
         if (queueList != null && !queueList.isEmpty()) {
@@ -303,12 +301,11 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
             Qos qos, InstanceIdentifier<Node> nodeIId) {
         InstanceIdentifier<QosEntries> qosIId = nodeIId
                 .augmentation(OvsdbNodeAugmentation.class)
-                .child(QosEntries.class, qosEntryBuilder.build().getKey());
+                .child(QosEntries.class, qosEntryBuilder.build().key());
         Collection<Long> queueListKeys = oldQueueList.keySet();
         for (Long queueListKey : queueListKeys) {
             KeyedInstanceIdentifier<QueueList, QueueListKey> otherIId =
-                    qosIId
-                    .child(QueueList.class, new QueueListKey(new Long(queueListKey.toString())));
+                    qosIId.child(QueueList.class, new QueueListKey(Long.valueOf(queueListKey.toString())));
             transaction.delete(LogicalDatastoreType.OPERATIONAL, otherIId);
         }
     }
@@ -323,9 +320,9 @@ public class OvsdbQosUpdateCommand extends AbstractTransactionCommand {
                 newQueueList.add(
                     new QueueListBuilder()
                     .setQueueNumber(queueEntry.getKey())
-                    .setQueueRef(new OvsdbQueueRef(queueIid))
-                    .setQueueUuid(new Uuid(queueEntry.getValue().toString())).build());
+                    .setQueueRef(new OvsdbQueueRef(queueIid)).build());
             }
+
         }
         qosEntryBuilder.setQueueList(newQueueList);
     }