You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/06/15 13:01:17 UTC
stratos git commit: fixing dependency startup issue
Repository: stratos
Updated Branches:
refs/heads/master 45850e71a -> 7db006b56
fixing dependency startup issue
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7db006b5
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7db006b5
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7db006b5
Branch: refs/heads/master
Commit: 7db006b565437d4d18a2c66e9794a0fdbaae279c
Parents: 45850e7
Author: reka <rt...@gmail.com>
Authored: Mon Jun 15 15:39:54 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Jun 15 15:40:14 2015 +0530
----------------------------------------------------------------------
.../component/ParentComponentMonitor.java | 30 +++++++++++++++++++-
.../domain/instance/GroupInstance.java | 19 +++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7db006b5/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 8a17795..6efa726 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
@@ -52,6 +52,7 @@ import org.apache.stratos.messaging.domain.application.ParentComponent;
import org.apache.stratos.messaging.domain.application.ScalingDependentList;
import org.apache.stratos.messaging.domain.instance.ClusterInstance;
import org.apache.stratos.messaging.domain.instance.GroupInstance;
+import org.apache.stratos.messaging.domain.instance.Instance;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -332,7 +333,34 @@ public abstract class ParentComponentMonitor extends Monitor {
boolean startDep = false;
if (!aliasToActiveChildMonitorsMap.containsKey(childId) ||
!pendingChildMonitorsList.contains(childId)) {
- startDep = startDependency(childId, instanceId);
+
+ // Need to decide whether it has become active in the first iteration.
+ // Then need to start the dependents.
+ // If it is a second iteration, then if there is no dependents,
+ // no need to invoke start dependencies.
+
+ Monitor childMonitor = aliasToActiveChildMonitorsMap.get(childId);
+ if(childMonitor != null) {
+ Instance instance = childMonitor.getInstance(instanceId);
+ boolean firstIteration = false;
+ if(instance != null) {
+ if(instance instanceof GroupInstance) {
+ GroupInstance groupInstance = (GroupInstance)instance;
+ firstIteration = groupInstance.getPreviousState() == GroupStatus.Created;
+ } else if(instance instanceof ClusterInstance) {
+ ClusterInstance clusterInstance = (ClusterInstance)instance;
+ firstIteration = clusterInstance.getPreviousState() == ClusterStatus.Created;
+ }
+ if(firstIteration || childMonitor.hasStartupDependents()) {
+ startDep = startDependency(childId, instanceId);
+ }
+ } else {
+ startDep = startDependency(childId, instanceId);
+ }
+ } else {
+ startDep = startDependency(childId, instanceId);
+ }
+
}
//Checking whether all the monitors got created
http://git-wip-us.apache.org/repos/asf/stratos/blob/7db006b5/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/GroupInstance.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/GroupInstance.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/GroupInstance.java
index 9c20fd8..a450a8c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/GroupInstance.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/GroupInstance.java
@@ -20,6 +20,7 @@
package org.apache.stratos.messaging.domain.instance;
import org.apache.stratos.messaging.domain.application.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateTransitionBehavior;
@@ -53,5 +54,23 @@ public class GroupInstance extends Instance<GroupStatus> implements LifeCycleSta
return this.lifeCycleStateManager.changeState(newState);
}
+ /**
+ * Get the current state
+ *
+ * @return the current state
+ */
+ public GroupStatus getCurrentState() {
+ return lifeCycleStateManager.getCurrentState();
+ }
+
+ /**
+ * Retrieves the previous state
+ *
+ * @return previous state
+ */
+ public GroupStatus getPreviousState() {
+ return lifeCycleStateManager.getPreviousState();
+ }
+
}