Fixed two minor issues : 89/2089/2
authorAnil Vishnoi <avishnoi@in.ibm.com>
Tue, 22 Oct 2013 21:56:43 +0000 (03:26 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 22 Oct 2013 22:15:28 +0000 (22:15 +0000)
    1) Throw error is VIP is not attached to any pool
    2) If source and destination machines are connected to same switch node, routing service returns null as a path between same node. Fixed this scenario by adding a check.

Change-Id: I8399bf40af2e1c90501240249802f8d89cc480e7
Signed-off-by: Anil Vishnoi <avishnoi@in.ibm.com>
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java

index 7eaa8b4ec03377cf429c67d670341dd74d20aa57..1e3b845b86c6fcb81e8719a8e7f98ccd1c4c8049 100644 (file)
@@ -230,6 +230,10 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager{
                     if(configManager.vipExists(vip)){
                         VIP vipWithPoolName = configManager.getVIPWithPoolName(vip);
                         String poolMemberIp = null;
                     if(configManager.vipExists(vip)){
                         VIP vipWithPoolName = configManager.getVIPWithPoolName(vip);
                         String poolMemberIp = null;
+                        if(vipWithPoolName.getPoolName() == null){
+                            lbsLogger.error("No pool attached. Please attach pool with the VIP -- {}",vip);
+                            return PacketResult.IGNORED;
+                        }
                         if(configManager.getPool(vipWithPoolName.getPoolName()).getLbMethod().equalsIgnoreCase(LBConst.ROUND_ROBIN_LB_METHOD)){
 
                             poolMemberIp = rrLBMethod.getPoolMemberForClient(client,vipWithPoolName);
                         if(configManager.getPool(vipWithPoolName.getPoolName()).getLbMethod().equalsIgnoreCase(LBConst.ROUND_ROBIN_LB_METHOD)){
 
                             poolMemberIp = rrLBMethod.getPoolMemberForClient(client,vipWithPoolName);
@@ -250,11 +254,23 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager{
                             lbsLogger.debug("Destination pool machine is connected to switch : {}",destNode.toString());
 
                             //Get path between both the nodes
                             lbsLogger.debug("Destination pool machine is connected to switch : {}",destNode.toString());
 
                             //Get path between both the nodes
-                            Path route = this.routing.getRoute(clientNode, destNode);
+                            NodeConnector forwardPort = null;
+
+                            if(clientNode.getNodeIDString().equals(destNode.getNodeIDString())){
+
+                                forwardPort = hnConnector.getnodeConnector();
 
 
-                            lbsLogger.info("Path between source (client) and destination switch nodes : {}",route.toString());
+                                lbsLogger.info("Both source (client) and destination pool machine is connected to same switch nodes. Respective ports are - {},{}",forwardPort,inPkt.getIncomingNodeConnector());
+
+                            }else{
 
 
-                            NodeConnector forwardPort = route.getEdges().get(0).getTailNodeConnector();
+                                Path route = this.routing.getRoute(clientNode, destNode);
+
+                                lbsLogger.info("Path between source (client) and destination switch nodes : {}",route.toString());
+
+                                forwardPort = route.getEdges().get(0).getTailNodeConnector();
+
+                            }
 
                             if(installLoadBalancerFlow(client,
                                                             vip,
 
                             if(installLoadBalancerFlow(client,
                                                             vip,