Search in sources :

Example 6 with DataObjectModification

use of org.opendaylight.controller.md.sal.binding.api.DataObjectModification in project lispflowmapping by opendaylight.

the class VppEndpointListener method handleChange.

private ListenableFuture<Void> handleChange(DataObjectModification modification) {
    Collection<DataObjectModification<? extends DataObject>> modifiedChildren = modification.getModifiedChildren();
    List<ListenableFuture<KeyedInstanceIdentifier<Node, NodeKey>>> processingTasks = new ArrayList<>();
    for (DataObjectModification modifiedNode : modifiedChildren) {
        final Node newOrModifiedNode = (Node) modifiedNode.getDataAfter();
        ListenableFuture<KeyedInstanceIdentifier<Node, NodeKey>> processingTask = processNode(newOrModifiedNode);
        Futures.addCallback(processingTask, new FutureCallback<KeyedInstanceIdentifier<Node, NodeKey>>() {

            @Override
            public void onSuccess(@Nullable KeyedInstanceIdentifier<Node, NodeKey> kiiToNode) {
                hostInformationManager.addHostRelatedInfo(newOrModifiedNode.getNodeId().getValue(), LispAddressUtil.toRloc(vppNodeReader.rlocIpOfNode(kiiToNode)));
            }

            @Override
            public void onFailure(Throwable throwable) {
                LOG.debug("Couldn't process {}", newOrModifiedNode.getNodeId().getValue());
            }
        }, MoreExecutors.directExecutor());
        processingTasks.add(processNode(newOrModifiedNode));
    }
    return Futures.immediateFuture(null);
}
Also used : DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Aggregations

DataObjectModification (org.opendaylight.controller.md.sal.binding.api.DataObjectModification)6 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)4 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Optional (com.google.common.base.Optional)1 Sets (com.google.common.collect.Sets)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Objects (java.util.Objects)1 Set (java.util.Set)1 BiPredicate (java.util.function.BiPredicate)1