*/
package org.opendaylight.lispflowmapping.neutron.intenthandler.listener;
-import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
-
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
import org.opendaylight.lispflowmapping.neutron.intenthandler.IntentHandlerAsyncExecutorProvider;
import org.opendaylight.lispflowmapping.neutron.intenthandler.util.VppNetconfConnectionProbe;
import org.opendaylight.lispflowmapping.neutron.intenthandler.util.VppNodeReader;
-import org.opendaylight.lispflowmapping.neutron.mappingmanager.HostIdToRlocMapper;
+import org.opendaylight.lispflowmapping.neutron.mappingmanager.HostInformationManager;
+import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
private final ListenerRegistration<?> reg;
private final VppNodeReader vppNodeReader;
- private final HostIdToRlocMapper hostIdToRlocMapper;
+ private final HostInformationManager hostInformationManager;
private final Multimap<NodeId, KeyedInstanceIdentifier<Node, NodeKey>> nodeIdToKeyedInstanceIdentifierMap =
ArrayListMultimap.create();
vppNodeReader = new VppNodeReader(this.dataBroker, this.mountService);
- hostIdToRlocMapper = HostIdToRlocMapper.getInstance();
+ hostInformationManager = HostInformationManager.getInstance();
reg = dataBroker.registerDataTreeChangeListener(
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, topologyII), this);
+ DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, topologyII), this);
executorService = IntentHandlerAsyncExecutorProvider.getInstace().getExecutor();
}
@Override
- public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Topology>> changes) {
+ public void onDataTreeChanged(Collection<DataTreeModification<Topology>> changes) {
for (DataTreeModification<Topology> change : changes) {
final DataObjectModification<Topology> modification = change.getRootNode();
ListenableFuture<Void> modificationTaskHandler;
}
Futures.addCallback(modificationTaskHandler, new FutureCallback<Void>() {
@Override
- public void onSuccess(@Nullable Void vd) {
+ public void onSuccess(Void vd) {
LOG.debug("VppEndpoint modification handled successfully!");
}
public void onFailure(Throwable throwable) {
LOG.debug("Failed to handle VppEndpoint modifications!");
}
- });
+ }, MoreExecutors.directExecutor());
}
}
ListenableFuture<KeyedInstanceIdentifier<Node, NodeKey>> processingTask = processNode(newOrModifiedNode);
Futures.addCallback(processingTask, new FutureCallback<KeyedInstanceIdentifier<Node, NodeKey>>() {
@Override
- public void onSuccess(@Nullable KeyedInstanceIdentifier<Node, NodeKey> kiiToNode) {
- hostIdToRlocMapper.addMapping(newOrModifiedNode.getNodeId().getValue(),
+ public void onSuccess(KeyedInstanceIdentifier<Node, NodeKey> kiiToNode) {
+ hostInformationManager.addHostRelatedInfo(newOrModifiedNode.getNodeId().getValue(),
LispAddressUtil.toRloc(vppNodeReader.rlocIpOfNode(kiiToNode)));
}
public void onFailure(Throwable throwable) {
LOG.debug("Couldn't process {}", newOrModifiedNode.getNodeId().getValue());
}
- });
+ }, MoreExecutors.directExecutor());
processingTasks.add(processNode(newOrModifiedNode));
}
return Futures.immediateFuture(null);
});
return Futures.transform(probeVppNodeForConnection,
- new Function<Void, KeyedInstanceIdentifier<Node, NodeKey>>() {
- @Nullable
- @Override
- public KeyedInstanceIdentifier<Node, NodeKey> apply(@Nullable Void vd) {
- return nodeIdToKeyedInstanceIdentifierMap.get(newOrModifiedNode.getNodeId()).iterator().next();
- }
- });
+ vd -> nodeIdToKeyedInstanceIdentifierMap.get(newOrModifiedNode.getNodeId()).iterator().next(),
+ MoreExecutors.directExecutor());
}
private void processNodeOnConnection(final Node newOrModifiedNode) {