Fcaps: changing alarm text parameter to be same while raising and clearing 19/48819/5
authorgowri <gowri.r@ericsson.com>
Wed, 30 Nov 2016 08:34:49 +0000 (14:04 +0530)
committerGowri R <gowri.r@ericsson.com>
Thu, 1 Dec 2016 09:19:12 +0000 (09:19 +0000)
Change-Id: I941aef182be4d3a1488399d8ea1eaa7432c707ff
Signed-off-by: gowri <gowri.r@ericsson.com>
fcapsapplication/fcapsapplication-impl/src/main/java/org/opendaylight/genius/fcapsapp/NodeEventListener.java
fcapsapplication/fcapsapplication-impl/src/main/java/org/opendaylight/genius/fcapsapp/alarm/AlarmAgent.java
itm/itm-impl/src/main/java/org/opendaylight/genius/itm/monitoring/ItmTunnelEventListener.java

index 60b59cd4a577188717be0f10f22d30279054389e..ea78937f44e3c9a88f8d23f291df11045d481f33 100644 (file)
@@ -85,7 +85,7 @@ public class NodeEventListener<D extends DataObject> implements ClusteredDataTre
                         if (mod.getDataBefore() == null) {
                             if (isNodeOwner(nodeId)) {
                                 LOG.debug("NodeAdded {} notification is received on host {}", nodeId, hostName);
-                                alarmAgent.clearControlPathAlarm(nodeId);
+                                alarmAgent.clearControlPathAlarm(nodeId, hostName);
                                 nodeUpdateCounter.nodeAddedNotification(nodeId, hostName);
                             } else {
                                 LOG.debug("ADD: Node {} is not connected to host {}", nodeId, hostName);
index 35c78d457b87d37fa07dfc10145319b2e3c93114..1b7a1b2f06c955feb569600878f5310a041270d4 100644 (file)
@@ -97,19 +97,18 @@ public class AlarmAgent {
      * @param host
      *         Controller hostname
      */
-    public void raiseControlPathAlarm(String nodeId,String host) {
-        StringBuilder alarmText = new StringBuilder();
+    public void raiseControlPathAlarm(String nodeId, String host) {
+        String alarmText;
         StringBuilder source = new StringBuilder();
 
         if (host != null) {
             try {
-                alarmText.append("OF Switch ").append(nodeId).append(" lost heart beat communication with controller ")
-                        .append(host);
+                alarmText = getAlarmText(nodeId, host);
                 source.append("Dpn=").append(nodeId);
 
                 s_logger.debug("Raising ControlPathConnectionFailure alarm... alarmText {} source {} ", alarmText, source);
                 //Invokes JMX raiseAlarm method
-                invokeFMraisemethod("ControlPathConnectionFailure", alarmText.toString(), source.toString());
+                invokeFMraisemethod("ControlPathConnectionFailure", alarmText, source.toString());
             } catch (Exception e) {
                 s_logger.error("Exception before invoking raise method in jmx {}", e);
             }
@@ -123,17 +122,26 @@ public class AlarmAgent {
      * @param nodeId
      *         Source of the alarm dpnId
      */
-    public void clearControlPathAlarm(String nodeId) {
+    public void clearControlPathAlarm(String nodeId, String host) {
         StringBuilder source = new StringBuilder();
+        String alarmText;
 
-        try {
-            source.append("Dpn=").append(nodeId);
-            s_logger.debug("Clearing ControlPathConnectionFailure alarm of source {} ", source);
-            //Invokes JMX clearAlarm method
-            invokeFMclearmethod("ControlPathConnectionFailure", "OF Switch gained communication with controller",
-                    source.toString());
-        } catch (Exception e) {
-            s_logger.error("Exception before invoking clear method jmx {}", e);
+        if (host != null) {
+            try {
+                alarmText = getAlarmText(nodeId, host);
+                source.append("Dpn=").append(nodeId);
+                s_logger.debug("Clearing ControlPathConnectionFailure alarm of source {} ", source);
+                //Invokes JMX clearAlarm method
+                invokeFMclearmethod("ControlPathConnectionFailure", alarmText, source.toString());
+            } catch (Exception e) {
+                s_logger.error("Exception before invoking clear method jmx {}", e);
+            }
+        } else {
+            s_logger.error("Received hostname is null");
         }
     }
+
+    private String getAlarmText(String nodeId, String host) {
+        return "OF Switch " + nodeId + " lost heart beat communication with controller " + host;
+    }
 }
\ No newline at end of file
index abe5f5983601103eb6e588bb00d7634445bfde42..b68cece18cda4d8c763deb173d8b6a93aa6e00fc 100644 (file)
@@ -63,7 +63,8 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                 BigInteger dstDpId = internalTunnel.getDestinationDPN();
                 String tunnelType = ItmUtils.convertTunnelTypetoString(internalTunnel.getTransportType());
                 logger.trace("ITM Tunnel removed b/w srcDpn: {} and dstDpn: {} for tunnelType: {}", srcDpId, dstDpId, tunnelType);
-                clearInternalDataPathAlarm(srcDpId.toString(),dstDpId.toString(),tunnelType);
+                String alarmText = getInternalAlarmText(srcDpId.toString(), dstDpId.toString(), tunnelType);
+                clearInternalDataPathAlarm(srcDpId.toString(), dstDpId.toString(), tunnelType, alarmText);
             }else {
                 ExternalTunnel externalTunnel = ItmUtils.getExternalTunnel(ifName,broker);
                 if( externalTunnel != null) {
@@ -71,7 +72,8 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                     String dstNode = externalTunnel.getDestinationDevice();
                     String tunnelType = ItmUtils.convertTunnelTypetoString(externalTunnel.getTransportType());
                     logger.trace("ITM Tunnel removed b/w srcNode: {} and dstNode: {} for tunnelType: {}", srcNode, dstNode, tunnelType);
-                    clearExternalDataPathAlarm(srcNode,dstNode,tunnelType);
+                    String alarmText = getExternalAlarmText(srcNode, dstNode, tunnelType);
+                    clearExternalDataPathAlarm(srcNode, dstNode, tunnelType, alarmText);
                 }
             }
         }
@@ -89,12 +91,11 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                 logger.trace("ITM Tunnel state event changed from :{} to :{} for Tunnel Interface - {}", isTunnelInterfaceUp(original), isTunnelInterfaceUp(update), ifName);
                 if(isTunnelInterfaceUp(update)) {
                     logger.trace("ITM Tunnel State is UP b/w srcDpn: {} and dstDpn: {} for tunnelType {} ", srcDpId, dstDpId, tunnelType);
-                    clearInternalDataPathAlarm(srcDpId.toString(),dstDpId.toString(),tunnelType);
+                    String alarmText = getInternalAlarmText(srcDpId.toString(), dstDpId.toString(), tunnelType);
+                    clearInternalDataPathAlarm(srcDpId.toString(), dstDpId.toString(), tunnelType, alarmText);
                 }else {
                     logger.trace("ITM Tunnel State is DOWN b/w srcDpn: {} and dstDpn: {}", srcDpId, dstDpId);
-                    String alarmText =
-                            "Data Path Connectivity is lost b/w " + "openflow:" + srcDpId + " and openflow:" +
-                                    dstDpId + " for tunnelType:" + tunnelType;
+                    String alarmText = getInternalAlarmText(srcDpId.toString(), dstDpId.toString(), tunnelType);
                     raiseInternalDataPathAlarm(srcDpId.toString(), dstDpId.toString(), tunnelType, alarmText);
                 }
             }else{
@@ -112,13 +113,12 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                     logger.trace("ITM Tunnel state event changed from :{} to :{} for Tunnel Interface - {}", isTunnelInterfaceUp(original), isTunnelInterfaceUp(update), ifName);
                     if(isTunnelInterfaceUp(update)) {
                         logger.trace("ITM Tunnel State is UP b/w srcNode: {} and dstNode: {} for tunnelType: {}", srcNode, dstNode, tunnelType);
-                        clearExternalDataPathAlarm(srcNode, dstNode,tunnelType);
+                        String alarmText = getExternalAlarmText(srcNode, dstNode, tunnelType);
+                        clearExternalDataPathAlarm(srcNode, dstNode, tunnelType, alarmText);
                     }else {
                         logger.trace("ITM Tunnel State is DOWN b/w srcNode: {} and dstNode: {}", srcNode, dstNode);
-                        //alarmText.append("Data Path Connectivity is lost between ").append(srcNode).append(" and ").append(
-                        //              dstNode).append(" for tunnelType:").append(tunnelType);
-                        raiseExternalDataPathAlarm(srcNode, dstNode, tunnelType,
-                                "DataPath lost b/w" + srcNode + " and " + dstNode);
+                        String alarmText = getExternalAlarmText(srcNode, dstNode, tunnelType);
+                        raiseExternalDataPathAlarm(srcNode, dstNode, tunnelType, alarmText);
                     }
                 }
             }
@@ -136,9 +136,7 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                 String tunnelType = ItmUtils.convertTunnelTypetoString(internalTunnel.getTransportType());
                 if(!isTunnelInterfaceUp(add)) {
                     logger.trace("ITM Tunnel State during tep add is DOWN b/w srcDpn: {} and dstDpn: {} for tunnelType: {}", srcDpId, dstDpId, tunnelType);
-
-                    String alarmText = "DataPath is down between " + "openflow:" + srcDpId + " and openflow:" +
-                            dstDpId + " for " + tunnelType + "tunnel initially";
+                    String alarmText = getInternalAlarmText(srcDpId.toString(), dstDpId.toString(), tunnelType);
                     raiseInternalDataPathAlarm(srcDpId.toString(), dstDpId.toString(), tunnelType, alarmText);
                 }
             }else {
@@ -155,10 +153,8 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
                     String tunnelType = ItmUtils.convertTunnelTypetoString(externalTunnel.getTransportType());
                     if(!isTunnelInterfaceUp(add)) {
                         logger.trace("ITM Tunnel State during tep add is DOWN b/w srcNode: {} and dstNode: {} for tunnelType: {}", srcNode, dstNode, tunnelType);
-
-                        //alarmText.append("DataPath is down between ").append(srcNode).append(" and ").append(dstNode).append(" for ").append(tunnelType).append("tunnel initially");
-                        raiseExternalDataPathAlarm(srcNode, dstNode, tunnelType,
-                                "Path down" + srcNode + " and " + dstNode + " initially");
+                        String alarmText = getExternalAlarmText(srcNode, dstNode, tunnelType);
+                        raiseExternalDataPathAlarm(srcNode, dstNode, tunnelType, alarmText);
                     }
                 }
             }
@@ -177,7 +173,7 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
         }
     }
 
-    public void raiseInternalDataPathAlarm(String srcDpnId,String dstDpnId,String tunnelType,String alarmText) {
+    public void raiseInternalDataPathAlarm(String srcDpnId, String dstDpnId, String tunnelType, String alarmText) {
 
         StringBuilder source = new StringBuilder();
         source.append("srcDpn=openflow:").append(srcDpnId).append("-dstDpn=openflow:").append(dstDpnId).append("-tunnelType").append(tunnelType);
@@ -187,16 +183,16 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
         alarmAgent.invokeFMraisemethod("DataPathConnectionFailure", alarmText, source.toString());
     }
 
-    public void clearInternalDataPathAlarm(String srcDpnId,String dstDpnId,String tunnelType) {
+    public void clearInternalDataPathAlarm(String srcDpnId, String dstDpnId, String tunnelType, String alarmText) {
         StringBuilder source = new StringBuilder();
 
         source.append("srcDpn=openflow:").append(srcDpnId).append("-dstDpn=openflow:").append(dstDpnId).append("-tunnelType").append(tunnelType);
-        logger.trace("Clearing DataPathConnectionFailure alarm of source {} ", source);
+        logger.trace("Clearing DataPathConnectionFailure alarm of source {} alarmText {} ", source, alarmText);
         //Invokes JMX clearAlarm method
-        alarmAgent.invokeFMclearmethod("DataPathConnectionFailure", "Clearing ITM Tunnel down alarm", source.toString());
+        alarmAgent.invokeFMclearmethod("DataPathConnectionFailure", alarmText, source.toString());
     }
 
-    public void raiseExternalDataPathAlarm(String srcDevice,String dstDevice,String tunnelType, String alarmText) {
+    public void raiseExternalDataPathAlarm(String srcDevice, String dstDevice, String tunnelType, String alarmText) {
 
         StringBuilder source = new StringBuilder();
         source.append("srcDevice=").append(srcDevice).append("-dstDevice=").append(dstDevice).append("-tunnelType").append(tunnelType);
@@ -207,12 +203,12 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
     }
 
 
-    public void clearExternalDataPathAlarm(String srcDevice,String dstDevice,String tunnelType) {
-
-        //logger.trace("Clearing DataPathConnectionFailure alarm of source {} ", source);
+    public void clearExternalDataPathAlarm(String srcDevice, String dstDevice, String tunnelType, String alarmText) {
+        StringBuilder source = new StringBuilder();
+        source.append("srcDevice=").append(srcDevice).append("-dstDevice=").append(dstDevice).append("-tunnelType").append(tunnelType);
+        logger.trace("Clearing DataPathConnectionFailure alarm of source {} alarmText {} ", source, alarmText);
         //Invokes JMX clearAlarm method
-        alarmAgent.invokeFMclearmethod("DataPathConnectionFailure", "Clearing ITM Tunnel down alarm",
-                "srcDevice=" + srcDevice + "-dstDevice=" + dstDevice + "-tunnelType" + tunnelType);
+        alarmAgent.invokeFMclearmethod("DataPathConnectionFailure", alarmText, source.toString());
 
     }
 
@@ -220,4 +216,18 @@ public class ItmTunnelEventListener extends AbstractDataChangeListener<Interface
         return Interface.OperStatus.Up.equals(intf.getOperStatus());
     }
 
+    private String getInternalAlarmText(String srcDpId, String dstDpId, String tunnelType) {
+        StringBuilder alarmText = new StringBuilder();
+        alarmText.append("Data Path Connectivity is lost between ").append("openflow:").append(srcDpId).append(" and openflow:")
+                .append(dstDpId).append(" for tunnelType:").append(tunnelType);
+        return alarmText.toString();
+    }
+
+    private String getExternalAlarmText(String srcNode, String dstNode, String tunnelType) {
+        StringBuilder alarmText = new StringBuilder();
+        alarmText.append("Data Path Connectivity is lost between ").append(srcNode).append(" and ").append(
+                dstNode).append(" for tunnelType:").append(tunnelType);
+        return alarmText.toString();
+    }
+
 }