From b32496bf7fbf29526b2f58c600c96a83502b9c68 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 14 May 2015 14:12:49 +0530 Subject: [PATCH] Changes to NextHopManager 1. Changed VpnInterfaceChangeListener DS type to Operational. 2. Added logging statements. Change-Id: Ia212ebe2e342eefe7cb570963fab327bdd207280 Signed-off-by: Abhinav Gupta --- .../vpnservice/nexthopmgr/NexthopManager.java | 16 ++++++++++++++-- .../nexthopmgr/NexthopmgrProvider.java | 6 ++++++ .../nexthopmgr/OdlInterfaceChangeListener.java | 3 ++- .../nexthopmgr/VpnInterfaceChangeListener.java | 6 +++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java index 571cdce3..5e565720 100644 --- a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java +++ b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java @@ -106,6 +106,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable { .build(); //TODO: Error handling Future> 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 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 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 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 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 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 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); } } diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java index 51494d92..de61812f 100644 --- a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java +++ b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java @@ -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) { diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java index 69cce9f9..43a5fc50 100644 --- a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java +++ b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java @@ -71,7 +71,7 @@ public class OdlInterfaceChangeListener extends AbstractDataChangeListener 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 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); diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java index 08ccadcf..cb2cc623 100644 --- a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java +++ b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java @@ -57,7 +57,7 @@ public class VpnInterfaceChangeListener extends AbstractDataChangeListener identifier, Adjacencies adjs) { - + LOG.trace("Adding adjacencies interface : key: " + identifier + ", value=" + adjs ); InstanceIdentifier vpnIfId = identifier.firstIdentifierOf(VpnInterface.class); - Optional vpnIf = read(LogicalDatastoreType.CONFIGURATION, vpnIfId); + Optional vpnIf = read(LogicalDatastoreType.OPERATIONAL, vpnIfId); VpnInterface vpnIfData = vpnIf.get(); List adjList = adjs.getAdjacency(); -- 2.36.6