stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [5/5] stratos git commit: Add group monitor as scheduled excutor
Date Sat, 13 Dec 2014 12:42:35 GMT
Add group monitor as scheduled excutor


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

Branch: refs/heads/4.1.0-test
Commit: 73174331542b4c4b101afc74f173997d86c98fd6
Parents: d61306a
Author: gayan <gayan@puppet.gayan.org>
Authored: Fri Dec 12 19:45:51 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Sat Dec 13 18:04:07 2014 +0530

----------------------------------------------------------------------
 .../component/ParentComponentMonitor.java       | 119 +++++++++----------
 1 file changed, 57 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/73174331/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
index 37455cc..dca89e9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
@@ -550,7 +550,7 @@ public abstract class ParentComponentMonitor extends Monitor {
             this.terminatingInstancesMap.put(childId, instanceIds);
         }
     }
-    }
+
 
     protected synchronized void startMonitor(ParentComponentMonitor parent,
                                              ApplicationChildContext context, List<String>
instanceId) {
@@ -636,79 +636,74 @@ public abstract class ParentComponentMonitor extends Monitor {
         return autoscaleAlgorithm;
     }
 
-    private class MonitorAdder implements Runnable {
-        private ApplicationChildContext context;
-        private ParentComponentMonitor parent;
-        private String appId;
-        private List<String> instanceId;
+private class MonitorAdder implements Runnable {
+    private ApplicationChildContext context;
+    private ParentComponentMonitor parent;
+    private String appId;
+    private List<String> instanceId;
 
-        public MonitorAdder(ParentComponentMonitor parent, ApplicationChildContext context,
-                            String appId, List<String> instanceId) {
-            this.parent = parent;
-            this.context = context;
-            this.appId = appId;
-            this.instanceId = instanceId;
-        }
+    public MonitorAdder(ParentComponentMonitor parent, ApplicationChildContext context,
+                        String appId, List<String> instanceId) {
+        this.parent = parent;
+        this.context = context;
+        this.appId = appId;
+        this.instanceId = instanceId;
+    }
 
-        public void run() {
-	        Monitor monitor = null;
-	        int retries = 5;
-	        boolean success = false;
-	        while (!success && retries != 0) {
-	            /*//TODO remove thread.sleep, exectutor service
+    public void run() {
+        Monitor monitor = null;
+        int retries = 5;
+        boolean success = false;
+        while (!success && retries != 0) {
+                /*//TODO remove thread.sleep, exectutor service
                 try {
                     Thread.sleep(5000);
                 } catch (InterruptedException e1) {
                 }*/
 
-		        if (log.isInfoEnabled()) {
-			        log.info("Monitor is going to be started for [group/cluster] "
-			                 + context.getId());
-		        }
-		        try {
-			        monitor = MonitorFactory.getMonitor(parent, context, appId, instanceId);
-		        } catch (DependencyBuilderException e) {
-			        String msg = "Monitor creation failed for: " + context.getId();
-			        log.warn(msg, e);
-			        retries--;
-		        } catch (TopologyInConsistentException e) {
-			        String msg = "Monitor creation failed for: " + context.getId();
-			        log.warn(msg, e);
-			        retries--;
-		        } catch (PolicyValidationException e) {
-			        String msg = "Monitor creation failed for: " + context.getId();
-			        log.warn(msg, e);
-			        retries--;
-		        } catch (PartitionValidationException e) {
-			        String msg = "Monitor creation failed for: " + context.getId();
-			        log.warn(msg, e);
-			        retries--;
-		        }
-		        success = true;
-		        if (log.isInfoEnabled()) {
-			        log.info(String
-					                 .format("Monitor thread has been started successfully: [cluster] %s
",
-					                         context.getId()));
-		        }
+            if (log.isInfoEnabled()) {
+                log.info("Monitor is going to be started for [group/cluster] "
+                        + context.getId());
             }
-
-            if (monitor == null) {
-                String msg = "Monitor creation failed, even after retrying for 5 times, "
-                        + "for : " + context.getId();
-                log.error(msg);
-                //TODO parent.notify();
-                throw new RuntimeException(msg);
+            try {
+                monitor = MonitorFactory.getMonitor(parent, context, appId, instanceId);
+            } catch (DependencyBuilderException e) {
+                String msg = "Monitor creation failed for: " + context.getId();
+                log.warn(msg, e);
+                retries--;
+            } catch (TopologyInConsistentException e) {
+                String msg = "Monitor creation failed for: " + context.getId();
+                log.warn(msg, e);
+                retries--;
+            } catch (PolicyValidationException e) {
+                String msg = "Monitor creation failed for: " + context.getId();
+                log.warn(msg, e);
+                retries--;
+            } catch (PartitionValidationException e) {
+                String msg = "Monitor creation failed for: " + context.getId();
+                log.warn(msg, e);
+                retries--;
             }
+            success = true;
+        }
 
-            aliasToActiveMonitorsMap.put(context.getId(), monitor);
-            pendingMonitorsList.remove(context.getId());
-            // ApplicationBuilder.
-            if (log.isInfoEnabled()) {
-                log.info(String.format("Monitor has been added successfully for: %s",
-                        context.getId()));
-            }
+        if (monitor == null) {
+            String msg = "Monitor creation failed, even after retrying for 5 times, "
+                    + "for : " + context.getId();
+            log.error(msg);
+            //TODO parent.notify();
+            throw new RuntimeException(msg);
+        }
+
+        aliasToActiveMonitorsMap.put(context.getId(), monitor);
+        pendingMonitorsList.remove(context.getId());
+        // ApplicationBuilder.
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Monitor has been added successfully for: %s",
+                    context.getId()));
         }
     }
+}
 
 	public Set<String> getScalingDependencies() {
 		return scalingDependencies;


Mime
View raw message