You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/12/01 17:56:08 UTC
stratos git commit: Making group monitor a thread by implementing
Runnable
Repository: stratos
Updated Branches:
refs/heads/master 2c07846c3 -> f2843a4fe
Making group monitor a thread by implementing Runnable
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/f2843a4f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/f2843a4f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/f2843a4f
Branch: refs/heads/master
Commit: f2843a4feecc2aa0097c2edfa5ec59ff36b5e3c9
Parents: 2c07846
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Mon Dec 1 22:26:32 2014 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Mon Dec 1 22:27:37 2014 +0530
----------------------------------------------------------------------
.../monitor/component/GroupMonitor.java | 54 +++++++++++++++++---
1 file changed, 48 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/f2843a4f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
index 455bafb..c64bccb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
@@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.context.partition.network.GroupLevelNetwork
import org.apache.stratos.autoscaler.exception.application.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.application.ParentMonitorNotFoundException;
import org.apache.stratos.autoscaler.exception.application.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.monitor.EventHandler;
import org.apache.stratos.autoscaler.monitor.Monitor;
import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
@@ -48,22 +47,26 @@ import org.apache.stratos.messaging.domain.instance.Instance;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* This is GroupMonitor to monitor the group which consists of
* groups and clusters
*/
-public class GroupMonitor extends ParentComponentMonitor implements EventHandler {
+public class GroupMonitor extends ParentComponentMonitor implements Runnable {
+
private static final Log log = LogFactory.getLog(GroupMonitor.class);
+
//whether groupScaling enabled or not
private boolean groupScalingEnabled;
+
+ private int monitoringIntervalMilliseconds = 60000;
+ //TODO get this from config file
+
//network partition contexts
private Map<String, GroupLevelNetworkPartitionContext> networkPartitionCtxts;
+ private boolean isDestroyed;
/**
* Constructor of GroupMonitor
@@ -82,6 +85,41 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
//startMinimumDependencies(group, parentInstanceId);
}
+ @Override
+ public void run() {
+ while (!isDestroyed) {
+ try {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Group monitor is running : " + this.toString());
+ }
+ monitor();
+ } catch (Exception e) {
+ log.error("Group monitor failed : " + this.toString(), e);
+ }
+ try {
+ Thread.sleep(monitoringIntervalMilliseconds);
+ } catch (InterruptedException ignore) {
+ }
+ }
+
+
+ }
+
+
+ public void monitor() {
+
+ Runnable monitoringRunnable = new Runnable() {
+ @Override
+ public void run() {
+ //TODO implement group monitor
+
+ }
+ };
+ monitoringRunnable.run();
+ }
+
+
/**
* Will set the status of the monitor based on Topology Group status/child status like scaling
*
@@ -425,4 +463,8 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
public void addNetworkPartitionContext(GroupLevelNetworkPartitionContext clusterLevelNetworkPartitionContext) {
this.networkPartitionCtxts.put(clusterLevelNetworkPartitionContext.getId(), clusterLevelNetworkPartitionContext);
}
+
+ public void setDestroyed(boolean isDestroyed) {
+ this.isDestroyed = isDestroyed;
+ }
}