Changes to NextHopManager 44/20344/2
authorAbhinav Gupta <abhi3123@gmail.com>
Thu, 14 May 2015 08:42:49 +0000 (14:12 +0530)
committerAbhinav Gupta <abhi3123@gmail.com>
Thu, 14 May 2015 09:46:49 +0000 (15:16 +0530)
1. Changed VpnInterfaceChangeListener DS type to Operational.
2. Added logging statements.

Change-Id: Ia212ebe2e342eefe7cb570963fab327bdd207280
Signed-off-by: Abhinav Gupta <abhi3123@gmail.com>
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java

index 571cdce3ad91cce5a23fa109fd5d88cb9d46a805..5e565720f59df0f706c864c9546ee188d4d9edb5 100644 (file)
@@ -106,6 +106,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             .build();
         //TODO: Error handling
         Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
+        LOG.trace("NextHopPointerPool result : {}", result);
 //            try {
 //                LOG.info("Result2: {}",result.get());
 //            } catch (InterruptedException | ExecutionException e) {
@@ -125,6 +126,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
         Optional<VpnInstance1> vpn = read(LogicalDatastoreType.OPERATIONAL, idx);
 
         if (vpn.isPresent()) {
+            LOG.debug("VPN id returned: {}", vpn.get().getVpnId());
             return vpn.get().getVpnId();
         } else {
             return -1;
@@ -134,6 +136,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
     private long getDpnId(String ifName) {
         String[] fields = ifName.split(":");
         long dpn = Integer.parseInt(fields[1]);
+        LOG.debug("DpnId: {}", dpn);
         return dpn;
     }
 
@@ -170,6 +173,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
                listActionInfo.add(new ActionInfo(ActionType.pop_mpls, new String[]{}));
             } else {
                 //FIXME: Log message here.
+                LOG.debug("mac address for new local nexthop is null");
             }
             listBucketInfo.add(bucket);
             GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
@@ -231,7 +235,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         InstanceIdentifier<VpnNexthop> id1 = idBuilder
                 .child(VpnNexthop.class, new VpnNexthopKey(ipPrefix)).build();
-        LOG.trace("Adding nextHop {} to Operational DS", nh);
+        LOG.trace("Adding vpnnextHop {} to Operational DS", nh);
         asyncWrite(LogicalDatastoreType.OPERATIONAL, id1, nh, DEFAULT_CALLBACK);
 
     }
@@ -249,6 +253,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
                 .setKey(new TunnelNexthopsKey(dpnId))
                 .setDpnId(dpnId)
                 .build();
+            LOG.trace("Adding tunnelnextHop {} to Operational DS for a new node", node);
             asyncWrite(LogicalDatastoreType.OPERATIONAL, id, node, DEFAULT_CALLBACK);
         }
 
@@ -260,7 +265,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         InstanceIdentifier<TunnelNexthop> id1 = idBuilder
                 .child(TunnelNexthop.class, new TunnelNexthopKey(ipPrefix)).build();
-
+        LOG.trace("Adding tunnelnextHop {} to Operational DS for a dpn node", nh);
         asyncWrite(LogicalDatastoreType.OPERATIONAL, id1, nh, DEFAULT_CALLBACK);
 
     }
@@ -279,6 +284,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             for (VpnNexthop nexthop : nexthops) {
                 if (nexthop.getIpAddress().equals(ipAddress)) {
                     // return nexthop 
+                    LOG.trace("VpnNextHop : {}",nexthop);
                     return nexthop;
                 }
             }
@@ -299,6 +305,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             List<TunnelNexthop> nexthops = dpnNexthops.get().getTunnelNexthop();
             for (TunnelNexthop nexthop : nexthops) {
                 if (nexthop.getIpAddress().equals(ipAddress)) {
+                    LOG.trace("TunnelNextHop : {}",nexthop);
                     return nexthop;
                 }
             }
@@ -313,6 +320,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             return vpnNextHop.getEgressPointer();
         } else {
             TunnelNexthop tunnelNextHop = getTunnelNexthop(dpnId, nextHopIp);
+            LOG.trace("NExtHopPointer : {}", tunnelNextHop.getEgressPointer());
             return tunnelNextHop.getEgressPointer();
         }
     }
@@ -324,6 +332,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
                 .child(TunnelNexthop.class, new TunnelNexthopKey(ipPrefix));
         InstanceIdentifier<TunnelNexthop> id = idBuilder.build();
         // remove from DS     
+        LOG.trace("Removing tunnel next hop from datastore : {}", id);
         delete(LogicalDatastoreType.OPERATIONAL, id);
     }
 
@@ -334,6 +343,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
                 .child(VpnNexthop.class, new VpnNexthopKey(ipPrefix));
         InstanceIdentifier<VpnNexthop> id = idBuilder.build();
         // remove from DS
+        LOG.trace("Removing vpn next hop from datastore : {}", id);
         delete(LogicalDatastoreType.OPERATIONAL, id);
     }
 
@@ -352,6 +362,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             removeVpnNexthopFromDS(vpnId, ipAddress);
         } else {
             //throw error
+            LOG.error("removal of local next hop failed");
         }
 
     }
@@ -372,6 +383,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             removeTunnelNexthopFromDS(dpnId, ipAddress);
         } else {
             //throw error
+            LOG.error("removal of remote next hop failed : dpnid : {}, ipaddress : {}", dpnId, ipAddress);
         }
 
     }
index 51494d92efcbffdea25f8bf7a76cf1712d792718..de61812fe958519ecc17da8c6822308b1f2c7027 100644 (file)
@@ -41,6 +41,7 @@ public class NexthopmgrProvider implements BindingAwareProvider, AutoCloseable {
 
     @Override
     public void onSessionInitiated(ProviderContext session) {
+        try {
         final  DataBroker dbx = session.getSALService(DataBroker.class);
         nhManager = new NexthopManager(dbx);
         vpnIfListener = new VpnInterfaceChangeListener(dbx, nhManager);
@@ -52,6 +53,11 @@ public class NexthopmgrProvider implements BindingAwareProvider, AutoCloseable {
         nhManager.setIdManager(idManager);
         nhManager.createNexthopPointerPool();
         LOG.info("NexthopmgrProvider Session Initiated");
+        }
+        catch (Exception e)
+        {
+            LOG.error("Error initializing services", e);
+        }
     }
 
     public void setMdsalManager(IMdsalApiManager mdsalManager) {
index 69cce9f9f0b78e4728a49f62c51196558aec17d0..43a5fc509fea72e2628d3b2a7cabd65bde616216 100644 (file)
@@ -71,7 +71,7 @@ public class OdlInterfaceChangeListener extends AbstractDataChangeListener<Inter
 
     @Override
     protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
-        LOG.trace("key: " + identifier + ", value=" + intrf );
+        LOG.trace("Adding Interface : key: " + identifier + ", value=" + intrf );
 
         if (intrf.getType().equals(L3tunnel.class)) {
             IfL3tunnel intfData = intrf.getAugmentation(IfL3tunnel.class);
@@ -97,6 +97,7 @@ public class OdlInterfaceChangeListener extends AbstractDataChangeListener<Inter
     @Override
     protected void remove(InstanceIdentifier<Interface> identifier,
             Interface intrf) {
+        LOG.trace("Removing interface : key: " + identifier + ", value=" + intrf );
         if (intrf.getType().equals(L3tunnel.class)) {
             long dpnId = interfaceManager.getDpnForInterface(intrf.getName());
             IfL3tunnel intfData = intrf.getAugmentation(IfL3tunnel.class);
index 08ccadcfe9b497196b758fe3e948a3c0601c92a8..cb2cc623e499e940e1790920556d109d36bfed76 100644 (file)
@@ -57,7 +57,7 @@ public class VpnInterfaceChangeListener extends AbstractDataChangeListener<Adjac
 
     private void registerListener(final DataBroker db) {
         try {
-            listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+            listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
                     getWildCardPath(), VpnInterfaceChangeListener.this, DataChangeScope.SUBTREE);
         } catch (final Exception e) {
             LOG.error("Nexthop Manager DataChange listener registration fail!", e);
@@ -68,9 +68,9 @@ public class VpnInterfaceChangeListener extends AbstractDataChangeListener<Adjac
     @Override
     protected void add(InstanceIdentifier<Adjacencies> identifier,
             Adjacencies adjs) {
-
+        LOG.trace("Adding adjacencies interface : key: " + identifier + ", value=" + adjs );
         InstanceIdentifier<VpnInterface> vpnIfId = identifier.firstIdentifierOf(VpnInterface.class);
-        Optional<VpnInterface> vpnIf = read(LogicalDatastoreType.CONFIGURATION, vpnIfId);
+        Optional<VpnInterface> vpnIf = read(LogicalDatastoreType.OPERATIONAL, vpnIfId);
         VpnInterface vpnIfData = vpnIf.get();
 
         List<Adjacency> adjList = adjs.getAdjacency();