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;
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) {
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);
}
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()))) {
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()) {
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 =
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());
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()) {
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 =
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());
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()) {
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);
}
}
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);
}