Magnesium platform upgrade
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / intenthandler / listener / VppEndpointListener.java
index 2692199b4e6a9dc74af4b650ddf09a28f128d6ab..2dcb8d9c677ceed5be5ed6decf5f488d3fd7759b 100644 (file)
@@ -7,34 +7,30 @@
  */
 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;
@@ -61,7 +57,7 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
     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();
@@ -77,16 +73,16 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
 
         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;
@@ -107,7 +103,7 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
             }
             Futures.addCallback(modificationTaskHandler, new FutureCallback<Void>() {
                 @Override
-                public void onSuccess(@Nullable Void vd) {
+                public void onSuccess(Void vd) {
                     LOG.debug("VppEndpoint modification handled successfully!");
                 }
 
@@ -115,7 +111,7 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
                 public void onFailure(Throwable throwable) {
                     LOG.debug("Failed to handle VppEndpoint modifications!");
                 }
-            });
+            }, MoreExecutors.directExecutor());
         }
     }
 
@@ -127,8 +123,8 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
             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)));
                 }
 
@@ -136,7 +132,7 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
                 public void onFailure(Throwable throwable) {
                     LOG.debug("Couldn't process {}", newOrModifiedNode.getNodeId().getValue());
                 }
-            });
+            }, MoreExecutors.directExecutor());
             processingTasks.add(processNode(newOrModifiedNode));
         }
         return Futures.immediateFuture(null);
@@ -150,13 +146,8 @@ public class VppEndpointListener implements AutoCloseable, ClusteredDataTreeChan
                 });
 
         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) {