You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/03/29 19:38:26 UTC

git commit: fixing https://issues.apache.org/jira/browse/STRATOS-564 - Cluster monitor creation should be re-tried few times, if failed once

Repository: incubator-stratos
Updated Branches:
  refs/heads/master d912bf2db -> 61a04ed8f


fixing https://issues.apache.org/jira/browse/STRATOS-564 - Cluster monitor creation should be re-tried few times, if failed once


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

Branch: refs/heads/master
Commit: 61a04ed8fb28f260fd710cbab3ae6f513985eab9
Parents: d912bf2
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Mar 30 00:08:07 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Mar 30 00:08:07 2014 +0530

----------------------------------------------------------------------
 .../topology/AutoscalerTopologyReceiver.java    | 85 ++++++++++++++------
 1 file changed, 59 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/61a04ed8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java
index 44ace7d..e000777 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java
@@ -367,19 +367,35 @@ public class AutoscalerTopologyReceiver implements Runnable {
         }
 
         public void run() {
-            LbClusterMonitor monitor;
-            try {
-                monitor = AutoscalerUtil.getLBClusterMonitor(cluster);
-
-            } catch (PolicyValidationException e) {
-                String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
-                log.error(msg, e);
-                throw new RuntimeException(msg, e);
-
-            } catch(PartitionValidationException e){
-                String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
-                log.error(msg, e);
-                throw new RuntimeException(msg, e);
+            LbClusterMonitor monitor = null;
+            int retries = 5;
+            boolean success = false;
+            do {
+            	try {
+					Thread.sleep(5000);
+				} catch (InterruptedException e1) {
+				}
+            	try {
+            		monitor = AutoscalerUtil.getLBClusterMonitor(cluster);
+            		success = true;
+            		
+            	} catch (PolicyValidationException e) {
+            		String msg = "LB Cluster monitor creation failed for cluster: "+cluster.getClusterId();
+            		log.debug(msg, e);
+            		retries--;
+            		
+            	} catch(PartitionValidationException e){
+            		String msg = "LB Cluster monitor creation failed for cluster: "+cluster.getClusterId();
+            		log.debug(msg, e);
+            		retries--;
+            	}
+            } while (!success && retries <= 0);
+            
+            if (monitor == null) {
+            	String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, "
+            			+ "for cluster: "+cluster.getClusterId();
+            	log.error(msg);
+            	throw new RuntimeException(msg);
             }
 
             Thread th = new Thread(monitor);
@@ -400,19 +416,36 @@ public class AutoscalerTopologyReceiver implements Runnable {
         }
 
         public void run() {
-            ClusterMonitor monitor;
-            try {
-                monitor = AutoscalerUtil.getClusterMonitor(cluster);
-
-            } catch (PolicyValidationException e) {
-                String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
-                log.error(msg, e);
-                throw new RuntimeException(msg, e);
-
-            } catch(PartitionValidationException e){
-                String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
-                log.error(msg, e);
-                throw new RuntimeException(msg, e);
+            ClusterMonitor monitor = null;
+            int retries = 5;
+            boolean success = false;
+            do {
+            	try {
+					Thread.sleep(5000);
+				} catch (InterruptedException e1) {
+				}
+            	
+            	try {
+            		monitor = AutoscalerUtil.getClusterMonitor(cluster);
+            		success = true;
+            		
+            	} catch (PolicyValidationException e) {
+            		String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
+            		log.debug(msg, e);
+            		retries--;
+            		
+            	} catch(PartitionValidationException e){
+            		String msg = "Cluster monitor creation failed for cluster: "+cluster.getClusterId();
+            		log.debug(msg, e);
+            		retries--;
+            	}
+            } while (!success && retries != 0);
+            
+            if (monitor == null) {
+            	String msg = "Cluster monitor creation failed, even after retrying for 5 times, "
+            			+ "for cluster: "+cluster.getClusterId();
+            	log.error(msg);
+            	throw new RuntimeException(msg);
             }
 
             Thread th = new Thread(monitor);