stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [22/50] [abbrv] git commit: adding the valid transition check for status changes
Date Thu, 30 Oct 2014 04:13:46 GMT
adding the valid transition check for status changes


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2ae7e2b9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2ae7e2b9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2ae7e2b9

Branch: refs/heads/docker-grouping-merge
Commit: 2ae7e2b947f9ad1635fecad739643f2379807efe
Parents: 097e884
Author: reka <rthirunavukkarasu23@gmail.com>
Authored: Tue Oct 28 13:14:40 2014 +0530
Committer: reka <rthirunavukkarasu23@gmail.com>
Committed: Tue Oct 28 13:14:48 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    | 198 ++++++++++++++-----
 .../AutoscalerTopologyEventReceiver.java        |  22 ++-
 .../monitor/AbstractClusterMonitor.java         |  24 +--
 .../monitor/application/ApplicationMonitor.java |   4 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |  17 +-
 5 files changed, 183 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index fece506..5b09a21 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -7,13 +7,6 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;
 
@@ -32,10 +25,23 @@ public class StatusEventPublisher {
                     " [cluster]: " + clusterId);
         }
 
-        AppStatusClusterActivatedEvent clusterActivatedEvent =
-                                            new AppStatusClusterActivatedEvent(appId, serviceName,
clusterId);
-
-        publishEvent(clusterActivatedEvent);
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+                    AppStatusClusterActivatedEvent clusterActivatedEvent =
+                            new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+        }
     }
 
     public static void sendClusterInActivateEvent(String appId, String serviceName, String
clusterId) {
@@ -45,36 +51,77 @@ public class StatusEventPublisher {
                     " [cluster]: " + clusterId);
         }
 
-        AppStatusClusterInactivateEvent clusterInActivateEvent =
-                                        new AppStatusClusterInactivateEvent(appId, serviceName,
clusterId);
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
+                    AppStatusClusterInactivateEvent clusterInActivateEvent =
+                            new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterInActivateEvent);
+                } else {
+                    log.warn("In-active is not in the possible state list of [cluster] "
+ clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
 
-        publishEvent(clusterInActivateEvent);
+        }
     }
 
     public static void sendClusterTerminatingEvent(String appId, String serviceName, String
clusterId) {
 
         if (log.isInfoEnabled()) {
-            log.info("Publishing Cluster in-activate event for [application]: " + appId +
+            log.info("Publishing Cluster Terminating event for [application]: " + appId +
                     " [cluster]: " + clusterId);
         }
-        //TODO
-        AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
-                new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                    AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
+                            new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+
+                    publishEvent(appStatusClusterTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [cluster]
" + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+
+        }
 
-        publishEvent(appStatusClusterTerminatingEvent);
     }
 
     public static void sendClusterTerminatedEvent(String appId, String serviceName, String
clusterId) {
 
         if (log.isInfoEnabled()) {
-            log.info("Publishing Cluster in-activate event for [application]: " + appId +
+            log.info("Publishing Cluster terminated event for [application]: " + appId +
                     " [cluster]: " + clusterId);
         }
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+                    AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
+                            new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(appStatusClusterTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [cluster] "
+ clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
 
-        AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
-                new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
-
-        publishEvent(appStatusClusterTerminatedEvent);
+        }
     }
 
     public static void sendGroupActivatedEvent(String appId, String groupId) {
@@ -87,9 +134,9 @@ public class StatusEventPublisher {
         try {
             TopologyManager.acquireReadLockForApplication(appId);
             Application application = TopologyManager.getTopology().getApplication(appId);
-            if(application != null) {
+            if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
-                if(group.getStatus().getNextStates().contains(GroupStatus.Active)) {
+                if (group.isStateTransitionValid(GroupStatus.Active)) {
                     AppStatusGroupActivatedEvent groupActivatedEvent =
                             new AppStatusGroupActivatedEvent(appId, groupId);
 
@@ -101,8 +148,6 @@ public class StatusEventPublisher {
         } finally {
             TopologyManager.releaseReadLockForApplication(appId);
         }
-
-
     }
 
     public static void sendGroupInActivateEvent(String appId, String groupId) {
@@ -114,10 +159,10 @@ public class StatusEventPublisher {
         try {
             TopologyManager.acquireReadLockForApplication(appId);
             Application application = TopologyManager.getTopology().getApplication(appId);
-            if(application != null) {
+            if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
-                if(group.getStatus().getNextStates().contains(GroupStatus.Inactive)) {
-                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new
+                if (group.isStateTransitionValid(GroupStatus.Inactive)) {
+                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
                             AppStatusGroupInactivateEvent(appId, groupId);
 
                     publishEvent(appStatusGroupInactivateEvent);
@@ -128,8 +173,6 @@ public class StatusEventPublisher {
         } finally {
             TopologyManager.releaseReadLockForApplication(appId);
         }
-
-
     }
 
     public static void sendGroupTerminatingEvent(String appId, String groupId) {
@@ -141,9 +184,9 @@ public class StatusEventPublisher {
         try {
             TopologyManager.acquireReadLockForApplication(appId);
             Application application = TopologyManager.getTopology().getApplication(appId);
-            if(application != null) {
+            if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
-                if(group.getStatus().getNextStates().contains(GroupStatus.Terminating)) {
+                if (group.isStateTransitionValid(GroupStatus.Terminating)) {
                     AppStatusGroupTerminatingEvent groupInTerminatingEvent =
                             new AppStatusGroupTerminatingEvent(appId, groupId);
                     publishEvent(groupInTerminatingEvent);
@@ -166,9 +209,9 @@ public class StatusEventPublisher {
         try {
             TopologyManager.acquireReadLockForApplication(appId);
             Application application = TopologyManager.getTopology().getApplication(appId);
-            if(application != null) {
+            if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
-                if(group.getStatus().getNextStates().contains(GroupStatus.Terminated)) {
+                if (group.isStateTransitionValid(GroupStatus.Terminated)) {
                     AppStatusGroupTerminatedEvent groupInTerminatedEvent =
                             new AppStatusGroupTerminatedEvent(appId, groupId);
                     publishEvent(groupInTerminatedEvent);
@@ -189,40 +232,87 @@ public class StatusEventPublisher {
             log.info("Publishing Application activated event for [application]: " + appId);
         }
 
-        AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId);
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Active)) {
+                    AppStatusApplicationActivatedEvent applicationActivatedEvent =
+                            new AppStatusApplicationActivatedEvent(appId);
 
-        publishEvent(applicationActivatedEvent);
+                    publishEvent(applicationActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [application] "
+ appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
     }
 
-    public static void sendApplicationInactivatedEvent(String appId){
+    public static void sendApplicationInactivatedEvent(String appId) {
         if (log.isInfoEnabled()) {
-            log.info("Publishing Application Inactivated event for [application]: " + appId);
+            log.info("Publishing Application In-activated event for [application]: " + appId);
         }
 
-        AppStatusApplicationInactivatedEvent applicationInActivatedEvent = new AppStatusApplicationInactivatedEvent(appId);
-
-        publishEvent(applicationInActivatedEvent);
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
+                    AppStatusApplicationInactivatedEvent applicationInActivatedEvent =
+                            new AppStatusApplicationInactivatedEvent(appId);
+                    publishEvent(applicationInActivatedEvent);
+                } else {
+                    log.warn("Inactive is not in the possible state list of [application]
" + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
     }
 
-    public static void sendApplicationTerminatingEvent (String appId) {
+    public static void sendApplicationTerminatingEvent(String appId) {
         if (log.isInfoEnabled()) {
             log.info("Publishing Application terminated event for [application]: " + appId);
         }
 
-        AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId);
-
-        publishEvent(applicationTerminatingEvent);
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                    AppStatusApplicationTerminatingEvent applicationTerminatingEvent =
+                            new AppStatusApplicationTerminatingEvent(appId);
+                    publishEvent(applicationTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [application]
" + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
     }
 
-    public static void sendApplicationTerminatedEvent (String appId, Set<ClusterDataHolder>
clusterData) {
+    public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder>
clusterData) {
         if (log.isInfoEnabled()) {
             log.info("Publishing Application terminated event for [application]: " + appId);
         }
-
-        AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
-                new AppStatusApplicationTerminatedEvent(appId, clusterData);
-
-        publishEvent(applicationTerminatedEvent);
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+                    AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
+                            new AppStatusApplicationTerminatedEvent(appId, clusterData);
+                    publishEvent(applicationTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [application]
" + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
     }
 
     public static void publishEvent(Event event) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index e5bbd55..99aa69c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -39,10 +39,6 @@ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -237,7 +233,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 
                 //changing the status in the monitor, will notify its parent monitor
-                clusterMonitor.setStatus(ClusterStatus.Terminated);
+                if (clusterMonitor != null) {
+                    clusterMonitor.setStatus(ClusterStatus.Terminated);
+                }
 
                 //starting the status checker to decide on the status of it's parent
                 //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId);
@@ -258,7 +256,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
 
                 //changing the status in the monitor, will notify its parent monitor
-                if(monitor != null) {
+                if (monitor != null) {
                     monitor.setStatus(GroupStatus.Active);
                 }
 
@@ -279,7 +277,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
 
                 //changing the status in the monitor, will notify its parent monitor
-                monitor.setStatus(GroupStatus.Inactive);
+                if (monitor != null) {
+                    monitor.setStatus(GroupStatus.Inactive);
+                }
 
             }
         });
@@ -298,7 +298,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
 
                 //changing the status in the monitor, will notify its parent monitor
-                monitor.setStatus(GroupStatus.Terminating);
+                if (monitor != null) {
+                    monitor.setStatus(GroupStatus.Terminating);
+                }
 
             }
         });
@@ -317,7 +319,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
 
                 //changing the status in the monitor, will notify its parent monitor
-                monitor.setStatus(GroupStatus.Terminated);
+                if (monitor != null) {
+                    monitor.setStatus(GroupStatus.Terminated);
+                }
 
             }
         });

http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 588d2c4..0a9d628 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -228,17 +228,19 @@ abstract public class AbstractClusterMonitor extends Monitor implements
Runnable
     public void setStatus(ClusterStatus status) {
         log.info(String.format("[Monitor] %s is notifying the parent" +
                 "on its state change from %s to %s", clusterId, this.status, status));
-        this.status = status;
-        /**
-         * notifying the parent monitor about the state change
-         * If the cluster in_active and if it is a in_dependent cluster,
-         * then won't send the notification to parent.
-         */
-        if(status == ClusterStatus.Inactive && !this.hasDependent) {
-            log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
-                    "since it is identified as the independent unit");
-        } else {
-            MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status,
this.clusterId);
+        if(this.status != status) {
+            this.status = status;
+            /**
+             * notifying the parent monitor about the state change
+             * If the cluster in_active and if it is a in_dependent cluster,
+             * then won't send the notification to parent.
+             */
+            if (status == ClusterStatus.Inactive && !this.hasDependent) {
+                log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
+                        "since it is identified as the independent unit");
+            } else {
+                MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status,
this.clusterId);
+            }
         }
 
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
index 66044ef..966c8b2 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
@@ -142,7 +142,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
     public void setStatus(ApplicationStatus status) {
         log.info(String.format("[ApplicationMonitor] %s " +
                 "state changes from %s to %s", id, this.status, status));
-        this.status = status;
+        if(this.status != status) {
+            this.status = status;
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index dff0bba..ab3ef16 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -140,13 +140,16 @@ public class GroupMonitor extends ParentComponentMonitor implements
EventHandler
     public void setStatus(GroupStatus status) {
         log.info(String.format("[Monitor] %s is notifying the parent" +
                 "on its state change from %s to %s", id, this.status, status));
-        this.status = status;
-        //notifying the parent
-        if (status == GroupStatus.Inactive && !this.hasDependent) {
-            log.info("[Group] " + this.id + "is not notifying the parent, " +
-                    "since it is identified as the independent unit");
-        } else {
-            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+        if(this.status != status) {
+            this.status = status;
+            //notifying the parent
+            if (status == GroupStatus.Inactive && !this.hasDependent) {
+                log.info("[Group] " + this.id + "is not notifying the parent, " +
+                        "since it is identified as the independent unit");
+            } else {
+                MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status,
this.id);
+            }
         }
+
     }
 }


Mime
View raw message