You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2013/12/20 09:22:16 UTC

[1/2] git commit: Correcting logic faults and dead codes in health event handler

Updated Branches:
  refs/heads/master a41ee2f77 -> febcde501


Correcting logic faults and dead codes in health event handler


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

Branch: refs/heads/master
Commit: f7b10924596772065cf80d720b4d09ffc35e3dc8
Parents: cc572db
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Dec 20 13:51:12 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Fri Dec 20 13:51:12 2013 -0500

----------------------------------------------------------------------
 .../health/HealthEventMessageDelegator.java     | 97 ++++++++++----------
 1 file changed, 47 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f7b10924/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java
index cab71e6..b6a8289 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java
@@ -210,72 +210,68 @@ public class HealthEventMessageDelegator implements Runnable {
     private LoadAverage findLoadAverage(Event event) {
         String memberId = event.getProperties().get("member_id");
         Member member = findMember(memberId);
-
-        if(member.isActive()){
+        
+        if(null == member){
+        	if(log.isErrorEnabled()) {
+                log.error(String.format("Member not found: [member] %s", memberId));
+            }
+            return null;
+        }
+        if(!member.isActive()){
             if(log.isDebugEnabled()){
                 log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" +
                         " the load average health stat", memberId));
             }
             return null;
         }
-        if(member != null) {
-            String networkPartitionId = findNetworkPartitionId(memberId);
-            LoadAverage loadAverage = AutoscalerContext.getInstance().getMonitor(member.getClusterId())
+        
+        String networkPartitionId = findNetworkPartitionId(memberId);
+        LoadAverage loadAverage = AutoscalerContext.getInstance().getMonitor(member.getClusterId())
+                .getNetworkPartitionCtxt(networkPartitionId)
+                .getPartitionCtxt(member.getPartitionId())
+                .getMemberStatsContext(memberId).getLoadAverage();
+
+        if(loadAverage == null) {
+            loadAverage = new LoadAverage();
+            AutoscalerContext.getInstance().getMonitor(member.getClusterId())
                     .getNetworkPartitionCtxt(networkPartitionId)
                     .getPartitionCtxt(member.getPartitionId())
-                    .getMemberStatsContext(memberId).getLoadAverage();
-
-            if(loadAverage == null) {
-                loadAverage = new LoadAverage();
-                AutoscalerContext.getInstance().getMonitor(member.getClusterId())
-                        .getNetworkPartitionCtxt(networkPartitionId)
-                        .getPartitionCtxt(member.getPartitionId())
-                        .getMemberStatsContext(memberId).setLoadAverage(loadAverage);
-            }
-            return loadAverage;
-        }
-        else {
-            if(log.isErrorEnabled()) {
-                log.error(String.format("Member not found: [member] %s", memberId));
-            }
-            return null;
+                    .getMemberStatsContext(memberId).setLoadAverage(loadAverage);
         }
+        return loadAverage;
     }
 
     private MemoryConsumption findMemoryConsumption(Event event) {
         String memberId = event.getProperties().get("member_id");
         Member member = findMember(memberId);
-
-        if(member.isActive()){
+        
+        if(null == member){
+        	if(log.isErrorEnabled()) {
+                log.error(String.format("Member not found: [member] %s", memberId));
+            }
+            return null;
+        }
+        if(!member.isActive()){
             if(log.isDebugEnabled()){
                 log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" +
                         " the health stat", memberId));
             }
             return null;
-        }
-
-        if(member != null) {
-            String networkPartitionId = findNetworkPartitionId(memberId);
-            MemoryConsumption memoryConsumption = AutoscalerContext.getInstance().getMonitor(member.getClusterId())
+        }        
+        String networkPartitionId = findNetworkPartitionId(memberId);
+        MemoryConsumption memoryConsumption = AutoscalerContext.getInstance().getMonitor(member.getClusterId())
+                .getNetworkPartitionCtxt(networkPartitionId)
+                .getPartitionCtxt(member.getPartitionId())
+                .getMemberStatsContext(memberId).getMemoryConsumption();
+
+        if(memoryConsumption == null) {
+            memoryConsumption = new MemoryConsumption();
+            AutoscalerContext.getInstance().getMonitor(member.getClusterId())
                     .getNetworkPartitionCtxt(networkPartitionId)
                     .getPartitionCtxt(member.getPartitionId())
-                    .getMemberStatsContext(memberId).getMemoryConsumption();
-
-            if(memoryConsumption == null) {
-                memoryConsumption = new MemoryConsumption();
-                AutoscalerContext.getInstance().getMonitor(member.getClusterId())
-                        .getNetworkPartitionCtxt(networkPartitionId)
-                        .getPartitionCtxt(member.getPartitionId())
-                        .getMemberStatsContext(memberId).setMemoryConsumption(memoryConsumption);
-            }
-            return memoryConsumption;
-        }
-        else {
-            if(log.isErrorEnabled()) {
-                log.error(String.format("Member not found: [member] %s", memberId));
-            }
-            return null;
+                    .getMemberStatsContext(memberId).setMemoryConsumption(memoryConsumption);
         }
+        return memoryConsumption;
     }
     private String findClusterId(String memberId) {
         for(Service service: TopologyManager.getTopology().getServices()){
@@ -348,6 +344,10 @@ public class HealthEventMessageDelegator implements Runnable {
             try{
             	TopologyManager.acquireReadLock();
             	Member member = findMember(memberId);
+            	
+            	if(null == member){
+            		return;
+            	}
                 if(!member.isActive()){
                     if(log.isDebugEnabled()){
                         log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" +
@@ -355,12 +355,9 @@ public class HealthEventMessageDelegator implements Runnable {
                     }
                     return;
                 }
-	            if (null == member) {
-	                // member has already terminated. So no action required
-	                return;
-	            } else{
-	            	nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member);
-	            }
+	            
+	            nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member);
+	            
             }finally{
             	TopologyManager.releaseReadLock();
             }


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by ud...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos


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

Branch: refs/heads/master
Commit: febcde501688f242e23cdc39a02acedd8ce4bf0c
Parents: f7b1092 a41ee2f
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Dec 20 13:52:17 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Fri Dec 20 13:52:17 2013 -0500

----------------------------------------------------------------------
 .../stratos/cartridge/agent/CartridgeAgent.java | 10 ++++-----
 .../apache/stratos/cartridge/agent/Main.java    |  3 +++
 .../config/CartridgeAgentConfiguration.java     |  4 ++--
 .../config/configurator/JndiConfigurator.java   | 18 ++++++++-------
 .../publisher/CartridgeAgentEventPublisher.java | 16 +++++++-------
 .../broker/heartbeat/TopicHealthChecker.java    |  2 +-
 .../distribution/src/main/assembly/bin.xml      |  1 -
 .../distribution/src/main/conf/jndi.properties  | 23 --------------------
 .../conf/templates/jndi.properties.template     |  2 +-
 9 files changed, 30 insertions(+), 49 deletions(-)
----------------------------------------------------------------------