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/04/05 08:58:47 UTC
git commit: should wait till the cluster monitor added to the
datastructures, before creating a new cluster monitor
Repository: incubator-stratos
Updated Branches:
refs/heads/master 24cc743d4 -> db1d1e4f6
should wait till the cluster monitor added to the datastructures, before creating a new cluster monitor
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/db1d1e4f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/db1d1e4f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/db1d1e4f
Branch: refs/heads/master
Commit: db1d1e4f6c177b18cf21571d86e3bb577ed5f49f
Parents: 24cc743
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Apr 5 12:28:04 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Apr 5 12:28:04 2014 +0530
----------------------------------------------------------------------
.../topology/AutoscalerTopologyReceiver.java | 57 ++++++++++----------
1 file changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/db1d1e4f/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 2062268..fd1fe8e 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
@@ -101,26 +101,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
TopologyManager.acquireReadLock();
for(Service service : TopologyManager.getTopology().getServices()) {
for (Cluster cluster : service.getClusters()) {
- Thread th = null;
- if (cluster.isLbCluster()
- && !AutoscalerContext.getInstance()
- .lbMonitorExist(
- cluster.getClusterId())) {
- th = new Thread(new LBClusterMonitorAdder(
- cluster));
- } else if (!AutoscalerContext.getInstance()
- .monitorExist(cluster.getClusterId())) {
- th = new Thread(
- new ClusterMonitorAdder(cluster));
- }
- if (th != null) {
- th.start();
- if (log.isDebugEnabled()) {
- log.debug(String
- .format("Cluster monitor thread has been started successfully: [cluster] %s ",
- cluster.getClusterId()));
- }
- }
+ startClusterMonitor(cluster);
}
}
}
@@ -129,6 +110,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
}
}
+
});
processorChain.addEventListener(new ClusterCreatedEventListener() {
@@ -140,13 +122,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
TopologyManager.acquireReadLock();
Service service = TopologyManager.getTopology().getService(e.getServiceName());
Cluster cluster = service.getCluster(e.getClusterId());
- if (cluster.isLbCluster()) {
- Thread th = new Thread(new LBClusterMonitorAdder(cluster));
- th.start();
- } else {
- Thread th = new Thread(new ClusterMonitorAdder(cluster));
- th.start();
- }
+ startClusterMonitor(cluster);
} finally {
TopologyManager.releaseReadLock();
}
@@ -486,4 +462,31 @@ public class AutoscalerTopologyReceiver implements Runnable {
topologyReceiver.terminate();
terminated = true;
}
+
+ protected synchronized void startClusterMonitor(Cluster cluster) {
+ Thread th = null;
+ if (cluster.isLbCluster()
+ && !AutoscalerContext.getInstance()
+ .lbMonitorExist(
+ cluster.getClusterId())) {
+ th = new Thread(new LBClusterMonitorAdder(
+ cluster));
+ } else if (!AutoscalerContext.getInstance()
+ .monitorExist(cluster.getClusterId())) {
+ th = new Thread(
+ new ClusterMonitorAdder(cluster));
+ }
+ if (th != null) {
+ th.start();
+ try {
+ th.join();
+ } catch (InterruptedException ignore) {}
+
+ if (log.isDebugEnabled()) {
+ log.debug(String
+ .format("Cluster monitor thread has been started successfully: [cluster] %s ",
+ cluster.getClusterId()));
+ }
+ }
+ }
}