Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping bd9197ded -> 13ef15c86


fixing the ClusterActivatedEvent issue and updating the cluster with appId


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

Branch: refs/heads/4.0.0-grouping
Commit: 13ef15c86080a22d65ac9830ba0ca147245a7bde
Parents: bd9197d
Author: reka <[email protected]>
Authored: Fri Sep 26 18:03:38 2014 +0530
Committer: reka <[email protected]>
Committed: Fri Sep 26 18:03:38 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/monitor/group/GroupMonitor.java  | 33 +++++++++++---------
 .../stratos/autoscaler/util/AutoscalerUtil.java |  1 +
 .../controller/topology/TopologyBuilder.java    |  4 +--
 .../messaging/domain/topology/Cluster.java      | 10 +++++-
 .../ApplicationStatusEventMessageDelegator.java | 17 ++++------
 5 files changed, 37 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/13ef15c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index c2f6ca4..cfab9de 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -96,23 +96,28 @@ public class GroupMonitor extends Monitor {
                     }
                 }
             } else if (dependency.contains("cartridge")) {
-                for(ClusterDataHolder dataHolder : 
component.getClusterDataMap().values()) {
-                    
if(dataHolder.getServiceType().equals(dependency.substring(10))) {
-                        String clusterId = dataHolder.getClusterId();
-                        String serviceName = dataHolder.getServiceType();
-                        Cluster cluster = null;
-                        //TopologyManager.acquireReadLock();
-                        cluster = 
TopologyManager.getTopology().getService(serviceName).getCluster(clusterId);
-                        //TopologyManager.releaseReadLock();
-                        if (cluster != null) {
-                            startClusterMonitor(this, cluster);
-                        } else {
-                            //TODO throw exception since Topology is 
inconsistent
+                ClusterDataHolder clusterDataHolder = 
component.getClusterData(dependency.substring(10));
+                String clusterId = clusterDataHolder.getClusterId();
+                String serviceName = clusterDataHolder.getServiceType();
+                Cluster cluster = null;
+                //TopologyManager.acquireReadLock();
+                Topology topology = TopologyManager.getTopology();
+                if (topology.serviceExists(serviceName)) {
+                    Service service = topology.getService(serviceName);
+                    if (service.clusterExists(clusterId)) {
+                        cluster = service.getCluster(clusterId);
+                        if (log.isDebugEnabled()) {
+                            log.debug("Dependency check starting the 
[cluster]" + clusterId);
                         }
+                        startClusterMonitor(this, cluster);
+                    } else {
+                        log.warn("[Cluster] " + clusterId + " cannot be found 
in the " +
+                                "Topology for [service] " + serviceName);
                     }
+                } else {
+                    log.warn("[Service] " + serviceName + " cannot be found in 
the Topology");
                 }
-
-
+                //TopologyManager.releaseReadLock();
             }
         } else {
             //all the groups/clusters have been started and waiting for 
activation

http://git-wip-us.apache.org/repos/asf/stratos/blob/13ef15c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
index df01a84..6a05371 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
@@ -111,6 +111,7 @@ public class AutoscalerUtil {
                                         new 
ClusterMonitor(cluster.getClusterId(),
                                                            
cluster.getServiceName(),
                                                            deploymentPolicy, 
policy);
+        clusterMonitor.setAppId(cluster.getAppId());
         clusterMonitor.setStatus(Status.Created);
         
         for (PartitionGroup partitionGroup: 
deploymentPolicy.getPartitionGroups()){

http://git-wip-us.apache.org/repos/asf/stratos/blob/13ef15c8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index b766007..9541ac0 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -140,7 +140,7 @@ public class TopologyBuilder {
                 cluster.setLbCluster(isLb);
             } else {
                 cluster = new Cluster(cartridgeType, clusterId,
-                        registrant.getDeploymentPolicyName(), 
registrant.getAutoScalerPolicyName());
+                        registrant.getDeploymentPolicyName(), 
registrant.getAutoScalerPolicyName(), null);
                 cluster.addHostName(registrant.getHostName());
                 if (service.getServiceType() == ServiceType.MultiTenant) {
                     cluster.setTenantRange(registrant.getTenantRange());
@@ -625,7 +625,7 @@ public class TopologyBuilder {
             for (ApplicationClusterContext applicationClusterContext : 
applicationClusterContexts) {
                 Cluster cluster = new 
Cluster(applicationClusterContext.getCartridgeType(),
                         applicationClusterContext.getClusterId(), 
applicationClusterContext.getDeploymentPolicyName(),
-                        applicationClusterContext.getAutoscalePolicyName());
+                        applicationClusterContext.getAutoscalePolicyName(), 
application.getId());
                 cluster.setStatus(Status.Created);
                 cluster.addHostName(applicationClusterContext.getHostName());
                 
cluster.setTenantRange(applicationClusterContext.getTenantRange());

http://git-wip-us.apache.org/repos/asf/stratos/blob/13ef15c8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
index 957fce4..578089a 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
@@ -51,17 +51,21 @@ public class Cluster implements Serializable {
 
     private Status status;
 
+    private String appId;
+
     private String loadBalanceAlgorithmName;
     @XmlJavaTypeAdapter(MapAdapter.class)
     private Properties properties;
 
-    public Cluster(String serviceName, String clusterId, String 
deploymentPolicyName, String autoscalePolicyName) {
+    public Cluster(String serviceName, String clusterId, String 
deploymentPolicyName,
+                   String autoscalePolicyName, String appId) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
         this.deploymentPolicyName = deploymentPolicyName;
         this.autoscalePolicyName = autoscalePolicyName;
         this.hostNames = new ArrayList<String>();
         this.memberMap = new HashMap<String, Member>();
+        this.appId = appId;
     }
 
     public String getServiceName() {
@@ -227,5 +231,9 @@ public class Cluster implements Serializable {
     public int hashCode () {
         return clusterId.hashCode();
     }
+
+    public String getAppId() {
+        return appId;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/13ef15c8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
index ccf9dd3..2b1ad5b 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.listener.EventListener;
 import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 import 
org.apache.stratos.messaging.message.processor.application.status.ApplicationStatusMessageProcessorChain;
+import org.apache.stratos.messaging.util.Constants;
 
 import javax.jms.TextMessage;
 
@@ -53,17 +54,11 @@ public class ApplicationStatusEventMessageDelegator 
implements Runnable {
                 try {
                     TextMessage message = messageQueue.take();
 
-                    String messageText = message.getText();
-                    if (log.isDebugEnabled()) {
-                        log.debug("Application status event message received: 
[message] " + messageText);
-                    }
-                    EventMessage eventMessage = 
jsonToEventMessage(messageText);
-                    if(eventMessage == null){
-                        log.error("Error occurred while extracting message");
-                        continue;
-                    }
-                    String type = eventMessage.getEventName();
-                    String json = eventMessage.getMessage();
+                    // Retrieve the header
+                    String type = 
message.getStringProperty(Constants.EVENT_CLASS_NAME);
+
+                    // Retrieve the actual message
+                    String json = message.getText();
 
                     if (log.isDebugEnabled()) {
                         log.debug(String.format("Application status event 
message received from queue: %s", type));

Reply via email to