import java.net.ConnectException;
import java.net.UnknownHostException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
}
private void updateData(@Nonnull Collection<DataTreeModification<Node>> changes) {
- for (Entry<InstanceIdentifier<Node>, OvsdbConnectionInstance> connectionInstanceEntry :
- connectionInstancesFromChanges(changes).entrySet()) {
- OvsdbConnectionInstance connectionInstance = connectionInstanceEntry.getValue();
+ for (Entry<OvsdbConnectionInstance, Collection<DataTreeModification<Node>>> connectionInstanceEntry :
+ changesPerConnectionInstance(changes).entrySet()) {
+ OvsdbConnectionInstance connectionInstance = connectionInstanceEntry.getKey();
+ Collection<DataTreeModification<Node>> clientChanges = connectionInstanceEntry.getValue();
connectionInstance.transact(new TransactCommandAggregator(),
- new BridgeOperationalState(db, changes), changes, instanceIdentifierCodec);
+ new BridgeOperationalState(db, clientChanges), clientChanges, instanceIdentifierCodec);
}
}
- private Map<InstanceIdentifier<Node>, OvsdbConnectionInstance> connectionInstancesFromChanges(
+ private Map<OvsdbConnectionInstance, Collection<DataTreeModification<Node>>> changesPerConnectionInstance(
@Nonnull Collection<DataTreeModification<Node>> changes) {
- Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> result =
- new HashMap<>();
+ Map<OvsdbConnectionInstance, Collection<DataTreeModification<Node>>> result = new HashMap<>();
for (DataTreeModification<Node> change : changes) {
OvsdbConnectionInstance client = null;
Node node = change.getRootNode().getDataAfter() != null
*/
if ( cm.getHasDeviceOwnership(client.getMDConnectionInfo())) {
LOG.debug("*This* instance of southbound plugin is an owner of the device {}", node);
- result.put(change.getRootPath().getRootIdentifier(), client);
+ result.computeIfAbsent(client, key -> new ArrayList<>()).add(change);
} else {
LOG.debug("*This* instance of southbound plugin is *not* an owner of the device {}", node);
}
LOG.debug("Did not find client for {}", node);
}
}
+
return result;
}
}