You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/11/03 08:32:16 UTC

[01/50] [abbrv] git commit: support cluster created when auto-recovery case in the member fault

Repository: stratos
Updated Branches:
  refs/heads/docker-grouping-merge a61fc9d0b -> 89fb37afb


support cluster created when auto-recovery case in the member fault


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

Branch: refs/heads/docker-grouping-merge
Commit: 65d96bce5237a4bee999fe35d21956d886dca1cc
Parents: 2414bca
Author: reka <rt...@gmail.com>
Authored: Thu Oct 30 18:01:17 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Oct 30 18:01:38 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    | 24 ++++++++++++++++++++
 .../monitor/ParentComponentMonitor.java         |  2 ++
 .../status/checker/StatusChecker.java           | 19 ++++++++++++++--
 3 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/65d96bce/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 7bbe8ce..8058c85 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -18,6 +18,30 @@ import java.util.Set;
 public class StatusEventPublisher {
     private static final Log log = LogFactory.getLog(StatusEventPublisher.class);
 
+    public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster activated event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    AppStatusClusterActivatedEvent clusterActivatedEvent =
+                            new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+        }
+    }
+
     public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) {
         try {
             TopologyManager.acquireReadLockForCluster(serviceName, clusterId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/65d96bce/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index ced698c..91d5275 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -205,6 +205,8 @@ public abstract class ParentComponentMonitor extends Monitor {
             //Find the non existent monitor by traversing dependency tree
             try {
                 this.startDependencyOnTermination();
+                List<ApplicationContext> applicationContexts = this.dependencyTree.
+                        getStarAbleDependenciesByTermination();
             } catch (TopologyInConsistentException e) {
                 //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
                 log.error("Error while starting the monitor upon termination" + e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/65d96bce/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index bc08c56..97f6476 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -89,12 +89,24 @@ public class StatusChecker {
                     TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
                     Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
                     Cluster cluster;
+                    String appId = monitor.getAppId();
                     if (service != null) {
                         cluster = service.getCluster(monitor.getClusterId());
                         if (cluster != null) {
+                            try {
+
+                                TopologyManager.acquireReadLockForApplication(appId);
+                                Application application = TopologyManager.getTopology().getApplication(appId);
+
                             if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
-                                StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
-                                        monitor.getClusterId());
+                                if(application.getStatus() == ApplicationStatus.Terminating) {
+                                    StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
+                                            monitor.getClusterId());
+                                } else {
+                                    StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
+                                            monitor.getClusterId());
+                                }
+
                             } else {
                                 log.info("Cluster has non terminated [members] and in the [status] "
                                         + cluster.getStatus().toString());
@@ -107,6 +119,9 @@ public class StatusChecker {
 
                         }*/
                             }
+                            } finally {
+                                TopologyManager.releaseReadLockForApplication(appId);
+                            }
                         }
                     }
 


[15/50] [abbrv] removing application status and adding applications, cluster status topic

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java
deleted file mode 100644
index 93eeb54..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.receiver.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-
-public class ApplicationStatusEventMessageListener implements MessageListener {
-    private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class);
-
-    private ApplicationStatusEventMessageQueue messageQueue;
-
-    public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue messageQueue) {
-        this.messageQueue = messageQueue;
-    }
-
-    @Override
-    public void onMessage(Message message) {
-        if (message instanceof TextMessage) {
-            TextMessage receivedMessage = (TextMessage) message;
-            try {
-                if (log.isDebugEnabled()) {
-                    log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText()));
-                }
-                // Add received message to the queue
-                messageQueue.add(receivedMessage);
-
-            } catch (JMSException e) {
-                log.error(e.getMessage(), e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java
deleted file mode 100644
index ba455c9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.receiver.application.status;
-
-
-import javax.jms.TextMessage;
-import java.util.concurrent.LinkedBlockingQueue;
-
-public class ApplicationStatusEventMessageQueue extends LinkedBlockingQueue<TextMessage> {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java
deleted file mode 100644
index 0b6cada..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.receiver.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber;
-import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.util.Constants;
-
-public class ApplicationStatusEventReceiver implements Runnable {
-    private static final Log log = LogFactory.getLog(ApplicationStatusEventReceiver.class);
-
-    private ApplicationStatusEventMessageDelegator messageDelegator;
-    private ApplicationStatusEventMessageListener messageListener;
-    private TopicSubscriber topicSubscriber;
-    private boolean terminated;
-
-    public ApplicationStatusEventReceiver() {
-        ApplicationStatusEventMessageQueue messageQueue = new ApplicationStatusEventMessageQueue();
-        this.messageDelegator = new ApplicationStatusEventMessageDelegator(messageQueue);
-        this.messageListener = new ApplicationStatusEventMessageListener(messageQueue);
-    }
-
-    public void addEventListener(EventListener eventListener) {
-        messageDelegator.addEventListener(eventListener);
-    }
-
-    @Override
-    public void run() {
-        try {
-            // Start topic subscriber thread
-            topicSubscriber = new TopicSubscriber(Constants.APPLICATION_STATUS_TOPIC);
-            topicSubscriber.setMessageListener(messageListener);
-            Thread subscriberThread = new Thread(topicSubscriber);
-            subscriberThread.start();
-            if (log.isDebugEnabled()) {
-                log.debug("Application status event message receiver thread started");
-            }
-
-            // Start Application status event message delegator thread
-            Thread receiverThread = new Thread(messageDelegator);
-            receiverThread.start();
-            if (log.isDebugEnabled()) {
-                log.debug("Application status event message delegator thread started");
-            }
-
-            // Keep the thread live until terminated
-            while (!terminated) {
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException ignore) {
-                }
-            }
-        } catch (Exception e) {
-            if (log.isErrorEnabled()) {
-                log.error("Application status failed", e);
-            }
-        }
-    }
-
-    public void terminate() {
-        topicSubscriber.terminate();
-        messageDelegator.terminate();
-        terminated = true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java
new file mode 100644
index 0000000..68d44b0
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.applications;
+
+import org.apache.commons.logging.Log;
+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.applications.ApplicationsMessageProcessorChain;
+import org.apache.stratos.messaging.util.Constants;
+
+import javax.jms.TextMessage;
+
+public class ApplicationsEventMessageDelegator implements Runnable {
+    private static final Log log = LogFactory.getLog(ApplicationsEventMessageDelegator.class);
+
+    private ApplicationsEventMessageQueue messageQueue;
+    private MessageProcessorChain processorChain;
+    private boolean terminated;
+
+    public ApplicationsEventMessageDelegator(ApplicationsEventMessageQueue messageQueue) {
+        this.messageQueue = messageQueue;
+        this.processorChain = new ApplicationsMessageProcessorChain();
+    }
+
+    public void addEventListener(EventListener eventListener) {
+        processorChain.addEventListener(eventListener);
+    }
+
+    @Override
+    public void run() {
+        try {
+            if (log.isInfoEnabled()) {
+                log.info("Application status event message delegator started");
+            }
+
+            while (!terminated) {
+                try {
+                    TextMessage message = messageQueue.take();
+
+                    // 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));
+                    }
+
+                    // Delegate message to message processor chain
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("Delegating application status event message: %s", type));
+                    }
+                    processorChain.process(type, json, null);
+                } catch (Exception e) {
+                    log.error("Failed to retrieve application status event message", e);
+                }
+            }
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Application status event message delegator failed", e);
+            }
+        }
+    }
+
+    /**
+     * Terminate topology event message delegator thread.
+     */
+    public void terminate() {
+        terminated = true;
+    }
+
+
+    private EventMessage jsonToEventMessage(String json) {
+
+        EventMessage event = new EventMessage();
+        String message;
+
+        //split the message to 3 parts using ':' first is class name, second contains the text 'message' and the third contains
+        //message
+        String[] MessageParts = json.split(":", 3);
+
+        String eventType = MessageParts[0].trim();
+        eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\""));
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Extracted [event type] %s", eventType));
+        }
+
+        event.setEventName(eventType);
+        String messageTag = MessageParts[1];
+        messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\""));
+
+        if ("message".equals(messageTag)) {
+            message = MessageParts[2].trim();
+            //Remove trailing bracket twice to get the message
+            message = message.substring(0, message.lastIndexOf("}")).trim();
+            message = message.substring(0, message.lastIndexOf("}")).trim();
+            if (message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1) {
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("[Extracted message] %s ", message));
+                }
+                event.setMessage(message);
+                return event;
+            }
+        }
+        return null;
+    }
+
+    private class EventMessage {
+        private String eventName;
+        private String message;
+
+        private String getEventName() {
+            return eventName;
+        }
+
+        private void setEventName(String eventName) {
+            this.eventName = eventName;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+
+        public void setMessage(String message) {
+            this.message = message;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
new file mode 100644
index 0000000..936c174
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+public class ApplicationsEventMessageListener implements MessageListener {
+    private static final Log log = LogFactory.getLog(ApplicationsEventMessageListener.class);
+
+    private ApplicationsEventMessageQueue messageQueue;
+
+    public ApplicationsEventMessageListener(ApplicationsEventMessageQueue messageQueue) {
+        this.messageQueue = messageQueue;
+    }
+
+    @Override
+    public void onMessage(Message message) {
+        if (message instanceof TextMessage) {
+            TextMessage receivedMessage = (TextMessage) message;
+            try {
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText()));
+                }
+                // Add received message to the queue
+                messageQueue.add(receivedMessage);
+
+            } catch (JMSException e) {
+                log.error(e.getMessage(), e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java
new file mode 100644
index 0000000..604513e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.applications;
+
+
+import javax.jms.TextMessage;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class ApplicationsEventMessageQueue extends LinkedBlockingQueue<TextMessage> {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java
new file mode 100644
index 0000000..b7577bd
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.util.Constants;
+
+public class ApplicationsEventReceiver implements Runnable {
+    private static final Log log = LogFactory.getLog(ApplicationsEventReceiver.class);
+
+    private ApplicationsEventMessageDelegator messageDelegator;
+    private ApplicationsEventMessageListener messageListener;
+    private TopicSubscriber topicSubscriber;
+    private boolean terminated;
+
+    public ApplicationsEventReceiver() {
+        ApplicationsEventMessageQueue messageQueue = new ApplicationsEventMessageQueue();
+        this.messageDelegator = new ApplicationsEventMessageDelegator(messageQueue);
+        this.messageListener = new ApplicationsEventMessageListener(messageQueue);
+    }
+
+    public void addEventListener(EventListener eventListener) {
+        messageDelegator.addEventListener(eventListener);
+    }
+
+    @Override
+    public void run() {
+        try {
+            // Start topic subscriber thread
+            topicSubscriber = new TopicSubscriber(Constants.APPLICATIONS_TOPIC);
+            topicSubscriber.setMessageListener(messageListener);
+            Thread subscriberThread = new Thread(topicSubscriber);
+            subscriberThread.start();
+            if (log.isDebugEnabled()) {
+                log.debug("Application status event message receiver thread started");
+            }
+
+            // Start Application status event message delegator thread
+            Thread receiverThread = new Thread(messageDelegator);
+            receiverThread.start();
+            if (log.isDebugEnabled()) {
+                log.debug("Application status event message delegator thread started");
+            }
+
+            // Keep the thread live until terminated
+            while (!terminated) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+            }
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Application status failed", e);
+            }
+        }
+    }
+
+    public void terminate() {
+        topicSubscriber.terminate();
+        messageDelegator.terminate();
+        terminated = true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java
new file mode 100644
index 0000000..a2fed87
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.cluster.status;
+
+import org.apache.commons.logging.Log;
+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.cluster.status.ClusterStatusMessageProcessorChain;
+import org.apache.stratos.messaging.util.Constants;
+
+import javax.jms.TextMessage;
+
+public class ClusterStatusEventMessageDelegator implements Runnable {
+    private static final Log log = LogFactory.getLog(ClusterStatusEventMessageDelegator.class);
+
+    private ClusterStatusEventMessageQueue messageQueue;
+    private MessageProcessorChain processorChain;
+    private boolean terminated;
+
+    public ClusterStatusEventMessageDelegator(ClusterStatusEventMessageQueue messageQueue) {
+        this.messageQueue = messageQueue;
+        this.processorChain = new ClusterStatusMessageProcessorChain();
+    }
+
+    public void addEventListener(EventListener eventListener) {
+        processorChain.addEventListener(eventListener);
+    }
+
+    @Override
+    public void run() {
+        try {
+            if (log.isInfoEnabled()) {
+                log.info("Application status event message delegator started");
+            }
+
+            while (!terminated) {
+                try {
+                    TextMessage message = messageQueue.take();
+
+                    // 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));
+                    }
+
+                    // Delegate message to message processor chain
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("Delegating application status event message: %s", type));
+                    }
+                    processorChain.process(type, json, null);
+                } catch (Exception e) {
+                    log.error("Failed to retrieve application status event message", e);
+                }
+            }
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Application status event message delegator failed", e);
+            }
+        }
+    }
+
+    /**
+     * Terminate topology event message delegator thread.
+     */
+    public void terminate() {
+        terminated = true;
+    }
+
+
+    private EventMessage jsonToEventMessage(String json) {
+
+        EventMessage event = new EventMessage();
+        String message;
+
+        //split the message to 3 parts using ':' first is class name, second contains the text 'message' and the third contains
+        //message
+        String[] MessageParts = json.split(":", 3);
+
+        String eventType = MessageParts[0].trim();
+        eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\""));
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Extracted [event type] %s", eventType));
+        }
+
+        event.setEventName(eventType);
+        String messageTag = MessageParts[1];
+        messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\""));
+
+        if ("message".equals(messageTag)) {
+            message = MessageParts[2].trim();
+            //Remove trailing bracket twice to get the message
+            message = message.substring(0, message.lastIndexOf("}")).trim();
+            message = message.substring(0, message.lastIndexOf("}")).trim();
+            if (message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1) {
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("[Extracted message] %s ", message));
+                }
+                event.setMessage(message);
+                return event;
+            }
+        }
+        return null;
+    }
+
+    private class EventMessage {
+        private String eventName;
+        private String message;
+
+        private String getEventName() {
+            return eventName;
+        }
+
+        private void setEventName(String eventName) {
+            this.eventName = eventName;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+
+        public void setMessage(String message) {
+            this.message = message;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java
new file mode 100644
index 0000000..12c7800
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+public class ClusterStatusEventMessageListener implements MessageListener {
+    private static final Log log = LogFactory.getLog(ClusterStatusEventMessageListener.class);
+
+    private ClusterStatusEventMessageQueue messageQueue;
+
+    public ClusterStatusEventMessageListener(ClusterStatusEventMessageQueue messageQueue) {
+        this.messageQueue = messageQueue;
+    }
+
+    @Override
+    public void onMessage(Message message) {
+        if (message instanceof TextMessage) {
+            TextMessage receivedMessage = (TextMessage) message;
+            try {
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText()));
+                }
+                // Add received message to the queue
+                messageQueue.add(receivedMessage);
+
+            } catch (JMSException e) {
+                log.error(e.getMessage(), e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java
new file mode 100644
index 0000000..9656800
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.cluster.status;
+
+
+import javax.jms.TextMessage;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class ClusterStatusEventMessageQueue extends LinkedBlockingQueue<TextMessage> {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java
new file mode 100644
index 0000000..72ccaed
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.receiver.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.util.Constants;
+
+public class ClusterStatusEventReceiver implements Runnable {
+    private static final Log log = LogFactory.getLog(ClusterStatusEventReceiver.class);
+
+    private ClusterStatusEventMessageDelegator messageDelegator;
+    private ClusterStatusEventMessageListener messageListener;
+    private TopicSubscriber topicSubscriber;
+    private boolean terminated;
+
+    public ClusterStatusEventReceiver() {
+        ClusterStatusEventMessageQueue messageQueue = new ClusterStatusEventMessageQueue();
+        this.messageDelegator = new ClusterStatusEventMessageDelegator(messageQueue);
+        this.messageListener = new ClusterStatusEventMessageListener(messageQueue);
+    }
+
+    public void addEventListener(EventListener eventListener) {
+        messageDelegator.addEventListener(eventListener);
+    }
+
+    @Override
+    public void run() {
+        try {
+            // Start topic subscriber thread
+            topicSubscriber = new TopicSubscriber(Constants.CLUSTER_STATUS_TOPIC);
+            topicSubscriber.setMessageListener(messageListener);
+            Thread subscriberThread = new Thread(topicSubscriber);
+            subscriberThread.start();
+            if (log.isDebugEnabled()) {
+                log.debug("Application status event message receiver thread started");
+            }
+
+            // Start Application status event message delegator thread
+            Thread receiverThread = new Thread(messageDelegator);
+            receiverThread.start();
+            if (log.isDebugEnabled()) {
+                log.debug("Application status event message delegator thread started");
+            }
+
+            // Keep the thread live until terminated
+            while (!terminated) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+            }
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Application status failed", e);
+            }
+        }
+    }
+
+    public void terminate() {
+        topicSubscriber.terminate();
+        messageDelegator.terminate();
+        terminated = true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
index 33f2f22..2d2d532 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
@@ -24,7 +24,9 @@ public class Constants {
 	public static final String HEALTH_STAT_TOPIC = "summarized-health-stats";
     public static final String INSTANCE_STATUS_TOPIC = "instance-status";
     public static final String INSTANCE_NOTIFIER_TOPIC = "instance-notifier";
-    public static final String APPLICATION_STATUS_TOPIC = "application-status";
+    public static final String APPLICATIONS_TOPIC = "applications";
+    public static final String CLUSTER_STATUS_TOPIC = "applications";
+
     public static final String PING_TOPIC = "ping";
     public static final String TENANT_TOPIC = "tenant";
     public static final String TENANT_RANGE_ALL = "*";


[36/50] [abbrv] git commit: adding complete application publisher task

Posted by im...@apache.org.
adding complete application publisher task


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

Branch: refs/heads/docker-grouping-merge
Commit: 0d726c8fe2ebc43576ed60d78997df2a5f921d9f
Parents: eb523d7
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 17:00:03 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 17:00:03 2014 +0530

----------------------------------------------------------------------
 .../apache/stratos/autoscaler/Constants.java    |  4 +
 .../ApplicationSynchronizeTask.java             | 51 ++++++++++++
 .../ApplicationSynchronizerTask.java            | 50 -----------
 .../ApplicationSynchronizerTaskScheduler.java   | 87 ++++++++++++++++++++
 .../topic/ApplicationsEventPublisher.java       |  9 ++
 .../internal/AutoscalerServerComponent.java     | 41 +++++++--
 .../autoscaler/util/ServiceReferenceHolder.java | 12 ++-
 7 files changed, 196 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
index 3e9e5e2..ef7be70 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java
@@ -34,6 +34,10 @@ public class Constants {
     public static final int SCHEDULE_DEFAULT_INITIAL_DELAY = 30;
     public static final int SCHEDULE_DEFAULT_PERIOD = 15;
 
+    public static final String APPLICATION_SYNC_CRON = "1 * * * * ? *";
+    public static final String APPLICATION_SYNC_TASK_NAME = "TOPOLOGY_SYNC_TASK";
+    public static final String APPLICATION_SYNC_TASK_TYPE = "TOPOLOGY_SYNC_TASK_TYPE";
+
     public static final String AUTOSCALER_CONFIG_FILE_NAME = "autoscaler.xml";
 
     public static final String CLOUD_CONTROLLER_SERVICE_SFX = "services/CloudControllerService";

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
new file mode 100644
index 0000000..e18cd12
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
+import org.wso2.carbon.ntask.core.Task;
+
+import java.util.Map;
+
+public class ApplicationSynchronizeTask implements Task {
+    private static final Log log = LogFactory.getLog(ApplicationSynchronizeTask.class);
+
+    @Override
+    public void execute() {
+        if (log.isDebugEnabled()) {
+            log.debug("Executing topology synchronization task");
+        }
+        // publish to the topic
+        if (ApplicationHolder.getApplications() != null) {
+            ApplicationsEventPublisher.sendCompleteTopologyEvent(ApplicationHolder.getApplications());
+        }
+    }
+
+    @Override
+    public void init() {
+        log.info("Applications Complete Event publisher task has been started...");
+
+    }
+
+    @Override
+    public void setProperties(Map<String, String> arg0) {}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
deleted file mode 100644
index a8ce042..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.autoscaler.applications;
-
-import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
-import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
-import org.wso2.carbon.ntask.core.Task;
-
-import java.util.Map;
-
-public class ApplicationSynchronizerTask implements Task {
-
-    @Override
-    public void setProperties(Map<String, String> stringStringMap) {
-
-    }
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void execute() {
-
-        Applications applications = ApplicationManager.getApplications();
-        if (applications != null) {
-            // publish complete Applications event
-            ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java
new file mode 100644
index 0000000..7d9eb1c
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.Constants;
+import org.wso2.carbon.ntask.common.TaskException;
+import org.wso2.carbon.ntask.core.TaskInfo;
+import org.wso2.carbon.ntask.core.TaskManager;
+import org.wso2.carbon.ntask.core.service.TaskService;
+
+import java.util.HashMap;
+
+/**
+ * Topology synchronizer task scheduler for scheduling the topology synchronizer task
+ * using carbon task service.
+ */
+public class ApplicationSynchronizerTaskScheduler {
+
+    private static final Log log = LogFactory.getLog(ApplicationSynchronizerTaskScheduler.class);
+
+    public static void schedule(TaskService taskService) {
+        TaskManager taskManager = null;
+        try {
+
+            //if (!taskService.getRegisteredTaskTypes().contains(CloudControllerConstants.TOPOLOGY_SYNC_TASK_TYPE)) {
+            // Register task type
+            taskService.registerTaskType(Constants.APPLICATION_SYNC_TASK_TYPE);
+
+                /*// Register task
+                taskManager = taskService.getTaskManager(CloudControllerConstants.TOPOLOGY_SYNC_TASK_TYPE);
+                String cronProp = dataHolder.getTopologyConfig().getProperty(CloudControllerConstants.CRON_PROPERTY);
+				String cron = cronProp != null ?  cronProp :CloudControllerConstants.TOPOLOGY_SYNC_CRON ;
+                TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(cron);
+                TaskInfo taskInfo = new TaskInfo(CloudControllerConstants.TOPOLOGY_SYNC_TASK_NAME,
+                        TopologySynchronizerTask.class.getName(),
+                        new HashMap<String, String>(), triggerInfo);
+                taskManager.registerTask(taskInfo);*/
+
+            taskManager = taskService.getTaskManager(Constants.APPLICATION_SYNC_TASK_TYPE);
+            String cronProp = Constants.APPLICATION_SYNC_CRON;
+            TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(cronProp);
+            TaskInfo taskInfo = new TaskInfo(Constants.APPLICATION_SYNC_TASK_NAME,
+                    ApplicationSynchronizeTask.class.getName(),
+                    new HashMap<String, String>(), triggerInfo);
+            taskManager.registerTask(taskInfo);
+            if (log.isDebugEnabled()) {
+                log.debug(String.format("Topology synchronization task scheduled: %s", Constants.APPLICATION_SYNC_TASK_NAME));
+            }
+            //}
+
+        } catch (Exception e) {
+            if (taskManager != null) {
+                try {
+                    taskManager.deleteTask(Constants.APPLICATION_SYNC_TASK_NAME);
+                } catch (TaskException te) {
+                    if (log.isErrorEnabled()) {
+                        log.error(te);
+                    }
+                }
+            }
+
+            String msg = String.format("Could not schedule topology synchronization task: %s",
+                    Constants.APPLICATION_SYNC_TASK_NAME);
+            log.error(msg, e);
+            throw new RuntimeException(msg, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index bbeeca4..7a1203a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -23,6 +23,15 @@ public class ApplicationsEventPublisher {
         publishEvent(new CompleteApplicationsEvent(completeApplications));
     }
 
+    public static void sendCompleteTopologyEvent(Applications applications) {
+        CompleteApplicationsEvent applicationsEvent = new CompleteApplicationsEvent(applications);
+
+        if(log.isDebugEnabled()) {
+            log.debug(String.format("Publishing complete Applications event"));
+        }
+        publishEvent(applicationsEvent);
+    }
+
     public static void sendGroupCreatedEvent(String appId, String groupId) {
         try {
             ApplicationManager.acquireReadLockForApplication(appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
index 4823057..5ada0b7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.internal;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
+import org.apache.stratos.autoscaler.applications.ApplicationSynchronizerTaskScheduler;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.message.receiver.health.AutoscalerHealthStatEventReceiver;
@@ -32,6 +33,7 @@ import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.ntask.core.service.TaskService;
 import org.wso2.carbon.registry.api.RegistryException;
 import org.wso2.carbon.registry.core.service.RegistryService;
 
@@ -41,6 +43,9 @@ import java.util.List;
 /**
  * @scr.component name=org.apache.stratos.autoscaler.internal.AutoscalerServerComponent"
  * immediate="true"
+ * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
+ * cardinality="1..1" policy="dynamic" bind="setTaskService"
+ * unbind="unsetTaskService"
  * @scr.reference name="registry.service"
  * interface=
  * "org.wso2.carbon.registry.core.service.RegistryService"
@@ -52,13 +57,13 @@ public class AutoscalerServerComponent {
 
     private static final Log log = LogFactory.getLog(AutoscalerServerComponent.class);
     AutoscalerTopologyEventReceiver asTopologyReceiver;
-//    TopicSubscriber healthStatTopicSubscriber;
+    //    TopicSubscriber healthStatTopicSubscriber;
     AutoscalerHealthStatEventReceiver autoscalerHealthStatEventReceiver;
 
     protected void activate(ComponentContext componentContext) throws Exception {
         try {
             // Start topology receiver
-        	asTopologyReceiver = new AutoscalerTopologyEventReceiver();
+            asTopologyReceiver = new AutoscalerTopologyEventReceiver();
             Thread topologyTopicSubscriberThread = new Thread(asTopologyReceiver);
             topologyTopicSubscriberThread.start();
             if (log.isDebugEnabled()) {
@@ -88,7 +93,7 @@ public class AutoscalerServerComponent {
                 Partition partition = partitionIterator.next();
                 PartitionManager.getInstance().addPartitionToInformationModel(partition);
             }
-            
+
             // Adding the network partitions stored in registry to the information model
             List<NetworkPartitionLbHolder> nwPartitionHolders = RegistryManager.getInstance().retrieveNetworkPartitionLbHolders();
             Iterator<NetworkPartitionLbHolder> nwPartitionIterator = nwPartitionHolders.iterator();
@@ -96,7 +101,7 @@ public class AutoscalerServerComponent {
                 NetworkPartitionLbHolder nwPartition = nwPartitionIterator.next();
                 PartitionManager.getInstance().addNetworkPartitionLbHolder(nwPartition);
             }
-            
+
             List<AutoscalePolicy> asPolicies = RegistryManager.getInstance().retrieveASPolicies();
             Iterator<AutoscalePolicy> asPolicyIterator = asPolicies.iterator();
             while (asPolicyIterator.hasNext()) {
@@ -112,6 +117,14 @@ public class AutoscalerServerComponent {
             }
 
             if (log.isInfoEnabled()) {
+                log.info("Scheduling tasks to publish applications");
+            }
+
+            ApplicationSynchronizerTaskScheduler
+                    .schedule(ServiceReferenceHolder.getInstance()
+                            .getTaskService());
+
+            if (log.isInfoEnabled()) {
                 log.info("Autoscaler Server Component activated");
             }
         } catch (Throwable e) {
@@ -120,10 +133,10 @@ public class AutoscalerServerComponent {
     }
 
     protected void deactivate(ComponentContext context) {
-    	asTopologyReceiver.terminate();
-    	autoscalerHealthStatEventReceiver.terminate();
+        asTopologyReceiver.terminate();
+        autoscalerHealthStatEventReceiver.terminate();
     }
-    
+
     protected void setRegistryService(RegistryService registryService) {
         if (log.isDebugEnabled()) {
             log.debug("Setting the Registry Service");
@@ -143,4 +156,18 @@ public class AutoscalerServerComponent {
         }
         ServiceReferenceHolder.getInstance().setRegistry(null);
     }
+
+    protected void setTaskService(TaskService taskService) {
+        if (log.isDebugEnabled()) {
+            log.debug("Setting the Task Service");
+        }
+        ServiceReferenceHolder.getInstance().setTaskService(taskService);
+    }
+
+    protected void unsetTaskService(TaskService taskService) {
+        if (log.isDebugEnabled()) {
+            log.debug("Unsetting the Task Service");
+        }
+        ServiceReferenceHolder.getInstance().setTaskService(null);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/0d726c8f/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
index 00629dc..9040f74 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
@@ -21,13 +21,15 @@ package org.apache.stratos.autoscaler.util;
 */
 
 
+import org.wso2.carbon.ntask.core.service.TaskService;
 import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.registry.core.session.UserRegistry;
 
 public class ServiceReferenceHolder {
 	
 	private static ServiceReferenceHolder instance;
-	private Registry registry;	
+	private Registry registry;
+    private TaskService taskService;
 
 	private ServiceReferenceHolder() {
 	}
@@ -46,4 +48,12 @@ public class ServiceReferenceHolder {
     public Registry getRegistry() {
 		return registry;
 	}
+
+    public TaskService getTaskService() {
+        return taskService;
+    }
+
+    public void setTaskService(TaskService taskService) {
+        this.taskService = taskService;
+    }
 }


[27/50] [abbrv] adding service group deployment to auto scaler

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
index 23b4099..d0665cf 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
@@ -1,1155 +1,1327 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax28="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax25="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax216="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax214="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.apache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax28="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax25="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax216="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax212="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.ap
 ache.org">
     <wsdl:documentation>AutoScalerService</wsdl:documentation>
     <wsdl:types>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="InvalidServiceGroupException">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
             <xs:complexType name="NonExistingLBException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidPartitionException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd">
             <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax25:Property"></xs:element>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax25:Property"/>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Property">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax217="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax213="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
-            <xs:import namespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://model.policy.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+        <xs:schema xmlns:ax214="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax217="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
+            <xs:import namespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://model.policy.autoscaler.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
+            <xs:element name="serviceGroupExist">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="serviceGroupExistResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="getValidDeploymentPoliciesforCartridge">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getValidDeploymentPoliciesforCartridgeResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceLBClusterId">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceType" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="serviceType" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceLBClusterIdResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getServiceGroup">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getServiceGroupResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax212:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="groupId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="groupId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionGroups">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax28:PartitionGroup"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax28:PartitionGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax24:Partition"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDefaultLBClusterId">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDefaultLBClusterIdResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax217:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllDeploymentPolicies">
                 <xs:complexType>
-                    <xs:sequence></xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllDeploymentPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAvailablePartitions">
                 <xs:complexType>
-                    <xs:sequence></xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAvailablePartitionsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAutoScalingPolicy">
                 <xs:complexType>
-                    <xs:sequence></xs:sequence>
+                    <xs:sequence/>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax217:AutoscalePolicy"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="AutoScalerServiceInvalidServiceGroupException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax219:InvalidServiceGroupException"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="deployServiceGroup">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax212:ServiceGroup"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkServiceLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkServiceLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceNonExistingLBException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="NonExistingLBException" nillable="true" type="ax217:NonExistingLBException"></xs:element>
+                        <xs:element minOccurs="0" name="NonExistingLBException" nillable="true" type="ax219:NonExistingLBException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkDefaultLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkDefaultLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkClusterLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkClusterLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceInvalidPartitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax217:InvalidPartitionException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax219:InvalidPartitionException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addPartition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax24:Partition"></xs:element>
+                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax24:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addPartitionResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax217:InvalidPolicyException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax219:InvalidPolicyException"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="depPolicy" nillable="true" type="ax23:DeploymentPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="depPolicy" nillable="true" type="ax23:DeploymentPolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="aspolicy" nillable="true" type="ax214:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="aspolicy" nillable="true" type="ax217:AutoscalePolicy"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="ServiceGroup">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax212:Dependencies"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="Dependencies">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
         <xs:schema xmlns:ax29="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
             <xs:complexType name="PartitionGroup">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax29:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax29:Partition"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://model.policy.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="AutoscalePolicy">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax214:LoadThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax216:LoadThresholds"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax214:LoadAverageThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax214:MemoryConsumptionThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax214:RequestsInFlightThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax216:LoadAverageThresholds"/>
+                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax216:MemoryConsumptionThresholds"/>
+                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax216:RequestsInFlightThresholds"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadAverageThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="MemoryConsumptionThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="RequestsInFlightThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema xmlns:ax27="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax210="http://partition.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
+            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"/>
             <xs:complexType name="DeploymentPolicy">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax27:Partition"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax28:PartitionGroup"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax27:Partition"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax28:PartitionGroup"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema xmlns:ax26="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"/>
             <xs:complexType name="Partition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"/>
+                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"/>
+                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"/>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"/>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
     </wsdl:types>
     <wsdl:message name="getPartitionsOfDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicy"/>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="getDefaultLBClusterIdRequest">
-        <wsdl:part name="parameters" element="ns:getDefaultLBClusterId"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDefaultLBClusterId"/>
     </wsdl:message>
     <wsdl:message name="getDefaultLBClusterIdResponse">
-        <wsdl:part name="parameters" element="ns:getDefaultLBClusterIdResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDefaultLBClusterIdResponse"/>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfGroupRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroup"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfGroup"/>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfGroupResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroupResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfGroupResponse"/>
     </wsdl:message>
     <wsdl:message name="getAllAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="getAllAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"/>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"/>
+    </wsdl:message>
+    <wsdl:message name="serviceGroupExistRequest">
+        <wsdl:part name="parameters" element="ns:serviceGroupExist"/>
+    </wsdl:message>
+    <wsdl:message name="serviceGroupExistResponse">
+        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"/>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidPolicyException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"/>
+    </wsdl:message>
+    <wsdl:message name="getServiceGroupRequest">
+        <wsdl:part name="parameters" element="ns:getServiceGroup"/>
+    </wsdl:message>
+    <wsdl:message name="getServiceGroupResponse">
+        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"/>
     </wsdl:message>
     <wsdl:message name="getAllDeploymentPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPolicies"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllDeploymentPolicies"/>
     </wsdl:message>
     <wsdl:message name="getAllDeploymentPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPoliciesResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllDeploymentPoliciesResponse"/>
     </wsdl:message>
     <wsdl:message name="getValidDeploymentPoliciesforCartridgeRequest">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridge"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridge"/>
     </wsdl:message>
     <wsdl:message name="getValidDeploymentPoliciesforCartridgeResponse">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridgeResponse"/>
     </wsdl:message>
     <wsdl:message name="getAllAvailablePartitionsRequest">
-        <wsdl:part name="parameters" element="ns:getAllAvailablePartitions"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllAvailablePartitions"/>
     </wsdl:message>
     <wsdl:message name="getAllAvailablePartitionsResponse">
-        <wsdl:part name="parameters" element="ns:getAllAvailablePartitionsResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAllAvailablePartitionsResponse"/>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"/>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="checkClusterLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicy"/>
     </wsdl:message>
     <wsdl:message name="checkClusterLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="checkDefaultLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicy"/>
     </wsdl:message>
     <wsdl:message name="checkDefaultLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="getPartitionRequest">
-        <wsdl:part name="parameters" element="ns:getPartition"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartition"/>
     </wsdl:message>
     <wsdl:message name="getPartitionResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionResponse"/>
     </wsdl:message>
     <wsdl:message name="addPartitionRequest">
-        <wsdl:part name="parameters" element="ns:addPartition"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addPartition"/>
     </wsdl:message>
     <wsdl:message name="addPartitionResponse">
-        <wsdl:part name="parameters" element="ns:addPartitionResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addPartitionResponse"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidPartitionException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPartitionException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPartitionException"/>
     </wsdl:message>
     <wsdl:message name="checkServiceLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicy"/>
     </wsdl:message>
     <wsdl:message name="checkServiceLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="addDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addDeploymentPolicy"/>
     </wsdl:message>
     <wsdl:message name="addDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicyResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:addDeploymentPolicyResponse"/>
     </wsdl:message>
     <wsdl:message name="getServiceLBClusterIdRequest">
-        <wsdl:part name="parameters" element="ns:getServiceLBClusterId"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceLBClusterId"/>
     </wsdl:message>
     <wsdl:message name="getServiceLBClusterIdResponse">
-        <wsdl:part name="parameters" element="ns:getServiceLBClusterIdResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getServiceLBClusterIdResponse"/>
+    </wsdl:message>
+    <wsdl:message name="deployServiceGroupRequest">
+        <wsdl:part name="parameters" element="ns:deployServiceGroup"/>
+    </wsdl:message>
+    <wsdl:message name="AutoScalerServiceInvalidServiceGroupException">
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidServiceGroupException"/>
     </wsdl:message>
     <wsdl:message name="getPartitionGroupsRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionGroups"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionGroups"/>
     </wsdl:message>
     <wsdl:message name="getPartitionGroupsResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionGroupsResponse"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:getPartitionGroupsResponse"/>
     </wsdl:message>
     <wsdl:message name="checkLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkLBExistenceAgainstPolicy"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:checkLBExistenceAgainstPolicy"/>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceNonExistingLBException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceNonExistingLBException"></wsdl:part>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceNonExistingLBException"/>
     </wsdl:message>
     <wsdl:portType name="AutoScalerServicePortType">
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <wsdl:input message="ns:getPartitionsOfDeploymentPolicyRequest" wsaw:Action="urn:getPartitionsOfDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:getPartitionsOfDeploymentPolicyResponse" wsaw:Action="urn:getPartitionsOfDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getPartitionsOfDeploymentPolicyRequest" wsaw:Action="urn:getPartitionsOfDeploymentPolicy"/>
+            <wsdl:output message="ns:getPartitionsOfDeploymentPolicyResponse" wsaw:Action="urn:getPartitionsOfDeploymentPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <wsdl:input message="ns:getDefaultLBClusterIdRequest" wsaw:Action="urn:getDefaultLBClusterId"></wsdl:input>
-            <wsdl:output message="ns:getDefaultLBClusterIdResponse" wsaw:Action="urn:getDefaultLBClusterIdResponse"></wsdl:output>
+            <wsdl:input message="ns:getDefaultLBClusterIdRequest" wsaw:Action="urn:getDefaultLBClusterId"/>
+            <wsdl:output message="ns:getDefaultLBClusterIdResponse" wsaw:Action="urn:getDefaultLBClusterIdResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <wsdl:input message="ns:getPartitionsOfGroupRequest" wsaw:Action="urn:getPartitionsOfGroup"></wsdl:input>
-            <wsdl:output message="ns:getPartitionsOfGroupResponse" wsaw:Action="urn:getPartitionsOfGroupResponse"></wsdl:output>
+            <wsdl:input message="ns:getPartitionsOfGroupRequest" wsaw:Action="urn:getPartitionsOfGroup"/>
+            <wsdl:output message="ns:getPartitionsOfGroupResponse" wsaw:Action="urn:getPartitionsOfGroupResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <wsdl:input message="ns:getAllAutoScalingPolicyRequest" wsaw:Action="urn:getAllAutoScalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:getAllAutoScalingPolicyResponse" wsaw:Action="urn:getAllAutoScalingPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getAllAutoScalingPolicyRequest" wsaw:Action="urn:getAllAutoScalingPolicy"/>
+            <wsdl:output message="ns:getAllAutoScalingPolicyResponse" wsaw:Action="urn:getAllAutoScalingPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"/>
+            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"/>
+        </wsdl:operation>
+        <wsdl:operation name="serviceGroupExist">
+            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"/>
+            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"/>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
+            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"/>
+            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"/>
+        </wsdl:operation>
+        <wsdl:operation name="getServiceGroup">
+            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"/>
+            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getAllDeploymentPolicies">
-            <wsdl:input message="ns:getAllDeploymentPoliciesRequest" wsaw:Action="urn:getAllDeploymentPolicies"></wsdl:input>
-            <wsdl:output message="ns:getAllDeploymentPoliciesResponse" wsaw:Action="urn:getAllDeploymentPoliciesResponse"></wsdl:output>
+            <wsdl:input message="ns:getAllDeploymentPoliciesRequest" wsaw:Action="urn:getAllDeploymentPolicies"/>
+            <wsdl:output message="ns:getAllDeploymentPoliciesResponse" wsaw:Action="urn:getAllDeploymentPoliciesResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <wsdl:input message="ns:getValidDeploymentPoliciesforCartridgeRequest" wsaw:Action="urn:getValidDeploymentPoliciesforCartridge"></wsdl:input>
-            <wsdl:output message="ns:getValidDeploymentPoliciesforCartridgeResponse" wsaw:Action="urn:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:output>
+            <wsdl:input message="ns:getValidDeploymentPoliciesforCartridgeRequest" wsaw:Action="urn:getValidDeploymentPoliciesforCartridge"/>
+            <wsdl:output message="ns:getValidDeploymentPoliciesforCartridgeResponse" wsaw:Action="urn:getValidDeploymentPoliciesforCartridgeResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getAllAvailablePartitions">
-            <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"></wsdl:input>
-            <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"></wsdl:output>
+            <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"/>
+            <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"></wsdl:input>
-            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"/>
+            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="checkClusterLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkClusterLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicy"></wsdl:input>
-            <wsdl:output message="ns:checkClusterLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:checkClusterLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicy"/>
+            <wsdl:output message="ns:checkClusterLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="checkDefaultLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkDefaultLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicy"></wsdl:input>
-            <wsdl:output message="ns:checkDefaultLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:checkDefaultLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicy"/>
+            <wsdl:output message="ns:checkDefaultLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="getPartition">
-            <wsdl:input message="ns:getPartitionRequest" wsaw:Action="urn:getPartition"></wsdl:input>
-            <wsdl:output message="ns:getPartitionResponse" wsaw:Action="urn:getPartitionResponse"></wsdl:output>
+            <wsdl:input message="ns:getPartitionRequest" wsaw:Action="urn:getPartition"/>
+            <wsdl:output message="ns:getPartitionResponse" wsaw:Action="urn:getPartitionResponse"/>
         </wsdl:operation>
         <wsdl:operation name="addPartition">
-            <wsdl:input message="ns:addPartitionRequest" wsaw:Action="urn:addPartition"></wsdl:input>
-            <wsdl:output message="ns:addPartitionResponse" wsaw:Action="urn:addPartitionResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPartitionException" name="AutoScalerServiceInvalidPartitionException" wsaw:Action="urn:addPartitionAutoScalerServiceInvalidPartitionException"></wsdl:fault>
+            <wsdl:input message="ns:addPartitionRequest" wsaw:Action="urn:addPartition"/>
+            <wsdl:output message="ns:addPartitionResponse" wsaw:Action="urn:addPartitionResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPartitionException" name="AutoScalerServiceInvalidPartitionException" wsaw:Action="urn:addPartitionAutoScalerServiceInvalidPartitionException"/>
         </wsdl:operation>
         <wsdl:operation name="checkServiceLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkServiceLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicy"></wsdl:input>
-            <wsdl:output message="ns:checkServiceLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicyResponse"></wsdl:output>
+            <wsdl:input message="ns:checkServiceLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicy"/>
+            <wsdl:output message="ns:checkServiceLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicyResponse"/>
         </wsdl:operation>
         <wsdl:operation name="addDeploymentPolicy">
-            <wsdl:input message="ns:addDeploymentPolicyRequest" wsaw:Action="urn:addDeploymentPolicy"></wsdl:input>
-            <wsdl:output message="ns:addDeploymentPolicyResponse" wsaw:Action="urn:addDeploymentPolicyResponse"></wsdl:output>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addDeploymentPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
+            <wsdl:input message="ns:addDeploymentPolicyRequest" wsaw:Action="urn:addDeploymentPolicy"/>
+            <wsdl:output message="ns:addDeploymentPolicyResponse" wsaw:Action="urn:addDeploymentPolicyResponse"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addDeploymentPolicyAutoScalerServiceInvalidPolicyException"/>
         </wsdl:operation>
         <wsdl:operation name="getServiceLBClusterId">
-            <wsdl:input message="ns:getServiceLBClusterIdRequest" wsaw:Action="urn:getServiceLBClusterId"></wsdl:input>
-            <wsdl:output message="ns:getServiceLBClusterIdResponse" wsaw:Action="urn:getServiceLBClusterIdResponse"></wsdl:output>
+            <wsdl:input message="ns:getServiceLBClusterIdRequest" wsaw:Action="urn:getServiceLBClusterId"/>
+            <wsdl:output message="ns:getServiceLBClusterIdResponse" wsaw:Action="urn:getServiceLBClusterIdResponse"/>
+        </wsdl:operation>
+        <wsdl:operation name="deployServiceGroup">
+            <wsdl:input message="ns:deployServiceGroupRequest" wsaw:Action="urn:deployServiceGroup"/>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidServiceGroupException" name="AutoScalerServiceInvalidServiceGroupException" wsaw:Action="urn:deployServiceGroupAutoScalerServiceInvalidServiceGroupException"/>
         </wsdl:operation>
         <wsdl:operation name="getPartitionGroups">
-            <wsdl:input message="ns:getPartitionGroupsRequest" wsaw:Action="urn:getPartitionGroups"></wsdl:input>
-            <wsdl:output message="ns:getPartitionGroupsResponse" wsaw:Action="urn:getPartitionGroupsResponse"></wsdl:output>
+            <wsdl:input message="ns:getPartitionGroupsRequest" wsaw:Action="urn:getPartitionGroups"/>
+            <wsdl:output message="ns:getPartitionGroupsResponse" wsaw:Action="urn:getPartitionGroupsResponse"/>
         </wsdl:operation>
         <wsdl:operation name="checkLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkLBExistenceAgainstPolicy"></wsdl:input>
-            <wsdl:fault message="ns:AutoScalerServiceNonExistingLBException" name="AutoScalerServiceNonExistingLBException" wsaw:Action="urn:checkLBExistenceAgainstPolicyAutoScalerServiceNonExistingLBException"></wsdl:fault>
+            <wsdl:input message="ns:checkLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkLBExistenceAgainstPolicy"/>
+            <wsdl:fault message="ns:AutoScalerServiceNonExistingLBException" name="AutoScalerServiceNonExistingLBException" wsaw:Action="urn:checkLBExistenceAgainstPolicyAutoScalerServiceNonExistingLBException"/>
         </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="AutoScalerServiceSoap11Binding" type="ns:AutoScalerServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <soap:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <soap:operation soapAction="urn:getDefaultLBClusterId" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getDefaultLBClusterId" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <soap:operation soapAction="urn:getPartitionsOfGroup" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getPartitionsOfGroup" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <soap:operation soapAction="urn:getAllAutoScalingPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getAllAutoScalingPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="serviceGroupExist">
+            <soap:operation soapAction="urn:serviceGroupExist" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap:fault>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"/>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="getServiceGroup">
+            <soap:operation soapAction="urn:getServiceGroup" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
         <wsdl:operation name="getAllDeploymentPolicies">
-            <soap:operation soapAction="urn:getAllDeploymentPolicies" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getAllDeploymentPolicies" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <soap:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAvailablePartitions">
-            <soap:operation soapAction="urn:getAllAvailablePartitions" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getAllAvailablePartitions" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkDefaultLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkClusterLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartition">
-            <soap:operation soapAction="urn:getPartition" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getPartition" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addPartition">
-            <soap:operation soapAction="urn:addPartition" style="document"></soap:operation>
+            <soap:operation soapAction="urn:addPartition" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPartitionException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPartitionException"></soap:fault>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPartitionException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="checkServiceLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addDeploymentPolicy">
-            <soap:operation soapAction="urn:addDeploymentPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:addDeploymentPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap:fault>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceLBClusterId">
-            <soap:operation soapAction="urn:getServiceLBClusterId" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getServiceLBClusterId" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionGroups">
-            <soap:operation soapAction="urn:getPartitionGroups" style="document"></soap:operation>
+            <soap:operation soapAction="urn:getPartitionGroups" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="deployServiceGroup">
+            <soap:operation soapAction="urn:deployServiceGroup" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceInvalidServiceGroupException">
+                <soap:fault use="literal" name="AutoScalerServiceInvalidServiceGroupException"/>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="checkLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkLBExistenceAgainstPolicy" style="document"></soap:operation>
+            <soap:operation soapAction="urn:checkLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap:body use="literal"></soap:body>
+                <soap:body use="literal"/>
             </wsdl:input>
             <wsdl:fault name="AutoScalerServiceNonExistingLBException">
-                <soap:fault use="literal" name="AutoScalerServiceNonExistingLBException"></soap:fault>
+                <soap:fault use="literal" name="AutoScalerServiceNonExistingLBException"/>
             </wsdl:fault>
         </wsdl:operation>
     </wsdl:binding>
     <wsdl:binding name="AutoScalerServiceSoap12Binding" type="ns:AutoScalerServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap12:binding>
+        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <soap12:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <soap12:operation soapAction="urn:getDefaultLBClusterId" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getDefaultLBClusterId" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <soap12:operation soapAction="urn:getPartitionsOfGroup" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getPartitionsOfGroup" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <soap12:operation soapAction="urn:getAllAutoScalingPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getAllAutoScalingPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <soap12:operation soapAction="urn:getDeploymentPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getDeploymentPolicy" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="serviceGroupExist">
+            <soap12:operation soapAction="urn:serviceGroupExist" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <soap12:operation soapAction="urn:addAutoScalingPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:addAutoScalingPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPolicyException">
-                <soap12:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap12:fault>
+                <soap12:fault use="literal" name="AutoScalerServiceInvalidPolicyException"/>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="getServiceGroup">
+            <soap12:operation soapAction="urn:getServiceGroup" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
         <wsdl:operation name="getAllDeploymentPolicies">
-            <soap12:operation soapAction="urn:getAllDeploymentPolicies" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getAllDeploymentPolicies" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <soap12:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAvailablePartitions">
-            <soap12:operation soapAction="urn:getAllAvailablePartitions" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getAllAvailablePartitions" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <soap12:operation soapAction="urn:getAutoscalingPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getAutoscalingPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkDefaultLBExistenceAgainstPolicy">
-            <soap12:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkClusterLBExistenceAgainstPolicy">
-            <soap12:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartition">
-            <soap12:operation soapAction="urn:getPartition" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:getPartition" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addPartition">
-            <soap12:operation soapAction="urn:addPartition" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:addPartition" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPartitionException">
-                <soap12:fault use="literal" name="AutoScalerServiceInvalidPartitionException"></soap12:fault>
+                <soap12:fault use="literal" name="AutoScalerServiceInvalidPartitionException"/>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="checkServiceLBExistenceAgainstPolicy">
-            <soap12:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addDeploymentPolicy">
-            <soap12:operation soapAction="urn:addDeploymentPolicy" style="document"></soap12:operation>
+            <soap12:operation soapAction="urn:addDeploymentPolicy" style="document"/>
             <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
+                <soap12:body use="literal"/>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="li

<TRUNCATED>

[24/50] [abbrv] git commit: adding cluster reset processor support

Posted by im...@apache.org.
adding cluster reset processor support


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

Branch: refs/heads/docker-grouping-merge
Commit: 4de85b55bcce498cffcf3aa89a2d01c9215783d6
Parents: 696bc0d
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 14:59:14 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 14:59:14 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        | 16 +++++++++++--
 .../topology/ClusterResetEventListener.java     | 24 ++++++++++++++++++++
 .../topology/TopologyMessageProcessorChain.java |  6 +++++
 3 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4de85b55/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index aacc31c..4678250 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -168,13 +168,13 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
             }
         });
 
-        topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() {
+        topologyEventReceiver.addEventListener(new ClusterResetEventListener() {
             @Override
             protected void onEvent(Event event) {
 
                 log.info("[ClusterCreatedEvent] Received: " + event.getClass());
 
-                ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
+                ClusterResetEvent clusterCreatedEvent = (ClusterResetEvent) event;
                 String clusterId = clusterCreatedEvent.getClusterId();
                 AbstractClusterMonitor clusterMonitor =
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
@@ -186,6 +186,18 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
             }
         });
 
+        topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                log.info("[ClusterCreatedEvent] Received: " + event.getClass());
+
+                ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
+                //TODO notify the monitor about cluster creation
+
+            }
+        });
+
         topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() {
             @Override
             protected void onEvent(Event event) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/4de85b55/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java
new file mode 100644
index 0000000..1516590
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.topology;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterResetEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4de85b55/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index 048e9a3..f5ada89 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -36,6 +36,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
     private ServiceCreatedMessageProcessor serviceCreatedMessageProcessor;
     private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor;
     private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
+    private ClusterResetMessageProcessor clusterResetMessageProcessor;
     private ClusterActivatedProcessor clusterActivatedProcessor;
     private ClusterInActivateProcessor clusterInActivateProcessor;
     private ClusterRemovedMessageProcessor clusterRemovedMessageProcessor;
@@ -75,6 +76,9 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
         clusterTerminatedProcessor = new ClusterTerminatedProcessor();
         add(clusterTerminatedProcessor);
 
+        clusterResetMessageProcessor = new ClusterResetMessageProcessor();
+        add(clusterResetMessageProcessor);
+
         clusterTerminatingProcessor = new ClusterTerminatingProcessor();
         add(clusterTerminatingProcessor);
 
@@ -117,6 +121,8 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
             clusterRemovedMessageProcessor.addEventListener(eventListener);
         } else if(eventListener instanceof ClusterTerminatedEventListener){
             clusterTerminatedProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof ClusterResetEventListener){
+            clusterResetMessageProcessor.addEventListener(eventListener);
         } else if(eventListener instanceof  ClusterTerminatingEventListener){
             clusterTerminatingProcessor.addEventListener(eventListener);
         }else if (eventListener instanceof InstanceSpawnedEventListener) {


[06/50] [abbrv] git commit: fixing appId issue and calculating status issue

Posted by im...@apache.org.
fixing appId issue and calculating status issue


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

Branch: refs/heads/docker-grouping-merge
Commit: fe4ccedd3c31bd0c4ca3153dee0affad1880360f
Parents: d41da06
Author: reka <rt...@gmail.com>
Authored: Thu Oct 30 19:02:30 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Oct 30 19:04:08 2014 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/monitor/AbstractClusterMonitor.java     | 1 -
 .../stratos/autoscaler/status/checker/StatusChecker.java       | 6 ++++++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/fe4ccedd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 881f838..8ec65c7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -63,7 +63,6 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
 
     protected String clusterId;
     protected String serviceId;
-    protected String appId;
 
     protected boolean hasFaultyMember = false;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/fe4ccedd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 348537e..a23e5bd 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -381,6 +381,9 @@ public class StatusChecker {
                 groupCreated = false;
             } else if (group.getStatus() == GroupStatus.Inactive) {
                 status = GroupStatus.Inactive;
+                groupActive = false;
+                groupTerminated = false;
+                groupCreated = false;
                 break;
             } else if (group.getStatus() == GroupStatus.Terminated) {
                 groupActive = false;
@@ -424,6 +427,9 @@ public class StatusChecker {
                 clusterCreated = false;
             } else if (cluster.getStatus() == ClusterStatus.Inactive) {
                 status = ClusterStatus.Inactive;
+                clusterActive = false;
+                clusterTerminated = false;
+                clusterCreated = false;
                 break;
             } else if (cluster.getStatus() == ClusterStatus.Terminated) {
                 clusterActive = false;


[02/50] [abbrv] git commit: adding created events for cluster and group in topology and in app statuc topics

Posted by im...@apache.org.
adding created events for cluster and group in topology and in app statuc topics


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

Branch: refs/heads/docker-grouping-merge
Commit: 2414bca4bf4ffcd373f010156c7d683afd11567d
Parents: 58f42ce
Author: reka <rt...@gmail.com>
Authored: Thu Oct 30 17:57:09 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Oct 30 18:01:38 2014 +0530

----------------------------------------------------------------------
 .../status/AppStatusClusterCreatedEvent.java    |  50 +++++++++
 .../status/AppStatusGroupCreatedEvent.java      |  44 ++++++++
 .../event/topology/GroupCreatedEvent.java       |  43 ++++++++
 .../AppStatusClusterCreatedEventListener.java   |  24 ++++
 .../AppStatusGroupCreatedEventListener.java     |  24 ++++
 .../topology/GroupCreatedEventListener.java     |  27 +++++
 ...AppStatusClusterCreatedMessageProcessor.java |  58 ++++++++++
 .../AppStatusGroupCreatedMessageProcessor.java  |  62 +++++++++++
 .../status/AppStatusMessageProcessorChain.java  |  15 ++-
 .../topology/GroupCreatedProcessor.java         | 109 +++++++++++++++++++
 .../topology/TopologyMessageProcessorChain.java |   6 +
 11 files changed, 461 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
new file mode 100644
index 0000000..6480af2
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusClusterCreatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
new file mode 100644
index 0000000..04ee30e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupCreatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public AppStatusGroupCreatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java
new file mode 100644
index 0000000..e3794f0
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.topology;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * Group Activated Event which will be sent to Topology upon group activation
+ */
+public class GroupCreatedEvent extends Event {
+    private String appId;
+    private String groupId;
+
+    public GroupCreatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
new file mode 100644
index 0000000..c0c62f9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppStatusClusterCreatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
new file mode 100644
index 0000000..82386a3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppStatusGroupCreatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
new file mode 100644
index 0000000..3fb2d11
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.topology;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This will get triggered by the groups activation processor after processing the event
+ */
+public abstract class GroupCreatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
new file mode 100644
index 0000000..a743c43
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppStatusClusterCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppStatusClusterCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppStatusClusterCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppStatusClusterCreatedEvent event = (AppStatusClusterCreatedEvent) Util.jsonToObject(message, AppStatusClusterCreatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
new file mode 100644
index 0000000..b9a1c6d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusGroupCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(AppStatusGroupCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppStatusGroupCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppStatusGroupCreatedEvent event =
+                    (AppStatusGroupCreatedEvent) Util.jsonToObject(message, AppStatusGroupCreatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received AppStatusGroupCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group created message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
index 14b8bc2..34cd02b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
@@ -31,10 +31,12 @@ import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 public class AppStatusMessageProcessorChain extends MessageProcessorChain {
     private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
 
+    private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
     private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
     private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
     private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
     private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
+    private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor;
     private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
     private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor;
     private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor;
@@ -48,6 +50,9 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain {
 
     public void initialize() {
         // Add instance notifier event processors
+        clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor();
+        add(clusterCreatedMessageProcessor);
+
         clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor();
         add(clusterActivatedMessageProcessor);
 
@@ -56,9 +61,13 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain {
 
         clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
         add(clusterTerminatingMessageProcessor);
+
         clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
         add(clusterTerminatedMessageProcessor);
 
+        groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor();
+        add(groupCreatedMessageProcessor);
+
         groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor();
         add(groupActivatedMessageProcessor);
 
@@ -92,10 +101,14 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain {
     }
 
     public void addEventListener(EventListener eventListener) {
-        if (eventListener instanceof AppStatusClusterActivatedEventListener) {
+        if(eventListener instanceof AppStatusClusterCreatedEventListener) {
+            clusterCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusClusterActivatedEventListener) {
             clusterActivatedMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof AppStatusClusterInactivateEventListener) {
             clusterInActivateMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusGroupCreatedEventListener) {
+            groupCreatedMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof AppStatusGroupActivatedEventListener) {
             groupActivatedMessageProcessor.addEventListener(eventListener);
         } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
new file mode 100644
index 0000000..4a8a744
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.topology;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.topology.Group;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
+import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
+import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupCreatedProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupCreatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupCreatedEvent event = (GroupCreatedEvent) Util.
+                    jsonToObject(message, GroupCreatedEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (GroupCreatedEvent event,Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the topology
+            if (!group.isStateTransitionValid(GroupStatus.Created)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+            }
+            group.setStatus(GroupStatus.Created);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/2414bca4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index 4f6d3a9..1ed5576 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -46,6 +46,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
     private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor;
     private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor;
     private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor;
+    private GroupCreatedProcessor groupCreatedProcessor;
     private GroupActivatedProcessor groupActivatedProcessor;
     private GroupInActivateProcessor groupInActivateProcessor;
     private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor;
@@ -109,6 +110,9 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
         memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor();
         add(memberTerminatedMessageProcessor);
 
+        groupCreatedProcessor = new GroupCreatedProcessor();
+        add(groupCreatedProcessor);
+
         groupActivatedProcessor = new GroupActivatedProcessor();
         add(groupActivatedProcessor);
 
@@ -179,6 +183,8 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
             memberMaintenanceModeProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof GroupActivatedEventListener) {
             groupActivatedProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof GroupCreatedEventListener) {
+            groupCreatedProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof GroupInActivateEventListener) {
             groupInActivateProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof GroupTerminatedEventListener){


[45/50] [abbrv] more refactoring

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java
deleted file mode 100755
index 2b3ea8b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
-
- *  http://www.apache.org/licenses/LICENSE-2.0
-
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-
-
-public class PayloadFactory {
-
-	private static Log log = LogFactory.getLog(PayloadFactory.class);
-
-    /**
-     * Creates and returns a PayloadData instance
-     *
-     * @param cartridgeProvider Cartridge provider
-     * @param cartridgeType Cartridge type
-     * @param basicPayloadData BasicPayloadData instance
-     * @return Payload subscription
-     */
-	public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType,
-                                                     BasicPayloadData basicPayloadData)
-            throws ApplicationDefinitionException {
-
-        PayloadData payloadData = null;
-
-        //TODO: fix after adding the property Category to Cartridge Definition
-        if (cartridgeProvider.equals("data")) {
-            payloadData = new DataCartridgePayloadData(basicPayloadData);
-        } else {
-            payloadData = new FrameworkCartridgePayloadData(basicPayloadData);
-        }
-
-        if(payloadData == null) {
-            throw new ApplicationDefinitionException("Unable to find matching payload for cartridge type " + cartridgeType +
-                    ", provider " + cartridgeProvider);
-        }
-
-        return payloadData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index ca2cc1e..a914946 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -24,17 +24,14 @@ import com.google.common.net.InetAddresses;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser;
 import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable;
 import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
 import org.apache.stratos.cloud.controller.exception.*;
-import org.apache.stratos.cloud.controller.interfaces.ApplicationParser;
 import org.apache.stratos.cloud.controller.interfaces.CloudControllerService;
 import org.apache.stratos.cloud.controller.interfaces.Iaas;
 import org.apache.stratos.cloud.controller.persist.Deserializer;
 import org.apache.stratos.cloud.controller.pojo.*;
-import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext;
 import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher;
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
@@ -42,7 +39,6 @@ import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
-import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.MemberStatus;
 import org.apache.stratos.messaging.util.Constants;
 import org.jclouds.compute.ComputeService;
@@ -1391,29 +1387,29 @@ public class CloudControllerServiceImpl implements CloudControllerService {
         return dataHolder.getClusterContext(clusterId);
     }
 
-    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        Application application = applicationParser.parse(applicationContext);
-
-        // Create a Cluster Context obj. for each of the Clusters in the Application
-        for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) {
-            dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(),
-                    applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(),
-                    applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster()));
-        }
-
-        /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
-                applicationParser.getPayloadData());
-*/
-        persist();
-    }
-
-    @Override
-    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
-
-        //TopologyBuilder.handleApplicationUndeployed(applicationId);
-    }
+//    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        Application application = applicationParser.parse(applicationContext);
+//
+//        // Create a Cluster Context obj. for each of the Clusters in the Application
+//        for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) {
+//            dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(),
+//                    applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(),
+//                    applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster()));
+//        }
+//
+//        /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
+//                applicationParser.getPayloadData());
+//*/
+//        persist();
+//    }
+//
+//    @Override
+//    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
+//
+//        //TopologyBuilder.handleApplicationUndeployed(applicationId);
+//    }
 
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
deleted file mode 100644
index 33e98f9..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.interfaces;
-
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext;
-import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
-import org.apache.stratos.messaging.domain.applications.Application;
-
-import java.util.Set;
-
-public interface ApplicationParser {
-
-    /**
-     * Parses the Application Definition
-     *
-     * @param obj Object with the Application Definition. An Object is used here since there can be
-     *            significant changes between the way composite Applications are defined in different
-     *            conventions
-     * @return Application structure denoting the parsed Application
-     * @throws ApplicationDefinitionException If the Application Definition is invalid
-     */
-    public Application parse (Object obj) throws ApplicationDefinitionException;
-
-    /**
-     * Returns a set of ApplicationClusterContext which will comprise of cluster related information
-     * extracted from the Application definition
-     *
-     * @return  Set of ApplicationClusterContext objects
-     * @throws ApplicationDefinitionException if any error occurs
-     */
-    public Set<ApplicationClusterContext> getApplicationClusterContexts() throws ApplicationDefinitionException;
-
-    // TODO: remove
-    public Set<MetaDataHolder> getPayloadData () throws ApplicationDefinitionException;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index 5301b14..016e98e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@ -21,7 +21,6 @@ package org.apache.stratos.cloud.controller.interfaces;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
 import org.apache.stratos.cloud.controller.exception.*;
 import org.apache.stratos.cloud.controller.pojo.*;
-import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext;
 
 /**
  * This API provides a way to communicate with underline
@@ -168,20 +167,4 @@ public interface CloudControllerService {
      */
     public ClusterContext getClusterContext (String clusterId);
 
-    /**
-     * deploys an Application Definition
-     *
-     * @param applicationContext {@link org.apache.stratos.cloud.controller.pojo.application.ApplicationContext} object
-     * @throws ApplicationDefinitionException if an error is encountered
-     */
-    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException;
-
-    /**
-     * undeploys an Application Definition
-     *
-     * @param applicationId Id of the Application to be undeployed
-     * @throws ApplicationDefinitionException if an error is encountered
-     */
-    public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException;
-
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java
deleted file mode 100644
index 3a8af44..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-public class ApplicationContext {
-
-    private int tenantId;
-
-    private String tenantDomain;
-
-    private String teantAdminUsername;
-
-    private String applicationId;
-
-    private String alias;
-
-    private ComponentContext componentContext;
-
-    private SubscribableInfoContext[] subscribableInfoContexts;
-
-    public String getApplicationId() {
-        return applicationId;
-    }
-
-    public void setApplicationId(String applicationId) {
-        this.applicationId = applicationId;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public ComponentContext getComponents() {
-        return componentContext;
-    }
-
-    public void setComponents(ComponentContext componentContext) {
-        this.componentContext = componentContext;
-    }
-
-    public SubscribableInfoContext[] getSubscribableInfoContext() {
-        return subscribableInfoContexts;
-    }
-
-    public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) {
-        this.subscribableInfoContexts = subscribableInfoContexts;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getTenantDomain() {
-        return tenantDomain;
-    }
-
-    public void setTenantDomain(String tenantDomain) {
-        this.tenantDomain = tenantDomain;
-    }
-
-    public String getTeantAdminUsername() {
-        return teantAdminUsername;
-    }
-
-    public void setTeantAdminUsername(String teantAdminUsername) {
-        this.teantAdminUsername = teantAdminUsername;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java
deleted file mode 100644
index d1a13a5..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-public class ComponentContext {
-
-    private GroupContext[] groupContexts;
-
-    private SubscribableContext[] subscribableContexts;
-
-    private DependencyContext dependencyContext;
-
-
-    public GroupContext[] getGroupContexts() {
-        return groupContexts;
-    }
-
-    public void setGroupContexts(GroupContext[] groupContexts) {
-        this.groupContexts = groupContexts;
-    }
-
-    public SubscribableContext[] getSubscribableContexts() {
-        return subscribableContexts;
-    }
-
-    public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
-        this.subscribableContexts = subscribableContexts;
-    }
-
-    public DependencyContext getDependencyContext() {
-        return dependencyContext;
-    }
-
-    public void setDependencyContext(DependencyContext dependencyContext) {
-        this.dependencyContext = dependencyContext;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java
deleted file mode 100644
index a99dcb0..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-
-public class DependencyContext {
-    
-    private String [] startupOrdersContexts;
-
-    private String terminationBehaviour;
-
-    public String getTerminationBehaviour() {
-        return terminationBehaviour;
-    }
-
-    public void setTerminationBehaviour(String terminationBehaviour) {
-        this.terminationBehaviour = terminationBehaviour;
-    }
-
-	public String [] getStartupOrdersContexts() {
-		return startupOrdersContexts;
-	}
-
-	public void setStartupOrdersContexts(String [] startupOrdersContexts) {
-		this.startupOrdersContexts = startupOrdersContexts;
-	}
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java
deleted file mode 100644
index fda4bec..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-public class GroupContext {
-
-    private String name;
-
-    private String alias;
-
-    private String deploymentPolicy;
-
-    private String autoscalingPolicy;
-
-    private SubscribableContext[] subscribableContexts;
-
-    private GroupContext[] groupContexts;
-
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public String getDeploymentPolicy() {
-        return deploymentPolicy;
-    }
-
-    public void setDeploymentPolicy(String deploymentPolicy) {
-        this.deploymentPolicy = deploymentPolicy;
-    }
-
-    public String getAutoscalingPolicy() {
-        return autoscalingPolicy;
-    }
-
-    public void setAutoscalingPolicy(String autoscalingPolicy) {
-        this.autoscalingPolicy = autoscalingPolicy;
-    }
-
-    public SubscribableContext[] getSubscribableContexts() {
-        return subscribableContexts;
-    }
-
-    public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
-        this.subscribableContexts = subscribableContexts;
-    }
-
-    public GroupContext[] getGroupContexts() {
-        return groupContexts;
-    }
-
-    public void setGroupContexts(GroupContext[] groupContexts) {
-        this.groupContexts = groupContexts;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java
deleted file mode 100644
index 6f7f4bc..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-public class SubscribableContext {
-
-    private String type;
-
-    private String alias;
-
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java
deleted file mode 100644
index 5f75a7c..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.application;
-
-public class SubscribableInfoContext {
-
-    private String alias;
-
-    private String deploymentPolicy;
-
-    private String autoscalingPolicy;
-
-    private String repoUrl;
-
-    private boolean privateRepo;
-
-    private String repoUsername;
-
-    private String repoPassword;
-
-    private String[] dependencyAliases;
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public String getDeploymentPolicy() {
-        return deploymentPolicy;
-    }
-
-    public void setDeploymentPolicy(String deploymentPolicy) {
-        this.deploymentPolicy = deploymentPolicy;
-    }
-
-    public String getAutoscalingPolicy() {
-        return autoscalingPolicy;
-    }
-
-    public void setAutoscalingPolicy(String autoscalingPolicy) {
-        this.autoscalingPolicy = autoscalingPolicy;
-    }
-
-    public String getRepoUrl() {
-        return repoUrl;
-    }
-
-    public void setRepoUrl(String repoUrl) {
-        this.repoUrl = repoUrl;
-    }
-
-    public boolean isPrivateRepo() {
-        return privateRepo;
-    }
-
-    public void setPrivateRepo(boolean privateRepo) {
-        this.privateRepo = privateRepo;
-    }
-
-    public String getRepoUsername() {
-        return repoUsername;
-    }
-
-    public void setRepoUsername(String repoUsername) {
-        this.repoUsername = repoUsername;
-    }
-
-    public String getRepoPassword() {
-        return repoPassword;
-    }
-
-    public void setRepoPassword(String repoPassword) {
-        this.repoPassword = repoPassword;
-    }
-
-    public String[] getDependencyAliases() {
-        return dependencyAliases;
-    }
-
-    public void setDependencyAliases(String[] dependencyAliases) {
-        this.dependencyAliases = dependencyAliases;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
deleted file mode 100644
index 3db9f71..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.pojo.payload;
-
-import java.util.Properties;
-
-/**
- * Holds payload/meta data related to a cluster
- */
-
-public class MetaDataHolder {
-
-    private String appId;
-
-    private String groupName;
-
-    private String clusterId;
-
-    private Properties properties;
-
-    public MetaDataHolder (String appId, String clusterId) {
-
-        this.appId = appId;
-        this.clusterId = clusterId;
-    }
-
-    public MetaDataHolder(String appId, String groupName, String clusterId) {
-
-        this.appId = appId;
-        this.groupName = groupName;
-        this.clusterId = clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public String getGroupName() {
-        return groupName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public boolean equals(Object other) {
-
-        if(other == null || !(other instanceof MetaDataHolder)) {
-            return false;
-        }
-
-        if(this == other) {
-            return true;
-        }
-
-        MetaDataHolder that = (MetaDataHolder)other;
-
-        if (this.groupName == null || that.groupName == null) {
-            return this.appId.equals(that.appId) && this.clusterId.equals(that.clusterId);
-        } else {
-            return this.appId.equals(that.appId) && this.groupName.equals(that.groupName) &&
-                    this.clusterId.equals(that.clusterId);
-        }
-    }
-
-    public int hashCode () {
-
-        if (this.getGroupName() == null) {
-            return this.appId.hashCode() + this.clusterId.hashCode();
-        } else {
-            return this.appId.hashCode() + this.groupName.hashCode() + this.clusterId.hashCode();
-        }
-    }
-
-    public Properties getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Properties properties) {
-        this.properties = properties;
-    }
-}


[12/50] [abbrv] renaming application.status topic to applications

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java
deleted file mode 100644
index cc26454..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will be triggered upon the application activated event received.
- */
-public abstract class ApplicationTerminatingEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java
deleted file mode 100644
index b28a40d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ApplicationUndeployedEventListener extends EventListener {
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java
deleted file mode 100644
index d19d013..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This will get triggered by the groups activation processor after processing the event
- */
-public abstract class GroupActivatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
deleted file mode 100644
index 3fb2d11..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This will get triggered by the groups activation processor after processing the event
- */
-public abstract class GroupCreatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java
deleted file mode 100644
index 93a5a60..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This will get triggered by the groups activation processor after processing the event
- */
-public abstract class GroupInActivateEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java
deleted file mode 100644
index af409e7..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This will get triggered by the groups activation processor after processing the event
- */
-public abstract class GroupTerminatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java
deleted file mode 100644
index ab4042f..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This will get triggered by the groups activation processor after processing the event
- */
-public abstract class GroupTerminatingEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
deleted file mode 100644
index 8b88724..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusApplicationActivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusApplicationActivatedEvent event =
-                    (AppStatusApplicationActivatedEvent) Util.jsonToObject(message, AppStatusApplicationActivatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
deleted file mode 100644
index 29fce0a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusApplicationCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusApplicationCreatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusApplicationCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusApplicationCreatedEvent event =
-                    (AppStatusApplicationCreatedEvent) Util.jsonToObject(message, AppStatusApplicationCreatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
deleted file mode 100644
index 972fca3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusApplicationInactivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusApplicationInactivatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusApplicationInactivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusApplicationInactivatedEvent event =
-                    (AppStatusApplicationInactivatedEvent) Util.jsonToObject(message, AppStatusApplicationInactivatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
deleted file mode 100644
index b639ac0..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusApplicationTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusApplicationTerminatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusApplicationTerminatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusApplicationTerminatedEvent event =
-                    (AppStatusApplicationTerminatedEvent) Util.jsonToObject(message, AppStatusApplicationTerminatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
deleted file mode 100644
index 143565a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusApplicationTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusApplicationTerminatingMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusApplicationTerminatingEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusApplicationTerminatingEvent event =
-                    (AppStatusApplicationTerminatingEvent) Util.jsonToObject(message, AppStatusApplicationTerminatingEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
deleted file mode 100644
index 3f3c6eb..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppStatusClusterActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppStatusClusterActivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusClusterActivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusClusterActivatedEvent event = (AppStatusClusterActivatedEvent) Util.jsonToObject(message, AppStatusClusterActivatedEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received ClusterActivatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
deleted file mode 100644
index a743c43..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppStatusClusterCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppStatusClusterCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusClusterCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusClusterCreatedEvent event = (AppStatusClusterCreatedEvent) Util.jsonToObject(message, AppStatusClusterCreatedEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
deleted file mode 100644
index 6e28972..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppStatusClusterInactivateMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppStatusClusterInactivateMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusClusterInactivateEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusClusterInactivateEvent event = (AppStatusClusterInactivateEvent) Util.
-                                                jsonToObject(message, AppStatusClusterInactivateEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received ClusterInActivateEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
deleted file mode 100644
index 55cec80..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppStatusClusterTerminatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util.
-                    jsonToObject(message, AppStatusClusterTerminatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java
deleted file mode 100644
index e387a15..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppStatusClusterTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppStatusClusterTerminatingMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusClusterTerminatingEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusClusterTerminatingEvent event = (AppStatusClusterTerminatingEvent) Util.
-                                                jsonToObject(message, AppStatusClusterTerminatingEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
deleted file mode 100644
index 473726c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusGroupActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusGroupActivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupActivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupActivatedEvent event =
-                    (AppStatusGroupActivatedEvent) Util.jsonToObject(message, AppStatusGroupActivatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupActivatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
deleted file mode 100644
index b9a1c6d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusGroupCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusGroupCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupCreatedEvent event =
-                    (AppStatusGroupCreatedEvent) Util.jsonToObject(message, AppStatusGroupCreatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received AppStatusGroupCreatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group created message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
deleted file mode 100644
index 714ee88..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusGroupInactivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusGroupInactivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupInactivateEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupInactivateEvent event =
-                    (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupInActivateEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
deleted file mode 100644
index daa7206..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusGroupTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusGroupTerminatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupTerminatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupTerminatedEvent event =
-                    (AppStatusGroupTerminatedEvent) Util.jsonToObject(message, AppStatusGroupTerminatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in GroupTerminatingEvent message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
deleted file mode 100644
index 75012e0..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class AppStatusGroupTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(AppStatusGroupTerminatingMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupTerminatingEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupTerminatingEvent event =
-                    (AppStatusGroupTerminatingEvent) Util.jsonToObject(message, AppStatusGroupTerminatingEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in GroupTerminatingEvent message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
deleted file mode 100644
index 34cd02b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.listener.application.status.*;
-import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
-
-/**
- * Application Status processor chain is to handle the list processors to parse the application
- * status.
- */
-public class AppStatusMessageProcessorChain extends MessageProcessorChain {
-    private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
-
-    private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
-    private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
-    private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
-    private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
-    private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
-    private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor;
-    private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
-    private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor;
-    private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor;
-    private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
-    private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
-    private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
-    private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
-
-    private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
-    private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
-
-    public void initialize() {
-        // Add instance notifier event processors
-        clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor();
-        add(clusterCreatedMessageProcessor);
-
-        clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor();
-        add(clusterActivatedMessageProcessor);
-
-        clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor();
-        add(clusterInActivateMessageProcessor);
-
-        clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
-        add(clusterTerminatingMessageProcessor);
-
-        clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
-        add(clusterTerminatedMessageProcessor);
-
-        groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor();
-        add(groupCreatedMessageProcessor);
-
-        groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor();
-        add(groupActivatedMessageProcessor);
-
-        groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor();
-        add(groupInActivateMessageProcessor);
-
-        appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor();
-        add(appActivatedMessageProcessor);
-
-        applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor();
-        this.add(applicationStatusAppCreatedMessageProcessor);
-
-        applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor();
-        this.add(applicationStatusAppInActivatedMessageProcessor);
-
-        applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor();
-        this.add(applicationStatusAppTerminatedMessageProcessor);
-
-        applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor();
-        this.add(applicationStatusAppTerminatingMessageProcessor);
-
-        groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor();
-        this.add(groupTerminatedMessageProcessor);
-
-        groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor();
-        this.add(groupTerminatingMessageProcessor);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Instance notifier message processor chain initialized");
-        }
-    }
-
-    public void addEventListener(EventListener eventListener) {
-        if(eventListener instanceof AppStatusClusterCreatedEventListener) {
-            clusterCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusClusterActivatedEventListener) {
-            clusterActivatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusClusterInactivateEventListener) {
-            clusterInActivateMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusGroupCreatedEventListener) {
-            groupCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupActivatedEventListener) {
-            groupActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){
-            clusterTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){
-            clusterTerminatingMessageProcessor.addEventListener(eventListener);
-        }else if (eventListener instanceof AppStatusGroupInactivateEventListener) {
-            groupInActivateMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) {
-            appActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){
-            applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){
-            applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){
-            applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){
-            applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){
-            groupTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){
-            groupTerminatedMessageProcessor.addEventListener(eventListener);
-        } else
-        {
-            throw new RuntimeException("Unknown event listener " + eventListener.toString());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
new file mode 100644
index 0000000..920f94e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppClusterActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppClusterActivatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppClusterActivatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppClusterActivatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppClusterActivatedEvent event = (AppClusterActivatedEvent) Util.jsonToObject(message, AppClusterActivatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received ClusterActivatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
new file mode 100644
index 0000000..9caa79c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppClusterCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppClusterCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppClusterCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppClusterCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppClusterCreatedEvent event = (AppClusterCreatedEvent) Util.jsonToObject(message, AppClusterCreatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
new file mode 100644
index 0000000..d9fb0e9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppClusterInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppClusterInactivateMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppClusterInactivateMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppClusterInactivateEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppClusterInactivateEvent event = (AppClusterInactivateEvent) Util.
+                                                jsonToObject(message, AppClusterInactivateEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received ClusterInActivateEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
new file mode 100644
index 0000000..843d355
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppClusterTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppClusterTerminatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppClusterTerminatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppClusterTerminatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppClusterTerminatedEvent event = (AppClusterTerminatedEvent) Util.
+                    jsonToObject(message, AppClusterTerminatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}


[07/50] [abbrv] git commit: fixing evaluating the status

Posted by im...@apache.org.
fixing evaluating the status


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

Branch: refs/heads/docker-grouping-merge
Commit: ae257c168a7b7590475d0f07a8cd7bda758bbaef
Parents: fe4cced
Author: reka <rt...@gmail.com>
Authored: Thu Oct 30 20:13:25 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Oct 30 20:13:25 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        |  1 +
 .../monitor/AbstractClusterMonitor.java         | 10 ++++++++
 .../monitor/cluster/ClusterMonitor.java         |  3 ++-
 .../autoscaler/monitor/group/GroupMonitor.java  | 14 ++++++----
 .../status/checker/StatusChecker.java           | 27 ++++++++++----------
 5 files changed, 36 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ae257c16/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index b02b2c9..54a1461 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -174,6 +174,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 
                 //changing the status in the monitor, will notify its parent monitor
+                clusterMonitor.setStop(true);
                 clusterMonitor.setStatus(ClusterStatus.Created);
 
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae257c16/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 8ec65c7..ac0871d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -66,6 +66,8 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
 
     protected boolean hasFaultyMember = false;
 
+    protected boolean stop = false;
+
     protected ClusterStatus status;
 
     //protected ParentComponentMonitor parent;
@@ -274,4 +276,12 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
     public void setHasFaultyMember(boolean hasFaultyMember) {
         this.hasFaultyMember = hasFaultyMember;
     }
+
+    public boolean isStop() {
+        return stop;
+    }
+
+    public void setStop(boolean stop) {
+        this.stop = stop;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae257c16/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 67539ed..988f266 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -87,7 +87,8 @@ public class ClusterMonitor extends AbstractClusterMonitor {
         while (!isDestroyed()) {
             try {
                 if (((this.status.getCode() <= ClusterStatus.Active.getCode()) ||
-                        (this.status == ClusterStatus.Inactive && !hasDependent)) && !this.hasFaultyMember) {
+                        (this.status == ClusterStatus.Inactive && !hasDependent)) && !this.hasFaultyMember
+                         && !stop) {
                     if (log.isDebugEnabled()) {
                         log.debug("Cluster monitor is running.. " + this.toString());
                     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae257c16/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 4a789bf..3623de9 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
@@ -73,6 +73,15 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
         } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
             onChildInActiveEvent(id);
 
+        } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) {
+            if(this.aliasToInActiveMonitorsMap.containsKey(id)) {
+                this.aliasToInActiveMonitorsMap.remove(id);
+            }
+            if (this.status == GroupStatus.Terminating) {
+                StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+            } else {
+                onChildTerminatedEvent(id);
+            }
         } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
             //mark the child monitor as inActive in the map
             this.markMonitorAsInactive(id);
@@ -84,15 +93,10 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
             } else {
                 log.warn("[monitor] " + id + " cannot be found in the inActive monitors list");
             }
-
             if (this.status == GroupStatus.Terminating || this.status == GroupStatus.Terminated) {
                 StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
                 log.info("Executing the un-subscription request for the [monitor] " + id);
-            } else {
-                onChildTerminatedEvent(id);
-
             }
-
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae257c16/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index a23e5bd..a742b89 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -331,7 +331,7 @@ public class StatusChecker {
                         log.info("sending group created : " + parent.getUniqueIdentifier());
                         StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
                     }
-                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
+                /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Terminating ||
                         groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) {
                     if (parent instanceof Application) {
@@ -340,7 +340,7 @@ public class StatusChecker {
                         //send activation to the parent
                         log.info("sending group terminating : " + parent.getUniqueIdentifier());
                         StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
-                    }
+                    }*/
                 } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Created ||
                         groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) {
@@ -393,15 +393,15 @@ public class StatusChecker {
                 groupActive = false;
                 groupTerminated = false;
                 groupCreated = groupCreated && true;
-            } else if (group.getStatus() == GroupStatus.Terminating) {
-                groupActive = false;
-                groupTerminated = false;
-                groupCreated = false;
-                status = GroupStatus.Terminating;
-
             }
         }
 
+        if(groups == null || groups != null && groups.isEmpty()) {
+            groupActive = false;
+            groupTerminated = false;
+            groupCreated = false;
+        }
+
         if (groupActive) {
             status = GroupStatus.Active;
         } else if (groupTerminated) {
@@ -435,11 +435,6 @@ public class StatusChecker {
                 clusterActive = false;
                 clusterCreated = false;
                 clusterTerminated = clusterTerminated && true;
-            } else if (cluster.getStatus() == ClusterStatus.Terminating) {
-                status = ClusterStatus.Terminating;
-                clusterActive = false;
-                clusterTerminated = false;
-                clusterCreated = false;
             } else if (cluster.getStatus() == ClusterStatus.Created) {
                 clusterActive = false;
                 clusterTerminated = false;
@@ -447,6 +442,12 @@ public class StatusChecker {
             }
         }
 
+        if(clusterData == null || clusterData != null && clusterData.isEmpty()) {
+            clusterActive = false;
+            clusterTerminated = false;
+            clusterCreated = false;
+        }
+
         if (clusterActive) {
             status = ClusterStatus.Active;
         } else if (clusterTerminated) {


[46/50] [abbrv] git commit: more refactoring

Posted by im...@apache.org.
more refactoring


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

Branch: refs/heads/docker-grouping-merge
Commit: 572cbe329bfd8008df899919787ec0732c387b85
Parents: 16f9ec3
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sun Nov 2 15:42:36 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sun Nov 2 15:42:36 2014 +0530

----------------------------------------------------------------------
 .../applications/parser/ApplicationParser.java  |    4 +-
 .../parser/DefaultApplicationParser.java        |   10 +-
 .../applications/topic/ApplicationBuilder.java  |    4 +-
 .../application/ApplicationUtils.java           |  291 -----
 .../application/ClusterInformation.java         |   27 -
 .../application/MTClusterInformation.java       |   45 -
 .../application/STClusterInformation.java       |   55 -
 .../parser/DefaultApplicationParser.java        |  634 ----------
 .../application/parser/ParserUtils.java         |  142 ---
 .../ApplicationCartridgePayloadData.java        |   27 -
 .../application/payload/BasicPayloadData.java   |  311 -----
 .../payload/DataCartridgePayloadData.java       |   27 -
 .../payload/FrameworkCartridgePayloadData.java  |   27 -
 .../LoadBalancerCartridgePayloadData.java       |   27 -
 .../application/payload/PayloadData.java        |   69 --
 .../application/payload/PayloadFactory.java     |   59 -
 .../impl/CloudControllerServiceImpl.java        |   50 +-
 .../interfaces/ApplicationParser.java           |   53 -
 .../interfaces/CloudControllerService.java      |   17 -
 .../pojo/application/ApplicationContext.java    |   93 --
 .../pojo/application/ComponentContext.java      |   54 -
 .../pojo/application/DependencyContext.java     |   44 -
 .../pojo/application/GroupContext.java          |   84 --
 .../pojo/application/SubscribableContext.java   |   44 -
 .../application/SubscribableInfoContext.java    |  103 --
 .../controller/pojo/payload/MetaDataHolder.java |   99 --
 .../CompositeApplicationParseTest.java          | 1108 +++++++++---------
 .../client/CloudControllerServiceClient.java    |   17 -
 .../domain/applications/ClusterDataHolder.java  |    1 -
 .../rest/endpoint/services/ServiceUtils.java    |    1 -
 .../pom.xml                                     |    3 +-
 .../main/resources/CloudControllerService.wsdl  |  622 ++++------
 32 files changed, 826 insertions(+), 3326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
index 529c1f8..f1f59e5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
@@ -26,7 +26,9 @@ import org.apache.stratos.messaging.domain.applications.Application;
 
 import java.util.Set;
 
-
+/**
+ * Parses the Application Definition
+ */
 public interface ApplicationParser {
 
     /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index a2c8ce5..fa31385 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -40,12 +40,14 @@ import org.apache.stratos.messaging.domain.applications.Group;
 
 import java.util.*;
 
+/**
+ * Default implementation of the Application Parser. One Application should be processed by one
+ * instance of the DefaultApplicationParser.
+ */
 public class DefaultApplicationParser implements ApplicationParser {
 
     private static Log log = LogFactory.getLog(DefaultApplicationParser.class);
 
-//    private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-
     private Set<ApplicationClusterContext> applicationClusterContexts;
 
     public DefaultApplicationParser () {
@@ -466,7 +468,7 @@ public class DefaultApplicationParser implements ApplicationParser {
      */
     private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
 
-        ServiceGroup serviceGroup = null;
+        ServiceGroup serviceGroup;
         try {
             serviceGroup = RegistryManager.getInstance().getServiceGroup(groupContext.getName());
         } catch (Exception e) {
@@ -512,7 +514,7 @@ public class DefaultApplicationParser implements ApplicationParser {
      */
     private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException {
 
-        ServiceGroup serviceGroup = null;
+        ServiceGroup serviceGroup;
         try {
             serviceGroup = RegistryManager.getInstance().getServiceGroup(serviceGroupName);
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index 07ddfb6..6adf3b1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -143,8 +143,8 @@ public class ApplicationBuilder {
 
         ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
     }*/
-    public static void handleApplicationCreated (Application application,
-                                                 Set<ApplicationClusterContext> appClusterCtxts) {
+    public static synchronized void handleApplicationCreated (Application application,
+                                                              Set<ApplicationClusterContext> appClusterContexts) {
 
         Applications applications = ApplicationHolder.getApplications();
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java
deleted file mode 100644
index 35600c4..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.application.payload.BasicPayloadData;
-import org.apache.stratos.cloud.controller.application.payload.PayloadData;
-import org.apache.stratos.cloud.controller.application.payload.PayloadFactory;
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.PortMapping;
-import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext;
-import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext;
-import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
-
-import java.util.*;
-import java.util.regex.Pattern;
-
-public class ApplicationUtils {
-    private static final Log log = LogFactory.getLog(ApplicationUtils.class);
-
-    public static boolean isAliasValid (String alias) {
-
-        String patternString = "([a-z0-9]+([-][a-z0-9])*)+";
-        Pattern pattern = Pattern.compile(patternString);
-
-        return pattern.matcher(alias).matches();
-    }
-
-    public static boolean isValid (String arg) {
-
-        if (arg == null || arg.isEmpty()) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    public static Properties getGlobalPayloadData () {
-
-        Properties globalProperties = new Properties();
-
-        if (System.getProperty("puppet.ip") != null) {
-            globalProperties.setProperty("PUPPET_IP", System.getProperty("puppet.ip"));
-        }
-        if (System.getProperty("puppet.hostname") != null) {
-            globalProperties.setProperty("PUPPET_HOSTNAME", System.getProperty("puppet.hostname"));
-        }
-        if (System.getProperty("puppet.env") != null) {
-            globalProperties.setProperty("PUPPET_ENV", System.getProperty("puppet.env"));
-        }
-        if (System.getProperty("puppet.dns.available") != null) {
-            globalProperties.setProperty("PUPPET_DNS_AVAILABLE", System.getProperty("puppet.dns.available"));
-        }
-
-        return globalProperties;
-    }
-
-    public static MetaDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key,
-                                                                String hostname, String tenantRange, String clusterId,
-                                                                SubscribableContext subscribableCtxt,
-                                                                SubscribableInfoContext subscribableInfoCtxt,
-                                                                Cartridge cartridge) {
-
-        MetaDataHolder metaDataHolder;
-        if (groupName != null) {
-            metaDataHolder = new MetaDataHolder(appId, groupName, clusterId);
-        } else {
-            metaDataHolder = new MetaDataHolder(appId, clusterId);
-        }
-
-        Properties clusterLevelPayloadProperties = new Properties();
-        // app id
-        clusterLevelPayloadProperties.setProperty("APP_ID", appId);
-        // group name
-        if (groupName != null) {
-            clusterLevelPayloadProperties.setProperty("GROUP_NAME", groupName);
-        }
-        // service name
-        if (subscribableCtxt.getType() != null) {
-            clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType());
-        }
-        // host name
-        if  (hostname != null) {
-            clusterLevelPayloadProperties.put("HOST_NAME", hostname);
-        }
-        // multi tenant
-        clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant()));
-        // tenant range
-        if (tenantRange != null) {
-            clusterLevelPayloadProperties.put("TENANT_RANGE", tenantRange);
-        }
-        // cartridge alias
-        if (subscribableCtxt.getAlias() != null) {
-            clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias());
-        }
-        // cluster id
-        if (clusterId != null) {
-            clusterLevelPayloadProperties.put("CLUSTER_ID", clusterId);
-        }
-        // repo url
-        if (subscribableInfoCtxt.getRepoUrl() != null) {
-            clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl());
-        }
-        // ports
-//        if (createPortMappingPayloadString(cartridge) != null) {
-//            clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge));
-//        }
-        // provider
-        if (cartridge.getProvider() != null) {
-            clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider());
-        }
-        // tenant id
-        clusterLevelPayloadProperties.setProperty("TENANT_ID", String.valueOf(tenantId));
-        // cartridge key
-        clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key);
-        // get global payload params
-        //clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData());
-
-        metaDataHolder.setProperties(clusterLevelPayloadProperties);
-        return metaDataHolder;
-    }
-
-    private static String createPortMappingPayloadString (Cartridge cartridge) {
-
-        // port mappings
-        StringBuilder portMapBuilder = new StringBuilder();
-        List<PortMapping> portMappings = cartridge.getPortMappings();
-        for (PortMapping portMapping : portMappings) {
-            String port = portMapping.getPort();
-            portMapBuilder.append(port).append("|");
-        }
-
-        // remove last "|" character
-        String portMappingString = portMapBuilder.toString().replaceAll("\\|$", "");
-
-        return portMappingString;
-    }
-
-    public static StringBuilder getTextPayload (String appId, String groupName, String clusterId) {
-
-        StringBuilder payloadBuilder = new StringBuilder();
-        payloadBuilder.append("APP_ID=" + appId);
-        if (groupName != null) {
-            payloadBuilder.append(",");
-            payloadBuilder.append("GROUP_NAME=" + groupName);
-        }
-        payloadBuilder.append(",");
-        payloadBuilder.append("CLUSTER_ID=" + clusterId);
-        // puppet related
-        if (System.getProperty("puppet.ip") != null) {
-            payloadBuilder.append(",");
-            payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip"));
-        }
-        if (System.getProperty("puppet.hostname") != null) {
-            payloadBuilder.append(",");
-            payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname"));
-        }
-        if (System.getProperty("puppet.env") != null) {
-            payloadBuilder.append(",");
-            payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.env"));
-        }
-        if (System.getProperty("puppet.dns.available") != null) {
-            payloadBuilder.append(",");
-            payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.dns.available"));
-        }
-        // meta data endpoint
-       // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) {
-            // TODO
-            //payloadBuilder.append(",");
-            //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl());
-       // }
-        payloadBuilder.append(",");
-
-        return payloadBuilder;
-    }
-
-    public static PayloadData createPayload(String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String clusterId,
-                                            String hostName, String repoUrl, String alias, Map<String, String> customPayloadEntries, String[] dependencyAliases)
-            throws ApplicationDefinitionException {
-
-        //Create the payload
-        BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridge, subscriptionKey,
-                clusterId, hostName, repoUrl, alias, tenantId, dependencyAliases);
-        //Populate the basic payload details
-        basicPayloadData.populatePayload();
-
-        PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridge.getProvider(),
-                cartridge.getType(), basicPayloadData);
-
-        boolean isDeploymentParam = false;
-        // get the payload parameters defined in the cartridge definition file for this cartridge type
-        if (cartridge.getProperties() != null && !cartridge.getProperties().isEmpty()) {
-
-            for (Map.Entry<String, String> propertyEntry : cartridge.getProperties().entrySet()) {
-                // check if a property is related to the payload. Currently this is done by checking if the
-                // property name starts with 'payload_parameter.' suffix. If so the payload param name will
-                // be taken as the substring from the index of '.' to the end of the property name.
-                if (propertyEntry.getKey()
-                        .startsWith("payload_parameter.")) {
-                    String payloadParamName = propertyEntry.getKey();
-                    String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1);
-                    if("DEPLOYMENT".equals(payloadParamSubstring)) {
-                        isDeploymentParam = true;
-                    }
-                    payloadData.add(payloadParamSubstring, propertyEntry.getValue());
-                }
-            }
-        }
-
-        // DEPLOYMENT payload param must be set because its used by puppet agent
-        // to generate the hostname. Therefore, if DEPLOYMENT is not set in cartridge properties,
-        // adding the DEPLOYMENT="default" param
-        if(!isDeploymentParam) {
-            payloadData.add("DEPLOYMENT", "default");
-        }
-        //check if there are any custom payload entries defined
-        if (customPayloadEntries != null) {
-            //add them to the payload
-            Set<Map.Entry<String,String>> entrySet = customPayloadEntries.entrySet();
-            for (Map.Entry<String, String> entry : entrySet) {
-                payloadData.add(entry.getKey(), entry.getValue());
-            }
-        }
-
-        return payloadData;
-    }
-
-    private static BasicPayloadData createBasicPayload(String appId, String groupName, Cartridge cartridge,
-                                                       String subscriptionKey, String clusterId,
-                                                       String hostName, String repoUrl, String alias,
-                                                       int tenantId, String[] dependencyAliases) {
-
-        BasicPayloadData basicPayloadData = new BasicPayloadData();
-        basicPayloadData.setAppId(appId);
-        basicPayloadData.setGroupName(groupName);
-        basicPayloadData.setApplicationPath(cartridge.getBaseDir());
-        basicPayloadData.setSubscriptionKey(subscriptionKey);
-        //basicPayloadData.setDeployment("default");//currently hard coded to default
-        basicPayloadData.setMultitenant(String.valueOf(cartridge.isMultiTenant()));
-        basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridge));
-        basicPayloadData.setServiceName(cartridge.getType());
-        basicPayloadData.setProvider(cartridge.getProvider());
-
-        if(repoUrl != null) {
-            basicPayloadData.setGitRepositoryUrl(repoUrl);
-        }
-
-        if (clusterId != null) {
-            basicPayloadData.setClusterId(clusterId);
-        }
-
-        if (hostName != null) {
-            basicPayloadData.setHostName(hostName);
-        }
-
-        if (alias != null) {
-            basicPayloadData.setSubscriptionAlias(alias);
-        }
-
-        basicPayloadData.setTenantId(tenantId);
-
-        basicPayloadData.setTenantRange("*");
-        basicPayloadData.setDependencyAliases(dependencyAliases);
-        if(cartridge.getExportingProperties() != null){
-            basicPayloadData.setExportingProperties(cartridge.getExportingProperties());
-            log.info("testing1 getExportingProperties " + cartridge.getExportingProperties());
-
-        }
-
-        return basicPayloadData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java
deleted file mode 100644
index 5fd6d57..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application;
-
-public interface ClusterInformation {
-
-    public String getClusterId (String alias, String cartridgeType);
-
-    public String getHostName (String alias, String cartridgeDefinitionHostName);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java
deleted file mode 100644
index ef3b255..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application;
-
-public class MTClusterInformation implements ClusterInformation {
-
-    @Override
-    public String getClusterId(String alias, String cartridgeType) {
-
-        if (!ApplicationUtils.isValid(cartridgeType))  {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]");
-        }
-
-        return cartridgeType + ".domain";
-    }
-
-    @Override
-    public String getHostName(String alias, String cartridgeDefinitionHostName) {
-
-        if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]");
-        }
-
-        return cartridgeDefinitionHostName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java
deleted file mode 100644
index c8c3d9b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application;
-
-public class STClusterInformation implements ClusterInformation {
-
-    @Override
-    public String getClusterId(String alias, String cartridgeType) {
-
-        if (!ApplicationUtils.isValid(alias)) {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]");
-        }
-
-        if (!ApplicationUtils.isValid(cartridgeType))  {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]");
-        }
-
-        return alias + "." + cartridgeType + ".domain";
-    }
-
-    @Override
-    public String getHostName(String alias, String cartridgeDefinitionHostName) {
-
-        if (!ApplicationUtils.isValid(alias)) {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]");
-        }
-
-        if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) {
-            // cannot happen
-            throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]");
-        }
-
-        return alias + "." + cartridgeDefinitionHostName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
deleted file mode 100644
index c75e883..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.parser;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.application.ApplicationUtils;
-import org.apache.stratos.cloud.controller.application.ClusterInformation;
-import org.apache.stratos.cloud.controller.application.MTClusterInformation;
-import org.apache.stratos.cloud.controller.application.STClusterInformation;
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-import org.apache.stratos.cloud.controller.interfaces.ApplicationParser;
-import org.apache.stratos.cloud.controller.pojo.*;
-import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.application.*;
-import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.applications.DependencyOrder;
-import org.apache.stratos.messaging.domain.applications.Group;
-
-import java.util.*;
-
-public class DefaultApplicationParser implements ApplicationParser {
-
-    private static Log log = LogFactory.getLog(DefaultApplicationParser.class);
-
-//    private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-
-    private Set<ApplicationClusterContext> applicationClusterContexts;
-
-    private Set<MetaDataHolder> metaDataHolders;
-
-    public DefaultApplicationParser () {
-
-        this.applicationClusterContexts = new HashSet<ApplicationClusterContext>();
-        this.metaDataHolders = new HashSet<MetaDataHolder>();
-    }
-
-    @Override
-    public Application parse(Object obj) throws ApplicationDefinitionException {
-
-        ApplicationContext applicationCtxt = (ApplicationContext) obj;
-
-        if (applicationCtxt == null) {
-            handleError("Invalid Composite Application Definition");
-        }
-
-        assert applicationCtxt != null;
-        if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) {
-            handleError("Invalid alias specified");
-        }
-
-        if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) {
-            handleError("Invalid Composite App id specified");
-        }
-
-        // get the defined groups
-        Map<String, GroupContext> definedGroups = getDefinedGroups(applicationCtxt);
-        if (log.isDebugEnabled()) {
-            if (definedGroups != null) {
-                Set<Map.Entry<String, GroupContext>> groupEntries = definedGroups.entrySet();
-                log.debug("Defined Groups: [ ");
-                for (Map.Entry<String, GroupContext> groupEntry : groupEntries) {
-                    log.debug("Group alias: " + groupEntry.getKey());
-                }
-                log.debug(" ]");
-            } else {
-                log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId());
-            }
-        }
-
-        // get the Subscribables Information
-        Map<String, SubscribableInfoContext> subscribablesInfo = getSubscribableInformation(applicationCtxt);
-        if (log.isDebugEnabled()) {
-            Set<Map.Entry<String, SubscribableInfoContext>> subscribableInfoCtxtEntries = subscribablesInfo.entrySet();
-            log.debug("Defined Subscribable Information: [ ");
-            for (Map.Entry<String, SubscribableInfoContext> subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) {
-                log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey());
-            }
-            log.debug(" ]");
-        }
-
-        if (subscribablesInfo == null) {
-            handleError("Invalid Composite Application Definition, no Subscribable Information specified");
-        }
-
-        return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo);
-    }
-
-    @Override
-    public Set<ApplicationClusterContext> getApplicationClusterContexts() throws ApplicationDefinitionException {
-        return applicationClusterContexts;
-    }
-
-    @Override
-    public Set<MetaDataHolder> getPayloadData() throws ApplicationDefinitionException {
-        return metaDataHolders;
-    }
-
-    /**
-     * Extract Group information from Application Definition
-     *
-     * @param appCtxt ApplicationContext object with Application information
-     * @return Map [group alias -> Group]
-     *
-     * @throws ApplicationDefinitionException if the Group information is invalid
-     */
-    private Map<String, GroupContext> getDefinedGroups (ApplicationContext appCtxt) throws
-            ApplicationDefinitionException {
-
-        // map [group alias -> Group Definition]
-        Map<String, GroupContext> definedGroups = null;
-
-        if (appCtxt.getComponents() != null) {
-            if (appCtxt.getComponents().getGroupContexts() != null) {
-                definedGroups = new HashMap<String, GroupContext>();
-
-                for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) {
-
-                    // check validity of group name
-                    if (StringUtils.isEmpty(groupContext.getName())) {
-                        handleError("Invalid Group name specified");
-                    }
-
-                    // check if group is deployed
-                    if(!isGroupDeployed(groupContext.getName())) {
-                        handleError("Group with name " + groupContext.getName() + " not deployed");
-                    }
-
-                    // check validity of group alias
-
-                    if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) {
-                        handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]");
-                    }
-
-                    // check if a group is already defined under the same alias
-                    if(definedGroups.get(groupContext.getAlias()) != null) {
-                        // a group with same alias already exists, can't continue
-                        handleError("A Group with alias " + groupContext.getAlias() + " already exists");
-                    }
-
-                    definedGroups.put(groupContext.getAlias(), groupContext);
-                    if (log.isDebugEnabled()) {
-                        log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]");
-                    }
-                }
-            }
-        }
-
-        return definedGroups;
-    }
-
-    /**
-     * Extract Subscription Information from the Application Definition
-     *
-     * @param appCtxt ApplicationContext object with Application information
-     * @return Map [cartridge alias -> Group]
-     *
-     * @throws ApplicationDefinitionException if the Subscription information is invalid
-     */
-    private Map<String, SubscribableInfoContext> getSubscribableInformation (ApplicationContext appCtxt) throws
-            ApplicationDefinitionException {
-
-        // map [cartridge alias -> Subscribable Information]
-        Map<String, SubscribableInfoContext> subscribableInformation = null;
-
-        if (appCtxt.getSubscribableInfoContext() != null) {
-            subscribableInformation = new HashMap<String, SubscribableInfoContext>();
-
-            for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) {
-
-                if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) ||
-                        !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) {
-                    handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]");
-                }
-
-                // check if a group is already defined under the same alias
-                if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) {
-                    // a group with same alias already exists, can't continue
-                    handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists");
-                }
-
-                subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt);
-                if (log.isDebugEnabled()) {
-                    log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]");
-                }
-            }
-        }
-
-        return subscribableInformation;
-    }
-
-    /**
-     * Check if a Group Definition is deployed
-     *
-     * @param serviceGroupName Group name
-     * @return true if the Group is deployed, else false
-     *
-     * @throws ApplicationDefinitionException
-     */
-    private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException {
-
-        return FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName) != null;
-    }
-
-    /**
-     * Builds the Application structure
-     *
-     * @param appCtxt ApplicationContext object with Application information
-     * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information
-     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
-     * @return Application Application object denoting the Application structure
-     *
-     * @throws ApplicationDefinitionException If an error occurs in building the Application structure
-     */
-    private Application buildCompositeAppStructure (ApplicationContext appCtxt,
-                                                            Map<String, GroupContext> definedGroupCtxts,
-                                                            Map<String, SubscribableInfoContext> subscribableInfoCtxts)
-            throws ApplicationDefinitionException {
-
-        Application application = new Application(appCtxt.getApplicationId());
-
-        // set tenant related information
-        application.setTenantId(appCtxt.getTenantId());
-        application.setTenantDomain(appCtxt.getTenantDomain());
-        application.setTenantAdminUserName(appCtxt.getTeantAdminUsername());
-
-        // following keeps track of all Clusters created for this application
-        //Set<Cluster> clusters = new HashSet<Cluster>();
-        //ClusterDataHolder clusterDataHolder = null;
-        Map<String, ClusterDataHolder> clusterDataMap;
-
-        if (appCtxt.getComponents() != null) {
-            // get top level Subscribables
-            if (appCtxt.getComponents().getSubscribableContexts() != null) {
-                clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(),
-                        application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()),
-                        subscribableInfoCtxts);
-                application.setClusterData(clusterDataMap);
-                //clusters.addAll(clusterDataHolder.getApplicationClusterContexts());
-            }
-
-            // get Groups
-            if (appCtxt.getComponents().getGroupContexts() != null) {
-                application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(),
-                        application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()),
-                        subscribableInfoCtxts, definedGroupCtxts));
-            }
-
-            // get top level Dependency definitions
-            if (appCtxt.getComponents().getDependencyContext() != null) {
-                DependencyOrder appDependencyOrder = new DependencyOrder();
-                String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts();
-                if (startupOrders != null) {
-                	if (log.isDebugEnabled()) {
-                    	log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + 
-                    				appCtxt.getAlias() + " #: " + startupOrders.length);
-                    }
-                    appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders));
-                } else {
-                	if (log.isDebugEnabled()) {
-                    	log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias());
-                    }
-                }
-                String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour();
-                validateTerminationBehavior(terminationBehavior);
-                appDependencyOrder.setTerminationBehaviour(terminationBehavior);
-
-                application.setDependencyOrder(appDependencyOrder);
-            }
-        }
-
-        log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully");
-
-        return application;
-    }
-
-    /**
-     * Validates terminationBehavior. The terminationBehavior should be one of the following:
-     *      1. terminate-none
-     *      2. terminate-dependents
-     *      3. terminate-all
-     *
-     * @throws ApplicationDefinitionException if terminationBehavior is different to what is
-     * listed above
-     */
-    private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException {
-
-        if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) ||
-                "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) {
-            throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " +
-                    terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " +
-                    " 'terminate-all' ");
-        }
-    }
-
-    /**
-     * Parse Group information
-     *
-     * @param appId Application id
-     * @param tenantId tenant id of tenant which deployed the Application
-     * @param key Generated key for the Application
-     * @param groupCtxts  Group information
-     * @param subscribableInformation Subscribable Information
-     * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
-     * @return Map [alias -> Group]
-     *
-     * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
-     */
-    private Map<String, Group> parseGroups (String appId, int tenantId, String key, List<GroupContext> groupCtxts,
-                                           Map<String, SubscribableInfoContext> subscribableInformation,
-                                           Map<String, GroupContext> definedGroupCtxts)
-            throws ApplicationDefinitionException {
-
-        Map<String, Group> groupAliasToGroup = new HashMap<String, Group>();
-
-        for (GroupContext groupCtxt : groupCtxts) {
-            Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts);
-            groupAliasToGroup.put(group.getAlias(), group);
-        }
-
-        //Set<GroupContext> topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup);
-        Set<Group> nestedGroups = new HashSet<Group>();
-        getNestedGroupContexts(nestedGroups, groupAliasToGroup.values());
-        filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups);
-
-        return groupAliasToGroup;
-    }
-
-    /**
-     * Extracts nested Group information recursively
-     *
-     * @param nestedGroups Nested Groups set to be populated recursively
-     * @param groups Collection of Groups
-     */
-    private void getNestedGroupContexts (Set<Group> nestedGroups, Collection<Group> groups) {
-
-        if (groups != null) {
-            for (Group group : groups) {
-                if (group.getGroups() != null) {
-                    nestedGroups.addAll(group.getGroups());
-                    getNestedGroupContexts(nestedGroups, group.getGroups());
-                }
-            }
-        }
-    }
-
-    /**
-     * Filters duplicated Groups from top level
-     *
-     * @param topLevelGroups Top level Groups
-     * @param nestedGroups nested Groups
-     */
-    private void filterDuplicatedGroupContexts (Collection<Group> topLevelGroups, Set<Group> nestedGroups) {
-
-        for (Group nestedGroup : nestedGroups) {
-            filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup);
-        }
-    }
-
-    private void filterNestedGroupFromTopLevel (Collection<Group> topLevelGroups, Group nestedGroup) {
-
-        Iterator<Group> parentIterator = topLevelGroups.iterator();
-        while (parentIterator.hasNext()) {
-            Group parentGroup = parentIterator.next();
-            // if there is an exactly similar nested Group Context and a top level Group Context
-            // it implies that they are duplicates. Should be removed from top level.
-            if (parentGroup.equals(nestedGroup)) {
-                parentIterator.remove();
-            }
-        }
-    }
-
-    /**
-     * Parses an individual Group
-     *
-     * @param appId Application id
-     * @param tenantId tenant id of tenant which deployed the Application
-     * @param key Generated key for the Application
-     * @param groupCtxt Group definition information
-     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
-     * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
-     * @return  Group object
-     *
-     * @throws ApplicationDefinitionException if unable to parse
-     */
-    private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt,
-                             Map<String, SubscribableInfoContext> subscribableInfoCtxts,
-                             Map<String, GroupContext> definedGroupCtxts)
-            throws ApplicationDefinitionException {
-
-        // check if are in the defined Group set
-        GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias());
-        if (definedGroupDef == null) {
-            handleError("Group Definition with name: " + groupCtxt.getName() + ", alias: " +
-                    groupCtxt.getAlias() + " is not found in the all Group Definitions collection");
-        }
-
-        Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias());
-
-        group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy());
-        group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy());
-        DependencyOrder dependencyOrder = new DependencyOrder();
-        // create the Dependency Ordering
-        String []  startupOrders = getStartupOrderForGroup(groupCtxt);
-        if (startupOrders != null) {
-            dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt));
-        }
-        dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName()));
-        group.setDependencyOrder(dependencyOrder);
-
-        Map<String, ClusterDataHolder> clusterDataMap;
-
-        // get group level Subscribables
-        if (groupCtxt.getSubscribableContexts() != null) {
-            clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(),
-                    Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts);
-            group.setClusterData(clusterDataMap);
-        }
-
-        // get nested groups
-        if (groupCtxt.getGroupContexts() != null) {
-            Map<String, Group> nestedGroups = new HashMap<String, Group>();
-            // check sub groups
-            for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) {
-                // get the complete Group Definition
-                subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias());
-                Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt,
-                        subscribableInfoCtxts,
-                        definedGroupCtxts);
-                nestedGroups.put(nestedGroup.getAlias(), nestedGroup);
-            }
-
-            group.setGroups(nestedGroups);
-        }
-
-        return group;
-    }
-
-    /**
-     * Find the startup order
-     *
-     * @param groupContext GroupContext with Group defintion information
-     * @return Set of Startup Orders which are defined in the Group
-     *
-     * @throws ApplicationDefinitionException
-     */
-    private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
-
-        ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(groupContext.getName());
-
-        if (serviceGroup == null) {
-            handleError("Service Group Definition not found for name " + groupContext.getName());
-        }
-        
-        if (log.isDebugEnabled()) {
-        	log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName());
-        }
-
-        assert serviceGroup != null;
-        if (serviceGroup.getDependencies() != null) {
-        	if (log.isDebugEnabled()) {
-            	log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " );
-            }
-            if (serviceGroup.getDependencies().getStartupOrders() != null) {
-            	
-            	String [] startupOrders = serviceGroup.getDependencies().getStartupOrders();
-            	if (log.isDebugEnabled()) {
-                	log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " +  startupOrders.length);
-                }
-                return startupOrders;
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Get kill behaviour related to a Group
-     *
-     * @param serviceGroupName Group name
-     * @return String indicating the kill behavior
-     *
-     * @throws ApplicationDefinitionException if an error occurs
-     */
-    private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException {
-
-        ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName);
-
-        if (serviceGroup == null) {
-            handleError("Service Group Definition not found for name " + serviceGroupName);
-        }
-
-        assert serviceGroup != null;
-        if (serviceGroup.getDependencies() != null) {
-            return serviceGroup.getDependencies().getKillBehaviour();
-        }
-
-        return null;
-
-    }
-
-    /**
-     * Parse Subscription Information
-     *
-     * @param appId Application id
-     * @param tenantId Tenant id of tenant which deployed the Application
-     * @param key Generated key for the Application
-     * @param groupName Group name (if relevant)
-     * @param subscribableCtxts Subscribable Information
-     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
-     * @return Map [subscription alias -> ClusterDataHolder]
-     *
-     * @throws ApplicationDefinitionException
-     */
-    private Map<String, ClusterDataHolder> parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName,
-                                                                 List<SubscribableContext> subscribableCtxts,
-                                                                 Map<String, SubscribableInfoContext> subscribableInfoCtxts)
-            throws ApplicationDefinitionException {
-
-        Map<String, ClusterDataHolder> clusterDataMap = new HashMap<String, ClusterDataHolder>();
-
-        for (SubscribableContext subscribableCtxt : subscribableCtxts) {
-
-            // check is there is a related Subscribable Information
-            SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias());
-            if (subscribableInfoCtxt == null) {
-                handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: "
-                        + subscribableCtxt.getAlias());
-            }
-
-            // check if Cartridge Type is valid
-            if (StringUtils.isEmpty(subscribableCtxt.getType())) {
-                handleError("Invalid Cartridge Type specified : [ "
-                        + subscribableCtxt.getType() + " ]");
-            }
-
-            // check if a cartridge with relevant type is already deployed. else, can't continue
-            Cartridge cartridge =  getCartridge(subscribableCtxt.getType());
-            if (cartridge == null) {
-                handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() +
-                        " ] for Composite Application");
-            }
-
-            // get hostname and cluster id
-            ClusterInformation clusterInfo;
-            assert cartridge != null;
-            if (cartridge.isMultiTenant()) {
-                clusterInfo = new MTClusterInformation();
-            } else {
-                clusterInfo = new STClusterInformation();
-            }
-
-            String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName());
-            String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType());
-
-            // create and collect this cluster's information
-            assert subscribableInfoCtxt != null;
-            ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge,
-                    key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(),
-                    clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases());
-
-            appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy());
-            this.applicationClusterContexts.add(appClusterCtxt);
-
-            // add relevant information to the map
-            clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId));
-        }
-
-        return clusterDataMap;
-    }
-
-    /**
-     * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
-     *
-     * @param appId Application id
-     * @param groupName Group name
-     * @param cartridge Cartridge information
-     * @param subscriptionKey Generated key for the Application
-     * @param tenantId Tenant Id of the tenant which deployed the Application
-     * @param repoUrl Repository URL
-     * @param alias alias specified for this Subscribable in the Application Definition
-     * @param clusterId Cluster id
-     * @param hostname Hostname
-     * @param deploymentPolicy Deployment policy used
-     * @param isLB if this cluster is an LB
-     * @return ApplicationClusterContext object with relevant information
-     *
-     * @throws ApplicationDefinitionException If any error occurs
-     */
-    private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge,
-                                                                       String subscriptionKey, int tenantId, String repoUrl,
-                                                                       String alias, String clusterId, String hostname,
-                                                                       String deploymentPolicy, boolean isLB, String[] dependencyAliases)
-            throws ApplicationDefinitionException {
-
-        // Create text payload
-        String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId,
-                hostname, repoUrl, alias, null, dependencyAliases).toString();
-
-        return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB);
-    }
-
-    private Cartridge getCartridge (String cartridgeType)  {
-
-        return FasterLookUpDataHolder.getInstance().getCartridge(cartridgeType);
-    }
-
-    private void handleError (String errorMsg) throws ApplicationDefinitionException {
-        log.error(errorMsg);
-        throw new ApplicationDefinitionException(errorMsg);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
deleted file mode 100644
index e6cdda0..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.parser;
-
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-import org.apache.stratos.cloud.controller.pojo.application.GroupContext;
-import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext;
-import org.apache.stratos.messaging.domain.applications.StartupOrder;
-
-import java.util.*;
-
-public class ParserUtils {
-
-    public static Set<StartupOrder> convert (String [] startupOrderArr) throws ApplicationDefinitionException {
-
-        Set<StartupOrder> startupOrders = new HashSet<StartupOrder>();
-
-        if (startupOrderArr == null) {
-            return startupOrders;
-        }
-
-        for (String commaSeparatedStartupOrder : startupOrderArr) {
-            startupOrders.add(getStartupOrder(commaSeparatedStartupOrder));
-        }
-
-        return startupOrders;
-    }
-
-    private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) throws ApplicationDefinitionException{
-
-        List<String> startupOrders = new ArrayList<String>();
-
-        for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) {
-            startupOrder = startupOrder.trim();
-            if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group.")) {
-                throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.' or 'group.'");
-            }
-
-            startupOrders.add(startupOrder);
-        }
-
-        return new StartupOrder(startupOrders);
-    }
-
-    public static Set<StartupOrder> convert (String [] startupOrderArr, GroupContext groupContext)
-            throws ApplicationDefinitionException {
-
-        Set<StartupOrder> startupOrders = new HashSet<StartupOrder>();
-
-        if (startupOrderArr == null) {
-            return startupOrders;
-        }
-
-
-        for (String commaSeparatedStartupOrder : startupOrderArr) {
-            // convert all Startup Orders to aliases-based
-            List<String> components = Arrays.asList(commaSeparatedStartupOrder.split(","));
-            startupOrders.add(getStartupOrder(components, groupContext));
-        }
-
-        return startupOrders;
-    }
-
-    private static StartupOrder getStartupOrder (List<String> components, GroupContext groupContext)
-            throws ApplicationDefinitionException {
-
-        List<String> aliasBasedComponents = new ArrayList<String>();
-
-        for (String component : components) {
-            component = component.trim();
-
-            String aliasBasedComponent;
-            if (component.startsWith("cartridge.")) {
-                String cartridgeType = component.substring(10);
-                aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext);
-                if (aliasBasedComponent == null) {
-                    throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " +
-                            "cannot find the matching alias for Service type " + cartridgeType);
-                }
-
-                aliasBasedComponent = "cartridge.".concat(aliasBasedComponent);
-
-            } else if (component.startsWith("group.")) {
-                String groupName = component.substring(6);
-                aliasBasedComponent = getAliasForGroupName(groupName, groupContext);
-                if (aliasBasedComponent == null) {
-                    throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " +
-                            "cannot find the matching alias for Group name " + groupName);
-                }
-
-                aliasBasedComponent = "group.".concat(aliasBasedComponent);
-
-            } else {
-                throw new ApplicationDefinitionException("Incorrect Startup Order specified, " +
-                        "should start with 'cartridge.' or 'group.'");
-            }
-            aliasBasedComponents.add(aliasBasedComponent);
-        }
-
-        return new StartupOrder(aliasBasedComponents);
-    }
-
-    private static String getAliasForGroupName (String groupName, GroupContext groupContext) {
-
-        for (GroupContext groupCtxt : groupContext.getGroupContexts()) {
-            if (groupName.equals(groupCtxt.getName())) {
-                return groupCtxt.getAlias();
-            }
-        }
-
-        return null;
-    }
-
-
-    private static String getAliasForServiceType (String serviceType, GroupContext groupContext) {
-
-        for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) {
-            if (serviceType.equals(subCtxt.getType())) {
-                return subCtxt.getAlias();
-            }
-        }
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java
deleted file mode 100644
index 870c22c..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-public class ApplicationCartridgePayloadData extends PayloadData {
-
-    public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) {
-        super(basicPayloadData);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java
deleted file mode 100644
index c655b1b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.Serializable;
-
-/**
- * Contains basic payload data fields
- */
-public class BasicPayloadData implements Serializable {
-
-    private static Log log = LogFactory.getLog(BasicPayloadData.class);
-
-    private String appId;
-    private String groupName;
-    private String serviceName;
-    private String clusterId;
-    private String hostName;
-    private int tenantId;
-    private String tenantRange;
-    private String subscriptionAlias;
-    private String deployment;
-    private String puppetIp;
-    private String puppetHostName;
-    private String puppetEnvironment;
-    private String subscriptionKey;
-    private String applicationPath;
-    private String gitRepositoryUrl;
-    private String portMappings;
-    private String multitenant;
-    private String provider;
-    private String[] dependencyAliases;
-    private String[] exportingProperties;
-
-    protected StringBuilder payloadBuilder;
-
-    public BasicPayloadData() {
-
-    }
-
-    public void populatePayload () {
-
-        payloadBuilder = new StringBuilder();
-
-        payloadBuilder.append("APP_ID=" + getAppId());
-        payloadBuilder.append(",");
-        payloadBuilder.append("GROUP_NAME=" + getGroupName());
-        payloadBuilder.append(",");
-        payloadBuilder.append("SERVICE_NAME=" + getServiceName());
-        payloadBuilder.append(",");
-        payloadBuilder.append("HOST_NAME=" + getHostName());
-        payloadBuilder.append(",");
-        payloadBuilder.append("MULTITENANT=" + getMultitenant());
-        payloadBuilder.append(",");
-        payloadBuilder.append("TENANT_ID=" + getTenantId());
-        payloadBuilder.append(",");
-        payloadBuilder.append("TENANT_RANGE=" + getTenantRange());
-        payloadBuilder.append(",");
-        payloadBuilder.append("CARTRIDGE_ALIAS=" + getSubscriptionAlias());
-        payloadBuilder.append(",");
-        payloadBuilder.append("CLUSTER_ID=" + getClusterId());
-        payloadBuilder.append(",");
-        payloadBuilder.append("CARTRIDGE_KEY=" + getSubscriptionKey());
-        payloadBuilder.append(",");
-        //payloadBuilder.append("DEPLOYMENT=" + getDeployment());
-        //payloadBuilder.append(",");
-        //payloadBuilder.append("APP_PATH=" + getApplicationPath());
-        //payloadBuilder.append(",");
-        payloadBuilder.append("REPO_URL=" + getGitRepositoryUrl());
-        payloadBuilder.append(",");
-        payloadBuilder.append("PORTS=" + getPortMappings());
-        payloadBuilder.append(",");
-        payloadBuilder.append("PROVIDER=" + getProvider());
-
-        //Payload Data exposed as system variables
-        payloadBuilder.append(",");
-        payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip"));
-        payloadBuilder.append(",");
-        payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname"));
-        payloadBuilder.append(",");
-        payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env"));
-        payloadBuilder.append(",");
-        payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available"));
-        payloadBuilder.append(",");
-        if(getDependencyAliasesPayloadString() != null){
-            payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString());
-        }
-        payloadBuilder.append(",");
-        if(getExportingPropertiesPayloadString() != null){
-            payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString());
-        }
-
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public void setClusterId(String clusterId) {
-        this.clusterId = clusterId;
-    }
-
-    public String getHostName() {
-        return hostName;
-    }
-
-    public void setHostName(String hostName) {
-        this.hostName = hostName;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getTenantRange() {
-        return tenantRange;
-    }
-
-    public void setTenantRange(String tenantRange) {
-        this.tenantRange = tenantRange;
-    }
-
-    public String getSubscriptionAlias() {
-        return subscriptionAlias;
-    }
-
-    public void setSubscriptionAlias(String subscriptionAlias) {
-        this.subscriptionAlias = subscriptionAlias;
-    }
-
-    public String getDeployment() {
-        return deployment;
-    }
-
-    public void setDeployment(String deployment) {
-        this.deployment = deployment;
-    }
-
-    public String getPuppetIp() {
-        return puppetIp;
-    }
-
-    public void setPuppetIp(String puppetIp) {
-        this.puppetIp = puppetIp;
-    }
-
-    public String getSubscriptionKey() {
-        return subscriptionKey;
-    }
-
-    public void setSubscriptionKey(String subscriptionKey) {
-        this.subscriptionKey = subscriptionKey;
-    }
-
-    public StringBuilder getPayloadData () {
-
-        return payloadBuilder;
-    }
-
-    public String getApplicationPath() {
-        return applicationPath;
-    }
-
-    public void setApplicationPath(String applicationPath) {
-        this.applicationPath = applicationPath;
-    }
-
-    public String getGitRepositoryUrl() {
-        return gitRepositoryUrl;
-    }
-
-    public void setGitRepositoryUrl(String gitRepositoryUrl) {
-        this.gitRepositoryUrl = gitRepositoryUrl;
-    }
-
-    public String getPortMappings() {
-        return portMappings;
-    }
-
-    public void setPortMappings(String portMappings) {
-        this.portMappings = portMappings;
-    }
-
-    public String getMultitenant() {
-        return multitenant;
-    }
-
-    public void setMultitenant(String multitenant) {
-        this.multitenant = multitenant;
-    }
-
-    public String getPuppetHostName() {
-        return puppetHostName;
-    }
-
-    public void setPuppetHostName(String puppetHostName) {
-        this.puppetHostName = puppetHostName;
-    }
-
-    public String getPuppetEnvironment() {
-        return puppetEnvironment;
-    }
-
-    public void setPuppetEnvironment(String puppetEnvironment) {
-        this.puppetEnvironment = puppetEnvironment;
-    }
-
-    public String getProvider() {
-        return provider;
-    }
-
-    public void setProvider(String provider) {
-        this.provider = provider;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public void setAppId(String appId) {
-        this.appId = appId;
-    }
-
-    public String getGroupName() {
-        return groupName;
-    }
-
-    public void setGroupName(String groupName) {
-        this.groupName = groupName;
-    }
-
-    public String[] getDependencyAliases() {
-        return dependencyAliases;
-    }
-
-    public void setDependencyAliases(String[] dependencyAliases) {
-        this.dependencyAliases = dependencyAliases;
-    }
-
-    private String getDependencyAliasesPayloadString(){
-        if(dependencyAliases == null){
-            return null;
-        }
-
-        StringBuilder dependencyAliasesPayload = new StringBuilder();
-        for(int i=0; i< dependencyAliases.length; i++){
-            dependencyAliasesPayload.append(dependencyAliases[i]);
-            if(i != dependencyAliases.length -1){
-                dependencyAliasesPayload.append("|");
-            }
-        }
-        log.info("testing1 getDependencyAliasesPayloadString " + dependencyAliasesPayload);
-        return dependencyAliasesPayload.toString();
-    }
-
-    private String getExportingPropertiesPayloadString(){
-        if(exportingProperties == null){
-            return null;
-        }
-
-        StringBuilder exportingPropertiesPayload = new StringBuilder();
-        for(int i=0; i< exportingProperties.length; i++){
-            exportingPropertiesPayload.append(exportingProperties[i]);
-            if(i != exportingProperties.length -1){
-                exportingPropertiesPayload.append("|");
-            }
-        }
-        log.info("testing1 getExportingPropertiesPayloadString " + exportingPropertiesPayload);
-        return exportingPropertiesPayload.toString();
-    }
-
-    public String[] getExportingProperties() {
-        return exportingProperties;
-    }
-
-    public void setExportingProperties(String[] exportingProperties) {
-        this.exportingProperties = exportingProperties;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java
deleted file mode 100644
index 1848b6d..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-public class DataCartridgePayloadData extends PayloadData {
-
-    public DataCartridgePayloadData(BasicPayloadData basicPayloadData) {
-        super(basicPayloadData);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java
deleted file mode 100644
index a22d40b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-public class FrameworkCartridgePayloadData extends PayloadData {
-
-    public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) {
-        super(basicPayloadData);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java
deleted file mode 100644
index 6ceeba9..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-public class LoadBalancerCartridgePayloadData extends PayloadData {
-
-    public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) {
-        super(basicPayloadData);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java
deleted file mode 100644
index 35b1fe6..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application.payload;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public abstract class PayloadData implements Serializable {
-
-    private BasicPayloadData basicPayloadData;
-    private Map<String, String> completePayloadMap;
-    public PayloadData(BasicPayloadData basicPayloadData) {
-
-        this.setBasicPayloadData(basicPayloadData);
-        completePayloadMap = new HashMap<String, String>();
-    }
-
-    public void add (String payloadDataName, String payloadDataValue) {
-        completePayloadMap.put(payloadDataName, payloadDataValue);
-    }
-
-    public StringBuilder getCompletePayloadData () {
-
-        //return completePayloadMap;
-        StringBuilder completePayload = new StringBuilder();
-        completePayload.append(basicPayloadData.getPayloadData());
-        Iterator< String > iter = completePayloadMap.keySet().iterator();
-        while(iter.hasNext()) {
-            String key = iter.next();
-            String val = completePayloadMap.get(key);
-            if(completePayload.length() > 0){
-                completePayload.append(",");
-            }
-            completePayload.append(key + "=" + val);
-        }
-        return completePayload;
-    }
-
-    public BasicPayloadData getBasicPayloadData() {
-        return basicPayloadData;
-    }
-
-    public void setBasicPayloadData(BasicPayloadData basicPayloadData) {
-        this.basicPayloadData = basicPayloadData;
-    }
-
-    public String toString () {
-        return getCompletePayloadData().toString();
-    }
-}


[47/50] [abbrv] git commit: support application monitor creation based on complete topology event

Posted by im...@apache.org.
support application monitor creation based on complete topology event


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

Branch: refs/heads/docker-grouping-merge
Commit: 14f5fe030ae1b5423af5e178d66be4b27ca01ac4
Parents: 572cbe3
Author: reka <rt...@gmail.com>
Authored: Mon Nov 3 11:26:21 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Nov 3 11:26:21 2014 +0530

----------------------------------------------------------------------
 .../ApplicationSynchronizeTask.java             |   4 +-
 .../applications/topic/ApplicationBuilder.java  | 149 +++++++++++++++++++
 .../internal/AutoscalerServerComponent.java     |   6 +-
 .../AutoscalerTopologyEventReceiver.java        |  62 +++++++-
 4 files changed, 210 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/14f5fe03/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
index 9f0ca8c..22a2805 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
 import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
 import org.wso2.carbon.ntask.core.Task;
 
@@ -36,7 +37,8 @@ public class ApplicationSynchronizeTask implements Task {
         }
         // publish to the topic
         if (ApplicationHolder.getApplications() != null) {
-            ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications());
+            //ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications());
+            ApplicationBuilder.handleCompleteApplication(ApplicationHolder.getApplications());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/14f5fe03/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index 6adf3b1..bf0ad01 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -20,9 +20,16 @@ package org.apache.stratos.autoscaler.applications.topic;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext;
+import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
+import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
+import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.messaging.domain.applications.*;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
 import java.util.Collection;
 import java.util.Set;
@@ -143,6 +150,17 @@ public class ApplicationBuilder {
 
         ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
     }*/
+
+    public static synchronized void handleCompleteApplication (Applications applications) {
+        log.info("Handling complete application");
+        ApplicationHolder.acquireReadLock();
+        try {
+            ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications);
+        } finally {
+            ApplicationHolder.releaseReadLock();
+        }
+    }
+
     public static synchronized void handleApplicationCreated (Application application,
                                                               Set<ApplicationClusterContext> appClusterContexts) {
 
@@ -153,6 +171,7 @@ public class ApplicationBuilder {
         try {
             if (applications.getApplication(application.getUniqueIdentifier()) != null) {
                 ApplicationHolder.persistApplication(application);
+               // startApplicationMonitor(application.getUniqueIdentifier());
             } else {
                 log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications");
             }
@@ -512,4 +531,134 @@ public class ApplicationBuilder {
             ApplicationHolder.releaseWriteLock();
         }
     }
+
+
+    protected static synchronized void startApplicationMonitor(String appId) {
+
+        ApplicationMonitor applicationMonitor = null;
+        int retries = 5;
+        boolean success = false;
+        do {
+            try {
+                Thread.sleep(5000);
+            } catch (InterruptedException e1) {
+            }
+            try {
+                long start = System.currentTimeMillis();
+                if (log.isDebugEnabled()) {
+                    log.debug("application monitor is going to be started for [application] " +
+                            appId);
+                }
+                applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId);
+
+                long end = System.currentTimeMillis();
+                log.info("Time taken to start app monitor: " + (end - start) / 1000);
+                success = true;
+            } catch (DependencyBuilderException e) {
+                String msg = "Application monitor creation failed for Application: ";
+                log.warn(msg, e);
+                retries--;
+            } catch (TopologyInConsistentException e) {
+                String msg = "Application monitor creation failed for Application: ";
+                log.warn(msg, e);
+                retries--;
+            }
+        } while (!success && retries != 0);
+
+        if (applicationMonitor == null) {
+            String msg = "Application monitor creation failed, even after retrying for 5 times, "
+                    + "for Application: " + appId;
+            log.error(msg);
+            throw new RuntimeException(msg);
+        }
+
+        AutoscalerContext.getInstance().addAppMonitor(applicationMonitor);
+
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Application monitor has been added successfully: " +
+                    "[application] %s", applicationMonitor.getId()));
+        }
+    }
+
+
+        /*Thread th = null;
+        if (!AutoscalerContext.getInstance()
+                .appMonitorExist(applicationId)) {
+            th = new Thread(
+                    new ApplicationMonitorAdder(applicationId));
+        }
+
+        if (th != null) {
+            th.start();
+            //    try {
+            //        th.join();
+            //    } catch (InterruptedException ignore) {
+
+            if (log.isDebugEnabled()) {
+                log.debug(String
+                        .format("Application monitor thread has been started successfully: " +
+                                "[application] %s ", applicationId));
+            }
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug(String
+                        .format("Application monitor thread already exists: " +
+                                "[application] %s ", applicationId));
+            }
+        }*/
+
+
+    private class ApplicationMonitorAdder implements Runnable {
+        private String appId;
+
+        public ApplicationMonitorAdder(String appId) {
+            this.appId = appId;
+        }
+
+        public void run() {
+            ApplicationMonitor applicationMonitor = null;
+            int retries = 5;
+            boolean success = false;
+            do {
+                try {
+                    Thread.sleep(5000);
+                } catch (InterruptedException e1) {
+                }
+                try {
+                    long start = System.currentTimeMillis();
+                    if (log.isDebugEnabled()) {
+                        log.debug("application monitor is going to be started for [application] " +
+                                appId);
+                    }
+                    applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId);
+
+                    long end = System.currentTimeMillis();
+                    log.info("Time taken to start app monitor: " + (end - start) / 1000);
+                    success = true;
+                } catch (DependencyBuilderException e) {
+                    String msg = "Application monitor creation failed for Application: ";
+                    log.warn(msg, e);
+                    retries--;
+                } catch (TopologyInConsistentException e) {
+                    String msg = "Application monitor creation failed for Application: ";
+                    log.warn(msg, e);
+                    retries--;
+                }
+            } while (!success && retries != 0);
+
+            if (applicationMonitor == null) {
+                String msg = "Application monitor creation failed, even after retrying for 5 times, "
+                        + "for Application: " + appId;
+                log.error(msg);
+                throw new RuntimeException(msg);
+            }
+
+            AutoscalerContext.getInstance().addAppMonitor(applicationMonitor);
+
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Application monitor has been added successfully: " +
+                        "[application] %s", applicationMonitor.getId()));
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/14f5fe03/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
index 5ada0b7..a946977 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
@@ -43,14 +43,14 @@ import java.util.List;
 /**
  * @scr.component name=org.apache.stratos.autoscaler.internal.AutoscalerServerComponent"
  * immediate="true"
- * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
- * cardinality="1..1" policy="dynamic" bind="setTaskService"
- * unbind="unsetTaskService"
  * @scr.reference name="registry.service"
  * interface=
  * "org.wso2.carbon.registry.core.service.RegistryService"
  * cardinality="1..1" policy="dynamic" bind="setRegistryService"
  * unbind="unsetRegistryService"
+ * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
+ * cardinality="1..1" policy="dynamic" bind="setTaskService"
+ * unbind="unsetTaskService"
  */
 
 public class AutoscalerServerComponent {

http://git-wip-us.apache.org/repos/asf/stratos/blob/14f5fe03/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index dcf3a82..72dc6e5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -22,6 +22,7 @@ package org.apache.stratos.autoscaler.message.receiver.topology;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.*;
+import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
@@ -39,6 +40,7 @@ import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
@@ -93,6 +95,46 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
         }
     }
 
+    private boolean allClustersInitialized(Application application) {
+        boolean allClustersInitialized = false;
+        for(ClusterDataHolder holder : application.getClusterDataMap().values()) {
+            TopologyManager.acquireReadLockForCluster(holder.getServiceType(),
+                    holder.getClusterId());
+
+            try {
+                Topology topology = TopologyManager.getTopology();
+                if(topology != null) {
+                    Service service = topology.getService(holder.getServiceType());
+                    if(service != null) {
+                        if(service.clusterExists(holder.getClusterId())) {
+                            allClustersInitialized = true;
+                        } else {
+                            if(log.isDebugEnabled()) {
+                                log.debug("[Cluster] " + holder.getClusterId() + " is not found in " +
+                                        "the Topology");
+                            }
+                            allClustersInitialized = false;
+                            return allClustersInitialized;
+                        }
+                    } else {
+                        if(log.isDebugEnabled()) {
+                            log.debug("Service is null in the CompleteTopologyEvent");
+                        }
+                    }
+                } else {
+                    if(log.isDebugEnabled()) {
+                        log.debug("Topology is null in the CompleteTopologyEvent");
+                    }
+                }
+            } finally {
+                TopologyManager.releaseReadLockForCluster(holder.getServiceType(),
+                        holder.getClusterId());
+            }
+        }
+        return allClustersInitialized;
+    }
+
+
     private void addEventListeners() {
         // Listen to topology events that affect clusters
         topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() {
@@ -101,18 +143,24 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 if (!topologyInitialized) {
                     log.info("[CompleteTopologyEvent] Received: " + event.getClass());
-
-                    TopologyManager.acquireReadLock();
+                    ApplicationHolder.acquireReadLock();
                     try {
-                        for (Application application : ApplicationManager.getApplications().getApplications().values()) {
-                            startApplicationMonitor(application.getUniqueIdentifier());
+                        Applications applications = ApplicationHolder.getApplications();
+                        if(applications != null) {
+                            for (Application application : applications.getApplications().values()) {
+                                if(allClustersInitialized(application)) {
+                                    startApplicationMonitor(application.getUniqueIdentifier());
+                                } else {
+                                    log.error("Complete Topology is not consistent with the applications " +
+                                            "which got persisted");
+                                }
+                            }
+                            topologyInitialized = true;
                         }
-
-                        topologyInitialized = true;
                     } catch (Exception e) {
                         log.error("Error processing event", e);
                     } finally {
-                        TopologyManager.releaseReadLock();
+                        ApplicationHolder.releaseReadLock();
                     }
                 }
             }


[17/50] [abbrv] removing application status and adding applications, cluster status topic

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
index db5d777..92d61ba 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
@@ -16,48 +16,106 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
-public class ApplicationCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
+import java.util.Set;
 
+public class ApplicationCreatedMessageProcessor extends MessageProcessor {
 
+    private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
     private MessageProcessor nextProcessor;
 
     @Override
     public void setNext(MessageProcessor nextProcessor) {
         this.nextProcessor = nextProcessor;
-
     }
 
     @Override
     public boolean process(String type, String message, Object object) {
+
+        Topology topology = (Topology) object;
+
         if (ApplicationCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            ApplicationCreatedEvent event =
-                    (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+            if (!topology.isInitialized()) {
+                return false;
+            }
 
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
+            ApplicationCreatedEvent event = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+            if (event == null) {
+                log.error("Unable to convert the JSON message to ApplicationCreatedEvent");
+                return false;
             }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
+
+            TopologyUpdater.acquireWriteLockForApplications();
+            // since the Clusters will also get modified, acquire write locks for each Service Type
+            Set<ClusterDataHolder> clusterDataHolders = event.getApplication().getClusterDataRecursively();
+            if (clusterDataHolders != null) {
+                for (ClusterDataHolder clusterData : clusterDataHolders) {
+                    TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
+                }
+            }
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                if (clusterDataHolders != null) {
+                    for (ClusterDataHolder clusterData : clusterDataHolders) {
+                        TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
+                    }
+                }
+                TopologyUpdater.releaseWriteLockForApplications();
+            }
+
         } else {
             if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
             } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
+
+    private boolean doProcess (ApplicationCreatedEvent event,Topology topology) {
+
+        // check if required properties are available
+        if (event.getApplication() == null) {
+            String errorMsg = "Application object of application created event is invalid";
+            log.error(errorMsg);
+            throw new RuntimeException(errorMsg);
+        }
+
+        if (event.getApplication().getUniqueIdentifier() == null || event.getApplication().getUniqueIdentifier().isEmpty()) {
+            String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getUniqueIdentifier() + " ]";
+            log.error(errorMsg);
+            throw new RuntimeException(errorMsg);
+        }
+
+        // check if an Application with same name exists in topology
+        if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) {
+            log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology");
+
+        } else {
+            // add application and the clusters to Topology
+            for(Cluster cluster: event.getClusterList()) {
+                topology.getService(cluster.getServiceName()).addCluster(cluster);
+            }
+            topology.addApplication(event.getApplication());
+        }
+
+        notifyEventListeners(event);
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
index d8f2aac..91eae8c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
@@ -20,10 +20,17 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
+/**
+ * This processor responsible to process the application Inactivation even and update the Topology.
+ */
 public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
     private static final Log log =
             LogFactory.getLog(ApplicationInactivatedMessageProcessor.class);
@@ -34,30 +41,64 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
     @Override
     public void setNext(MessageProcessor nextProcessor) {
         this.nextProcessor = nextProcessor;
-
     }
 
+
     @Override
     public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
         if (ApplicationInactivatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
             // Parse complete message and build event
-            ApplicationInactivatedEvent event =
-                    (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class);
+            ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
+                    jsonToObject(message, ApplicationInactivatedEvent.class);
 
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString());
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
             }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
+
         } else {
             if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
             } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
             }
+            return false;
+        } else {
+            // Apply changes to the topology
+            if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) {
+                log.error("Invalid State transfer from [ " + application.getStatus() +
+                        " ] to [ " + ApplicationStatus.Inactive + " ]");
+            }
+            application.setStatus(ApplicationStatus.Inactive);
+
         }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
index a121ffb..8cd2182 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
@@ -20,10 +20,18 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
+import java.util.Set;
+
+/**
+ * This processor responsible to process the application Inactivation even and update the Topology.
+ */
 public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
     private static final Log log =
             LogFactory.getLog(ApplicationTerminatedMessageProcessor.class);
@@ -34,30 +42,95 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
     @Override
     public void setNext(MessageProcessor nextProcessor) {
         this.nextProcessor = nextProcessor;
-
     }
 
+
     @Override
     public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
         if (ApplicationTerminatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
             // Parse complete message and build event
-            ApplicationTerminatedEvent event =
-                    (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class);
+            ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
+                    jsonToObject(message, ApplicationTerminatedEvent.class);
 
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString());
+            TopologyUpdater.acquireWriteLockForApplications();
+                        Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
+            if (clusterDataHolders != null) {
+                for (ClusterDataHolder clusterData : clusterDataHolders) {
+                    TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
+                }
             }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplications();
+                if (clusterDataHolders != null) {
+                    for (ClusterDataHolder clusterData : clusterDataHolders) {
+                        TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
+                    }
+                }
+            }
+
         } else {
             if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
             } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
+
+    private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) {
+
+        // check if required properties are available
+        if (event.getAppId() == null) {
+            String errorMsg = "Application Id of application removed event is invalid";
+            log.error(errorMsg);
+            throw new RuntimeException(errorMsg);
+        }
+
+        if (event.getTenantDomain()== null) {
+            String errorMsg = "Application tenant domain of application removed event is invalid";
+            log.error(errorMsg);
+            throw new RuntimeException(errorMsg);
+        }
+
+        // check if an Application with same name exists in topology
+        String appId = event.getAppId();
+        if (topology.applicationExists(appId)) {
+            log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
+            topology.removeApplication(appId);
+        }
+
+        if (event.getClusterData() != null) {
+            // remove the Clusters from the Topology
+            for (ClusterDataHolder clusterData : event.getClusterData()) {
+                Service service = topology.getService(clusterData.getServiceType());
+                if (service != null) {
+                    service.removeCluster(clusterData.getClusterId());
+                    if (log.isDebugEnabled()) {
+                        log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
+                    }
+                }  else {
+                    log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
+                }
+            }
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("ApplicationRemovedMessageProcessor notifying listener ");
+        }
+
+        notifyEventListeners(event);
+        return true;
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
index 280de2c..057d013 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
@@ -20,10 +20,17 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
+/**
+ * This processor responsible to process the application Inactivation even and update the Topology.
+ */
 public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
     private static final Log log =
             LogFactory.getLog(ApplicationTerminatingMessageProcessor.class);
@@ -34,30 +41,64 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
     @Override
     public void setNext(MessageProcessor nextProcessor) {
         this.nextProcessor = nextProcessor;
-
     }
 
+
     @Override
     public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
         if (ApplicationTerminatingEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
             // Parse complete message and build event
-            ApplicationTerminatingEvent event =
-                    (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class);
+            ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
+                    jsonToObject(message, ApplicationTerminatingEvent.class);
 
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString());
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
             }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
+
         } else {
             if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
             } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
             }
+            return false;
+        } else {
+            // Apply changes to the topology
+            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                log.error("Invalid State transfer from [ " + application.getStatus() +
+                        " ] to [ " + ApplicationStatus.Terminating + " ]");
+            }
+            application.setStatus(ApplicationStatus.Terminating);
+
         }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
new file mode 100644
index 0000000..7e91ab8
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+import java.util.Set;
+
+public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
+
+    private static final Log log = LogFactory.getLog(ApplicationUndeployedMessageProcessor.class);
+
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+
+        Topology topology = (Topology) object;
+
+        if (ApplicationUndeployedEvent.class.getName().equals(type)) {
+            if (!topology.isInitialized()) {
+                return false;
+            }
+
+            ApplicationUndeployedEvent event = (ApplicationUndeployedEvent)
+                    Util.jsonToObject(message, ApplicationUndeployedEvent.class);
+            if (event == null) {
+                log.error("Unable to convert the JSON message to ApplicationUndeployedEvent");
+                return false;
+            }
+
+            // get write lock for the application and relevant Clusters
+            TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId());
+            Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
+            if (clusterDataHolders != null) {
+                for (ClusterDataHolder clusterData : clusterDataHolders) {
+                    TopologyUpdater.acquireWriteLockForCluster(clusterData.getServiceType(),
+                            clusterData.getClusterId());
+                }
+            }
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                // remove locks
+                if (clusterDataHolders != null) {
+                    for (ClusterDataHolder clusterData : clusterDataHolders) {
+                        TopologyUpdater.releaseWriteLockForCluster(clusterData.getServiceType(),
+                                clusterData.getClusterId());
+                    }
+                }
+                TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format
+                    ("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) {
+
+        // update the application status to Terminating
+        Application application = topology.getApplication(event.getApplicationId());
+        // check and update application status to 'Terminating'
+        if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+            log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
+        }
+        // for now anyway update the status forcefully
+        application.setStatus(ApplicationStatus.Terminating);
+
+        // update all the Clusters' statuses to 'Terminating'
+        Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
+        // update the Cluster statuses to Terminating
+        for (ClusterDataHolder clusterDataHolder : clusterData) {
+            Service service = topology.getService(clusterDataHolder.getServiceType());
+            if (service != null) {
+                Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
+                if (aCluster != null) {
+                    // validate state transition
+                    if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                        log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
+                                + ClusterStatus.Terminating);
+                    }
+                    // for now anyway update the status forcefully
+                    aCluster.setStatus(ClusterStatus.Terminating);
+
+                } else {
+                    log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
+                            " in Topology");
+                }
+
+            } else {
+                log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
+                        " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
+            }
+        }
+
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
new file mode 100644
index 0000000..e75b604
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.listener.applications.*;
+import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
+
+/**
+ * Application Status processor chain is to handle the list processors to parse the application
+ * status.
+ */
+public class ApplicationsMessageProcessorChain extends MessageProcessorChain {
+    private static final Log log = LogFactory.getLog(ApplicationsMessageProcessorChain.class);
+
+    private GroupCreatedProcessor groupCreatedMessageProcessor;
+    private GroupActivatedProcessor groupActivatedMessageProcessor;
+    private GroupInActivateProcessor groupInActivateMessageProcessor;
+    private GroupTerminatedProcessor groupTerminatedProcessor;
+    private GroupTerminatingProcessor groupTerminatingProcessor;
+    private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor;
+    private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor;
+    private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor;
+    private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor;
+    private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor;
+    private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor;
+
+    public void initialize() {
+        // Add instance notifier event processors
+
+        groupCreatedMessageProcessor = new GroupCreatedProcessor();
+        add(groupCreatedMessageProcessor);
+
+        groupActivatedMessageProcessor = new GroupActivatedProcessor();
+        add(groupActivatedMessageProcessor);
+
+        groupInActivateMessageProcessor = new GroupInActivateProcessor();
+        add(groupInActivateMessageProcessor);
+
+        groupTerminatedProcessor = new GroupTerminatedProcessor();
+        add(groupTerminatedProcessor);
+
+        groupTerminatingProcessor = new GroupTerminatingProcessor();
+        add(groupTerminatingProcessor);
+
+        applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor();
+        add(applicationActivatedMessageProcessor);
+
+        applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor();
+        add(applicationCreatedMessageProcessor);
+
+        applicationInactivatedMessageProcessor = new ApplicationInactivatedMessageProcessor();
+        add(applicationInactivatedMessageProcessor);
+
+        applicationTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor();
+        add(applicationTerminatingMessageProcessor);
+
+        applicationTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor();
+        add(applicationTerminatedMessageProcessor);
+
+        applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor();
+        add(applicationUndeployedMessageProcessor);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Instance notifier message processor chain initialized");
+        }
+    }
+
+    public void addEventListener(EventListener eventListener) {
+
+        if(eventListener instanceof GroupCreatedEventListener) {
+            groupCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof GroupInactivateEventListener) {
+            groupInActivateMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof GroupActivatedEventListener) {
+            groupActivatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof GroupTerminatingEventListener) {
+            groupTerminatingProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof GroupTerminatedEventListener) {
+            groupTerminatedProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationCreatedEventListener) {
+            applicationCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationActivatedEventListener) {
+            applicationActivatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationInactivatedEventListener) {
+            applicationInactivatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationTerminatingEventListener) {
+            applicationTerminatingMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationTerminatedEventListener) {
+            applicationTerminatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ApplicationUndeployedEventListener) {
+            applicationUndeployedMessageProcessor.addEventListener(eventListener);
+        } else {
+            throw new RuntimeException("Unknown event listener " + eventListener.toString());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
deleted file mode 100644
index 02ddda8..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class GroupActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(GroupActivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (GroupActivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            GroupActivatedEvent event =
-                    (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupActivatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
new file mode 100644
index 0000000..845e933
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupActivatedProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupActivatedProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupActivatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupActivatedEvent event = (GroupActivatedEvent) Util.
+                    jsonToObject(message, GroupActivatedEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (GroupActivatedEvent event,Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the topology
+            if (!group.isStateTransitionValid(GroupStatus.Active)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+            }
+            group.setStatus(GroupStatus.Active);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
deleted file mode 100644
index d04d7f9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class GroupCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(GroupCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (GroupCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            GroupCreatedEvent event =
-                    (GroupCreatedEvent) Util.jsonToObject(message, GroupCreatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received AppStatusGroupCreatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group created message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
new file mode 100644
index 0000000..47d4457
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupCreatedProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupCreatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupCreatedEvent event = (GroupCreatedEvent) Util.
+                    jsonToObject(message, GroupCreatedEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (GroupCreatedEvent event,Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the topology
+            if (!group.isStateTransitionValid(GroupStatus.Created)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created  + " " +
+                        "for Group " + group.getAlias());
+            }
+            group.setStatus(GroupStatus.Created);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
new file mode 100644
index 0000000..063a3de
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupInActivateProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupInActivateProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupInactivateEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupInactivateEvent event = (GroupInactivateEvent) Util.
+                    jsonToObject(message, GroupInactivateEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess(GroupInactivateEvent event, Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            group.setStatus(GroupStatus.Inactive);
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Group updated as in-activated : %s",
+                        group.getUniqueIdentifier()));
+            }
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
deleted file mode 100644
index 6cf2587..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class GroupInactivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(GroupInactivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppStatusGroupInactivateEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppStatusGroupInactivateEvent event =
-                    (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupInActivateEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
deleted file mode 100644
index a917a14..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class GroupTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(GroupTerminatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (GroupTerminatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            GroupTerminatedEvent event =
-                    (GroupTerminatedEvent) Util.jsonToObject(message, GroupTerminatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in GroupTerminatingEvent message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
new file mode 100644
index 0000000..3de0914
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupTerminatedProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupTerminatedProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupTerminatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupTerminatedEvent event = (GroupTerminatedEvent) Util.
+                    jsonToObject(message, GroupTerminatedEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (GroupTerminatedEvent event,Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the topology
+            if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
+            }
+            group.setStatus(GroupStatus.Terminated);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
deleted file mode 100644
index 63c055d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class GroupTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(GroupTerminatingMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (GroupTerminatingEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            GroupTerminatingEvent event =
-                    (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received GroupTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group in GroupTerminatingEvent message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
new file mode 100644
index 0000000..e124b7b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupTerminatingProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupTerminatingProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
+        if (GroupTerminatingEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupTerminatingEvent event = (GroupTerminatingEvent) Util.
+                    jsonToObject(message, GroupTerminatingEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (GroupTerminatingEvent event,Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the topology
+            if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+            }
+            group.setStatus(GroupStatus.Terminating);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
new file mode 100644
index 0000000..694c3f3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterActivatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterActivatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterActivatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterActivatedEvent event = (ClusterStatusClusterActivatedEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterActivatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received ClusterActivatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
new file mode 100644
index 0000000..9b4780b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterCreatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}


[20/50] [abbrv] git commit: adding Application locks, Application Holder and persisting in Autoscaler

Posted by im...@apache.org.
adding Application locks, Application Holder and persisting in Autoscaler


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

Branch: refs/heads/docker-grouping-merge
Commit: 18f16549c953f5355afd34c10882c2723e78d9de
Parents: 275ba2d
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 13:34:23 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 13:34:38 2014 +0530

----------------------------------------------------------------------
 .../applications/ApplicationHolder.java         | 113 +++++++++++++++++++
 .../autoscaler/registry/RegistryManager.java    |  42 +++++++
 .../autoscaler/util/AutoScalerConstants.java    |   2 +-
 .../stratos/autoscaler/util/AutoscalerUtil.java |  49 +++++---
 .../domain/applications/Applications.java       |  46 ++++++++
 .../applications/locking/ApplicationLock.java   |  59 ++++++++++
 .../locking/ApplicationLockHierarchy.java       |  88 +++++++++++++++
 7 files changed, 382 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
new file mode 100644
index 0000000..e147d1b
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import com.google.gson.Gson;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.util.AutoscalerUtil;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
+
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class ApplicationHolder {
+
+    private static final Log log = LogFactory.getLog(ApplicationHolder.class);
+
+    private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
+    private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
+    private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
+    private static volatile Applications applications;
+
+    private ApplicationHolder () {}
+
+    public static void acquireReadLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Read lock acquired");
+        }
+        readLock.lock();
+    }
+
+    public static void releaseReadLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Read lock released");
+        }
+        readLock.unlock();
+    }
+
+    public static void acquireWriteLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Write lock acquired");
+        }
+        writeLock.lock();
+    }
+
+    public static void releaseWriteLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Write lock released");
+        }
+        writeLock.unlock();
+    }
+
+    public static Applications getApplications () {
+
+        if (applications == null) {
+            synchronized (ApplicationHolder.class) {
+                if (applications == null) {
+                    // retrieve from registry
+                    applications = AutoscalerUtil.getApplications();
+                    if (log.isDebugEnabled()) {
+                        log.debug("Trying to retrieve Applications from registry");
+                    }
+                    if (applications == null) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("No applications found in Registry");
+                        }
+                        // create a new Applications object
+                        applications = new Applications();
+                    }
+                }
+            }
+        }
+
+        return applications;
+    }
+
+    public static void persistApplication (Application application) {
+
+        synchronized (ApplicationHolder.class) {
+            if (log.isDebugEnabled()) {
+                log.debug("Updating topology");
+            }
+            applications.addApplication(application);
+            AutoscalerUtil.persistApplication(application);
+            if (log.isDebugEnabled()) {
+                log.debug(String.format("Topology updated: %s", toJson(applications)));
+            }
+        }
+
+    }
+
+    private static String toJson(Object object) {
+        Gson gson = new Gson();
+        return gson.toJson(object);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 7b3413e..25caf0e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -32,6 +32,8 @@ import org.apache.stratos.autoscaler.util.Deserializer;
 import org.apache.stratos.autoscaler.util.Serializer;
 import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
@@ -139,6 +141,46 @@ public class RegistryManager {
             log.debug(deploymentPolicy.toString());
         }
     }
+
+    public void persistApplication (Application application) {
+
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                "/" + application.getUniqueIdentifier();
+        persist(application, resourcePath);
+        if(log.isDebugEnabled()) {
+            log.debug("Application [ " + application.getUniqueIdentifier() +
+                    " ] persisted successfully in the Autoscaler Registry");
+        }
+    }
+
+    public String [] getApplicationResourcePaths () {
+        Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE +
+                AutoScalerConstants.APPLICATIONS_RESOURCE);
+
+        if (obj != null) {
+            if (obj instanceof String []) {
+                return (String []) obj;
+            } else {
+                log.warn("Expected object type not found for Applications in Registry");
+                return null;
+            }
+        }
+        return null;
+    }
+
+    public Application getApplication (String applicationResourcePath) {
+        Object obj = retrieve(applicationResourcePath);
+
+        if (obj != null) {
+            if (obj instanceof Application) {
+                return (Application) obj;
+            } else {
+                log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry");
+                return null;
+            }
+        }
+        return null;
+    }
     
     private Object retrieve(String resourcePath) {
         try {

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
index 03cf861..b30e0e6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
@@ -38,7 +38,7 @@ public final class AutoScalerConstants {
 	public static final String NETWORK_PARTITION_LB_HOLDER_RESOURCE = "/network-partitions";
 	public static final String AS_POLICY_RESOURCE = "/policies/autoscalingPolicies";
 	public static final String DEPLOYMENT_POLICY_RESOURCE = "/policies/deploymentPolicies";
-
+    public static final String APPLICATIONS_RESOURCE = "/applications";
 
     /**
      * Configs

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/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 59dda9f..4b95118 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
@@ -22,24 +22,12 @@ package org.apache.stratos.autoscaler.util;
 import org.apache.axiom.om.OMElement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.MemberStatsContext;
-import org.apache.stratos.autoscaler.NetworkPartitionContext;
-import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
-import org.apache.stratos.autoscaler.PartitionContext;
-import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.autoscaler.exception.PartitionValidationException;
-import org.apache.stratos.autoscaler.exception.PolicyValidationException;
-import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor;
-import org.apache.stratos.autoscaler.partition.PartitionGroup;
-import org.apache.stratos.autoscaler.partition.PartitionManager;
-import org.apache.stratos.autoscaler.policy.PolicyManager;
-import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
-import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
+import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.stub.pojo.Property;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.util.Constants;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
+
 
 import javax.xml.namespace.QName;
 import java.util.*;
@@ -55,6 +43,35 @@ public class AutoscalerUtil {
 
     }
 
+    public static Applications  getApplications () {
+
+        Applications applications;
+        String [] appResourcePaths = RegistryManager.getInstance().getApplicationResourcePaths();
+        if (appResourcePaths != null) {
+            applications = new Applications();
+            for (String appResourcePath : appResourcePaths) {
+                applications.addApplication(getApplicationFromPath(appResourcePath));
+            }
+
+            return applications;
+        }
+
+        return null;
+    }
+
+    public static Application getApplication (String appId) {
+        return getApplicationFromPath(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                "/" + appId);
+    }
+
+    public static void persistApplication (Application application) {
+        RegistryManager.getInstance().persistApplication(application);
+    }
+
+    private static Application getApplicationFromPath (String appResourcePath) {
+        return RegistryManager.getInstance().getApplication(appResourcePath);
+    }
+
     /*public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException {
         // FIXME fix the following code to correctly update
         // AutoscalerContext context = AutoscalerContext.getInstance();

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
new file mode 100644
index 0000000..9455a4c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Applications implements Serializable {
+
+    private static Log log = LogFactory.getLog(Applications.class);
+
+    private Map<String, Application> applicationMap;
+
+    public Applications () {
+        this.applicationMap = new HashMap<String, Application>();
+    }
+
+    public void addApplication (Application application) {
+        this.applicationMap.put(application.getUniqueIdentifier(), application);
+    }
+
+    public Application getApplication (String appId) {
+        return this.applicationMap.get(appId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java
new file mode 100644
index 0000000..5d01e36
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications.locking;
+
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class ApplicationLock {
+
+    private final ReentrantReadWriteLock lock;
+
+    public ApplicationLock () {
+        lock = new ReentrantReadWriteLock(true);
+    }
+
+    /**
+     * acquires write lock
+     */
+    public void acquireWriteLock() {
+        lock.writeLock().lock();
+    }
+
+    /**
+     * releases write lock
+     */
+    public void releaseWritelock() {
+        lock.writeLock().unlock();
+    }
+
+    /**
+     * acquires read lock
+     */
+    public void acquireReadLock() {
+        lock.readLock().lock();
+    }
+
+    /**
+     * releases read lock
+     */
+    public void releaseReadLock() {
+        lock.readLock().unlock();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/18f16549/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
new file mode 100644
index 0000000..71bfe03
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications.locking;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ApplicationLockHierarchy {
+
+    private static final Log log = LogFactory.getLog(ApplicationLockHierarchy.class);
+
+    // lock for Applications
+    private final ApplicationLock applicationLock;
+
+    // key = Application.id
+    private final Map<String, ApplicationLock> appIdToApplicationLockMap;
+
+    private static volatile ApplicationLockHierarchy applicationLockHierarchy;
+
+    private ApplicationLockHierarchy () {
+        this.applicationLock = new ApplicationLock();
+        this.appIdToApplicationLockMap = new HashMap<String, ApplicationLock>();
+    }
+
+    public static ApplicationLockHierarchy getInstance () {
+
+        if (applicationLockHierarchy == null) {
+            synchronized (ApplicationLockHierarchy.class) {
+                if (applicationLockHierarchy == null) {
+                    applicationLockHierarchy = new ApplicationLockHierarchy();
+                }
+            }
+        }
+
+        return applicationLockHierarchy;
+    }
+
+    public void addApplicationLock (String appId, final ApplicationLock appLock) {
+
+        if (!appIdToApplicationLockMap.containsKey(appId)) {
+            synchronized (appIdToApplicationLockMap) {
+                if (!appIdToApplicationLockMap.containsKey(appId)) {
+                    appIdToApplicationLockMap.put(appId, appLock);
+                    log.info("Added lock for Application " + appId);
+                }
+            }
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("Topology Lock for Application " + appId + " already exists");
+            }
+        }
+    }
+
+    public ApplicationLock getLock (String appId) {
+        return appIdToApplicationLockMap.get(appId);
+    }
+
+    public void removeLock (String appId) {
+        if (appIdToApplicationLockMap.remove(appId) != null) {
+            log.info("Removed lock for Application " + appId);
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("Lock already removed for Application " + appId);
+            }
+        }
+    }
+
+}


[30/50] [abbrv] moving applications stuff to autoscaler - II

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
index bbbfbf5..e987abf 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
@@ -23,8 +23,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
 import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
 /**
@@ -67,21 +66,21 @@ public class ApplicationsUpdater {
     // Top level locks - should be used to lock the entire Topology
 
     /**
-     * Acquires write lock for the Complete Topology
+     * Acquires write lock for all Applications
      */
-    public static void acquireWriteLock() {
+    public static void acquireWriteLockForApplications() {
         if(log.isDebugEnabled()) {
-            log.debug("Write lock acquired for Topology");
+            log.debug("Write lock acquired for Applications");
         }
         applicationLockHierarchy.getApplicationLock().acquireWriteLock();
     }
 
     /**
-     * Releases write lock for the Complete Topology
+     * Releases write lock for all Applications
      */
-    public static void releaseWriteLock() {
+    public static void releaseWriteLockForApplications() {
         if(log.isDebugEnabled()) {
-            log.debug("Write lock released for Topology");
+            log.debug("Write lock released for Applications");
         }
         applicationLockHierarchy.getApplicationLock().releaseWritelock();
     }
@@ -94,9 +93,9 @@ public class ApplicationsUpdater {
     public static void acquireWriteLockForApplication (String appId) {
 
         // acquire read lock for all Applications
-        TopologyManager.acquireReadLockForApplications();
+        ApplicationManager.acquireReadLockForApplications();
 
-        ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+        ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
         if (applicationLock == null)  {
             handleLockNotFound("Topology lock not found for Application " + appId);
 
@@ -116,7 +115,7 @@ public class ApplicationsUpdater {
      */
     public static void releaseWriteLockForApplication (String appId) {
 
-        ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+        ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
         if (applicationLock == null)  {
             handleLockNotFound("Topology lock not found for Application " + appId);
 
@@ -129,7 +128,7 @@ public class ApplicationsUpdater {
         }
 
         // release read lock for all Applications
-        TopologyManager.releaseReadLockForApplications();
+        ApplicationManager.releaseReadLockForApplications();
     }
 
     private static void handleLockNotFound (String errorMsg) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
index 787ac74..ea1f83b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
@@ -149,21 +149,6 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
             }
         }
 
-        // add existing Applications to Topology
-        Collection<Application> applications = event.getTopology().getApplications();
-        if (applications != null && !applications.isEmpty()) {
-            for (Application application : applications) {
-                topology.addApplication(application);
-                if (log.isDebugEnabled()) {
-                    log.debug("Application with id [ " +  application.getUniqueIdentifier() + " ] added to Topology");
-                }
-            }
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("No Application information found in Complete Topology event");
-            }
-        }
-
         if (log.isInfoEnabled()) {
             log.info("Topology initialized");
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
index 9867223..e4b1c66 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
@@ -83,27 +83,7 @@ public class TopologyUpdater {
         topologyLockHierarchy.getCompleteTopologyLock().releaseWritelock();
     }
 
-    // Application and Service write locks
-    /**
-     * Acquires write lock for the all Applications
-     */
-    public static void acquireWriteLockForApplications() {
-        if(log.isDebugEnabled()) {
-            log.debug("Write lock acquired for Applications");
-        }
-        topologyLockHierarchy.getApplicatioLock().acquireWriteLock();
-    }
-
-    /**
-     * Releases write lock for the all Applications
-     */
-    public static void releaseWriteLockForApplications() {
-        if(log.isDebugEnabled()) {
-            log.debug("Write lock released for Applications");
-        }
-        topologyLockHierarchy.getApplicatioLock().releaseWritelock();
-    }
-
+    // Service write locks
     /**
      * Acquires write lock for the all Services
      */
@@ -218,52 +198,6 @@ public class TopologyUpdater {
         TopologyManager.releaseReadLockForService(serviceName);
     }
 
-    /**
-     * Acquires write lock for the Application
-     *
-     * @param appId Application id
-     */
-    public static void acquireWriteLockForApplication (String appId) {
-
-        // acquire read lock for all Applications
-        TopologyManager.acquireReadLockForApplications();
-
-        TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
-        if (topologyAppLock == null)  {
-            handleLockNotFound("Topology lock not found for Application " + appId);
-
-        } else {
-            // now, lock Application
-            topologyAppLock.acquireWriteLock();
-            if(log.isDebugEnabled()) {
-                log.debug("Write lock acquired for Application " + appId);
-            }
-        }
-    }
-
-    /**
-     * Releases write lock for the Application
-     *
-     * @param appId Application id
-     */
-    public static void releaseWriteLockForApplication (String appId) {
-
-        TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
-        if (topologyAppLock == null)  {
-            handleLockNotFound("Topology lock not found for Application " + appId);
-
-        } else {
-            // release App lock
-            topologyAppLock.releaseWritelock();
-            if(log.isDebugEnabled()) {
-                log.debug("Write lock released for Application " + appId);
-            }
-        }
-
-        // release read lock for all Applications
-        TopologyManager.releaseReadLockForApplications();
-    }
-
     private static void handleLockNotFound (String errorMsg) {
         log.warn(errorMsg);
         //throw new RuntimeException(errorMsg);

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
new file mode 100644
index 0000000..0c3aa0e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.message.receiver.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
+
+public class ApplicationManager {
+
+    private static final Log log = LogFactory.getLog(ApplicationManager.class);
+
+    private static volatile Applications applications;
+    private static volatile ApplicationLockHierarchy applicationLockHierarchy =
+            ApplicationLockHierarchy.getInstance();
+
+    public static Applications getApplications () {
+
+        if (applications == null) {
+            synchronized (ApplicationManager.class){
+                if (applications == null) {
+                    applications = new Applications();
+                    if(log.isDebugEnabled()) {
+                        log.debug("Applications object created");
+                    }
+                }
+            }
+        }
+        return applications;
+    }
+
+    /**
+     * Acquires read lock for all Applications
+     */
+    public static void acquireReadLockForApplications() {
+        if(log.isDebugEnabled()) {
+            log.debug("Read lock acquired for Applications");
+        }
+        applicationLockHierarchy.getApplicationLock().acquireReadLock();
+    }
+
+    /**
+     * Releases read lock for all Applications
+     */
+    public static void releaseReadLockForApplications() {
+        if(log.isDebugEnabled()) {
+            log.debug("Read lock released for Applications");
+        }
+        applicationLockHierarchy.getApplicationLock().releaseReadLock();
+    }
+
+    /**
+     * Acquires read lock for an Application
+     *
+     * @param applicationId Application Id to acquire read lock
+     */
+    public static void acquireReadLockForApplication(String applicationId) {
+
+        // acquire read lock for all Applications
+        acquireReadLockForApplications();
+
+        ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId);
+        if (applicationLock == null) {
+            handleLockNotFound("Application lock not found for Application " + applicationId);
+
+        } else {
+            applicationLock.acquireReadLock();
+            if(log.isDebugEnabled()) {
+                log.debug("Read lock acquired for Application " + applicationId);
+            }
+        }
+    }
+
+    /**
+     * Releases read lock for an Application
+     *
+     * @param applicationId Application Id to release read lock
+     */
+    public static void releaseReadLockForApplication(String applicationId) {
+
+        ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId);
+        if (applicationLock == null) {
+            handleLockNotFound("Application lock not found for Application " + applicationId);
+
+        } else {
+            applicationLock.releaseReadLock();
+            if(log.isDebugEnabled()) {
+                log.debug("Read lock released for Application " + applicationId);
+            }
+        }
+
+        // release read lock for all Applications
+        releaseReadLockForApplications();
+    }
+
+    private static void handleLockNotFound (String errorMsg) {
+        log.warn(errorMsg);
+        //throw new RuntimeException(errorMsg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
index 1d74616..159e128 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
@@ -85,26 +85,7 @@ public class TopologyManager {
         topologyLockHierarchy.getCompleteTopologyLock().releaseReadLock();
     }
 
-    // Application and Service read locks
-    /**
-     * Acquires read lock for the all Applications
-     */
-    public static void acquireReadLockForApplications() {
-        if(log.isDebugEnabled()) {
-            log.debug("Read lock acquired for Applications");
-        }
-        topologyLockHierarchy.getApplicatioLock().acquireReadLock();
-    }
-
-    /**
-     * Releases read lock for the all Applications
-     */
-    public static void releaseReadLockForApplications() {
-        if(log.isDebugEnabled()) {
-            log.debug("Read lock released for Applications");
-        }
-        topologyLockHierarchy.getApplicatioLock().releaseReadLock();
-    }
+    // Service read locks
 
     /**
      * Acquires read lock for the all Services
@@ -222,52 +203,6 @@ public class TopologyManager {
         releaseReadLockForService(serviceName);
     }
 
-    /**
-     * Acquires read lock for the Application
-     *
-     * @param appId Application id
-     */
-    public static void acquireReadLockForApplication (String appId) {
-
-        // acquire read lock for all Applications
-        acquireReadLockForApplications();
-
-        TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
-        if (topologyAppLock == null)  {
-            handleLockNotFound("Topology lock not found for Application " + appId);
-
-        } else {
-            // now, lock Application
-            topologyAppLock.acquireReadLock();
-            if(log.isDebugEnabled()) {
-                log.debug("Read lock acquired for Application " + appId);
-            }
-        }
-    }
-
-    /**
-     * Releases read lock for the Application
-     *
-     * @param appId Application id
-     */
-    public static void releaseReadLockForApplication (String appId) {
-
-        TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
-        if (topologyAppLock == null)  {
-            handleLockNotFound("Topology lock not found for Application " + appId);
-
-        } else {
-            // release App lock
-            topologyAppLock.releaseReadLock();
-            if(log.isDebugEnabled()) {
-                log.debug("Read lock released for Application " + appId);
-            }
-        }
-
-        // release read lock for all Applications
-        releaseReadLockForApplications();
-    }
-
     private static void handleLockNotFound (String errorMsg) {
         log.warn(errorMsg);
         //throw new RuntimeException(errorMsg);


[05/50] [abbrv] git commit: renaming couple of methods

Posted by im...@apache.org.
renaming couple of methods


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

Branch: refs/heads/docker-grouping-merge
Commit: d41da06c6ab034c382f25503dc926781ddac3bd2
Parents: db1fd26
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Thu Oct 30 18:39:12 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Thu Oct 30 18:39:12 2014 +0530

----------------------------------------------------------------------
 .../status/receiver/ApplicationStatusTopicReceiver.java          | 4 ++--
 .../stratos/cloud/controller/topology/TopologyBuilder.java       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d41da06c/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index e155875..9db0998 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -67,7 +67,7 @@ public class ApplicationStatusTopicReceiver implements Runnable {
         statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterReset((AppStatusClusterCreatedEvent) event);
+                TopologyBuilder.handleClusterCreated((AppStatusClusterCreatedEvent) event);
             }
         });
 
@@ -103,7 +103,7 @@ public class ApplicationStatusTopicReceiver implements Runnable {
         statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupReset((AppStatusGroupCreatedEvent) event);
+                TopologyBuilder.handleGroupCreated((AppStatusGroupCreatedEvent) event);
             }
         });
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d41da06c/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 5d14971..2cf4905 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
@@ -114,7 +114,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterReset (AppStatusClusterCreatedEvent event) {
+    public static void handleClusterCreated (AppStatusClusterCreatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -151,7 +151,7 @@ public class TopologyBuilder {
                 event.getClusterId());
     }
 
-    public static void handleGroupReset (AppStatusGroupCreatedEvent event) {
+    public static void handleGroupCreated (AppStatusGroupCreatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 


[13/50] [abbrv] renaming application.status topic to applications

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
new file mode 100644
index 0000000..8ff0db3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application inactivated is detected.
+ */
+public class ApplicationInactivatedEvent extends StatusEvent implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String appId;
+
+    public ApplicationInactivatedEvent(String appId) {
+        this.appId = appId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
new file mode 100644
index 0000000..024327a
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * This event will be fired upon the application terminated is detected.
+ */
+public class ApplicationTerminatedEvent extends StatusEvent implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String appId;
+    private Set<ClusterDataHolder> clusterData;
+
+    public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
+        this.appId = appId;
+        this.clusterData = clusterData;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public Set<ClusterDataHolder> getClusterData() {
+        return clusterData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
new file mode 100644
index 0000000..e81b988
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application terminating is detected.
+ */
+public class ApplicationTerminatingEvent extends StatusEvent implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String appId;
+
+    public ApplicationTerminatingEvent(String appId) {
+        this.appId = appId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
new file mode 100644
index 0000000..c200217
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupActivatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupActivatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
new file mode 100644
index 0000000..8b622c5
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupCreatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupCreatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
new file mode 100644
index 0000000..5723305
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event will be fired upon the instability of group detection by autoscaler.
+ */
+public class GroupMaintenanceModeEvent extends StatusEvent {
+    private String groupId;
+    private String appId;
+
+    public GroupMaintenanceModeEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId(String groupId) {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
new file mode 100644
index 0000000..8099015
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by autoscaler before actually terminate a group.
+ */
+public class GroupReadyToShutdownEvent extends StatusEvent {
+    private String groupId;
+    private String appId;
+
+    public GroupReadyToShutdownEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId(String groupId) {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
new file mode 100644
index 0000000..6cfa888
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupTerminatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupTerminatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
new file mode 100644
index 0000000..ba6f979
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupTerminatingEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupTerminatingEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
new file mode 100644
index 0000000..91dbab3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
+/**
+ * Represents all instance status events.
+ */
+public abstract class StatusEvent extends Event implements Serializable {
+    private static final long serialVersionUID = -4790128084271867615L;
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
deleted file mode 100644
index 4dfc8b5..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application activated event.
- */
-public abstract class AppStatusApplicationActivatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
deleted file mode 100644
index 79a7d21..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application created event.
- */
-public abstract class AppStatusApplicationCreatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
deleted file mode 100644
index c2a356d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application inactivated event.
- */
-public abstract class AppStatusApplicationInactivatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
deleted file mode 100644
index ad1be52..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application terminated event.
- */
-public abstract class AppStatusApplicationTerminatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
deleted file mode 100644
index a454f16..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application terminating event.
- */
-public abstract class AppStatusApplicationTerminatingEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
deleted file mode 100644
index 75da7b8..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusClusterActivatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
deleted file mode 100644
index c0c62f9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusClusterCreatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
deleted file mode 100644
index 03da7f7..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusClusterInactivateEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java
deleted file mode 100644
index a47c371..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusClusterTerminatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java
deleted file mode 100644
index 11bdb97..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusClusterTerminatingEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
deleted file mode 100644
index e6381e3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusGroupActivatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
deleted file mode 100644
index 82386a3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusGroupCreatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
deleted file mode 100644
index 0873a70..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusGroupInactivateEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
deleted file mode 100644
index 785abbd..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusGroupTerminatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
deleted file mode 100644
index 8d56555..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppStatusGroupTerminatingEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
new file mode 100644
index 0000000..f99e15b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppClusterActivatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
new file mode 100644
index 0000000..d43f360
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppClusterCreatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
new file mode 100644
index 0000000..1adaeef
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppClusterInactivateEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
new file mode 100644
index 0000000..89a66e9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppClusterTerminatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
new file mode 100644
index 0000000..9cd9a5d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppClusterTerminatingEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java
new file mode 100644
index 0000000..e244ae9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application activated event.
+ */
+public abstract class ApplicationActivatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java
new file mode 100644
index 0000000..8e17c7b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application created event.
+ */
+public abstract class ApplicationCreatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java
new file mode 100644
index 0000000..d0593fb
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application inactivated event.
+ */
+public abstract class ApplicationInactivatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java
new file mode 100644
index 0000000..064465c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application terminated event.
+ */
+public abstract class ApplicationTerminatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java
new file mode 100644
index 0000000..3be2ad2
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application terminating event.
+ */
+public abstract class ApplicationTerminatingEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java
new file mode 100644
index 0000000..3abd823
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ApplicationUndeployedEventListener extends EventListener {
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java
new file mode 100644
index 0000000..51455ae
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupActivatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
new file mode 100644
index 0000000..f13ed10
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupCreatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java
new file mode 100644
index 0000000..aeb58da
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupInactivateEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java
new file mode 100644
index 0000000..ed4bb3a
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupTerminatedEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java
new file mode 100644
index 0000000..5168f77
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupTerminatingEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java
deleted file mode 100644
index f54ab9e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will be triggered upon the application activated event received.
- */
-public abstract class ApplicationActivatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java
deleted file mode 100644
index bbc853f..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ApplicationCreatedEventListener extends EventListener {
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java
deleted file mode 100644
index d33c037..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will be triggered upon the application activated event received.
- */
-public abstract class ApplicationInActivateEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java
deleted file mode 100644
index 0b6fd59..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will be triggered upon the application activated event received.
- */
-public abstract class ApplicationTerminatedEventListener extends EventListener {
-}


[14/50] [abbrv] git commit: renaming application.status topic to applications

Posted by im...@apache.org.
renaming application.status topic to applications


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

Branch: refs/heads/docker-grouping-merge
Commit: f0ba4beb168eb119011aef6c424cc4d60057585b
Parents: e153430
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 12:22:29 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 12:23:39 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    |  54 +++----
 .../status/checker/StatusChecker.java           |  62 ++++++++-
 .../AppStatusApplicationActivatedEvent.java     |  38 -----
 .../AppStatusApplicationCreatedEvent.java       |  38 -----
 .../AppStatusApplicationInactivatedEvent.java   |  38 -----
 .../AppStatusApplicationTerminatedEvent.java    |  47 -------
 .../AppStatusApplicationTerminatingEvent.java   |  38 -----
 .../status/AppStatusClusterActivatedEvent.java  |  50 -------
 .../status/AppStatusClusterCreatedEvent.java    |  50 -------
 .../status/AppStatusClusterInactivateEvent.java |  50 -------
 .../AppStatusClusterMaintenanceModeEvent.java   |  49 -------
 .../AppStatusClusterReadyToShutdownEvent.java   |  47 -------
 .../status/AppStatusClusterTerminatedEvent.java |  50 -------
 .../AppStatusClusterTerminatingEvent.java       |  50 -------
 .../status/AppStatusGroupActivatedEvent.java    |  44 ------
 .../status/AppStatusGroupCreatedEvent.java      |  44 ------
 .../status/AppStatusGroupInactivateEvent.java   |  44 ------
 .../AppStatusGroupMaintenanceModeEvent.java     |  41 ------
 .../AppStatusGroupReadyToShutdownEvent.java     |  40 ------
 .../status/AppStatusGroupTerminatedEvent.java   |  44 ------
 .../status/AppStatusGroupTerminatingEvent.java  |  44 ------
 .../event/application/status/StatusEvent.java   |  31 -----
 .../applications/AppClusterActivatedEvent.java  |  50 +++++++
 .../applications/AppClusterCreatedEvent.java    |  50 +++++++
 .../applications/AppClusterInactivateEvent.java |  50 +++++++
 .../applications/AppClusterTerminatedEvent.java |  50 +++++++
 .../AppClusterTerminatingEvent.java             |  50 +++++++
 .../AppStatusGroupInactivateEvent.java          |  44 ++++++
 .../applications/ApplicationActivatedEvent.java |  38 +++++
 .../applications/ApplicationCreatedEvent.java   |  38 +++++
 .../ApplicationInactivatedEvent.java            |  38 +++++
 .../ApplicationTerminatedEvent.java             |  47 +++++++
 .../ApplicationTerminatingEvent.java            |  38 +++++
 .../event/applications/GroupActivatedEvent.java |  44 ++++++
 .../event/applications/GroupCreatedEvent.java   |  44 ++++++
 .../applications/GroupMaintenanceModeEvent.java |  41 ++++++
 .../applications/GroupReadyToShutdownEvent.java |  40 ++++++
 .../applications/GroupTerminatedEvent.java      |  44 ++++++
 .../applications/GroupTerminatingEvent.java     |  44 ++++++
 .../event/applications/StatusEvent.java         |  31 +++++
 ...StatusApplicationActivatedEventListener.java |  27 ----
 ...ppStatusApplicationCreatedEventListener.java |  27 ----
 ...atusApplicationInactivatedEventListener.java |  27 ----
 ...tatusApplicationTerminatedEventListener.java |  27 ----
 ...atusApplicationTerminatingEventListener.java |  27 ----
 .../AppStatusClusterActivatedEventListener.java |  24 ----
 .../AppStatusClusterCreatedEventListener.java   |  24 ----
 ...AppStatusClusterInactivateEventListener.java |  24 ----
 ...AppStatusClusterTerminatedEventListener.java |  24 ----
 ...ppStatusClusterTerminatingEventListener.java |  24 ----
 .../AppStatusGroupActivatedEventListener.java   |  24 ----
 .../AppStatusGroupCreatedEventListener.java     |  24 ----
 .../AppStatusGroupInactivateEventListener.java  |  24 ----
 .../AppStatusGroupTerminatedEventListener.java  |  24 ----
 .../AppStatusGroupTerminatingEventListener.java |  24 ----
 .../AppClusterActivatedEventListener.java       |  24 ++++
 .../AppClusterCreatedEventListener.java         |  24 ++++
 .../AppClusterInactivateEventListener.java      |  24 ++++
 .../AppClusterTerminatedEventListener.java      |  24 ++++
 .../AppClusterTerminatingEventListener.java     |  24 ++++
 .../ApplicationActivatedEventListener.java      |  27 ++++
 .../ApplicationCreatedEventListener.java        |  27 ++++
 .../ApplicationInactivatedEventListener.java    |  27 ++++
 .../ApplicationTerminatedEventListener.java     |  27 ++++
 .../ApplicationTerminatingEventListener.java    |  27 ++++
 .../ApplicationUndeployedEventListener.java     |  26 ++++
 .../GroupActivatedEventListener.java            |  24 ++++
 .../applications/GroupCreatedEventListener.java |  24 ++++
 .../GroupInactivateEventListener.java           |  24 ++++
 .../GroupTerminatedEventListener.java           |  24 ++++
 .../GroupTerminatingEventListener.java          |  24 ++++
 .../ApplicationActivatedEventListener.java      |  27 ----
 .../ApplicationCreatedEventListener.java        |  26 ----
 .../ApplicationInActivateEventListener.java     |  27 ----
 .../ApplicationTerminatedEventListener.java     |  27 ----
 .../ApplicationTerminatingEventListener.java    |  27 ----
 .../ApplicationUndeployedEventListener.java     |  26 ----
 .../topology/GroupActivatedEventListener.java   |  27 ----
 .../topology/GroupCreatedEventListener.java     |  27 ----
 .../topology/GroupInActivateEventListener.java  |  27 ----
 .../topology/GroupTerminatedEventListener.java  |  27 ----
 .../topology/GroupTerminatingEventListener.java |  27 ----
 ...tusApplicationActivatedMessageProcessor.java |  62 ---------
 ...tatusApplicationCreatedMessageProcessor.java |  63 ---------
 ...sApplicationInactivatedMessageProcessor.java |  63 ---------
 ...usApplicationTerminatedMessageProcessor.java |  63 ---------
 ...sApplicationTerminatingMessageProcessor.java |  63 ---------
 ...pStatusClusterActivatedMessageProcessor.java |  57 --------
 ...AppStatusClusterCreatedMessageProcessor.java |  58 --------
 ...StatusClusterInactivateMessageProcessor.java |  58 --------
 ...StatusClusterTerminatedMessageProcessor.java |  58 --------
 ...tatusClusterTerminatingMessageProcessor.java |  58 --------
 ...AppStatusGroupActivatedMessageProcessor.java |  61 --------
 .../AppStatusGroupCreatedMessageProcessor.java  |  62 ---------
 ...pStatusGroupInactivatedMessageProcessor.java |  61 --------
 ...ppStatusGroupTerminatedMessageProcessor.java |  61 --------
 ...pStatusGroupTerminatingMessageProcessor.java |  61 --------
 .../status/AppStatusMessageProcessorChain.java  | 139 -------------------
 .../AppClusterActivatedMessageProcessor.java    |  57 ++++++++
 .../AppClusterCreatedMessageProcessor.java      |  57 ++++++++
 .../AppClusterInactivateMessageProcessor.java   |  58 ++++++++
 .../AppClusterTerminatedMessageProcessor.java   |  58 ++++++++
 .../AppClusterTerminatingMessageProcessor.java  |  58 ++++++++
 .../AppStatusMessageProcessorChain.java         | 139 +++++++++++++++++++
 .../ApplicationActivatedMessageProcessor.java   |  62 +++++++++
 .../ApplicationCreatedMessageProcessor.java     |  63 +++++++++
 .../ApplicationInactivatedMessageProcessor.java |  63 +++++++++
 .../ApplicationTerminatedMessageProcessor.java  |  63 +++++++++
 .../ApplicationTerminatingMessageProcessor.java |  63 +++++++++
 .../GroupActivatedMessageProcessor.java         |  61 ++++++++
 .../GroupCreatedMessageProcessor.java           |  61 ++++++++
 .../GroupInactivatedMessageProcessor.java       |  61 ++++++++
 .../GroupTerminatedMessageProcessor.java        |  61 ++++++++
 .../GroupTerminatingMessageProcessor.java       |  61 ++++++++
 114 files changed, 2316 insertions(+), 2623 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index eb6e084..c0e77de 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -7,7 +7,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.application.status.*;
+import org.apache.stratos.messaging.event.applications.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;
 
@@ -30,8 +30,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Cluster created event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterCreatedEvent clusterCreatedEvent =
-                            new AppStatusClusterCreatedEvent(appId, serviceName, clusterId);
+                    AppClusterCreatedEvent clusterCreatedEvent =
+                            new AppClusterCreatedEvent(appId, serviceName, clusterId);
 
                     publishEvent(clusterCreatedEvent);
                 } else {
@@ -54,8 +54,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Cluster activated event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterActivatedEvent clusterActivatedEvent =
-                            new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
+                    AppClusterActivatedEvent clusterActivatedEvent =
+                            new AppClusterActivatedEvent(appId, serviceName, clusterId);
 
                     publishEvent(clusterActivatedEvent);
                 } else {
@@ -78,8 +78,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Cluster in-activate event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterInactivateEvent clusterInActivateEvent =
-                            new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
+                    AppClusterInactivateEvent clusterInActivateEvent =
+                            new AppClusterInactivateEvent(appId, serviceName, clusterId);
 
                     publishEvent(clusterInActivateEvent);
                 } else {
@@ -104,8 +104,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Cluster Terminating event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
-                            new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+                    AppClusterTerminatingEvent appStatusClusterTerminatingEvent =
+                            new AppClusterTerminatingEvent(appId, serviceName, clusterId);
 
                     publishEvent(appStatusClusterTerminatingEvent);
                 } else {
@@ -130,8 +130,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Cluster terminated event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
-                            new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+                    AppClusterTerminatedEvent appStatusClusterTerminatedEvent =
+                            new AppClusterTerminatedEvent(appId, serviceName, clusterId);
 
                     publishEvent(appStatusClusterTerminatedEvent);
                 } else {
@@ -155,8 +155,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Group created event for [application]: " + appId +
                                 " [group]: " + groupId);
                     }
-                    AppStatusGroupCreatedEvent groupCreatedEvent =
-                            new AppStatusGroupCreatedEvent(appId, groupId);
+                    GroupCreatedEvent groupCreatedEvent =
+                            new GroupCreatedEvent(appId, groupId);
 
                     publishEvent(groupCreatedEvent);
                 } else {
@@ -179,8 +179,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Group activated event for [application]: " + appId +
                                 " [group]: " + groupId);
                     }
-                    AppStatusGroupActivatedEvent groupActivatedEvent =
-                            new AppStatusGroupActivatedEvent(appId, groupId);
+                    GroupActivatedEvent groupActivatedEvent =
+                            new GroupActivatedEvent(appId, groupId);
 
                     publishEvent(groupActivatedEvent);
                 } else {
@@ -227,8 +227,8 @@ public class StatusEventPublisher {
                         log.info("Publishing Group terminating event for [application]: " + appId +
                                 " [group]: " + groupId);
                     }
-                    AppStatusGroupTerminatingEvent groupInTerminatingEvent =
-                            new AppStatusGroupTerminatingEvent(appId, groupId);
+                    GroupTerminatingEvent groupInTerminatingEvent =
+                            new GroupTerminatingEvent(appId, groupId);
                     publishEvent(groupInTerminatingEvent);
                 } else {
                     log.warn("Terminating is not in the possible state list of [group] " + groupId);
@@ -252,8 +252,8 @@ public class StatusEventPublisher {
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Terminated)) {
-                    AppStatusGroupTerminatedEvent groupInTerminatedEvent =
-                            new AppStatusGroupTerminatedEvent(appId, groupId);
+                    GroupTerminatedEvent groupInTerminatedEvent =
+                            new GroupTerminatedEvent(appId, groupId);
                     publishEvent(groupInTerminatedEvent);
                 } else {
                     log.warn("Terminated is not in the possible state list of [group] " + groupId);
@@ -275,8 +275,8 @@ public class StatusEventPublisher {
                     if (log.isInfoEnabled()) {
                         log.info("Publishing Application activated event for [application]: " + appId);
                     }
-                    AppStatusApplicationActivatedEvent applicationActivatedEvent =
-                            new AppStatusApplicationActivatedEvent(appId);
+                    ApplicationActivatedEvent applicationActivatedEvent =
+                            new ApplicationActivatedEvent(appId);
 
                     publishEvent(applicationActivatedEvent);
                 } else {
@@ -298,8 +298,8 @@ public class StatusEventPublisher {
             Application application = TopologyManager.getTopology().getApplication(appId);
             if (application != null) {
                 if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
-                    AppStatusApplicationInactivatedEvent applicationInActivatedEvent =
-                            new AppStatusApplicationInactivatedEvent(appId);
+                    ApplicationInactivatedEvent applicationInActivatedEvent =
+                            new ApplicationInactivatedEvent(appId);
                     publishEvent(applicationInActivatedEvent);
                 } else {
                     log.warn("Inactive is not in the possible state list of [application] " + appId);
@@ -319,8 +319,8 @@ public class StatusEventPublisher {
                     if (log.isInfoEnabled()) {
                         log.info("Publishing Application terminated event for [application]: " + appId);
                     }
-                    AppStatusApplicationTerminatingEvent applicationTerminatingEvent =
-                            new AppStatusApplicationTerminatingEvent(appId);
+                    ApplicationTerminatingEvent applicationTerminatingEvent =
+                            new ApplicationTerminatingEvent(appId);
                     publishEvent(applicationTerminatingEvent);
                 } else {
                     log.warn("Terminating is not in the possible state list of [application] " + appId);
@@ -340,8 +340,8 @@ public class StatusEventPublisher {
                     if (log.isInfoEnabled()) {
                         log.info("Publishing Application terminated event for [application]: " + appId);
                     }
-                    AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
-                            new AppStatusApplicationTerminatedEvent(appId, clusterData);
+                    ApplicationTerminatedEvent applicationTerminatedEvent =
+                            new ApplicationTerminatedEvent(appId, clusterData);
                     publishEvent(applicationTerminatedEvent);
                 } else {
                     log.warn("Terminated is not in the possible state list of [application] " + appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 392a0d5..408776f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -30,6 +30,7 @@ import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
+import javax.net.ssl.SSLEngineResult;
 import java.util.Map;
 
 /**
@@ -287,7 +288,7 @@ public class StatusChecker {
                 TopologyManager.acquireReadLockForApplication(appId);
                 Application application = TopologyManager.getTopology().getApplication(appId);
 
-                if (groups.isEmpty() && clusterStatus == ClusterStatus.Active ||
+                if (groups.isEmpty() && getClusterAllInSameState(clusterData,ClusterStatus.Active) ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Active ||
                         groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) {
                     //send activation event
@@ -369,6 +370,65 @@ public class StatusChecker {
         return childFound;
     }
 
+    private boolean getGroupInActive(Map<String, Group> groups) {
+        boolean groupStat = false;
+        for (Group group : groups.values()) {
+            if (group.getStatus() == GroupStatus.Inactive) {
+                groupStat = true;
+                return groupStat;
+            } else {
+                groupStat = false;
+            }
+        }
+        return groupStat;
+    }
+
+    private boolean allGroupInSameState(Map<String, Group> groups, GroupStatus status) {
+        boolean groupStat = false;
+        for (Group group : groups.values()) {
+            if (group.getStatus() == status) {
+                groupStat = true;
+            } else {
+                groupStat = false;
+                return groupStat;
+            }
+        }
+        return groupStat;
+    }
+
+
+    private boolean getClusterInActive(Map<String, ClusterDataHolder> clusterData) {
+        boolean clusterStat = false;
+        for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
+            Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType());
+            Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId());
+            if (cluster.getStatus() == ClusterStatus.Inactive) {
+                clusterStat = true;
+                return clusterStat;
+            } else {
+                clusterStat = false;
+
+            }
+        }
+        return clusterStat;
+    }
+
+    private boolean getClusterAllInSameState(Map<String, ClusterDataHolder> clusterData,
+                                             ClusterStatus status) {
+        boolean clusterStat = false;
+        for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
+            Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType());
+            Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId());
+            if (cluster.getStatus() == status) {
+                clusterStat = true;
+            } else {
+                clusterStat = false;
+                return clusterStat;
+            }
+        }
+        return clusterStat;
+    }
+
     private GroupStatus getGroupStatus(Map<String, Group> groups) {
         GroupStatus status = null;
         boolean groupActive = true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
deleted file mode 100644
index f04ae02..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application activated is detected.
- */
-public class AppStatusApplicationActivatedEvent extends StatusEvent implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String appId;
-
-    public AppStatusApplicationActivatedEvent(String appId) {
-        this.appId = appId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
deleted file mode 100644
index c432e14..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application created is detected.
- */
-public class AppStatusApplicationCreatedEvent extends StatusEvent implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String appId;
-
-    public AppStatusApplicationCreatedEvent(String appId) {
-        this.appId = appId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
deleted file mode 100644
index f00a97a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application inactivated is detected.
- */
-public class AppStatusApplicationInactivatedEvent extends StatusEvent implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String appId;
-
-    public AppStatusApplicationInactivatedEvent(String appId) {
-        this.appId = appId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
deleted file mode 100644
index 2dafcdc..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * This event will be fired upon the application terminated is detected.
- */
-public class AppStatusApplicationTerminatedEvent extends StatusEvent implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String appId;
-    private Set<ClusterDataHolder> clusterData;
-
-    public AppStatusApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
-        this.appId = appId;
-        this.clusterData = clusterData;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public Set<ClusterDataHolder> getClusterData() {
-        return clusterData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
deleted file mode 100644
index e2a3a09..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application terminating is detected.
- */
-public class AppStatusApplicationTerminatingEvent extends StatusEvent implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String appId;
-
-    public AppStatusApplicationTerminatingEvent(String appId) {
-        this.appId = appId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
deleted file mode 100644
index c5737c6..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusClusterActivatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
deleted file mode 100644
index 6480af2..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusClusterCreatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
deleted file mode 100644
index 6d8ed46..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusClusterInactivateEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
deleted file mode 100644
index 527d86e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This will be fired upon the cluster instability detection by either cep/autoscaler.
- */
-public class AppStatusClusterMaintenanceModeEvent extends StatusEvent implements Serializable {
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
deleted file mode 100644
index 7841d9c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by autoscaler before actually terminate a cluster.
- */
-public class AppStatusClusterReadyToShutdownEvent extends StatusEvent {
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java
deleted file mode 100644
index 919d0ca..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusClusterTerminatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java
deleted file mode 100644
index 7a6baf0..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusClusterTerminatingEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppStatusClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
deleted file mode 100644
index 3da8667..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusGroupActivatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupActivatedEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
deleted file mode 100644
index 04ee30e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusGroupCreatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupCreatedEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
deleted file mode 100644
index ee26292..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusGroupInactivateEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupInactivateEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
deleted file mode 100644
index a1a787c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event will be fired upon the instability of group detection by autoscaler.
- */
-public class AppStatusGroupMaintenanceModeEvent extends StatusEvent {
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupMaintenanceModeEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId(String groupId) {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
deleted file mode 100644
index eaba17d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by autoscaler before actually terminate a group.
- */
-public class AppStatusGroupReadyToShutdownEvent extends StatusEvent {
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupReadyToShutdownEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId(String groupId) {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
deleted file mode 100644
index db31b64..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusGroupTerminatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupTerminatedEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
deleted file mode 100644
index 52db5fb..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppStatusGroupTerminatingEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public AppStatusGroupTerminatingEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java
deleted file mode 100644
index 7ffc449..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-import org.apache.stratos.messaging.event.Event;
-
-import java.io.Serializable;
-
-/**
- * Represents all instance status events.
- */
-public abstract class StatusEvent extends Event implements Serializable {
-    private static final long serialVersionUID = -4790128084271867615L;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
new file mode 100644
index 0000000..688b382
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppClusterActivatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppClusterActivatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
new file mode 100644
index 0000000..3382a34
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppClusterCreatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
new file mode 100644
index 0000000..bf8926e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppClusterInactivateEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppClusterInactivateEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
new file mode 100644
index 0000000..d269d38
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppClusterTerminatedEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
new file mode 100644
index 0000000..547a681
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppClusterTerminatingEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public AppClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
new file mode 100644
index 0000000..6eeb2dc
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupInactivateEvent extends StatusEvent {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public AppStatusGroupInactivateEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
new file mode 100644
index 0000000..7e6a8b4
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application activated is detected.
+ */
+public class ApplicationActivatedEvent extends StatusEvent implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String appId;
+
+    public ApplicationActivatedEvent(String appId) {
+        this.appId = appId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
new file mode 100644
index 0000000..5d220fa
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.applications;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application created is detected.
+ */
+public class ApplicationCreatedEvent extends StatusEvent implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String appId;
+
+    public ApplicationCreatedEvent(String appId) {
+        this.appId = appId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}


[09/50] [abbrv] git commit: moving Application Strucutre related classes to applications package

Posted by im...@apache.org.
moving Application Strucutre related classes to applications package


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

Branch: refs/heads/docker-grouping-merge
Commit: e15343080254dc46756804fffd454bbbd6dacced
Parents: ae257c1
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 12:06:42 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 12:06:42 2014 +0530

----------------------------------------------------------------------
 .../grouping/dependency/DependencyBuilder.java  |   2 +-
 .../grouping/dependency/DependencyTree.java     |   1 -
 .../context/ApplicationContextFactory.java      |   5 +-
 .../grouping/topic/StatusEventPublisher.java    |   1 +
 .../AutoscalerTopologyEventReceiver.java        |   4 +
 .../monitor/ApplicationMonitorFactory.java      |   2 +
 .../monitor/MonitorStatusEventBuilder.java      |   4 +-
 .../monitor/ParentComponentMonitor.java         |   6 +-
 .../monitor/application/ApplicationMonitor.java |   6 +-
 .../monitor/cluster/ClusterMonitor.java         |   4 +-
 .../monitor/events/ApplicationStatusEvent.java  |   2 +-
 .../monitor/events/GroupStatusEvent.java        |   2 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |   7 +-
 .../status/checker/StatusChecker.java           |   1 +
 .../parser/DefaultApplicationParser.java        |   5 +-
 .../application/parser/ParserUtils.java         |   2 +-
 .../impl/CloudControllerServiceImpl.java        |   4 +-
 .../interfaces/ApplicationParser.java           |   2 +-
 .../controller/topology/TopologyBuilder.java    |   1 +
 .../topology/TopologyEventPublisher.java        |   1 +
 .../StratosManagerTopologyEventReceiver.java    |   2 +-
 .../domain/applications/Application.java        | 124 +++++++++++
 .../domain/applications/ApplicationStatus.java  |  74 +++++++
 .../domain/applications/ClusterDataHolder.java  |  51 +++++
 .../domain/applications/DependencyOrder.java    |  52 +++++
 .../messaging/domain/applications/Group.java    | 112 ++++++++++
 .../domain/applications/GroupStatus.java        |  73 +++++++
 .../domain/applications/ParentComponent.java    | 212 +++++++++++++++++++
 .../domain/applications/StartupOrder.java       |  40 ++++
 .../messaging/domain/topology/Application.java  | 123 -----------
 .../domain/topology/ApplicationStatus.java      |  74 -------
 .../domain/topology/ClusterDataHolder.java      |  51 -----
 .../domain/topology/DependencyOrder.java        |  52 -----
 .../messaging/domain/topology/Group.java        | 111 ----------
 .../messaging/domain/topology/GroupStatus.java  |  73 -------
 .../domain/topology/ParentComponent.java        | 212 -------------------
 .../messaging/domain/topology/StartupOrder.java |  40 ----
 .../messaging/domain/topology/Topology.java     |   1 +
 .../AppStatusApplicationTerminatedEvent.java    |   2 +-
 .../event/topology/ApplicationCreatedEvent.java |   2 +-
 .../topology/ApplicationTerminatedEvent.java    |   2 +-
 .../topology/ApplicationUndeployedEvent.java    |   2 +-
 .../ApplicationActivatedMessageProcessor.java   |   4 +-
 .../ApplicationCreatedMessageProcessor.java     |   2 +-
 .../ApplicationInactivatedMessageProcessor.java |   4 +-
 .../ApplicationTerminatedMessageProcessor.java  |   2 +-
 .../ApplicationTerminatingMessageProcessor.java |   4 +-
 .../ApplicationUndeployedMessageProcessor.java  |   3 +
 .../CompleteTopologyMessageProcessor.java       |   1 +
 .../topology/GroupActivatedProcessor.java       |   3 +
 .../topology/GroupCreatedProcessor.java         |   8 +-
 .../topology/GroupInActivateProcessor.java      |   7 +-
 .../topology/GroupTerminatedProcessor.java      |   6 +-
 .../topology/GroupTerminatingProcessor.java     |   6 +-
 .../topology/locking/TopologyLockingTest.java   |   2 +
 .../bean/util/converter/PojoConverter.java      |   4 +-
 .../rest/endpoint/services/ServiceUtils.java    |   3 +
 57 files changed, 811 insertions(+), 795 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
index 4e67848..bf1233f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
@@ -24,7 +24,7 @@ import org.apache.stratos.autoscaler.*;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory;
-import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.applications.*;
 
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
index 1ec686b..05769a6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
@@ -21,7 +21,6 @@ package org.apache.stratos.autoscaler.grouping.dependency;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.messaging.domain.topology.Application;
 
 import java.util.ArrayList;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
index 631e5d4..3ea4cd5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
@@ -22,9 +22,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.Constants;
 import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.ParentComponent;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ParentComponent;
 
 /**
  * Factory to create new GroupContext or ClusterContext

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 9b39a52..eb6e084 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -4,6 +4,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.broker.publish.EventPublisher;
 import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.application.status.*;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index 54a1461..fe4d9df 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -37,6 +37,10 @@ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.topology.*;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index 2ead896..debcf93 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -44,6 +44,8 @@ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 import org.apache.stratos.cloud.controller.stub.pojo.Property;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
index 59bb4c0..dac53b4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
@@ -24,9 +24,9 @@ import org.apache.stratos.autoscaler.monitor.events.ApplicationStatusEvent;
 import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent;
 import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 
 /**
  * This will build the necessary monitor status events to be sent to the parent/child  monitor

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 91d5275..c304027 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -28,12 +28,8 @@ import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder;
 import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
 import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
-import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.ParentComponent;
+import org.apache.stratos.messaging.domain.applications.ParentComponent;
 
 import java.util.HashMap;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
index 4632361..dbcbabb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
@@ -31,10 +31,10 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
 
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 988f266..22b5e48 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -33,9 +33,9 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 import org.apache.stratos.cloud.controller.stub.pojo.Property;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 
 import java.util.ArrayList;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java
index d92de77..83c764d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java
@@ -18,7 +18,7 @@
  */
 package org.apache.stratos.autoscaler.monitor.events;
 
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 
 /**
  * This will use to notify observers upon a application activation events received in Topology.

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java
index 7956914..7f21761 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java
@@ -18,7 +18,7 @@
  */
 package org.apache.stratos.autoscaler.monitor.events;
 
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 
 /**
  * This will use to notify observers upon a group activation events received in Topology.

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/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 3623de9..d48c7ae 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
@@ -24,7 +24,6 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
 import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.EventHandler;
-import org.apache.stratos.autoscaler.monitor.Monitor;
 import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
 import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
 import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent;
@@ -32,10 +31,10 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
 
 /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index a742b89..392a0d5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -26,6 +26,7 @@ import org.apache.stratos.autoscaler.PartitionContext;
 import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
+import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
index 06f749a..000a06a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
@@ -33,7 +33,10 @@ import org.apache.stratos.cloud.controller.pojo.Cartridge;
 import org.apache.stratos.cloud.controller.pojo.application.*;
 import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.DependencyOrder;
+import org.apache.stratos.messaging.domain.applications.Group;
 
 import java.util.*;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
index 23b0bab..e6cdda0 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
@@ -22,7 +22,7 @@ package org.apache.stratos.cloud.controller.application.parser;
 import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
 import org.apache.stratos.cloud.controller.pojo.application.GroupContext;
 import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext;
-import org.apache.stratos.messaging.domain.topology.StartupOrder;
+import org.apache.stratos.messaging.domain.applications.StartupOrder;
 
 import java.util.*;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 6e003b1..0c27316 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -39,12 +39,10 @@ import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublis
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
-import org.apache.stratos.cloud.controller.topology.TopologyManager;
 import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.MemberStatus;
 import org.apache.stratos.messaging.util.Constants;
 import org.jclouds.compute.ComputeService;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
index 7bd471d..33e98f9 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java
@@ -22,7 +22,7 @@ package org.apache.stratos.cloud.controller.interfaces;
 import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
 import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext;
 import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
-import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.applications.Application;
 
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/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 2cf4905..e31cf32 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
@@ -29,6 +29,7 @@ import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublis
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.application.status.*;
 import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index c9337d2..f96ba8e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -26,6 +26,7 @@ import org.apache.stratos.cloud.controller.pojo.PortMapping;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.messaging.broker.publish.EventPublisher;
 import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
index d4e90cc..d6cc395 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
@@ -26,7 +26,7 @@ import org.apache.stratos.manager.exception.ApplicationSubscriptionException;
 import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
 import org.apache.stratos.manager.subscription.ApplicationSubscription;
 import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
-import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.event.Event;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
new file mode 100644
index 0000000..e33de39
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
+
+import java.util.*;
+
+/**
+ * Represents an Application in the Topology
+ */
+
+public class Application extends ParentComponent implements LifeCycleStateTransitionBehavior<ApplicationStatus> {
+
+    private static final long serialVersionUID = -5092959597171649688L;
+    // Unique id for the Application, defined in Application Definition
+    private String id;
+    // Key used for authentication (with metadata service, etc.)
+    private String key;
+    // tenant id
+    private int tenantId;
+    // tenant domain
+    private String tenantDomain;
+    // tenant admin user
+    private String tenantAdminUserName;
+    // Life cycle state manager
+    protected LifeCycleStateManager<ApplicationStatus> applicationStateManager;
+
+    public Application (String id) {
+        super();
+        this.id = id;
+        this.key = RandomStringUtils.randomAlphanumeric(16);
+        this.applicationStateManager =
+                new LifeCycleStateManager<ApplicationStatus>(ApplicationStatus.Created, id);
+    }
+
+    public String getUniqueIdentifier() {
+        return id;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getTenantDomain() {
+        return tenantDomain;
+    }
+
+    public void setTenantDomain(String tenantDomain) {
+        this.tenantDomain = tenantDomain;
+    }
+
+    public String getTenantAdminUserName() {
+        return tenantAdminUserName;
+    }
+
+    public void setTenantAdminUserName(String tenantAdminUserName) {
+        this.tenantAdminUserName = tenantAdminUserName;
+    }
+
+    @Override
+    public boolean isStateTransitionValid(ApplicationStatus newState) {
+        return this.applicationStateManager.isStateTransitionValid(newState);
+    }
+
+    @Override
+    public Stack<ApplicationStatus> getTransitionedStates() {
+        return this.applicationStateManager.getStateStack();
+    }
+
+    @Override
+    public ApplicationStatus getStatus() {
+        return this.applicationStateManager.getCurrentState();
+    }
+
+    @Override
+    public void setStatus(ApplicationStatus newState) {
+        this.applicationStateManager.changeState(newState);
+    }
+
+    public boolean equals(Object other) {
+        if(other == null || !(other instanceof Application)) {
+            return false;
+        }
+
+        if(this == other) {
+            return true;
+        }
+
+        Application that = (Application)other;
+        return this.id.equals(that.id);
+    }
+
+    public int hashCode () {
+        return id.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java
new file mode 100644
index 0000000..38ac01c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public enum ApplicationStatus implements LifeCycleState {
+
+    Created (0) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Created,
+                    ApplicationStatus.Active, ApplicationStatus.Terminating));
+        }
+    },
+    Active (1) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Active,
+                    ApplicationStatus.Terminating, ApplicationStatus.Inactive));
+        }
+    },
+    Inactive (2) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Inactive, ApplicationStatus.Active,
+                    ApplicationStatus.Terminating));
+        }
+    },
+    Terminating (3) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Terminating,
+                    ApplicationStatus.Terminated));
+        }
+    },
+    Terminated (4) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Terminated));
+        }
+    };
+
+    private int code;
+
+    private ApplicationStatus (int code) {
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
new file mode 100644
index 0000000..6a7e421
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import java.io.Serializable;
+
+/**
+ * Data Holder for a Cluster.
+ * Will hold the Service Type and Cluster Id.
+ */
+
+public class ClusterDataHolder implements Serializable {
+
+    // Service/Cartridge type
+    private String serviceType;
+
+    // Cluster id
+    private String clusterId;
+
+    public ClusterDataHolder (String serviceType, String clusterId) {
+
+        this.serviceType = serviceType;
+        this.clusterId = clusterId;
+    }
+
+
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java
new file mode 100644
index 0000000..9ece450
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import java.io.Serializable;
+import java.util.Set;
+
+public class DependencyOrder implements Serializable {
+
+	private static final long serialVersionUID = -599600831844477527L;
+
+	private Set<StartupOrder> startupOrders;
+
+    private String terminationBehaviour;
+
+    public DependencyOrder () {
+
+    }
+
+    public String getTerminationBehaviour() {
+        return terminationBehaviour;
+    }
+
+    public void setTerminationBehaviour(String terminationBehaviour) {
+        this.terminationBehaviour = terminationBehaviour;
+    }
+
+	public Set<StartupOrder> getStartupOrders() {
+		return startupOrders;
+	}
+
+	public void setStartupOrders(Set<StartupOrder> startupOrders) {
+		this.startupOrders = startupOrders;
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
new file mode 100644
index 0000000..1f4d323
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
+
+import java.util.Stack;
+
+/**
+ * Represents a Group/nested Group in an Application/Group
+ */
+
+public class Group extends ParentComponent implements LifeCycleStateTransitionBehavior<GroupStatus> {
+
+    private static final long serialVersionUID = 8347096598203655846L;
+    // Name of the Group, specified in Group Definition
+    private String name;
+    // Group alias
+    private String alias;
+    // Group deployment policy
+    private String deploymentPolicy;
+    // Group level autoscaling policy
+    private String autoscalingPolicy;
+    // Life cycle state manager
+    protected LifeCycleStateManager<GroupStatus> groupStateManager;
+
+    public Group (String name, String alias) {
+        super();
+        this.name = name;
+        this.alias = alias;
+        this.groupStateManager = new LifeCycleStateManager<GroupStatus>(GroupStatus.Created, alias);
+    }
+
+    public String getUniqueIdentifier() {
+        return alias;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public String getDeploymentPolicy() {
+        return deploymentPolicy;
+    }
+
+    public void setDeploymentPolicy(String deploymentPolicy) {
+        this.deploymentPolicy = deploymentPolicy;
+    }
+
+    public String getAutoscalingPolicy() {
+        return autoscalingPolicy;
+    }
+
+    public void setAutoscalingPolicy(String autoscalingPolicy) {
+        this.autoscalingPolicy = autoscalingPolicy;
+    }
+
+    @Override
+    public boolean isStateTransitionValid(GroupStatus newState) {
+        return groupStateManager.isStateTransitionValid(newState);
+    }
+
+    @Override
+    public Stack<GroupStatus> getTransitionedStates() {
+        return groupStateManager.getStateStack();
+    }
+
+    @Override
+    public GroupStatus getStatus() {
+        return groupStateManager.getCurrentState();
+    }
+
+    @Override
+    public void setStatus(GroupStatus newState) {
+        this.groupStateManager.changeState(newState);
+    }
+
+    public boolean equals(Object other) {
+        if(other == null || !(other instanceof Group)) {
+            return false;
+        }
+
+        if(this == other) {
+            return true;
+        }
+
+        Group that = (Group)other;
+        return this.name.equals(that.name) && this.alias.equals(that.alias);
+    }
+
+    public int hashCode () {
+        return name.hashCode() + alias.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java
new file mode 100644
index 0000000..0079476
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.domain.applications;
+
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public enum GroupStatus implements LifeCycleState {
+
+    Created(0) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Created,
+                    GroupStatus.Active, GroupStatus.Terminating));
+        }
+    },
+    Active(1) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Active,
+                    GroupStatus.Inactive, GroupStatus.Terminating));
+        }
+    },
+    Inactive(2) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Inactive, GroupStatus.Terminating));
+        }
+    },
+    Terminating(3) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Terminating,
+                    GroupStatus.Terminated, GroupStatus.Created));
+        }
+    },
+    Terminated(4) {
+        @Override
+        public Set<LifeCycleState> getNextStates() {
+            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Terminated));
+        }
+    };
+
+    private int code;
+
+    private GroupStatus(int code) {
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
new file mode 100644
index 0000000..3c2814f
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Abstraction for a an entity that can have child entities
+ * in an Application withing the Topology
+ */
+
+public abstract class ParentComponent implements Serializable {
+
+    // Dependency Order
+    private DependencyOrder dependencyOrder;
+    // Group Map, key = Group.alias
+    private Map<String, Group> aliasToGroupMap;
+    // Cluster Id map, key = subscription alias for the cartridge type
+    private Map<String, ClusterDataHolder> aliasToClusterDataMap;
+    // Application status
+
+    public ParentComponent () {
+        aliasToGroupMap = new HashMap<String, Group>();
+        aliasToClusterDataMap = new HashMap<String, ClusterDataHolder>();
+    }
+
+    /**
+     * This method should be implemented in each concrete child class
+     * to return the unique identifier for each implementation
+     * ex.: group alias for a Group, app id for an Application
+     *
+     * @return unique identifier String
+     */
+    public abstract String getUniqueIdentifier ();
+
+    /**
+     * Adds a group
+     *
+     * @param group Group instance to be added
+     */
+    public void addGroup(Group group) {
+        aliasToGroupMap.put(group.getUniqueIdentifier(), group);
+    }
+
+    /**
+     * Setter for Group alias to Group map
+     *
+     * @param groupAliasToGroup Map, key = alias given to the Group, value = Group
+     */
+    public void setGroups(Map<String, Group> groupAliasToGroup) {
+        aliasToGroupMap.putAll(groupAliasToGroup);
+    }
+
+    /**
+     * Get the Group for the given alias in the context of the parent entity.
+     * Will not search recursively in the nested levels.
+     *
+     * @param groupAlias alias of the Group
+     * @return Group, if exists for the given alias, else null
+     */
+    public Group getGroup(String groupAlias) {
+        return aliasToGroupMap.get(groupAlias);
+    }
+
+    /**
+     * Get the Group for the given alias in the context of the parent entity.
+     * Will search recursively in the nested levels.
+     *
+     * @param groupAlias alias of the Group
+     * @return Group, if exists for the given alias, else null
+     */
+    public Group getGroupRecursively(String groupAlias) {
+
+        return travereAndCheckRecursively(aliasToGroupMap, groupAlias);
+    }
+
+    private Group travereAndCheckRecursively (Map<String,Group> aliasToGroupMap, String groupAlias) {
+
+        if (aliasToGroupMap.containsKey(groupAlias)) {
+            synchronized (aliasToGroupMap) {
+                if (aliasToGroupMap.containsKey(groupAlias)) {
+                    return aliasToGroupMap.get(groupAlias);
+                }
+            }
+        } else {
+            for (Group group : aliasToGroupMap.values()) {
+                return travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Getter for alias to Group map
+     * Will not search recursively in the nested levels.
+     *
+     * @return Map, key = alias given to the Group, value = Group
+     */
+    public Map<String, Group> getAliasToGroupMap() {
+        return this.aliasToGroupMap;
+    }
+
+    /**
+     * Getter for cluster alias to ClusterData map for this level
+     *
+     * @return Map, key = alias given to the cluster, value =  ClusterData object
+     */
+    public Map<String, ClusterDataHolder> getClusterDataMap() {
+        return this.aliasToClusterDataMap;
+    }
+
+    /**
+     * Collection of Groups in this level
+     *
+     * @return Group Collection object, empty if no Groups are found
+     */
+    public Collection<Group> getGroups() {
+        return aliasToGroupMap.values();
+    }
+
+    /**
+     * Setter for Dependency Order
+     *
+     * @param dependencyOrder Dependency Order object
+     */
+    public void setDependencyOrder(DependencyOrder dependencyOrder) {
+        this.dependencyOrder = dependencyOrder;
+    }
+
+    /**
+     * Getter for Dependency Order for this level
+     *
+     * @return Dependency Order object
+     */
+    public DependencyOrder getDependencyOrder() {
+        return dependencyOrder;
+    }
+
+    /**
+     * Setter for alias to Cluster Data map
+     *
+     * @param aliasToClusterData Map, key = alias given to the cluster, value =  ClusterData object
+     */
+    public void setClusterData(Map<String, ClusterDataHolder> aliasToClusterData) {
+        this.aliasToClusterDataMap.putAll(aliasToClusterData);
+    }
+
+    /**
+     * Getter for Cluster Data instance for the given alias
+     * Will not search recursively in the nested levels.
+     *
+     * @param alias
+     * @return
+     */
+    public ClusterDataHolder getClusterData(String alias) {
+        return aliasToClusterDataMap.get(alias);
+    }
+
+    /**
+     * Collects the Cluster Data for the parent component and all the
+     * child components recursively
+     *
+     * @return Set of ClusterDataHolder objects if available, else null
+     */
+    public Set<ClusterDataHolder> getClusterDataRecursively () {
+
+        Set<ClusterDataHolder> appClusterData = new HashSet<ClusterDataHolder>();
+
+        // get top level Cluster Data
+        if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) {
+            appClusterData.addAll(this.aliasToClusterDataMap.values());
+        }
+
+        // find other nested Cluster Data (in the Groups)
+        if (getGroups() != null) {
+            getClusterData(appClusterData, getGroups());
+        }
+
+        return appClusterData;
+    }
+
+    private void getClusterData (Set<ClusterDataHolder> clusterData, Collection<Group> groups) {
+
+        for (Group group : groups) {
+            if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) {
+                clusterData.addAll(group.getClusterDataMap().values());
+                if (group.getGroups() != null) {
+                    getClusterData(clusterData, group.getGroups());
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java
new file mode 100644
index 0000000..83d583e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.domain.applications;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class StartupOrder implements Serializable {
+
+    private List<String> startList;
+
+    public StartupOrder (List<String> startList) {
+        this.startList = startList;
+    }
+
+    public List<String> getStartList() {
+        return startList;
+    }
+
+    public void setStartList(List<String> startList) {
+        this.startList = startList;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java
deleted file mode 100644
index 0e4438b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
-
-import java.util.*;
-
-/**
- * Represents an Application in the Topology
- */
-
-public class Application extends ParentComponent implements LifeCycleStateTransitionBehavior<ApplicationStatus> {
-
-    private static final long serialVersionUID = -5092959597171649688L;
-    // Unique id for the Application, defined in Application Definition
-    private String id;
-    // Key used for authentication (with metadata service, etc.)
-    private String key;
-    // tenant id
-    private int tenantId;
-    // tenant domain
-    private String tenantDomain;
-    // tenant admin user
-    private String tenantAdminUserName;
-    // Life cycle state manager
-    protected LifeCycleStateManager<ApplicationStatus> applicationStateManager;
-
-    public Application (String id) {
-        super();
-        this.id = id;
-        this.key = RandomStringUtils.randomAlphanumeric(16);
-        this.applicationStateManager =
-                new LifeCycleStateManager<ApplicationStatus>(ApplicationStatus.Created, id);
-    }
-
-    public String getUniqueIdentifier() {
-        return id;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getTenantDomain() {
-        return tenantDomain;
-    }
-
-    public void setTenantDomain(String tenantDomain) {
-        this.tenantDomain = tenantDomain;
-    }
-
-    public String getTenantAdminUserName() {
-        return tenantAdminUserName;
-    }
-
-    public void setTenantAdminUserName(String tenantAdminUserName) {
-        this.tenantAdminUserName = tenantAdminUserName;
-    }
-
-    @Override
-    public boolean isStateTransitionValid(ApplicationStatus newState) {
-        return this.applicationStateManager.isStateTransitionValid(newState);
-    }
-
-    @Override
-    public Stack<ApplicationStatus> getTransitionedStates() {
-        return this.applicationStateManager.getStateStack();
-    }
-
-    @Override
-    public ApplicationStatus getStatus() {
-        return this.applicationStateManager.getCurrentState();
-    }
-
-    @Override
-    public void setStatus(ApplicationStatus newState) {
-        this.applicationStateManager.changeState(newState);
-    }
-
-    public boolean equals(Object other) {
-        if(other == null || !(other instanceof Application)) {
-            return false;
-        }
-
-        if(this == other) {
-            return true;
-        }
-
-        Application that = (Application)other;
-        return this.id.equals(that.id);
-    }
-
-    public int hashCode () {
-        return id.hashCode();
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java
deleted file mode 100644
index 2173f86..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public enum ApplicationStatus implements LifeCycleState {
-
-    Created (0) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Created,
-                    ApplicationStatus.Active, ApplicationStatus.Terminating));
-        }
-    },
-    Active (1) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Active,
-                    ApplicationStatus.Terminating, ApplicationStatus.Inactive));
-        }
-    },
-    Inactive (2) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Inactive, ApplicationStatus.Active,
-                    ApplicationStatus.Terminating));
-        }
-    },
-    Terminating (3) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Terminating,
-                    ApplicationStatus.Terminated));
-        }
-    },
-    Terminated (4) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(ApplicationStatus.Terminated));
-        }
-    };
-
-    private int code;
-
-    private ApplicationStatus (int code) {
-        this.code = code;
-    }
-
-    public int getCode() {
-        return code;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java
deleted file mode 100644
index 70eab4c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import java.io.Serializable;
-
-/**
- * Data Holder for a Cluster.
- * Will hold the Service Type and Cluster Id.
- */
-
-public class ClusterDataHolder implements Serializable {
-
-    // Service/Cartridge type
-    private String serviceType;
-
-    // Cluster id
-    private String clusterId;
-
-    public ClusterDataHolder (String serviceType, String clusterId) {
-
-        this.serviceType = serviceType;
-        this.clusterId = clusterId;
-    }
-
-
-    public String getServiceType() {
-        return serviceType;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java
deleted file mode 100644
index bdba59c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import java.io.Serializable;
-import java.util.Set;
-
-public class DependencyOrder implements Serializable {
-
-	private static final long serialVersionUID = -599600831844477527L;
-
-	private Set<StartupOrder> startupOrders;
-
-    private String terminationBehaviour;
-
-    public DependencyOrder () {
-
-    }
-
-    public String getTerminationBehaviour() {
-        return terminationBehaviour;
-    }
-
-    public void setTerminationBehaviour(String terminationBehaviour) {
-        this.terminationBehaviour = terminationBehaviour;
-    }
-
-	public Set<StartupOrder> getStartupOrders() {
-		return startupOrders;
-	}
-
-	public void setStartupOrders(Set<StartupOrder> startupOrders) {
-		this.startupOrders = startupOrders;
-	}
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
deleted file mode 100644
index 79ce4bc..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
-
-import java.util.Stack;
-
-/**
- * Represents a Group/nested Group in an Application/Group
- */
-
-public class Group extends ParentComponent implements LifeCycleStateTransitionBehavior<GroupStatus> {
-
-    private static final long serialVersionUID = 8347096598203655846L;
-    // Name of the Group, specified in Group Definition
-    private String name;
-    // Group alias
-    private String alias;
-    // Group deployment policy
-    private String deploymentPolicy;
-    // Group level autoscaling policy
-    private String autoscalingPolicy;
-    // Life cycle state manager
-    protected LifeCycleStateManager<GroupStatus> groupStateManager;
-
-    public Group (String name, String alias) {
-        super();
-        this.name = name;
-        this.alias = alias;
-        this.groupStateManager = new LifeCycleStateManager<GroupStatus>(GroupStatus.Created, alias);
-    }
-
-    public String getUniqueIdentifier() {
-        return alias;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public String getDeploymentPolicy() {
-        return deploymentPolicy;
-    }
-
-    public void setDeploymentPolicy(String deploymentPolicy) {
-        this.deploymentPolicy = deploymentPolicy;
-    }
-
-    public String getAutoscalingPolicy() {
-        return autoscalingPolicy;
-    }
-
-    public void setAutoscalingPolicy(String autoscalingPolicy) {
-        this.autoscalingPolicy = autoscalingPolicy;
-    }
-
-    @Override
-    public boolean isStateTransitionValid(GroupStatus newState) {
-        return groupStateManager.isStateTransitionValid(newState);
-    }
-
-    @Override
-    public Stack<GroupStatus> getTransitionedStates() {
-        return groupStateManager.getStateStack();
-    }
-
-    @Override
-    public GroupStatus getStatus() {
-        return groupStateManager.getCurrentState();
-    }
-
-    @Override
-    public void setStatus(GroupStatus newState) {
-        this.groupStateManager.changeState(newState);
-    }
-
-    public boolean equals(Object other) {
-        if(other == null || !(other instanceof Group)) {
-            return false;
-        }
-
-        if(this == other) {
-            return true;
-        }
-
-        Group that = (Group)other;
-        return this.name.equals(that.name) && this.alias.equals(that.alias);
-    }
-
-    public int hashCode () {
-        return name.hashCode() + alias.hashCode();
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java
deleted file mode 100644
index fbbaebc..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.domain.topology;
-
-import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public enum GroupStatus implements LifeCycleState {
-
-    Created(0) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Created,
-                    GroupStatus.Active, GroupStatus.Terminating));
-        }
-    },
-    Active(1) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Active,
-                    GroupStatus.Inactive, GroupStatus.Terminating));
-        }
-    },
-    Inactive(2) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Inactive, GroupStatus.Terminating));
-        }
-    },
-    Terminating(3) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Terminating,
-                    GroupStatus.Terminated, GroupStatus.Created));
-        }
-    },
-    Terminated(4) {
-        @Override
-        public Set<LifeCycleState> getNextStates() {
-            return new HashSet<LifeCycleState>(Arrays.asList(GroupStatus.Terminated));
-        }
-    };
-
-    private int code;
-
-    private GroupStatus(int code) {
-        this.code = code;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-}


[26/50] [abbrv] git commit: adding application builder

Posted by im...@apache.org.
adding application builder


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

Branch: refs/heads/docker-grouping-merge
Commit: 686d0e063be8926447a7eef7e636622c2be55863
Parents: 4de85b5
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 15:55:14 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 15:55:14 2014 +0530

----------------------------------------------------------------------
 .../dependency/DependencyBuilder.java           | 156 ++++++
 .../applications/dependency/DependencyTree.java | 290 +++++++++++
 .../dependency/context/ApplicationContext.java  | 113 +++++
 .../context/ApplicationContextFactory.java      | 101 ++++
 .../dependency/context/ClusterContext.java      |  38 ++
 .../dependency/context/GroupContext.java        |  25 +
 .../applications/topic/ApplicationBuilder.java  | 478 +++++++++++++++++++
 .../topic/ApplicationsEventPublisher.java       | 236 +++++++++
 .../grouping/dependency/DependencyBuilder.java  | 156 ------
 .../grouping/dependency/DependencyTree.java     | 290 -----------
 .../dependency/context/ApplicationContext.java  | 113 -----
 .../context/ApplicationContextFactory.java      | 101 ----
 .../dependency/context/ClusterContext.java      |  38 --
 .../dependency/context/GroupContext.java        |  25 -
 .../topic/ApplicationsEventPublisher.java       | 238 ---------
 .../AutoscalerTopologyEventReceiver.java        |   4 +-
 .../monitor/ApplicationMonitorFactory.java      |   6 +-
 .../monitor/ParentComponentMonitor.java         |   8 +-
 .../monitor/cluster/ClusterMonitor.java         |   1 -
 .../autoscaler/monitor/group/GroupMonitor.java  |   5 +-
 .../status/checker/StatusChecker.java           |  78 ++-
 .../impl/CloudControllerServiceImpl.java        |   6 +-
 .../controller/topology/TopologyBuilder.java    | 421 +---------------
 23 files changed, 1502 insertions(+), 1425 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
new file mode 100644
index 0000000..48c22fd
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.*;
+import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContextFactory;
+import org.apache.stratos.messaging.domain.applications.*;
+
+import java.util.Set;
+
+/**
+ * This is to build the startup/termination dependencies
+ * across immediate children according to the start order defined.
+ */
+public class DependencyBuilder {
+    private static final Log log = LogFactory.getLog(DependencyBuilder.class);
+
+    private DependencyBuilder() {
+
+    }
+
+    private static class Holder {
+        private static final DependencyBuilder INSTANCE = new DependencyBuilder();
+    }
+
+    public static DependencyBuilder getInstance() {
+        return Holder.INSTANCE;
+    }
+
+    /**
+     * This will build the dependency tree based on the given dependency order
+     * @param component it will give the necessary information to build the tree
+     * @return the dependency tree out of the dependency orders
+     */
+    public DependencyTree buildDependency(ParentComponent component) throws DependencyBuilderException{
+
+        String identifier = component.getUniqueIdentifier();
+        DependencyTree dependencyTree = new DependencyTree(identifier);
+        DependencyOrder dependencyOrder = component.getDependencyOrder();
+
+        if (dependencyOrder != null) {
+            log.info("Building dependency for the Application/Group " + identifier);
+
+            //Parsing the kill behaviour
+            String terminationBehaviour = dependencyOrder.getTerminationBehaviour();
+
+            if (Constants.TERMINATE_NONE.equals(terminationBehaviour)) {
+                dependencyTree.setKillNone(true);
+            } else if (Constants.TERMINATE_ALL.equals(terminationBehaviour)) {
+                dependencyTree.setKillAll(true);
+            } else if (Constants.TERMINATE_DEPENDENTS.equals(terminationBehaviour)) {
+                dependencyTree.setKillDependent(true);
+            }
+
+            log.info("Setting the [terminationBehaviour] " + terminationBehaviour + " to the " +
+                        "[dependency-tree] " + dependencyTree.getId());
+
+
+            //Parsing the start up order
+            Set<StartupOrder> startupOrders = dependencyOrder.getStartupOrders();
+            ApplicationContext foundContext;
+            ApplicationContext parentContext;
+
+            if (startupOrders != null) {
+                for (StartupOrder startupOrder : startupOrders) {
+                    foundContext = null;
+                    parentContext = null;
+                    for (String start : startupOrder.getStartList()) {
+
+                        if (start != null) {
+                            ApplicationContext applicationContext = ApplicationContextFactory.
+                                    getApplicationContext(start, component, dependencyTree);
+                            String id = applicationContext.getId();
+
+                            ApplicationContext existingApplicationContext =
+                                    dependencyTree.findApplicationContextWithId(id);
+                            if (existingApplicationContext == null) {
+                                if (parentContext != null) {
+                                    //appending the start up order to already added parent group/cluster
+                                    parentContext.addApplicationContext(applicationContext);
+                                    parentContext = applicationContext;
+                                    if (log.isDebugEnabled()) {
+                                        log.debug("Found an existing [dependency] " + parentContext.getId() +
+                                                " and adding the [dependency] " + id + " as the child");
+                                    }
+                                } else {
+                                    //adding list of startup order to the dependency tree
+                                    dependencyTree.addApplicationContext(applicationContext);
+                                    parentContext = applicationContext;
+                                }
+                            } else {
+                                if (foundContext == null) {
+                                    //if existing context found, add it to child of existing context and
+                                    //set the existing context as the next parent
+                                    existingApplicationContext.addApplicationContext(applicationContext);
+                                    parentContext = existingApplicationContext;
+                                    if (log.isDebugEnabled()) {
+                                        log.debug("Found an existing [dependency] " + id + " and setting it " +
+                                                "for the next dependency to follow");
+                                    }
+                                } else {
+                                    String msg = "Startup order is not consistent. It contains the group/cluster " +
+                                            "which has been used more than one in another startup order";
+                                    throw new DependencyBuilderException(msg);
+                                }
+
+                            }
+                        }
+                    }
+
+                }
+            }
+            //TODO need to parser the scalable dependencies
+        }
+
+
+        //adding the rest of the children who are independent to the top level
+        // as they can start in parallel.
+        for (Group group1 : component.getAliasToGroupMap().values()) {
+            if (dependencyTree.findApplicationContextWithId(group1.getAlias()) == null) {
+                ApplicationContext context = ApplicationContextFactory.
+                        getGroupContext(group1.getAlias(), dependencyTree.isKillDependent());
+                dependencyTree.addApplicationContext(context);
+            }
+        }
+        for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) {
+            if (dependencyTree.findApplicationContextWithId(dataHolder.getClusterId()) == null) {
+                ApplicationContext context = ApplicationContextFactory.getClusterContext(dataHolder,
+                                                                dependencyTree.isKillDependent());
+                dependencyTree.addApplicationContext(context);
+
+            }
+        }
+        return dependencyTree;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
new file mode 100644
index 0000000..0cb9aa4
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This is to contain the dependency tree of an application/group
+ */
+public class DependencyTree {
+    private static final Log log = LogFactory.getLog(DependencyTree.class);
+
+    private List<ApplicationContext> applicationContextList;
+
+    private boolean started;
+
+    private boolean terminated;
+
+    private boolean killAll;
+
+    private boolean killNone;
+
+    private boolean killDependent;
+
+    private boolean startupOder;
+
+    private boolean reverseStartupOrder;
+
+    private String id;
+
+    public DependencyTree(String id) {
+        applicationContextList = new ArrayList<ApplicationContext>();
+        this.setId(id);
+        if (log.isDebugEnabled()) {
+            log.debug("Starting a dependency tree for the [group/application] " + id);
+        }
+    }
+
+    public List<ApplicationContext> getApplicationContextList() {
+        return applicationContextList;
+    }
+
+    public void setApplicationContextList(List<ApplicationContext> applicationContextList) {
+        this.applicationContextList = applicationContextList;
+    }
+
+    public void addApplicationContext(ApplicationContext applicationContext) {
+        applicationContextList.add(applicationContext);
+
+    }
+
+    /**
+     * Find an ApplicationContext from dependency tree with the given id
+     *
+     * @param id the alias/id of group/cluster
+     * @return ApplicationContext of the given id
+     */
+    public ApplicationContext findApplicationContextWithId(String id) {
+        return findApplicationContextWithId(id, applicationContextList);
+    }
+
+    /**
+     * Find the ApplicationContext using Breadth first search.
+     *
+     * @param id       the alias/id of group/cluster
+     * @param contexts the list of contexts in the same level of the tree
+     * @return ApplicationContext of the given id
+     */
+    private ApplicationContext findApplicationContextWithId(String id, List<ApplicationContext> contexts) {
+        for (ApplicationContext context : contexts) {
+            //TODO check for the status
+            if (context.getId().equals(id)) {
+                return context;
+            }
+        }
+        //if not found in the top level search recursively
+        for (ApplicationContext context : contexts) {
+            return findApplicationContextWithId(id, context.getApplicationContextList());
+        }
+        return null;
+    }
+
+    public ApplicationContext findParentContextWithId(String id) {
+        return findParentContextWithId(null, id, this.applicationContextList);
+    }
+
+    public List<ApplicationContext> findAllParentContextWithId(String id) {
+        List<ApplicationContext> applicationContexts = new ArrayList<ApplicationContext>();
+        return findAllParent(applicationContexts, id);
+    }
+
+    private List<ApplicationContext> findAllParent(List<ApplicationContext> parentContexts, String id) {
+        ApplicationContext context = findParentContextWithId(null, id, this.applicationContextList);
+        if (context != null) {
+            parentContexts.add(context);
+            findAllParent(parentContexts, context.getId());
+        }
+        return parentContexts;
+    }
+
+
+    private ApplicationContext findParentContextWithId(ApplicationContext parent, String id,
+                                                       List<ApplicationContext> contexts) {
+        for (ApplicationContext context : contexts) {
+            //TODO check for the status
+            if (context.getId().equals(id)) {
+                return parent;
+            }
+        }
+        //if not found in the top level search recursively
+        for (ApplicationContext context : this.applicationContextList) {
+            return findParentContextWithId(context, id, context.getApplicationContextList());
+        }
+        return null;
+    }
+
+    /**
+     * Getting the next start able dependencies upon the activate event
+     * received for a group/cluster which is part of this tree.
+     *
+     * @param id the alias/id of group/cluster which received the activated event.
+     * @return list of dependencies
+     */
+    public List<ApplicationContext> getStarAbleDependencies(String id) {
+        //finding the application context which received the activated event and
+        // returning it's immediate children as the dependencies.
+        ApplicationContext context = findApplicationContextWithId(id);
+        return context.getApplicationContextList();
+    }
+
+    /**
+     * Getting the next start able dependencies upon the monitor initialization.
+     *
+     * @return list of dependencies
+     */
+    public List<ApplicationContext> getStarAbleDependencies() {
+        //returning the top level as the monitor is in initializing state
+        return this.applicationContextList;
+    }
+
+    public List<ApplicationContext> getStarAbleDependenciesByTermination() {
+        //Breadth First search over the graph to find out which level has the terminated contexts
+        return traverseGraphByLevel(this.applicationContextList);
+    }
+
+
+    private List<ApplicationContext> traverseGraphByLevel(List<ApplicationContext> contexts) {
+        for(ApplicationContext context : contexts) {
+            if(context.isTerminated()) {
+                return contexts;
+            }
+        }
+
+        for(ApplicationContext context : contexts) {
+            return traverseGraphByLevel(context.getApplicationContextList());
+        }
+        return null;
+    }
+
+
+
+    /**
+     * When one group/cluster terminates/in_maintenance, need to consider about other
+     * dependencies
+     *
+     * @param id the alias/id of group/cluster in which terminated event received
+     * @return all the kill able children dependencies
+     */
+    public List<ApplicationContext> getTerminationDependencies(String id) {
+        List<ApplicationContext> allChildrenOfAppContext = new ArrayList<ApplicationContext>();
+        ApplicationContext applicationContext = findApplicationContextWithId(id);
+
+        if (this.killDependent) {
+            //finding the ApplicationContext of the given id
+            //finding all the children of the found application context
+            allChildrenOfAppContext.add(applicationContext);
+            findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
+                    allChildrenOfAppContext);
+            return allChildrenOfAppContext;
+        } else if (this.killAll) {
+            //killall will be killed by the monitor from it's list.
+            findAllChildrenOfAppContext(this.applicationContextList,
+                    allChildrenOfAppContext);
+
+        }
+        //return empty for the kill-none case, what ever returns here will be killed in
+        return allChildrenOfAppContext;
+    }
+
+    /**
+     * This will help to find out all the children of a particular node
+     *
+     * @param applicationContexts app contexts of the particular node
+     * @param childContexts       contains the children of the node
+     * @return all the children of the given node
+     */
+    public List<ApplicationContext> findAllChildrenOfAppContext(List<ApplicationContext> applicationContexts,
+                                                                List<ApplicationContext> childContexts) {
+        for (ApplicationContext context : applicationContexts) {
+            childContexts.add(context);
+            findAllChildrenOfAppContext(context.getApplicationContextList(), childContexts);
+        }
+        return childContexts;
+    }
+
+    public boolean isKillAll() {
+        return killAll;
+    }
+
+    public void setKillAll(boolean killAll) {
+        this.killAll = killAll;
+    }
+
+    public boolean isKillNone() {
+        return killNone;
+    }
+
+    public void setKillNone(boolean killNone) {
+        this.killNone = killNone;
+    }
+
+    public boolean isStarted() {
+        return started;
+    }
+
+    public void setStarted(boolean started) {
+        this.started = started;
+    }
+
+    public boolean isTerminated() {
+        return terminated;
+    }
+
+    public void setTerminated(boolean terminated) {
+        this.terminated = terminated;
+    }
+
+    public boolean isKillDependent() {
+        return killDependent;
+    }
+
+    public void setKillDependent(boolean killDependent) {
+        this.killDependent = killDependent;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public boolean isStartupOder() {
+        return startupOder;
+    }
+
+    public void setStartupOder(boolean startupOder) {
+        this.startupOder = startupOder;
+    }
+
+    public boolean isReverseStartupOrder() {
+        return reverseStartupOrder;
+    }
+
+    public void setReverseStartupOrder(boolean reverseStartupOrder) {
+        this.reverseStartupOrder = reverseStartupOrder;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
new file mode 100644
index 0000000..45d1544
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency.context;
+
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * This is to keep track of the
+ */
+public abstract class ApplicationContext {
+    private List<ApplicationContext> applicationContextList;
+
+    private String id;
+    protected boolean started;
+    private boolean terminated;
+
+    private ClusterStatus status;
+
+    private Stack<ClusterStatus> statusLifeCycle;
+
+    protected boolean isDependent;
+
+    public ApplicationContext(String id, boolean killDependent) {
+        applicationContextList = new ArrayList<ApplicationContext>();
+        statusLifeCycle = new Stack<ClusterStatus>();
+        this.setDependent(killDependent);
+        this.id = id;
+    }
+
+    public List<ApplicationContext> getApplicationContextList() {
+        return applicationContextList;
+    }
+
+    public void setApplicationContextList(List<ApplicationContext> applicationContextList) {
+        this.applicationContextList = applicationContextList;
+    }
+
+    public void addApplicationContext(ApplicationContext applicationContext) {
+        applicationContextList.add(applicationContext);
+
+    }
+
+    public void addStatusToLIfeCycle(ClusterStatus status) {
+       this.statusLifeCycle.push(status);
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public ClusterStatus getCurrentStatus() {
+        return status;
+    }
+
+    public void setCurrentStatus(ClusterStatus status) {
+        this.status = status;
+    }
+
+    public List<ClusterStatus> getStatusLifeCycle() {
+        return statusLifeCycle;
+    }
+
+    public boolean hasChild() {
+        boolean hasChild;
+        if(this.applicationContextList.isEmpty()) {
+            hasChild = false;
+        } else {
+            hasChild = true;
+        }
+        return hasChild;
+    }
+
+
+    public boolean isTerminated() {
+        return terminated;
+    }
+
+    public void setTerminated(boolean terminated) {
+        this.terminated = terminated;
+    }
+
+    public boolean isDependent() {
+        return isDependent;
+    }
+
+    public void setDependent(boolean isDependent) {
+        this.isDependent = isDependent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
new file mode 100644
index 0000000..b4d7740
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency.context;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ParentComponent;
+
+/**
+ * Factory to create new GroupContext or ClusterContext
+ */
+public class ApplicationContextFactory {
+    private static final Log log = LogFactory.getLog(ApplicationContextFactory.class);
+
+    /**
+     * Will return the GroupContext/ClusterContext based on the type in start order
+     *
+     * @param startOrder      reference of group/cluster in the start order
+     * @param component       The component which used to build the dependency
+     * @param tree kill dependent behaviour of this component
+     * @return Context
+     */
+    public static ApplicationContext getApplicationContext(String startOrder,
+                                                           ParentComponent component,
+                                                           DependencyTree tree) {
+        String id;
+        ApplicationContext applicationContext = null;
+        boolean isDependent = tree.isKillDependent() || tree.isKillAll();
+        if (startOrder.startsWith(Constants.GROUP + ".")) {
+            //getting the group alias
+            id = getGroupFromStartupOrder(startOrder);
+            applicationContext = getGroupContext(id, isDependent);
+        } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) {
+            //getting the cluster alias
+            id = getClusterFromStartupOrder(startOrder);
+            //getting the cluster-id from cluster alias
+            ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id);
+            applicationContext = getClusterContext(clusterDataHolder, isDependent);
+
+        } else {
+            log.warn("[Startup Order]: " + startOrder + " contains unknown reference");
+        }
+        return applicationContext;
+
+    }
+
+    /**
+     * Utility method to get the group alias from the startup order Eg: group.mygroup
+     *
+     * @param startupOrder startup order
+     * @return group alias
+     */
+    public static String getGroupFromStartupOrder(String startupOrder) {
+        return startupOrder.substring(Constants.GROUP.length() + 1);
+    }
+
+    /**
+     * Utility method to get the cluster alias from startup order Eg: cartridge.myphp
+     *
+     * @param startupOrder startup order
+     * @return cluster alias
+     */
+    public static String getClusterFromStartupOrder(String startupOrder) {
+        return startupOrder.substring(Constants.CARTRIDGE.length() + 1);
+    }
+
+    public static ApplicationContext getClusterContext(ClusterDataHolder dataHolder,
+                                                       boolean isKillDependent) {
+        ApplicationContext applicationContext;
+        applicationContext = new ClusterContext(dataHolder.getClusterId(),
+                isKillDependent);
+        ((ClusterContext) applicationContext).setServiceName(dataHolder.getServiceType());
+        return  applicationContext;
+    }
+
+    public static ApplicationContext getGroupContext(String id, boolean isDependent) {
+        ApplicationContext applicationContext;
+        applicationContext = new GroupContext(id,
+                isDependent);
+        return applicationContext;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
new file mode 100644
index 0000000..6de38d4
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency.context;
+
+/**
+ * ClusterContext to keep cluster level context information
+ */
+public class ClusterContext extends ApplicationContext {
+    private String serviceName;
+
+    public ClusterContext(String id, boolean killDependent) {
+        super(id ,killDependent);
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
new file mode 100644
index 0000000..3f546c5
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.dependency.context;
+
+public class GroupContext extends ApplicationContext {
+    public GroupContext(String id, boolean killDependent) {
+        super(id ,killDependent);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
new file mode 100644
index 0000000..5aa05a2
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -0,0 +1,478 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.applications.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.ApplicationHolder;
+import org.apache.stratos.messaging.domain.applications.*;
+import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
+import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
+import org.apache.stratos.messaging.event.topology.*;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * This will build the application.
+ */
+public class ApplicationBuilder {
+    private static final Log log = LogFactory.getLog(ApplicationBuilder.class);
+
+
+    /*public static synchronized void handleApplicationDeployed(Application application,
+                                                              Set<ApplicationClusterContext> applicationClusterContexts,
+                                                              Set<MetaDataHolder> metaDataHolders) {
+
+
+        Applications applications = Appcation.getApplications();
+        try {
+            ApplicationHolder.acquireWriteLock();
+
+            if (applications.applicationExists(application.getUniqueIdentifier())) {
+                log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Applications");
+                return;
+            }
+            List<Cluster> clusters = new ArrayList<Cluster>();
+            for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) {
+                Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(),
+                        applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(),
+                        applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier());
+                //cluster.setStatus(Status.Created);
+                cluster.addHostName(applicationClusterContext.getHostName());
+                cluster.setTenantRange(applicationClusterContext.getTenantRange());
+                clusters.add(cluster);
+
+                Service service = applications.getService(applicationClusterContext.getCartridgeType());
+                if (service != null) {
+                    service.addCluster(cluster);
+                    log.info("Added Cluster " + cluster.toString() + " to Applications for Application with id: " + application.getUniqueIdentifier());
+                } else {
+                    log.error("Service " + applicationClusterContext.getCartridgeType() + " not found");
+                    return;
+                }
+            }
+
+            // add to Applications and update
+            applications.addApplication(application);
+            ApplicationHolder.persistApplication(applications);
+
+            log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Applications successfully");
+            org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent(application, clusters);
+            ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent);
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+    }*/
+
+    /*public static synchronized void handleApplicationUndeployed(String applicationId) {
+
+        Set<ClusterDataHolder> clusterData;
+
+        // update the Application and Cluster Statuses as 'Terminating'
+        ApplicationHolder.acquireWriteLock();
+
+        try {
+
+            Applications applications = ApplicationHolder.getApplications();
+
+            if (!applications.applicationExists(applicationId)) {
+                log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications");
+                return;
+            }
+
+            Application application = applications.getApplication(applicationId);
+            // check and update application status to 'Terminating'
+            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
+            }
+            // for now anyway update the status forcefully
+            application.setStatus(ApplicationStatus.Terminating);
+
+            // update all the Clusters' statuses to 'Terminating'
+            clusterData = application.getClusterDataRecursively();
+            for (ClusterDataHolder clusterDataHolder : clusterData) {
+                Service service = applications.getService(clusterDataHolder.getServiceType());
+                if (service != null) {
+                    Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
+                    if (aCluster != null) {
+                        // validate state transition
+                        if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                            log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
+                                    + ClusterStatus.Terminating);
+                        }
+                        // for now anyway update the status forcefully
+                        aCluster.setStatus(ClusterStatus.Terminating);
+
+                    } else {
+                        log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
+                                " in Applications");
+                    }
+
+                } else {
+                    log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " +
+                            " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
+                }
+            }
+
+            // update all Group's statuses to 'Terminating'
+            if (application.getGroups() != null) {
+                updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
+            }
+
+            ApplicationHolder.persistApplication(applications);
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+
+        ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
+    }*/
+
+    public static void handleGroupTerminatedEvent(String appId, String groupId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        Group group = application.getGroupRecursively(groupId);
+        if (group == null) {
+            log.warn(String.format("Group %s does not exist",
+                    groupId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            group.setStatus(GroupStatus.Terminated);
+            log.info("Group terminated adding status started for " + group.getUniqueIdentifier());
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendGroupTerminatedEvent(appId, groupId);
+    }
+
+    public static void handleGroupActivatedEvent(String appId, String groupId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        Group group = application.getGroupRecursively(groupId);
+        if (group == null) {
+            log.warn(String.format("Group %s does not exist",
+                    groupId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            group.setStatus(GroupStatus.Active);
+            log.info("Group activated adding status started for " + group.getUniqueIdentifier());
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendGroupActivatedEvent(application.getUniqueIdentifier(),
+                group.getUniqueIdentifier());
+    }
+
+    public static void handleGroupCreatedEvent(String appId, String groupId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        Group group = application.getGroupRecursively(groupId);
+        if (group == null) {
+            log.warn(String.format("Group %s does not exist",
+                    groupId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            group.setStatus(GroupStatus.Created);
+            log.info("Group created adding status started for " + group.getUniqueIdentifier());
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendGroupCreatedEvent(appId, groupId);
+    }
+
+    public static void handleGroupInActivateEvent(String appId, String groupId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        Group group = application.getGroupRecursively(groupId);
+        if (group == null) {
+            log.warn(String.format("Group %s does not exist",
+                    groupId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            group.setStatus(GroupStatus.Inactive);
+            log.info("Group in-active adding status started for " + group.getUniqueIdentifier());
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendGroupInActivateEvent(appId, groupId);
+    }
+
+    public static void handleGroupTerminatingEvent(String appId, String groupId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        Group group = application.getGroupRecursively(groupId);
+        if (group == null) {
+            log.warn(String.format("Group %s does not exist",
+                    groupId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            group.setStatus(GroupStatus.Terminating);
+            log.info("Group terminating adding status started for " + group.getUniqueIdentifier());
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, groupId);
+    }
+
+    public static void handleApplicationActivatedEvent(String appId) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(appId);
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    appId));
+            return;
+        }
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+            application.setStatus(ApplicationStatus.Active);
+            log.info("Application activated adding status started for Applications");
+
+            ApplicationHolder.persistApplication(application);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendApplicationActivatedEvent(appId);
+    }
+
+    /*public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) {
+        Applications applications = ApplicationHolder.getApplications();
+        Application application = applications.getApplication(event.getAppId());
+        //update the status of the Group
+        if (application == null) {
+            log.warn(String.format("Application %s does not exist",
+                    event.getAppId()));
+            return;
+        }
+        List<Cluster> clusters = new ArrayList<Cluster>();
+        Set<ClusterDataHolder> allClusters = application.getClusterDataRecursively();
+
+        for (ClusterDataHolder clusterDataHolder : allClusters) {
+            String clusterId = clusterDataHolder.getClusterId();
+            String serviceName = clusterDataHolder.getServiceType();
+            clusters.add(ApplicationHolder.getApplications().getService(serviceName).getCluster(clusterId));
+        }
+        org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationActivatedEvent =
+                new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent(
+                        application, clusters);
+        try {
+            ApplicationHolder.acquireWriteLock();
+            application.setStatus(ApplicationStatus.Created);
+            log.info("Application created adding status started for Applications");
+
+            ApplicationHolder.persistApplication(applications);
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+        //publishing data
+        ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent);
+    }*/
+
+    public static void handleApplicationTerminatingEvent(String appId) {
+
+        String applicationId = appId;
+
+        // update the Application Status as 'Terminating'
+        ApplicationHolder.acquireWriteLock();
+
+        try {
+
+            Applications applications = ApplicationHolder.getApplications();
+
+            if (!applications.applicationExists(applicationId)) {
+                log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications");
+                return;
+            }
+
+            Application application = applications.getApplication(applicationId);
+            // check and update application status to 'Terminating'
+            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
+            }
+            // for now anyway update the status forcefully
+            application.setStatus(ApplicationStatus.Terminating);
+            log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+
+        ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId);
+    }
+
+    private static void updateGroupStatusesRecursively(GroupStatus groupStatus, Collection<Group> groups) {
+
+        for (Group group : groups) {
+            if (!group.isStateTransitionValid(groupStatus)) {
+                log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus);
+            }
+            // force update for now
+            group.setStatus(groupStatus);
+
+            // go recursively and update
+            if (group.getGroups() != null) {
+                updateGroupStatusesRecursively(groupStatus, group.getGroups());
+            }
+        }
+    }
+
+    public static void handleApplicationTerminatedEvent(String appId) {
+
+        Applications applications = ApplicationHolder.getApplications();
+
+        try {
+            ApplicationHolder.acquireWriteLock();
+
+            if (!applications.applicationExists(appId)) {
+                log.warn("Application with id [ " + appId + " ] doesn't exist in Applications");
+                //ApplicationsEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain);
+
+            } else {
+                Application application = applications.getApplication(appId);
+
+                if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+                    log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated);
+                }
+                // forcefully set status for now
+                application.setStatus(ApplicationStatus.Terminated);
+
+                int tenantId = application.getTenantId();
+                String tenantDomain = application.getTenantDomain();
+                Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
+                // remove clusters
+                /*for (ClusterDataHolder clusterDataHolder : clusterData) {
+                    Service service = applications.getService(clusterDataHolder.getServiceType());
+                    if (service != null) {
+                        // remove Cluster
+                        service.removeCluster(clusterDataHolder.getClusterId());
+
+                        if (log.isDebugEnabled()) {
+                            log.debug("Removed cluster with id " + clusterDataHolder.getClusterId());
+                        }
+                    } else {
+                        log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " +
+                                " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
+                    }
+
+                    // remove runtime data
+                    FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
+                    dataHolder.removeClusterContext(clusterDataHolder.getClusterId());
+                    if (log.isDebugEnabled()) {
+                        log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId());
+                    }
+
+                    try {
+                        RegistryManager.getInstance().persist(dataHolder);
+                    } catch (RegistryException e) {
+                        log.error("Unable to persist data in Registry", e);
+                    }
+                }
+
+
+                // remove application
+                applications.removeApplication(event.getAppId());
+                ApplicationHolder.persistApplication(applications);
+
+                deleteAppResourcesFromMetadataService(event);
+
+                log.info("Removed application [ " + event.getAppId() + " ] from Applications");
+
+                ApplicationsEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent(event.getAppId(),
+                        clusterData, tenantId, tenantDomain))*/
+                ;
+            }
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
new file mode 100644
index 0000000..f8d989f
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -0,0 +1,236 @@
+package org.apache.stratos.autoscaler.applications.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.applications.*;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.messaging.util.Constants;
+
+import java.util.Set;
+
+/**
+ * This will publish application related events to application status topic.
+ */
+public class ApplicationsEventPublisher {
+    private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class);
+
+
+    public static void sendGroupCreatedEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Created)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group created event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupCreatedEvent groupCreatedEvent =
+                            new GroupCreatedEvent(appId, groupId);
+
+                    publishEvent(groupCreatedEvent);
+                } else {
+                    log.warn("Created is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupActivatedEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group activated event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupActivatedEvent groupActivatedEvent =
+                            new GroupActivatedEvent(appId, groupId);
+
+                    publishEvent(groupActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupInActivateEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Inactive)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group in-activate event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
+                            AppStatusGroupInactivateEvent(appId, groupId);
+
+                    publishEvent(appStatusGroupInactivateEvent);
+                } else {
+                    log.warn("InActive is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupTerminatingEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Terminating)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group terminating event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupTerminatingEvent groupInTerminatingEvent =
+                            new GroupTerminatingEvent(appId, groupId);
+                    publishEvent(groupInTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupTerminatedEvent(String appId, String groupId) {
+
+        if (log.isInfoEnabled()) {
+            log.info("Publishing Group terminated event for [application]: " + appId +
+                    " [group]: " + groupId);
+        }
+
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Terminated)) {
+                    GroupTerminatedEvent groupInTerminatedEvent =
+                            new GroupTerminatedEvent(appId, groupId);
+                    publishEvent(groupInTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+
+
+    }
+
+    public static void sendApplicationActivatedEvent(String appId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application activated event for [application]: " + appId);
+                    }
+                    ApplicationActivatedEvent applicationActivatedEvent =
+                            new ApplicationActivatedEvent(appId);
+
+                    publishEvent(applicationActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationInactivatedEvent(String appId) {
+        if (log.isInfoEnabled()) {
+            log.info("Publishing Application In-activated event for [application]: " + appId);
+        }
+
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
+                    ApplicationInactivatedEvent applicationInActivatedEvent =
+                            new ApplicationInactivatedEvent(appId);
+                    publishEvent(applicationInActivatedEvent);
+                } else {
+                    log.warn("Inactive is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationTerminatingEvent(String appId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application terminated event for [application]: " + appId);
+                    }
+                    ApplicationTerminatingEvent applicationTerminatingEvent =
+                            new ApplicationTerminatingEvent(appId);
+                    publishEvent(applicationTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application terminated event for [application]: " + appId);
+                    }
+                    ApplicationTerminatedEvent applicationTerminatedEvent =
+                            new ApplicationTerminatedEvent(appId, clusterData);
+                    publishEvent(applicationTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void publishEvent(Event event) {
+        //publishing events to application status topic
+        EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATIONS_TOPIC);
+        eventPublisher.publish(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
deleted file mode 100644
index bf1233f..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.*;
-import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory;
-import org.apache.stratos.messaging.domain.applications.*;
-
-import java.util.Set;
-
-/**
- * This is to build the startup/termination dependencies
- * across immediate children according to the start order defined.
- */
-public class DependencyBuilder {
-    private static final Log log = LogFactory.getLog(DependencyBuilder.class);
-
-    private DependencyBuilder() {
-
-    }
-
-    private static class Holder {
-        private static final DependencyBuilder INSTANCE = new DependencyBuilder();
-    }
-
-    public static DependencyBuilder getInstance() {
-        return Holder.INSTANCE;
-    }
-
-    /**
-     * This will build the dependency tree based on the given dependency order
-     * @param component it will give the necessary information to build the tree
-     * @return the dependency tree out of the dependency orders
-     */
-    public DependencyTree buildDependency(ParentComponent component) throws DependencyBuilderException{
-
-        String identifier = component.getUniqueIdentifier();
-        DependencyTree dependencyTree = new DependencyTree(identifier);
-        DependencyOrder dependencyOrder = component.getDependencyOrder();
-
-        if (dependencyOrder != null) {
-            log.info("Building dependency for the Application/Group " + identifier);
-
-            //Parsing the kill behaviour
-            String terminationBehaviour = dependencyOrder.getTerminationBehaviour();
-
-            if (Constants.TERMINATE_NONE.equals(terminationBehaviour)) {
-                dependencyTree.setKillNone(true);
-            } else if (Constants.TERMINATE_ALL.equals(terminationBehaviour)) {
-                dependencyTree.setKillAll(true);
-            } else if (Constants.TERMINATE_DEPENDENTS.equals(terminationBehaviour)) {
-                dependencyTree.setKillDependent(true);
-            }
-
-            log.info("Setting the [terminationBehaviour] " + terminationBehaviour + " to the " +
-                        "[dependency-tree] " + dependencyTree.getId());
-
-
-            //Parsing the start up order
-            Set<StartupOrder> startupOrders = dependencyOrder.getStartupOrders();
-            ApplicationContext foundContext;
-            ApplicationContext parentContext;
-
-            if (startupOrders != null) {
-                for (StartupOrder startupOrder : startupOrders) {
-                    foundContext = null;
-                    parentContext = null;
-                    for (String start : startupOrder.getStartList()) {
-
-                        if (start != null) {
-                            ApplicationContext applicationContext = ApplicationContextFactory.
-                                    getApplicationContext(start, component, dependencyTree);
-                            String id = applicationContext.getId();
-
-                            ApplicationContext existingApplicationContext =
-                                    dependencyTree.findApplicationContextWithId(id);
-                            if (existingApplicationContext == null) {
-                                if (parentContext != null) {
-                                    //appending the start up order to already added parent group/cluster
-                                    parentContext.addApplicationContext(applicationContext);
-                                    parentContext = applicationContext;
-                                    if (log.isDebugEnabled()) {
-                                        log.debug("Found an existing [dependency] " + parentContext.getId() +
-                                                " and adding the [dependency] " + id + " as the child");
-                                    }
-                                } else {
-                                    //adding list of startup order to the dependency tree
-                                    dependencyTree.addApplicationContext(applicationContext);
-                                    parentContext = applicationContext;
-                                }
-                            } else {
-                                if (foundContext == null) {
-                                    //if existing context found, add it to child of existing context and
-                                    //set the existing context as the next parent
-                                    existingApplicationContext.addApplicationContext(applicationContext);
-                                    parentContext = existingApplicationContext;
-                                    if (log.isDebugEnabled()) {
-                                        log.debug("Found an existing [dependency] " + id + " and setting it " +
-                                                "for the next dependency to follow");
-                                    }
-                                } else {
-                                    String msg = "Startup order is not consistent. It contains the group/cluster " +
-                                            "which has been used more than one in another startup order";
-                                    throw new DependencyBuilderException(msg);
-                                }
-
-                            }
-                        }
-                    }
-
-                }
-            }
-            //TODO need to parser the scalable dependencies
-        }
-
-
-        //adding the rest of the children who are independent to the top level
-        // as they can start in parallel.
-        for (Group group1 : component.getAliasToGroupMap().values()) {
-            if (dependencyTree.findApplicationContextWithId(group1.getAlias()) == null) {
-                ApplicationContext context = ApplicationContextFactory.
-                        getGroupContext(group1.getAlias(), dependencyTree.isKillDependent());
-                dependencyTree.addApplicationContext(context);
-            }
-        }
-        for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) {
-            if (dependencyTree.findApplicationContextWithId(dataHolder.getClusterId()) == null) {
-                ApplicationContext context = ApplicationContextFactory.getClusterContext(dataHolder,
-                                                                dependencyTree.isKillDependent());
-                dependencyTree.addApplicationContext(context);
-
-            }
-        }
-        return dependencyTree;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
deleted file mode 100644
index 05769a6..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This is to contain the dependency tree of an application/group
- */
-public class DependencyTree {
-    private static final Log log = LogFactory.getLog(DependencyTree.class);
-
-    private List<ApplicationContext> applicationContextList;
-
-    private boolean started;
-
-    private boolean terminated;
-
-    private boolean killAll;
-
-    private boolean killNone;
-
-    private boolean killDependent;
-
-    private boolean startupOder;
-
-    private boolean reverseStartupOrder;
-
-    private String id;
-
-    public DependencyTree(String id) {
-        applicationContextList = new ArrayList<ApplicationContext>();
-        this.setId(id);
-        if (log.isDebugEnabled()) {
-            log.debug("Starting a dependency tree for the [group/application] " + id);
-        }
-    }
-
-    public List<ApplicationContext> getApplicationContextList() {
-        return applicationContextList;
-    }
-
-    public void setApplicationContextList(List<ApplicationContext> applicationContextList) {
-        this.applicationContextList = applicationContextList;
-    }
-
-    public void addApplicationContext(ApplicationContext applicationContext) {
-        applicationContextList.add(applicationContext);
-
-    }
-
-    /**
-     * Find an ApplicationContext from dependency tree with the given id
-     *
-     * @param id the alias/id of group/cluster
-     * @return ApplicationContext of the given id
-     */
-    public ApplicationContext findApplicationContextWithId(String id) {
-        return findApplicationContextWithId(id, applicationContextList);
-    }
-
-    /**
-     * Find the ApplicationContext using Breadth first search.
-     *
-     * @param id       the alias/id of group/cluster
-     * @param contexts the list of contexts in the same level of the tree
-     * @return ApplicationContext of the given id
-     */
-    private ApplicationContext findApplicationContextWithId(String id, List<ApplicationContext> contexts) {
-        for (ApplicationContext context : contexts) {
-            //TODO check for the status
-            if (context.getId().equals(id)) {
-                return context;
-            }
-        }
-        //if not found in the top level search recursively
-        for (ApplicationContext context : contexts) {
-            return findApplicationContextWithId(id, context.getApplicationContextList());
-        }
-        return null;
-    }
-
-    public ApplicationContext findParentContextWithId(String id) {
-        return findParentContextWithId(null, id, this.applicationContextList);
-    }
-
-    public List<ApplicationContext> findAllParentContextWithId(String id) {
-        List<ApplicationContext> applicationContexts = new ArrayList<ApplicationContext>();
-        return findAllParent(applicationContexts, id);
-    }
-
-    private List<ApplicationContext> findAllParent(List<ApplicationContext> parentContexts, String id) {
-        ApplicationContext context = findParentContextWithId(null, id, this.applicationContextList);
-        if (context != null) {
-            parentContexts.add(context);
-            findAllParent(parentContexts, context.getId());
-        }
-        return parentContexts;
-    }
-
-
-    private ApplicationContext findParentContextWithId(ApplicationContext parent, String id,
-                                                       List<ApplicationContext> contexts) {
-        for (ApplicationContext context : contexts) {
-            //TODO check for the status
-            if (context.getId().equals(id)) {
-                return parent;
-            }
-        }
-        //if not found in the top level search recursively
-        for (ApplicationContext context : this.applicationContextList) {
-            return findParentContextWithId(context, id, context.getApplicationContextList());
-        }
-        return null;
-    }
-
-    /**
-     * Getting the next start able dependencies upon the activate event
-     * received for a group/cluster which is part of this tree.
-     *
-     * @param id the alias/id of group/cluster which received the activated event.
-     * @return list of dependencies
-     */
-    public List<ApplicationContext> getStarAbleDependencies(String id) {
-        //finding the application context which received the activated event and
-        // returning it's immediate children as the dependencies.
-        ApplicationContext context = findApplicationContextWithId(id);
-        return context.getApplicationContextList();
-    }
-
-    /**
-     * Getting the next start able dependencies upon the monitor initialization.
-     *
-     * @return list of dependencies
-     */
-    public List<ApplicationContext> getStarAbleDependencies() {
-        //returning the top level as the monitor is in initializing state
-        return this.applicationContextList;
-    }
-
-    public List<ApplicationContext> getStarAbleDependenciesByTermination() {
-        //Breadth First search over the graph to find out which level has the terminated contexts
-        return traverseGraphByLevel(this.applicationContextList);
-    }
-
-
-    private List<ApplicationContext> traverseGraphByLevel(List<ApplicationContext> contexts) {
-        for(ApplicationContext context : contexts) {
-            if(context.isTerminated()) {
-                return contexts;
-            }
-        }
-
-        for(ApplicationContext context : contexts) {
-            return traverseGraphByLevel(context.getApplicationContextList());
-        }
-        return null;
-    }
-
-
-
-    /**
-     * When one group/cluster terminates/in_maintenance, need to consider about other
-     * dependencies
-     *
-     * @param id the alias/id of group/cluster in which terminated event received
-     * @return all the kill able children dependencies
-     */
-    public List<ApplicationContext> getTerminationDependencies(String id) {
-        List<ApplicationContext> allChildrenOfAppContext = new ArrayList<ApplicationContext>();
-        ApplicationContext applicationContext = findApplicationContextWithId(id);
-
-        if (this.killDependent) {
-            //finding the ApplicationContext of the given id
-            //finding all the children of the found application context
-            allChildrenOfAppContext.add(applicationContext);
-            findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
-                    allChildrenOfAppContext);
-            return allChildrenOfAppContext;
-        } else if (this.killAll) {
-            //killall will be killed by the monitor from it's list.
-            findAllChildrenOfAppContext(this.applicationContextList,
-                    allChildrenOfAppContext);
-
-        }
-        //return empty for the kill-none case, what ever returns here will be killed in
-        return allChildrenOfAppContext;
-    }
-
-    /**
-     * This will help to find out all the children of a particular node
-     *
-     * @param applicationContexts app contexts of the particular node
-     * @param childContexts       contains the children of the node
-     * @return all the children of the given node
-     */
-    public List<ApplicationContext> findAllChildrenOfAppContext(List<ApplicationContext> applicationContexts,
-                                                                List<ApplicationContext> childContexts) {
-        for (ApplicationContext context : applicationContexts) {
-            childContexts.add(context);
-            findAllChildrenOfAppContext(context.getApplicationContextList(), childContexts);
-        }
-        return childContexts;
-    }
-
-    public boolean isKillAll() {
-        return killAll;
-    }
-
-    public void setKillAll(boolean killAll) {
-        this.killAll = killAll;
-    }
-
-    public boolean isKillNone() {
-        return killNone;
-    }
-
-    public void setKillNone(boolean killNone) {
-        this.killNone = killNone;
-    }
-
-    public boolean isStarted() {
-        return started;
-    }
-
-    public void setStarted(boolean started) {
-        this.started = started;
-    }
-
-    public boolean isTerminated() {
-        return terminated;
-    }
-
-    public void setTerminated(boolean terminated) {
-        this.terminated = terminated;
-    }
-
-    public boolean isKillDependent() {
-        return killDependent;
-    }
-
-    public void setKillDependent(boolean killDependent) {
-        this.killDependent = killDependent;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public boolean isStartupOder() {
-        return startupOder;
-    }
-
-    public void setStartupOder(boolean startupOder) {
-        this.startupOder = startupOder;
-    }
-
-    public boolean isReverseStartupOrder() {
-        return reverseStartupOrder;
-    }
-
-    public void setReverseStartupOrder(boolean reverseStartupOrder) {
-        this.reverseStartupOrder = reverseStartupOrder;
-    }
-}


[31/50] [abbrv] git commit: moving applications stuff to autoscaler - II

Posted by im...@apache.org.
moving applications stuff to autoscaler -  II


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

Branch: refs/heads/docker-grouping-merge
Commit: c42d7c1dc232256e4bbb7a10bda7e8f110ddb795
Parents: d4f90be
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 15:55:27 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530

----------------------------------------------------------------------
 .../topic/ApplicationsEventPublisher.java       |  56 ++++-----
 .../AutoscalerTopologyEventReceiver.java        |   7 +-
 .../monitor/ApplicationMonitorFactory.java      |  13 +-
 .../status/checker/StatusChecker.java           |  21 ++--
 .../topology/TopologyEventPublisher.java        |   2 +-
 .../domain/applications/Applications.java       |   2 +-
 .../locking/ApplicationLockHierarchy.java       |   4 +-
 .../topology/locking/TopologyLockHierarchy.java |  42 -------
 .../ApplicationActivatedMessageProcessor.java   |  24 ++--
 .../ApplicationCreatedMessageProcessor.java     |  18 ++-
 .../ApplicationInactivatedMessageProcessor.java |  24 ++--
 .../ApplicationTerminatedMessageProcessor.java  |  43 +++----
 .../ApplicationTerminatingMessageProcessor.java |  24 ++--
 .../ApplicationUndeployedMessageProcessor.java  |  61 +++++-----
 .../CompleteApplicationsMessageProcessor.java   |  17 +--
 .../applications/GroupActivatedProcessor.java   |  20 ++--
 .../applications/GroupCreatedProcessor.java     |  24 ++--
 .../applications/GroupInActivateProcessor.java  |  22 ++--
 .../applications/GroupTerminatedProcessor.java  |  24 ++--
 .../applications/GroupTerminatingProcessor.java |  24 ++--
 .../updater/ApplicationsUpdater.java            |  23 ++--
 .../CompleteTopologyMessageProcessor.java       |  15 ---
 .../topology/updater/TopologyUpdater.java       |  68 +----------
 .../applications/ApplicationManager.java        | 119 +++++++++++++++++++
 .../receiver/topology/TopologyManager.java      |  67 +----------
 25 files changed, 351 insertions(+), 413 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index f8d989f..bdbffc0 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -7,7 +7,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.util.Constants;
 
 import java.util.Set;
@@ -21,8 +21,8 @@ public class ApplicationsEventPublisher {
 
     public static void sendGroupCreatedEvent(String appId, String groupId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Created)) {
@@ -39,14 +39,14 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
     public static void sendGroupActivatedEvent(String appId, String groupId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Active)) {
@@ -63,14 +63,14 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
     public static void sendGroupInActivateEvent(String appId, String groupId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Inactive)) {
@@ -87,14 +87,14 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
     public static void sendGroupTerminatingEvent(String appId, String groupId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Terminating)) {
@@ -110,7 +110,7 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
@@ -122,8 +122,8 @@ public class ApplicationsEventPublisher {
         }
 
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 Group group = application.getGroupRecursively(groupId);
                 if (group.isStateTransitionValid(GroupStatus.Terminated)) {
@@ -135,7 +135,7 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
 
 
@@ -143,8 +143,8 @@ public class ApplicationsEventPublisher {
 
     public static void sendApplicationActivatedEvent(String appId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 if (application.isStateTransitionValid(ApplicationStatus.Active)) {
                     if (log.isInfoEnabled()) {
@@ -159,7 +159,7 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
@@ -169,8 +169,8 @@ public class ApplicationsEventPublisher {
         }
 
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
                     ApplicationInactivatedEvent applicationInActivatedEvent =
@@ -181,14 +181,14 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
     public static void sendApplicationTerminatingEvent(String appId) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
                     if (log.isInfoEnabled()) {
@@ -202,14 +202,14 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 
     public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
         try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            ApplicationManager.acquireReadLockForApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
                     if (log.isInfoEnabled()) {
@@ -223,7 +223,7 @@ public class ApplicationsEventPublisher {
                 }
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index 18929ed..dcf3a82 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -45,6 +45,7 @@ import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.topology.*;
 import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
 import org.apache.stratos.messaging.listener.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
@@ -103,7 +104,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                     TopologyManager.acquireReadLock();
                     try {
-                        for (Application application : TopologyManager.getTopology().getApplications()) {
+                        for (Application application : ApplicationManager.getApplications().getApplications().values()) {
                             startApplicationMonitor(application.getUniqueIdentifier());
                         }
 
@@ -172,8 +173,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 log.info("[ClusterCreatedEvent] Received: " + event.getClass());
 
-                ClusterResetEvent clusterCreatedEvent = (ClusterResetEvent) event;
-                String clusterId = clusterCreatedEvent.getClusterId();
+                ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
+                String clusterId = clusterCreatedEvent.getCluster().getClusterId();
                 AbstractClusterMonitor clusterMonitor =
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index 1e64d78..f693310 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -47,6 +47,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.Property;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;
 
@@ -102,10 +103,10 @@ public class ApplicationMonitorFactory {
             throws DependencyBuilderException,
             TopologyInConsistentException {
         GroupMonitor groupMonitor;
-        TopologyManager.acquireReadLockForApplication(appId);
+        ApplicationManager.acquireReadLockForApplication(appId);
 
         try {
-            Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(context.getId());
+            Group group = ApplicationManager.getApplications().getApplication(appId).getGroupRecursively(context.getId());
             groupMonitor = new GroupMonitor(group, appId);
             groupMonitor.setAppId(appId);
             if(parentMonitor != null) {
@@ -126,7 +127,7 @@ public class ApplicationMonitorFactory {
             }
 
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
 
         }
         return groupMonitor;
@@ -146,9 +147,9 @@ public class ApplicationMonitorFactory {
             throws DependencyBuilderException,
             TopologyInConsistentException {
         ApplicationMonitor applicationMonitor;
-        TopologyManager.acquireReadLockForApplication(appId);
+        ApplicationManager.acquireReadLockForApplication(appId);
         try {
-            Application application = TopologyManager.getTopology().getApplication(appId);
+            Application application = ApplicationManager.getApplications().getApplication(appId);
             if (application != null) {
                 applicationMonitor = new ApplicationMonitor(application);
                 applicationMonitor.setHasDependent(false);
@@ -158,7 +159,7 @@ public class ApplicationMonitorFactory {
                 throw new TopologyInConsistentException(msg);
             }
         } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
+            ApplicationManager.releaseReadLockForApplication(appId);
         }
 
         return applicationMonitor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index eafa269..5468f6d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
 import java.util.Map;
@@ -98,8 +99,8 @@ public class StatusChecker {
                         if (cluster != null) {
                             try {
 
-                                TopologyManager.acquireReadLockForApplication(appId);
-                                Application application = TopologyManager.getTopology().getApplication(appId);
+                                ApplicationManager.acquireReadLockForApplication(appId);
+                                Application application = ApplicationManager.getApplications().getApplication(appId);
 
                                 if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
                                     if (application.getStatus() == ApplicationStatus.Terminating) {
@@ -123,7 +124,7 @@ public class StatusChecker {
                         }*/
                                 }
                             } finally {
-                                TopologyManager.releaseReadLockForApplication(appId);
+                                ApplicationManager.releaseReadLockForApplication(appId);
                             }
                         }
                     }
@@ -233,22 +234,22 @@ public class StatusChecker {
         Runnable group = new Runnable() {
             public void run() {
                 try {
-                    TopologyManager.acquireReadLockForApplication(appId);
+                    ApplicationManager.acquireReadLockForApplication(appId);
                     ParentComponent component;
                     if (groupId.equals(appId)) {
                         //it is an application
-                        component = TopologyManager.getTopology().
+                        component = ApplicationManager.getApplications().
                                 getApplication(appId);
                     } else {
                         //it is a group
-                        component = TopologyManager.getTopology().
+                        component = ApplicationManager.getApplications().
                                 getApplication(appId).getGroupRecursively(groupId);
                     }
                     Map<String, ClusterDataHolder> clusterIds = component.getClusterDataMap();
                     Map<String, Group> groups = component.getAliasToGroupMap();
                     updateChildStatus(appId, idOfChild, groups, clusterIds, component);
                 } finally {
-                    TopologyManager.releaseReadLockForApplication(appId);
+                    ApplicationManager.releaseReadLockForApplication(appId);
 
                 }
 
@@ -286,8 +287,8 @@ public class StatusChecker {
             clusterStatus = getClusterStatus(clusterData);
             groupStatus = getGroupStatus(groups);
             try {
-                TopologyManager.acquireReadLockForApplication(appId);
-                Application application = TopologyManager.getTopology().getApplication(appId);
+                ApplicationManager.acquireReadLockForApplication(appId);
+                Application application = ApplicationManager.getApplications().getApplication(appId);
 
                 if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) ||
                         clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) ||
@@ -352,7 +353,7 @@ public class StatusChecker {
                     log.warn("Clusters/groups not found in this [component] " + appId);
                 }
             } finally {
-                TopologyManager.releaseReadLockForApplication(appId);
+                ApplicationManager.releaseReadLockForApplication(appId);
             }
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index f96ba8e..2e0883b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -78,7 +78,7 @@ public class TopologyEventPublisher {
     }
 
     public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId);
+        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
 
         if(log.isInfoEnabled()) {
             log.info("Publishing cluster created event: " +clusterId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
index e5a7921..e1feb82 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -68,6 +68,6 @@ public class Applications implements Serializable {
 
     public synchronized void removeApplication (String appId) {
         this.applicationMap.remove(appId);
-        ApplicationLockHierarchy.getInstance().removeLock(appId);
+        ApplicationLockHierarchy.getInstance().removeLockForApplication(appId);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
index cc31892..2b457d7 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
@@ -71,11 +71,11 @@ public class ApplicationLockHierarchy {
         }
     }
 
-    public ApplicationLock getLock (String appId) {
+    public ApplicationLock getLockForApplication(String appId) {
         return appIdToApplicationLockMap.get(appId);
     }
 
-    public void removeLock (String appId) {
+    public void removeLockForApplication (String appId) {
         if (appIdToApplicationLockMap.remove(appId) != null) {
             log.info("Removed lock for Application " + appId);
         } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
index bb6b8fa..e89df3a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
@@ -35,15 +35,9 @@ public class TopologyLockHierarchy {
     // lock for Services
     private final TopologyLock serviceLock;
 
-    // lock for Applications
-    private final TopologyLock applicatioLock;
-
     // key = Service.name
     private final Map<String, TopologyLock> serviceNameToTopologyLockMap;
 
-    // key = Application.id
-    private final Map<String, TopologyLock> applicationIdToTopologyLockMap;
-
     // key = Cluster.id
     private final Map<String, TopologyLock> clusterIdToTopologyLockMap;
 
@@ -53,9 +47,7 @@ public class TopologyLockHierarchy {
 
         this.completeTopologyLock = new TopologyLock();
         this.serviceLock = new TopologyLock();
-        this.applicatioLock = new TopologyLock();
         this.serviceNameToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
-        this.applicationIdToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
         this.clusterIdToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
     }
 
@@ -72,26 +64,6 @@ public class TopologyLockHierarchy {
         return topologyLockHierarchy;
     }
 
-    public void addApplicationLock (String appId, final TopologyLock topologyLock) {
-
-        if (!applicationIdToTopologyLockMap.containsKey(appId)) {
-            synchronized (applicationIdToTopologyLockMap) {
-                if (!applicationIdToTopologyLockMap.containsKey(appId)) {
-                    applicationIdToTopologyLockMap.put(appId, topologyLock);
-                    log.info("Added lock for Application " + appId);
-                }
-            }
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("Topology Lock for Application " + appId + " already exists");
-            }
-        }
-    }
-
-    public TopologyLock getTopologyLockForApplication (String appId) {
-        return applicationIdToTopologyLockMap.get(appId);
-    }
-
     public void addServiceLock (String serviceName, final TopologyLock topologyLock) {
 
         if (!serviceNameToTopologyLockMap.containsKey(serviceName)) {
@@ -132,16 +104,6 @@ public class TopologyLockHierarchy {
         return clusterIdToTopologyLockMap.get(clusterId);
     }
 
-    public void removeTopologyLockForApplication (String appId) {
-        if (applicationIdToTopologyLockMap.remove(appId) != null) {
-            log.info("Removed lock for Application " + appId);
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("Lock already removed for Application " + appId);
-            }
-        }
-    }
-
     public void removeTopologyLockForService (String serviceName) {
         if (serviceNameToTopologyLockMap.remove(serviceName) != null) {
             log.info("Removed lock for Service " + serviceName);
@@ -166,10 +128,6 @@ public class TopologyLockHierarchy {
         return serviceLock;
     }
 
-    public TopologyLock getApplicatioLock() {
-        return applicatioLock;
-    }
-
     public TopologyLock getCompleteTopologyLock() {
         return completeTopologyLock;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
index 6c82925..da75265 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -46,40 +48,40 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationActivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util.
                     jsonToObject(message, ApplicationActivatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess(ApplicationActivatedEvent event, Topology topology) {
+    private boolean doProcess(ApplicationActivatedEvent event, Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
             }
             return false;
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!application.isStateTransitionValid(ApplicationStatus.Active)) {
                 log.error("Invalid State transfer from [ " + application.getStatus() +
                         " ] to [ " + ApplicationStatus.Active + " ]");

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
index db8e3c8..cfe8500 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
@@ -22,15 +22,11 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.util.Util;
 
-import java.util.Set;
-
 public class ApplicationCreatedMessageProcessor extends MessageProcessor {
 
     private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
@@ -57,12 +53,12 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
                 return false;
             }
 
-            TopologyUpdater.acquireWriteLockForApplications();
+            ApplicationsUpdater.acquireWriteLockForApplications();
             try {
                 return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplications();
+                ApplicationsUpdater.releaseWriteLockForApplications();
             }
 
         } else {
@@ -75,7 +71,7 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess(ApplicationCreatedEvent event, Applications topology) {
+    private boolean doProcess(ApplicationCreatedEvent event, Applications applications) {
 
         // check if required properties are available
         if (event.getApplication() == null) {
@@ -90,13 +86,13 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
             throw new RuntimeException(errorMsg);
         }
 
-        // check if an Application with same name exists in topology
-        if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) {
+        // check if an Application with same name exists in applications
+        if (applications.applicationExists(event.getApplication().getUniqueIdentifier())) {
             log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology");
 
         } else {
             // add application and the clusters to Topology
-            topology.addApplication(event.getApplication());
+            applications.addApplication(event.getApplication());
         }
 
         notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
index 91eae8c..e97e3fc 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -46,40 +48,40 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationInactivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
                     jsonToObject(message, ApplicationInactivatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+    private boolean doProcess (ApplicationInactivatedEvent event, Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
             }
             return false;
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) {
                 log.error("Invalid State transfer from [ " + application.getStatus() +
                         " ] to [ " + ApplicationStatus.Inactive + " ]");

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
index 8cd2182..99d08fe 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
@@ -20,10 +20,12 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -47,18 +49,18 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationTerminatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
                     jsonToObject(message, ApplicationTerminatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplications();
+            ApplicationsUpdater.acquireWriteLockForApplications();
                         Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
             if (clusterDataHolders != null) {
                 for (ClusterDataHolder clusterData : clusterDataHolders) {
@@ -67,10 +69,10 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
             }
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplications();
+                ApplicationsUpdater.releaseWriteLockForApplications();
                 if (clusterDataHolders != null) {
                     for (ClusterDataHolder clusterData : clusterDataHolders) {
                         TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
@@ -81,14 +83,14 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) {
+    private boolean doProcess (ApplicationTerminatedEvent event, Applications applications) {
 
         // check if required properties are available
         if (event.getAppId() == null) {
@@ -103,25 +105,26 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
             throw new RuntimeException(errorMsg);
         }
 
-        // check if an Application with same name exists in topology
+        // check if an Application with same name exists in applications
         String appId = event.getAppId();
-        if (topology.applicationExists(appId)) {
+        if (applications.applicationExists(appId)) {
             log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
-            topology.removeApplication(appId);
+            applications.removeApplication(appId);
         }
 
         if (event.getClusterData() != null) {
             // remove the Clusters from the Topology
             for (ClusterDataHolder clusterData : event.getClusterData()) {
-                Service service = topology.getService(clusterData.getServiceType());
-                if (service != null) {
-                    service.removeCluster(clusterData.getClusterId());
-                    if (log.isDebugEnabled()) {
-                        log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
-                    }
-                }  else {
-                    log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
-                }
+                log.info("################################ TODO ################################");
+//                Service service = applications.getService(clusterData.getServiceType());
+//                if (service != null) {
+//                    service.removeCluster(clusterData.getClusterId());
+//                    if (log.isDebugEnabled()) {
+//                        log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
+//                    }
+//                }  else {
+//                    log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
+//                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
index 057d013..633e080 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -46,40 +48,40 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationTerminatingEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
                     jsonToObject(message, ApplicationTerminatingEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
+    private boolean doProcess (ApplicationTerminatingEvent event, Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
             }
             return false;
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
                 log.error("Invalid State transfer from [ " + application.getStatus() +
                         " ] to [ " + ApplicationStatus.Terminating + " ]");

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
index 7e91ab8..e911b77 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
@@ -23,10 +23,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -46,10 +48,10 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
     @Override
     public boolean process(String type, String message, Object object) {
 
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationUndeployedEvent.class.getName().equals(type)) {
-            if (!topology.isInitialized()) {
+            if (!applications.isInitialized()) {
                 return false;
             }
 
@@ -61,7 +63,7 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
             }
 
             // get write lock for the application and relevant Clusters
-            TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getApplicationId());
             Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
             if (clusterDataHolders != null) {
                 for (ClusterDataHolder clusterData : clusterDataHolders) {
@@ -71,7 +73,7 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
             }
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
                 // remove locks
@@ -81,13 +83,13 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
                                 clusterData.getClusterId());
                     }
                 }
-                TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getApplicationId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format
                     ("Failed to process message using available message processors: [type] %s [body] %s", type, message));
@@ -95,10 +97,10 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) {
+    private boolean doProcess (ApplicationUndeployedEvent event, Applications applications) {
 
         // update the application status to Terminating
-        Application application = topology.getApplication(event.getApplicationId());
+        Application application = applications.getApplication(event.getApplicationId());
         // check and update application status to 'Terminating'
         if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
             log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
@@ -110,27 +112,28 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
         Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
         // update the Cluster statuses to Terminating
         for (ClusterDataHolder clusterDataHolder : clusterData) {
-            Service service = topology.getService(clusterDataHolder.getServiceType());
-            if (service != null) {
-                Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
-                if (aCluster != null) {
-                    // validate state transition
-                    if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
-                        log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
-                                + ClusterStatus.Terminating);
-                    }
-                    // for now anyway update the status forcefully
-                    aCluster.setStatus(ClusterStatus.Terminating);
-
-                } else {
-                    log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
-                            " in Topology");
-                }
-
-            } else {
-                log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
-                        " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
-            }
+            log.info("############################### TODO ###############################");
+//            Service service = applications.getService(clusterDataHolder.getServiceType());
+//            if (service != null) {
+//                Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
+//                if (aCluster != null) {
+//                    // validate state transition
+//                    if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+//                        log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
+//                                + ClusterStatus.Terminating);
+//                    }
+//                    // for now anyway update the status forcefully
+//                    aCluster.setStatus(ClusterStatus.Terminating);
+//
+//                } else {
+//                    log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
+//                            " in Topology");
+//                }
+//
+//            } else {
+//                log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
+//                        " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
+//            }
         }
 
         notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
index 53c469b..c9af67a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
@@ -22,25 +22,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
 import org.apache.stratos.messaging.event.applications.CompleteApplicationsEvent;
-import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
-import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 
 public class CompleteApplicationsMessageProcessor extends MessageProcessor {
 
@@ -62,13 +49,13 @@ public class CompleteApplicationsMessageProcessor extends MessageProcessor {
                     jsonToObject(message, CompleteApplicationsEvent.class);
 
             if (!applications.isInitialized()) {
-                ApplicationsUpdater.acquireWriteLock();
+                ApplicationsUpdater.acquireWriteLockForApplications();
 
                 try {
                     doProcess(event, applications);
 
                 } finally {
-                    ApplicationsUpdater.releaseWriteLock();
+                    ApplicationsUpdater.releaseWriteLockForApplications();
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
index 845e933..5c8d477 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -43,40 +45,40 @@ public class GroupActivatedProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (GroupActivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             GroupActivatedEvent event = (GroupActivatedEvent) Util.
                     jsonToObject(message, GroupActivatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (GroupActivatedEvent event,Topology topology) {
+    private boolean doProcess (GroupActivatedEvent event, Applications applications) {
 
         // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
index 47d4457..67861e4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -43,40 +45,40 @@ public class GroupCreatedProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (GroupCreatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             GroupCreatedEvent event = (GroupCreatedEvent) Util.
                     jsonToObject(message, GroupCreatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (GroupCreatedEvent event,Topology topology) {
+    private boolean doProcess (GroupCreatedEvent event,Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupCreatedProcessor extends MessageProcessor {
                         event.getGroupId()));
             }
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!group.isStateTransitionValid(GroupStatus.Created)) {
                 log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created  + " " +
                         "for Group " + group.getAlias());

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
index 063a3de..4f2e581 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -43,40 +45,40 @@ public class GroupInActivateProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (GroupInactivateEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             GroupInactivateEvent event = (GroupInactivateEvent) Util.
                     jsonToObject(message, GroupInactivateEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess(GroupInactivateEvent event, Topology topology) {
+    private boolean doProcess(GroupInactivateEvent event, Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
index 3de0914..6e985b7 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -43,40 +45,40 @@ public class GroupTerminatedProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (GroupTerminatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             GroupTerminatedEvent event = (GroupTerminatedEvent) Util.
                     jsonToObject(message, GroupTerminatedEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (GroupTerminatedEvent event,Topology topology) {
+    private boolean doProcess (GroupTerminatedEvent event, Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupTerminatedProcessor extends MessageProcessor {
                         event.getGroupId()));
             }
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
                 log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
index e124b7b..c9a136f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
@@ -43,40 +45,40 @@ public class GroupTerminatingProcessor extends MessageProcessor {
 
     @Override
     public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (GroupTerminatingEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
                 return false;
 
             // Parse complete message and build event
             GroupTerminatingEvent event = (GroupTerminatingEvent) Util.
                     jsonToObject(message, GroupTerminatingEvent.class);
 
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
 
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (GroupTerminatingEvent event,Topology topology) {
+    private boolean doProcess (GroupTerminatingEvent event,Applications applications) {
 
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
         if (application == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupTerminatingProcessor extends MessageProcessor {
                         event.getGroupId()));
             }
         } else {
-            // Apply changes to the topology
+            // Apply changes to the applications
             if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
                 log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
             }


[39/50] [abbrv] git commit: adding undeploy service group

Posted by im...@apache.org.
adding undeploy service group


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

Branch: refs/heads/docker-grouping-merge
Commit: 7d7cd50d23cb78af9411c1680a4ddc48d7631500
Parents: 828269f
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 18:19:48 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 18:19:48 2014 +0530

----------------------------------------------------------------------
 .../src/main/resources/AutoScalerService.wsdl   | 885 ++++++++++---------
 1 file changed, 470 insertions(+), 415 deletions(-)
----------------------------------------------------------------------



[49/50] [abbrv] Merge branch '4.0.0-grouping' into docker-grouping-merge

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
index 8ec9f8e,b13465f..6f90516
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
@@@ -27,29 -25,20 +27,33 @@@ import org.apache.commons.logging.Log
  import org.apache.commons.logging.LogFactory;
  import org.apache.stratos.autoscaler.Constants;
  import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.autoscaler.exception.NonExistingKubernetesGroupException;
+ import org.apache.stratos.autoscaler.exception.CartridgeInformationException;
  import org.apache.stratos.autoscaler.exception.PartitionValidationException;
  import org.apache.stratos.autoscaler.exception.SpawningException;
  import org.apache.stratos.autoscaler.exception.TerminationException;
 +import org.apache.stratos.autoscaler.kubernetes.KubernetesManager;
  import org.apache.stratos.autoscaler.util.ConfUtil;
 -import org.apache.stratos.cloud.controller.stub.*;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidClusterExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidMemberExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidPartitionExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceMemberTerminationFailedExceptionException;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 +import org.apache.stratos.cloud.controller.stub.pojo.ContainerClusterContext;
+ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
  import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
  import org.apache.stratos.cloud.controller.stub.pojo.Properties;
  import org.apache.stratos.cloud.controller.stub.pojo.Property;
 +import org.apache.stratos.common.constants.StratosConstants;
 +import org.apache.stratos.common.kubernetes.KubernetesGroup;
 +import org.apache.stratos.common.kubernetes.KubernetesMaster;
  
+ import java.rmi.RemoteException;
+ 
  
  /**
   * This class will call cloud controller web service to take the action decided by Autoscaler
@@@ -239,109 -228,20 +243,125 @@@ public class CloudControllerClient 
          }
      }
  
+     public CartridgeInfo getCartrdgeInformation (String cartridgeType) throws CartridgeInformationException {
+ 
+         try {
+             return stub.getCartridgeInfo(cartridgeType);
+ 
+         } catch (RemoteException e) {
+             String msg = e.getMessage();
+             log.error(msg, e);
+             throw new CartridgeInformationException(msg, e);
+         } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+             String msg = e.getMessage();
+             log.error(msg, e);
+             throw new CartridgeInformationException(msg, e);
+         }
+     }
+ 
 +    /**
 +     * @param kubernetesClusterId
 +     * @param clusterId
 +     * @return
 +     * @throws SpawningException
 +     */
 +    public synchronized MemberContext[] startContainers(String kubernetesClusterId, String clusterId) throws SpawningException {
 +        try {
-         	
-         	KubernetesManager kubernetesManager = KubernetesManager.getInstance();
-         	KubernetesMaster kubernetesMaster = kubernetesManager.getKubernetesMasterInGroup(kubernetesClusterId);
-         	String kubernetesMasterIP = kubernetesMaster.getHostIpAddress();
-         	KubernetesGroup kubernetesGroup = kubernetesManager.getKubernetesGroup(kubernetesClusterId);
-     		int lower = kubernetesGroup.getPortRange().getLower();
-     		int upper = kubernetesGroup.getPortRange().getUpper();
-     		String portRange = Integer.toString(lower) + "-" + Integer.toString(upper);
-     		
++
++            KubernetesManager kubernetesManager = KubernetesManager.getInstance();
++            KubernetesMaster kubernetesMaster = kubernetesManager.getKubernetesMasterInGroup(kubernetesClusterId);
++            String kubernetesMasterIP = kubernetesMaster.getHostIpAddress();
++            KubernetesGroup kubernetesGroup = kubernetesManager.getKubernetesGroup(kubernetesClusterId);
++            int lower = kubernetesGroup.getPortRange().getLower();
++            int upper = kubernetesGroup.getPortRange().getUpper();
++            String portRange = Integer.toString(lower) + "-" + Integer.toString(upper);
++
 +            ContainerClusterContext context = new ContainerClusterContext();
 +            context.setClusterId(clusterId);
 +            Properties memberContextProps = new Properties();
 +            Property kubernetesClusterMasterIPProps = new Property();
 +            kubernetesClusterMasterIPProps.setName(StratosConstants.KUBERNETES_MASTER_IP);
 +            kubernetesClusterMasterIPProps.setValue(kubernetesMasterIP);
 +            memberContextProps.addProperties(kubernetesClusterMasterIPProps);
 +            Property kubernetesClusterPortRangeProps = new Property();
 +            kubernetesClusterPortRangeProps.setName(StratosConstants.KUBERNETES_PORT_RANGE);
 +            kubernetesClusterPortRangeProps.setValue(portRange);
 +            memberContextProps.addProperties(kubernetesClusterPortRangeProps);
 +            context.setProperties(memberContextProps);
 +            long startTime = System.currentTimeMillis();
 +            MemberContext[] memberContexts = stub.startContainers(context);
-             
++
 +            if(log.isDebugEnabled()) {
 +                long endTime = System.currentTimeMillis();
 +                log.debug(String.format("Service call startContainer() returned in %dms", (endTime - startTime)));
 +            }
 +            return memberContexts;
 +        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
-         	String message = e.getFaultMessage().getUnregisteredCartridgeException().getMessage();
-         	log.error(message, e);
- 			throw new SpawningException(message, e);
++            String message = e.getFaultMessage().getUnregisteredCartridgeException().getMessage();
++            log.error(message, e);
++            throw new SpawningException(message, e);
 +        } catch (RemoteException e) {
-         	log.error(e.getMessage(), e);
++            log.error(e.getMessage(), e);
 +            throw new SpawningException(e.getMessage(), e);
- 		} catch (NonExistingKubernetesGroupException e){
++        } catch (NonExistingKubernetesGroupException e){
 +            log.error(e.getMessage(), e);
 +            throw new SpawningException(e.getMessage(), e);
 +        }
 +    }
-     
++
 +    public synchronized void terminateAllContainers(String clusterId) throws TerminationException {
 +        try {
 +            if(log.isInfoEnabled()) {
 +                log.info(String.format("Terminating containers via cloud controller: [cluster] %s", clusterId));
 +            }
 +            long startTime = System.currentTimeMillis();
 +            stub.terminateAllContainers(clusterId);
 +            if(log.isDebugEnabled()) {
 +                long endTime = System.currentTimeMillis();
 +                log.debug(String.format("Service call terminateContainer() returned in %dms", (endTime - startTime)));
 +            }
 +        } catch (RemoteException e) {
-         	String msg = e.getMessage();
++            String msg = e.getMessage();
 +            log.error(msg, e);
 +            throw new TerminationException(msg, e);
 +        } catch (CloudControllerServiceInvalidClusterExceptionException e) {
-         	String msg = e.getFaultMessage().getInvalidClusterException().getMessage();
++            String msg = e.getFaultMessage().getInvalidClusterException().getMessage();
 +            log.error(msg, e);
 +            throw new TerminationException(msg, e);
- 		} 
++        }
 +    }
 +
 +    public synchronized MemberContext[] updateContainers(String clusterId, int replicas)
-     		throws SpawningException {
++            throws SpawningException {
 +        try {
 +            log.info(String.format("Updating kubernetes replication controller via cloud controller: " +
-                                    "[cluster] %s [replicas] %s", clusterId, replicas));
++                    "[cluster] %s [replicas] %s", clusterId, replicas));
 +            MemberContext[] memberContexts = stub.updateContainers(clusterId, replicas);
 +            return memberContexts;
 +        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
 +            String msg = "Error while updating kubernetes controller, cartridge not found for [cluster] " + clusterId;
 +            log.error(msg, e);
 +            throw new SpawningException(msg, e);
 +        } catch (RemoteException e) {
 +            String msg = "Error while updating kubernetes controller, cannot communicate with " +
-                          "cloud controller service";
++                    "cloud controller service";
 +            log.error(msg, e);
 +            throw new SpawningException(msg, e);
-         } 
++        }
 +    }
-     
++
 +    public synchronized void terminateContainer(String memberId) throws TerminationException{
-     	try {
- 			stub.terminateContainer(memberId);
- 		} catch (RemoteException e) {
++        try {
++            stub.terminateContainer(memberId);
++        } catch (RemoteException e) {
 +            String msg = "Error while updating kubernetes controller, cannot communicate with " +
 +                    "cloud controller service";
 +            log.error(msg, e);
 +            throw new TerminationException(msg, e);
- 		} catch (CloudControllerServiceMemberTerminationFailedExceptionException e) {
++        } catch (CloudControllerServiceMemberTerminationFailedExceptionException e) {
 +            String msg = "Error while terminating container, member not valid for member id : " + memberId;
 +            log.error(msg, e);
 +            throw new TerminationException(msg, e);
- 		}
++        }
 +    }
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
index 2cc5fb7,74cbb56..16e809d
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
@@@ -19,10 -20,13 +20,15 @@@ package org.apache.stratos.autoscaler.i
   *
  */
  
 +package org.apache.stratos.autoscaler.interfaces;
  
+ import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
  import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.autoscaler.exception.*;
+ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+ import org.apache.stratos.autoscaler.exception.InvalidPartitionException;
+ import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
+ import org.apache.stratos.autoscaler.exception.NonExistingLBException;
  import org.apache.stratos.autoscaler.partition.PartitionGroup;
  import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
@@@ -177,16 -83,25 +183,32 @@@ public interface AutoScalerServiceInter
       * @return true if the service based LB exists in all the network partitions of this policy,
       * false if a LB couldn't find even in one network partition.
       */
 -	public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId);
 +    public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId);
  
 -    public String getDefaultLBClusterId (String deploymentPolicyName);
 +    public String getDefaultLBClusterId(String deploymentPolicyName);
  
-     public String getServiceLBClusterId(String serviceType, String deploymentPolicyName);
-     
+     public String getServiceLBClusterId (String serviceType, String deploymentPolicyName);
+ 
      /**
 +     * Dynamically update the properties of an Autoscaling Cluster Monitor
 +     * @param clusterId id of the cluster.
 +     * @param properties updated properties.
 +     */
 +    void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException;
++    
++    /**
+      * deploys an Application Definition
+      *
+      * @param applicationContext {@link org.apache.stratos.autoscaler.applications.pojo.ApplicationContext} object
+      * @throws ApplicationDefinitionException if an error is encountered
+      */
+     public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException;
+ 
+     /**
+      * undeploys an Application Definition
+      *
+      * @param applicationId Id of the Application to be undeployed
+      * @throws ApplicationDefinitionException if an error is encountered
+      */
+     public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException;
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
index 4a8b269,a946977..203d6e0
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
@@@ -21,9 -21,9 +21,10 @@@ package org.apache.stratos.autoscaler.i
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
+ import org.apache.stratos.autoscaler.applications.ApplicationSynchronizerTaskScheduler;
  import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
  import org.apache.stratos.autoscaler.exception.AutoScalerException;
 +import org.apache.stratos.autoscaler.kubernetes.KubernetesManager;
  import org.apache.stratos.autoscaler.message.receiver.health.AutoscalerHealthStatEventReceiver;
  import org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver;
  import org.apache.stratos.autoscaler.partition.PartitionManager;
@@@ -32,8 -32,8 +33,9 @@@ import org.apache.stratos.autoscaler.po
  import org.apache.stratos.autoscaler.registry.RegistryManager;
  import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 +import org.apache.stratos.common.kubernetes.KubernetesGroup;
  import org.osgi.service.component.ComponentContext;
+ import org.wso2.carbon.ntask.core.service.TaskService;
  import org.wso2.carbon.registry.api.RegistryException;
  import org.wso2.carbon.registry.core.service.RegistryService;
  
@@@ -105,19 -116,19 +110,27 @@@ public class AutoscalerServerComponent 
                  PolicyManager.getInstance().addDeploymentPolicyToInformationModel(depPolicy);
              }
  
 +            // Adding KubernetesGroups stored in registry to the information model
 +            List<KubernetesGroup> kubernetesGroupList = RegistryManager.getInstance().retrieveKubernetesGroups();
 +            Iterator<KubernetesGroup> kubernetesGroupIterator = kubernetesGroupList.iterator();
 +            while (kubernetesGroupIterator.hasNext()) {
 +                KubernetesGroup kubernetesGroup = kubernetesGroupIterator.next();
 +                KubernetesManager.getInstance().addNewKubernetesGroup(kubernetesGroup);
 +            }
 +
              if (log.isInfoEnabled()) {
+                 log.info("Scheduling tasks to publish applications");
+             }
+ 
+             ApplicationSynchronizerTaskScheduler
+                     .schedule(ServiceReferenceHolder.getInstance()
+                             .getTaskService());
+ 
+             if (log.isInfoEnabled()) {
 -                log.info("Autoscaler Server Component activated");
 +                log.info("Autoscaler server Component activated");
              }
          } catch (Throwable e) {
-             log.error("Error in activating autoscaler component", e);
+             log.error("Error in activating the autoscaler component ", e);
          }
      }
  
@@@ -145,4 -156,18 +158,18 @@@
          }
          ServiceReferenceHolder.getInstance().setRegistry(null);
      }
+ 
+     protected void setTaskService(TaskService taskService) {
+         if (log.isDebugEnabled()) {
+             log.debug("Setting the Task Service");
+         }
+         ServiceReferenceHolder.getInstance().setTaskService(taskService);
+     }
+ 
+     protected void unsetTaskService(TaskService taskService) {
+         if (log.isDebugEnabled()) {
 -            log.debug("Unsetting the Task Service");
++            log.debug("Un-setting the Task Service");
+         }
+         ServiceReferenceHolder.getInstance().setTaskService(null);
+     }
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index fedeab9,72dc6e5..f449560
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@@ -19,75 -19,40 +19,96 @@@
  
  package org.apache.stratos.autoscaler.message.receiver.topology;
  
 +import java.util.Set;
 +
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.AutoscalerContext;
 +import org.apache.stratos.autoscaler.NetworkPartitionContext;
+ import org.apache.stratos.autoscaler.*;
+ import org.apache.stratos.autoscaler.applications.ApplicationHolder;
+ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
  import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 -import org.apache.stratos.autoscaler.exception.TerminationException;
 +import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 +import org.apache.stratos.autoscaler.exception.PolicyValidationException;
  import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+ import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
+ import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
  import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher;
 +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
+ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
+ import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
  import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory;
 +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
 +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory;
 +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
 +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
 +import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 +import org.apache.stratos.messaging.domain.topology.Application;
 +import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
 +import org.apache.stratos.messaging.domain.topology.Cluster;
 +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
 +import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 +import org.apache.stratos.messaging.domain.topology.GroupStatus;
+ import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
+ import org.apache.stratos.autoscaler.partition.PartitionManager;
+ import org.apache.stratos.autoscaler.policy.PolicyManager;
+ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+ import org.apache.stratos.messaging.domain.applications.Application;
+ import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+ import org.apache.stratos.messaging.domain.applications.Applications;
+ import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+ import org.apache.stratos.messaging.domain.topology.*;
  import org.apache.stratos.messaging.event.Event;
+ import org.apache.stratos.messaging.event.topology.*;
+ import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
+ import org.apache.stratos.messaging.listener.topology.*;
+ import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 +import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
 +import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
 +import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 +import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterInactivateEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent;
 +import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent;
 +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 +import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
 +import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
 +import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
 +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent;
 +import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent;
 +import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent;
 +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
 +import org.apache.stratos.messaging.listener.topology.ApplicationActivatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ApplicationCreatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ApplicationTerminatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ApplicationTerminatingEventListener;
 +import org.apache.stratos.messaging.listener.topology.ApplicationUndeployedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterTerminatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.ClusterTerminatingEventListener;
 +import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener;
 +import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.GroupInActivateEventListener;
 +import org.apache.stratos.messaging.listener.topology.GroupTerminatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.GroupTerminatingEventListener;
 +import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener;
 +import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener;
 +import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener;
 +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener;
  import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
  import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 -
 -import java.util.List;
 -import java.util.Set;
 +import org.drools.runtime.StatefulKnowledgeSession;
 +import org.drools.runtime.rule.FactHandle;
  
  /**
   * Autoscaler topology receiver.
@@@ -135,16 -140,23 +196,22 @@@ public class AutoscalerTopologyEventRec
          topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() {
              @Override
              protected void onEvent(Event event) {
 -
                  if (!topologyInitialized) {
                      log.info("[CompleteTopologyEvent] Received: " + event.getClass());
- 
-                     TopologyManager.acquireReadLock();
+                     ApplicationHolder.acquireReadLock();
                      try {
-                         for (Application application : TopologyManager.getTopology().getApplications()) {
-                             startApplicationMonitor(application.getUniqueIdentifier());
+                         Applications applications = ApplicationHolder.getApplications();
+                         if(applications != null) {
+                             for (Application application : applications.getApplications().values()) {
+                                 if(allClustersInitialized(application)) {
+                                     startApplicationMonitor(application.getUniqueIdentifier());
+                                 } else {
+                                     log.error("Complete Topology is not consistent with the applications " +
+                                             "which got persisted");
+                                 }
+                             }
+                             topologyInitialized = true;
                          }
- 
-                         topologyInitialized = true;
                      } catch (Exception e) {
                          log.error("Error processing event", e);
                      } finally {
@@@ -209,11 -222,12 +277,12 @@@
                  log.info("[ClusterCreatedEvent] Received: " + event.getClass());
  
                  ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
-                 String clusterId = clusterCreatedEvent.getClusterId();
+                 String clusterId = clusterCreatedEvent.getCluster().getClusterId();
                  AbstractClusterMonitor clusterMonitor =
 -                        (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 +                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
  
                  //changing the status in the monitor, will notify its parent monitor
+                 clusterMonitor.setStop(true);
                  clusterMonitor.setStatus(ClusterStatus.Created);
  
              }
@@@ -617,106 -935,56 +989,69 @@@
                      TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(),
                              memberActivatedEvent.getClusterId());
                  }
-         	}
+             }
          });
-         
+ 
          topologyEventReceiver.addEventListener(new MemberMaintenanceListener() {
-         	@Override
-         	protected void onEvent(Event event) {
-         	MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event;
-             //TopologyManager.acquireReadLock();
-             TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(),
-                     memberMaintenanceModeEvent.getClusterId());
-         	try {
-         		String clusterId = memberMaintenanceModeEvent.getClusterId();
-         		AbstractClusterMonitor monitor;
-         		AutoscalerContext asCtx = AutoscalerContext.getInstance();
-         		monitor = asCtx.getClusterMonitor(clusterId);
-         		if (null == monitor) {
-         			if (log.isDebugEnabled()) {
-         				log.debug(String.format("A cluster monitor is not found in autoscaler context "
-         						+ "[cluster] %s", clusterId));
-         			}
-         			return;
-         		}
-         		monitor.handleMemberMaintenanceModeEvent(memberMaintenanceModeEvent);
-         		} catch (Exception e) {
-         			String msg = "Error processing event " + e.getLocalizedMessage();
-         			log.error(msg, e);
-         		} finally {
-                     TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(),
-                             memberMaintenanceModeEvent.getClusterId());
-                 }
-         	}
-         });
-     }
+             @Override
+             protected void onEvent(Event event) {
  
-     private class ClusterMonitorAdder implements Runnable {
-         private Cluster cluster;
+                 MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event;
  
-         public ClusterMonitorAdder(Cluster cluster) {
-             this.cluster = cluster;
-         }
+                 //TopologyManager.acquireReadLock();
+                 TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(),
+                         memberMaintenanceModeEvent.getClusterId());
  
-         public void run() {
-             AbstractClusterMonitor monitor = null;
-             int retries = 5;
-             boolean success = false;
-             do {
                  try {
-                     Thread.sleep(5000);
-                 } catch (InterruptedException e1) {
-                 }
  
-                 try {
-                     monitor = ClusterMonitorFactory.getMonitor(cluster);
-                     success = true;
-                 } catch (PolicyValidationException e) {
-                     if (log.isDebugEnabled()) {
-                         String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId();
-                         log.debug(msg, e);
+                     String memberId = memberMaintenanceModeEvent.getMemberId();
+                     String partitionId = memberMaintenanceModeEvent.getPartitionId();
+                     String networkPartitionId = memberMaintenanceModeEvent.getNetworkPartitionId();
+ 
+                     PartitionContext partitionContext;
+                     String clusterId = memberMaintenanceModeEvent.getClusterId();
+                     AbstractClusterMonitor monitor;
+ 
+                     if (AutoscalerContext.getInstance().monitorExist(clusterId)) {
+                         monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
+                         partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).
+                                 getPartitionCtxt(partitionId);
+                     } else {
+                         monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId);
+                         partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).
+                                 getPartitionCtxt(partitionId);
                      }
-                     retries--;
-                 } catch (PartitionValidationException e) {
+                     partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
                      if (log.isDebugEnabled()) {
-                         String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId();
-                         log.debug(msg, e);
+                         log.debug(String.format("Member has been moved as pending termination: " +
+                                 "[member] %s", memberId));
                      }
-                     retries--;
-                 }
-             } while (!success && retries != 0);
+                     partitionContext.moveActiveMemberToTerminationPendingMembers(memberId);
  
-             if (monitor == null) {
-                 String msg = "Cluster monitor creation failed, even after retrying for 5 times, "
-                              + "for cluster: " + cluster.getClusterId();
-                 log.error(msg);
-                 throw new RuntimeException(msg);
-             }
- 
- //            Thread th = new Thread(monitor);
- //            th.start();
-             monitor.startScheduler();
-             AutoscalerContext.getInstance().addClusterMonitor(monitor);
-             if (log.isInfoEnabled()) {
-                 log.info(String.format("Cluster monitor has been added successfully: [cluster] %s",
-                                        cluster.getClusterId()));
+                 } catch (Exception e) {
+                     log.error("Error processing event", e);
+                 } finally {
+                     //TopologyManager.releaseReadLock();
+                     TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(),
+                             memberMaintenanceModeEvent.getClusterId());
+                 }
              }
-         }
+         });
      }
  
 +    @SuppressWarnings("unused")
 +    private void runTerminateAllRule(VMClusterMonitor monitor) {
 +
 +        FactHandle terminateAllFactHandle = null;
 +
 +        StatefulKnowledgeSession terminateAllKnowledgeSession = null;
 +
 +        for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
 +            terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll(terminateAllKnowledgeSession
 +                    , terminateAllFactHandle, networkPartitionContext);
 +        }
 +
 +    }
  
      /**
       * Terminate load balancer topology receiver thread.

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 0000000,ac0871d..fb23985
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@@ -1,0 -1,287 +1,277 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  * 
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied.  See the License for the 
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ package org.apache.stratos.autoscaler.monitor;
+ 
+ import org.apache.commons.configuration.XMLConfiguration;
+ import org.apache.commons.logging.Log;
+ import org.apache.commons.logging.LogFactory;
+ import org.apache.stratos.autoscaler.NetworkPartitionContext;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
+ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
+ import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
+ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
+ import org.apache.stratos.autoscaler.util.AutoScalerConstants;
+ import org.apache.stratos.autoscaler.util.ConfUtil;
+ import org.apache.stratos.messaging.domain.topology.*;
+ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+ import org.drools.runtime.StatefulKnowledgeSession;
+ import org.drools.runtime.rule.FactHandle;
+ 
+ import java.util.Map;
+ 
+ /**
+  * Is responsible for monitoring a service cluster. This runs periodically
+  * and perform minimum instance check and scaling check using the underlying
+  * rules engine.
+  */
+ abstract public class AbstractClusterMonitor extends Monitor implements Runnable {
+ 
+     private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class);
+     // Map<NetworkpartitionId, Network Partition Context>
+     protected Map<String, NetworkPartitionContext> networkPartitionCtxts;
+     protected DeploymentPolicy deploymentPolicy;
+     protected AutoscalePolicy autoscalePolicy;
+ 
+ 
+     protected FactHandle minCheckFactHandle;
+     protected FactHandle scaleCheckFactHandle;
+     protected FactHandle terminateDependencyFactHandle;
+     protected FactHandle terminateAllFactHandle;
+ 
+     protected StatefulKnowledgeSession minCheckKnowledgeSession;
+     protected StatefulKnowledgeSession scaleCheckKnowledgeSession;
+     protected StatefulKnowledgeSession terminateAllKnowledgeSession;
+     protected boolean isDestroyed;
+ 
+     protected String clusterId;
+     protected String serviceId;
++    protected String appId;
+ 
+     protected boolean hasFaultyMember = false;
+ 
 -    protected boolean stop = false;
 -
+     protected ClusterStatus status;
+ 
+     //protected ParentComponentMonitor parent;
+ 
+     protected AutoscalerRuleEvaluator autoscalerRuleEvaluator;
+ 
+     // time intereval between two runs of the Monitor. Default is 90000ms.
+     protected int monitorInterval;
+ 
+     public AbstractClusterMonitor() {
+         readConfigurations();
+         status = ClusterStatus.Created;
+     }
+ 
+     private void readConfigurations() {
+ 
+         XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
+         monitorInterval = conf.getInt(AutoScalerConstants.AUTOSCALER_MONITOR_INTERVAL, 90000);
+         if (log.isDebugEnabled()) {
+             log.debug("Cluster Monitor task interval: " + getMonitorInterval());
+         }
+     }
+ 
+     @Override
+     public void run() {
+         // TODO Auto-generated method stub
+     }
+ 
+ 
+     public NetworkPartitionContext getNetworkPartitionCtxt(Member member) {
+         log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId());
+         String networkPartitionId = member.getNetworkPartitionId();
+         if (networkPartitionCtxts.containsKey(networkPartitionId)) {
+             log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId));
+             return networkPartitionCtxts.get(networkPartitionId);
+         }
+         log.info("returning null getNetworkPartitionCtxt");
+         return null;
+     }
+ 
+     public String getPartitionOfMember(String memberId) {
+         for (Service service : TopologyManager.getTopology().getServices()) {
+             for (Cluster cluster : service.getClusters()) {
+                 if (cluster.memberExists(memberId)) {
+                     return cluster.getMember(memberId).getPartitionId();
+                 }
+             }
+         }
+         return null;
+     }
+ 
+     public void destroy() {
+         minCheckKnowledgeSession.dispose();
+         scaleCheckKnowledgeSession.dispose();
+         terminateAllKnowledgeSession.dispose();
+         setDestroyed(true);
+         if (log.isDebugEnabled()) {
+             log.debug("Cluster Monitor Drools session has been disposed. " + this.toString());
+         }
+     }
+ 
+     public abstract void terminateAllMembers ();
+ 
+     public boolean isDestroyed() {
+         return isDestroyed;
+     }
+ 
+     public void setDestroyed(boolean isDestroyed) {
+         this.isDestroyed = isDestroyed;
+     }
+ 
+     public String getServiceId() {
+         return serviceId;
+     }
+ 
+     public void setServiceId(String serviceId) {
+         this.serviceId = serviceId;
+     }
+ 
+     public DeploymentPolicy getDeploymentPolicy() {
+         return deploymentPolicy;
+     }
+ 
+     public void setDeploymentPolicy(DeploymentPolicy deploymentPolicy) {
+         this.deploymentPolicy = deploymentPolicy;
+     }
+ 
+     public AutoscalePolicy getAutoscalePolicy() {
+         return autoscalePolicy;
+     }
+ 
+     public void setAutoscalePolicy(AutoscalePolicy autoscalePolicy) {
+         this.autoscalePolicy = autoscalePolicy;
+     }
+ 
+     public String getClusterId() {
+         return clusterId;
+     }
+ 
+     public void setClusterId(String clusterId) {
+         this.clusterId = clusterId;
+     }
+ 
+     public String getAppId() {
+         return appId;
+     }
+ 
+     public void setAppId(String appId) {
+         this.appId = appId;
+     }
+ 
+     public Map<String, NetworkPartitionContext> getNetworkPartitionCtxts() {
+         return networkPartitionCtxts;
+     }
+ 
+     public NetworkPartitionContext getNetworkPartitionCtxt(String networkPartitionId) {
+         return networkPartitionCtxts.get(networkPartitionId);
+     }
+ 
+     public void setPartitionCtxt(Map<String, NetworkPartitionContext> partitionCtxt) {
+         this.networkPartitionCtxts = partitionCtxt;
+     }
+ 
+     public boolean partitionCtxtAvailable(String partitionId) {
+         return networkPartitionCtxts.containsKey(partitionId);
+     }
+ 
+     public void addNetworkPartitionCtxt(NetworkPartitionContext ctxt) {
+         this.networkPartitionCtxts.put(ctxt.getId(), ctxt);
+     }
+ 
+     public NetworkPartitionContext getPartitionCtxt(String id) {
+         return this.networkPartitionCtxts.get(id);
+     }
+ 
+     public StatefulKnowledgeSession getMinCheckKnowledgeSession() {
+         return minCheckKnowledgeSession;
+     }
+ 
+     public void setMinCheckKnowledgeSession(StatefulKnowledgeSession minCheckKnowledgeSession) {
+         this.minCheckKnowledgeSession = minCheckKnowledgeSession;
+     }
+ 
+     public FactHandle getMinCheckFactHandle() {
+         return minCheckFactHandle;
+     }
+ 
+     public void setMinCheckFactHandle(FactHandle minCheckFactHandle) {
+         this.minCheckFactHandle = minCheckFactHandle;
+     }
+ 
+ 
+     public int getMonitorInterval() {
+         return monitorInterval;
+     }
+ 
+     public ClusterStatus getStatus() {
+         return status;
+     }
+ 
+     public void setStatus(ClusterStatus status) {
+ 
+         //if(this.status != status) {
+             this.status = status;
+             /**
+              * notifying the parent monitor about the state change
+              * If the cluster in_active and if it is a in_dependent cluster,
+              * then won't send the notification to parent.
+              */
+             if (status == ClusterStatus.Inactive && !this.hasDependent) {
+                 log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
+                         "since it is identified as the independent unit");
+ 
 -            /*} else if (status == ClusterStatus.Terminating) {
++            } else if (status == ClusterStatus.Terminating) {
+                 // notify parent
+                 log.info("[Cluster] " + clusterId + " is not notifying the parent, " +
+                         "since it is in Terminating State");
 -*/
++
+             } else {
 -                log.info("[Group] " + this.id + "is notifying the [parent] " + this.parent.getId());
+                 MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
+             }
+         //}
+ 
+     }
+ 
+     @Override
+     public void onChildEvent(MonitorStatusEvent statusEvent) {
+ 
+     }
+ 
+     @Override
+     public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
+ 
+     }
+ 
+     @Override
+     public void onEvent(MonitorScalingEvent scalingEvent) {
+ 
+     }
+ 
+     public boolean isHasFaultyMember() {
+         return hasFaultyMember;
+     }
+ 
+     public void setHasFaultyMember(boolean hasFaultyMember) {
+         this.hasFaultyMember = hasFaultyMember;
+     }
 -
 -    public boolean isStop() {
 -        return stop;
 -    }
 -
 -    public void setStop(boolean stop) {
 -        this.stop = stop;
 -    }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
index bc23dd4,0000000..7f3de58
mode 100644,000000..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
@@@ -1,225 -1,0 +1,246 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *  http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.stratos.autoscaler.monitor.application;
 +
 +import org.apache.commons.logging.Log;
 +import org.apache.commons.logging.LogFactory;
++import org.apache.stratos.autoscaler.AutoscalerContext;
++import org.apache.stratos.autoscaler.MemberStatsContext;
++import org.apache.stratos.autoscaler.NetworkPartitionContext;
++import org.apache.stratos.autoscaler.PartitionContext;
++import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
++import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 +import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 +import org.apache.stratos.autoscaler.exception.PolicyValidationException;
 +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
++import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
++import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext;
++import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext;
++import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
++import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
 +import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext;
 +import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext;
 +import org.apache.stratos.autoscaler.monitor.Monitor;
 +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
 +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
 +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory;
 +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
 +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
++import org.apache.stratos.autoscaler.partition.PartitionGroup;
++import org.apache.stratos.autoscaler.policy.PolicyManager;
++import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
++import org.apache.stratos.autoscaler.status.checker.StatusChecker;
++import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
++import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 +import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 +import org.apache.stratos.cloud.controller.stub.pojo.Property;
++import org.apache.stratos.messaging.domain.applications.Application;
++import org.apache.stratos.messaging.domain.applications.Group;
 +import org.apache.stratos.messaging.domain.topology.*;
++import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
++import org.apache.stratos.messaging.util.Constants;
 +
 +import java.util.Map;
 +
 +/**
 + * Factory class to get the Monitors.
 + */
 +public class ApplicationMonitorFactory {
 +    private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class);
 +
 +    /**
 +     * Factor method used to create relevant monitors based on the given context
 +     *
 +     * @param context       Application/Group/Cluster context
 +     * @param appId         appId of the application which requires to create app monitor
 +     * @param parentMonitor parent of the monitor
 +     * @return Monitor which can be ApplicationMonitor/GroupMonitor/ClusterMonitor
 +     * @throws TopologyInConsistentException throws while traversing thr topology
 +     * @throws DependencyBuilderException    throws while building dependency for app monitor
 +     * @throws PolicyValidationException     throws while validating the policy associated with cluster
 +     * @throws PartitionValidationException  throws while validating the partition used in a cluster
 +     */
 +    public static Monitor getMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId)
 +            throws TopologyInConsistentException,
 +            DependencyBuilderException, PolicyValidationException, PartitionValidationException {
 +        Monitor monitor;
 +
 +        if (context instanceof GroupContext) {
 +            monitor = getGroupMonitor(parentMonitor, context, appId);
 +        } else if (context instanceof ClusterContext) {
 +            monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId);
 +            //Start the thread
 +            Thread th = new Thread((AbstractClusterMonitor) monitor);
 +            th.start();
 +        } else {
 +            monitor = getApplicationMonitor(appId);
 +        }
 +        return monitor;
 +    }
 +
 +    /**
 +     * This will create the GroupMonitor based on given groupId by going thr Topology
 +     *
 +     * @param parentMonitor parent of the monitor
 +     * @param context       groupId of the group
 +     * @param appId         appId of the relevant application
 +     * @return Group monitor
 +     * @throws DependencyBuilderException    throws while building dependency for app monitor
 +     * @throws TopologyInConsistentException throws while traversing thr topology
 +     */
 +    public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId)
 +            throws DependencyBuilderException,
 +            TopologyInConsistentException {
 +        GroupMonitor groupMonitor;
-         TopologyManager.acquireReadLockForApplication(appId);
++        ApplicationManager.acquireReadLockForApplication(appId);
 +
 +        try {
-             Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(context.getId());
++            Group group = ApplicationManager.getApplications().getApplication(appId).getGroupRecursively(context.getId());
 +            groupMonitor = new GroupMonitor(group, appId);
 +            groupMonitor.setAppId(appId);
 +            if(parentMonitor != null) {
 +                groupMonitor.setParent(parentMonitor);
 +                //Setting the dependent behaviour of the monitor
 +                if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) {
 +                    groupMonitor.setHasDependent(true);
 +                } else {
 +                    groupMonitor.setHasDependent(false);
 +                }
 +                //TODO make sure when it is async
 +
 +                if (group.getStatus() != groupMonitor.getStatus()) {
 +                    //updating the status, if the group is not in created state when creating group Monitor
 +                    //so that groupMonitor will notify the parent (useful when restarting stratos)
 +                    groupMonitor.setStatus(group.getStatus());
 +                }
 +            }
 +
 +        } finally {
-             TopologyManager.releaseReadLockForApplication(appId);
++            ApplicationManager.releaseReadLockForApplication(appId);
 +
 +        }
 +        return groupMonitor;
 +
 +    }
 +
 +    /**
 +     * This will create a new app monitor based on the give appId by getting the
 +     * application from Topology
 +     *
 +     * @param appId appId of the application which requires to create app monitor
 +     * @return ApplicationMonitor
 +     * @throws DependencyBuilderException    throws while building dependency for app monitor
 +     * @throws TopologyInConsistentException throws while traversing thr topology
 +     */
 +    public static ApplicationMonitor getApplicationMonitor(String appId)
 +            throws DependencyBuilderException,
 +            TopologyInConsistentException {
 +        ApplicationMonitor applicationMonitor;
-         TopologyManager.acquireReadLockForApplication(appId);
++        ApplicationManager.acquireReadLockForApplication(appId);
 +        try {
-             Application application = TopologyManager.getTopology().getApplication(appId);
++            Application application = ApplicationManager.getApplications().getApplication(appId);
 +            if (application != null) {
 +                applicationMonitor = new ApplicationMonitor(application);
 +                applicationMonitor.setHasDependent(false);
 +
 +            } else {
 +                String msg = "[Application] " + appId + " cannot be found in the Topology";
 +                throw new TopologyInConsistentException(msg);
 +            }
 +        } finally {
-             TopologyManager.releaseReadLockForApplication(appId);
++            ApplicationManager.releaseReadLockForApplication(appId);
 +        }
 +
 +        return applicationMonitor;
 +
 +    }
 +
 +    /**
 +     * Updates ClusterContext for given cluster
 +     *
 +     * @param parentMonitor parent of the monitor
 +     * @param context
 +     * @return ClusterMonitor - Updated ClusterContext
 +     * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException
 +     * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException
 +     */
 +    public static VMClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor,
 +                                                   ClusterContext context, String appId)
 +            throws PolicyValidationException,
 +            PartitionValidationException,
 +            TopologyInConsistentException {
 +        //Retrieving the Cluster from Topology
 +        String clusterId = context.getId();
 +        String serviceName = context.getServiceName();
 +
 +        Cluster cluster;
 +        AbstractClusterMonitor clusterMonitor;
 +        //acquire read lock for the service and cluster
 +        TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
 +        try {
 +            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);
 +                    //context.setCurrentStatus(Status.Created);
 +                } else {
 +                    String msg = "[Cluster] " + clusterId + " cannot be found in the " +
 +                            "Topology for [service] " + serviceName;
 +                    throw new TopologyInConsistentException(msg);
 +                }
 +            } else {
 +                String msg = "[Service] " + serviceName + " cannot be found in the Topology";
 +                throw new TopologyInConsistentException(msg);
 +
 +            }
 +
 +
 +            clusterMonitor = ClusterMonitorFactory.getMonitor(cluster);
 +            if (clusterMonitor instanceof VMClusterMonitor) {
 +                return (VMClusterMonitor) clusterMonitor;
 +            } else if (clusterMonitor != null) {
 +                log.warn("Unknown cluster monitor found: " + clusterMonitor.getClass().toString());
 +            }
 +            return null;
 +        } finally {
 +            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
 +        }
 +    }
 +
 +
 +    private static Properties convertMemberPropsToMemberContextProps(
 +            java.util.Properties properties) {
 +        Properties props = new Properties();
 +        for (Map.Entry<Object, Object> e : properties.entrySet()) {
 +            Property prop = new Property();
 +            prop.setName((String) e.getKey());
 +            prop.setValue((String) e.getValue());
 +            props.addProperties(prop);
 +        }
 +        return props;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java
index 9d0f134,0000000..dc97dc7
mode 100644,000000..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java
@@@ -1,235 -1,0 +1,326 @@@
 +/*
-  * Licensed to the Apache Software Foundation (ASF) under one 
++ * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
-  * 
++ *
 + *  http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
-  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
-  * KIND, either express or implied.  See the License for the 
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.stratos.autoscaler.monitor.cluster;
 +
 +import java.util.ArrayList;
 +import java.util.List;
 +import java.util.concurrent.ConcurrentHashMap;
 +
 +import org.apache.commons.configuration.XMLConfiguration;
 +import org.apache.commons.logging.Log;
 +import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.NetworkPartitionContext;
 +import org.apache.stratos.autoscaler.PartitionContext;
 +import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
++import org.apache.stratos.autoscaler.exception.TerminationException;
++import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
++import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
++import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 +import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 +import org.apache.stratos.autoscaler.util.AutoScalerConstants;
 +import org.apache.stratos.autoscaler.util.ConfUtil;
 +import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 +import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 +import org.apache.stratos.cloud.controller.stub.pojo.Property;
++import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 +import org.apache.stratos.common.constants.StratosConstants;
 +import org.apache.stratos.messaging.domain.topology.ClusterStatus;
++import org.apache.stratos.messaging.domain.applications.GroupStatus;
 +
 +/**
 + * Is responsible for monitoring a service cluster. This runs periodically
 + * and perform minimum instance check and scaling check using the underlying
 + * rules engine.
 + */
 +public class VMServiceClusterMonitor extends VMClusterMonitor {
 +
 +    private static final Log log = LogFactory.getLog(VMServiceClusterMonitor.class);
 +    private String lbReferenceType;
 +    private boolean hasPrimary;
 +
 +    public VMServiceClusterMonitor(String clusterId, String serviceId,
 +                                   DeploymentPolicy deploymentPolicy,
 +                                   AutoscalePolicy autoscalePolicy) {
 +        super(clusterId, serviceId,
 +              new AutoscalerRuleEvaluator(StratosConstants.VM_MIN_CHECK_DROOL_FILE,
 +                                          StratosConstants.VM_SCALE_CHECK_DROOL_FILE),
 +              deploymentPolicy, autoscalePolicy,
 +              new ConcurrentHashMap<String, NetworkPartitionContext>());
 +        readConfigurations();
 +    }
 +
++    private static void terminateMember(String memberId) {
++        try {
++            CloudControllerClient.getInstance().terminate(memberId);
++
++        } catch (TerminationException e) {
++            log.error("Unable to terminate member [member id ] " + memberId, e);
++        }
++    }
++
 +    @Override
 +    public void run() {
 +        while (!isDestroyed()) {
 +            try {
 +                if ((this.status.getCode() <= ClusterStatus.Active.getCode()) ||
 +                        (this.status == ClusterStatus.Inactive && !hasDependent) ||
 +                        !this.hasFaultyMember) {
 +                    if (log.isDebugEnabled()) {
 +                        log.debug("Cluster monitor is running.. " + this.toString());
 +                    }
 +                    monitor();
 +                } else {
 +                    if (log.isDebugEnabled()) {
 +                        log.debug("Cluster monitor is suspended as the cluster is in " +
 +                                ClusterStatus.Inactive + " mode......");
 +                    }
 +                }
 +            } catch (Exception e) {
 +                log.error("Cluster monitor: Monitor failed." + this.toString(), e);
 +            }
 +            try {
-                 Thread.sleep(getMonitorIntervalMilliseconds());
++                Thread.sleep(monitorInterval);
 +            } catch (InterruptedException ignore) {
 +            }
 +        }
++
++
 +    }
 +
 +    @Override
-     protected void monitor() {
++    public void terminateAllMembers() {
++
++        Thread memberTerminator = new Thread(new Runnable() {
++            public void run() {
++
++                for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) {
++                    for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
++                        //if (log.isDebugEnabled()) {
++                        log.info("Starting to terminate all members in Network Partition [ " +
++                                networkPartitionContext.getId() + " ], Partition [ " +
++                                partitionContext.getPartitionId() + " ]");
++                        // }
++                        // need to terminate active, pending and obsolete members
++
++                        // active members
++                        for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) {
++                            log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId());
++                            terminateMember(activeMemberCtxt.getMemberId());
++                        }
++
++                        // pending members
++                        for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) {
++                            log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId());
++                            terminateMember(pendingMemberCtxt.getMemberId());
++                        }
++
++                        // obsolete members
++                        for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) {
++                            log.info("Terminating obsolete member [member id] " + obsoleteMemberId);
++                            terminateMember(obsoleteMemberId);
++                        }
++
++//                terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll
++//                        (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext);
++                    }
++                }
++            }
++        }, "Member Terminator - [cluster id] " + this.clusterId);
++
++        memberTerminator.start();
++    }
++
++    private boolean isPrimaryMember(MemberContext memberContext) {
++        Properties props = memberContext.getProperties();
++        if (log.isDebugEnabled()) {
++            log.debug(" Properties [" + props + "] ");
++        }
++        if (props != null && props.getProperties() != null) {
++            for (Property prop : props.getProperties()) {
++                if (prop.getName().equals("PRIMARY")) {
++                    if (Boolean.parseBoolean(prop.getValue())) {
++                        log.debug("Adding member id [" + memberContext.getMemberId() + "] " +
++                                "member instance id [" + memberContext.getInstanceId() + "] as a primary member");
++                        return true;
++                    }
++                }
++            }
++        }
++        return false;
++    }
 +
++    public void monitor() {
 +        //TODO make this concurrent
++
 +        for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) {
 +            // store primary members in the network partition context
 +            List<String> primaryMemberListInNetworkPartition = new ArrayList<String>();
- 
 +            //minimum check per partition
 +            for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
 +                // store primary members in the partition context
 +                List<String> primaryMemberListInPartition = new ArrayList<String>();
 +                // get active primary members in this partition context
 +                for (MemberContext memberContext : partitionContext.getActiveMembers()) {
 +                    if (isPrimaryMember(memberContext)) {
 +                        primaryMemberListInPartition.add(memberContext.getMemberId());
 +                    }
 +                }
++
 +                // get pending primary members in this partition context
 +                for (MemberContext memberContext : partitionContext.getPendingMembers()) {
 +                    if (isPrimaryMember(memberContext)) {
 +                        primaryMemberListInPartition.add(memberContext.getMemberId());
 +                    }
 +                }
 +                primaryMemberListInNetworkPartition.addAll(primaryMemberListInPartition);
-                 getMinCheckKnowledgeSession().setGlobal("clusterId", getClusterId());
-                 getMinCheckKnowledgeSession().setGlobal("lbRef", lbReferenceType);
-                 getMinCheckKnowledgeSession().setGlobal("isPrimary", hasPrimary);
-                 getMinCheckKnowledgeSession().setGlobal("primaryMemberCount", primaryMemberListInPartition.size());
++                minCheckKnowledgeSession.setGlobal("clusterId", clusterId);
++                minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType);
++                minCheckKnowledgeSession.setGlobal("isPrimary", hasPrimary);
++
 +
 +                if (log.isDebugEnabled()) {
 +                    log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId()));
 +                }
 +
-                 minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(getMinCheckKnowledgeSession()
++                minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession
 +                        , minCheckFactHandle, partitionContext);
 +
++                //checking the status of the cluster
++
++
 +            }
 +
-             boolean rifReset = networkPartitionContext.isRifReset();
++        	/*boolean rifReset = networkPartitionContext.isRifReset();
 +            boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset();
 +            boolean loadAverageReset = networkPartitionContext.isLoadAverageReset();
++
 +            if (log.isDebugEnabled()) {
 +                log.debug("flag of rifReset: " + rifReset + " flag of memoryConsumptionReset" + memoryConsumptionReset
-                           + " flag of loadAverageReset" + loadAverageReset);
++                        + " flag of loadAverageReset" + loadAverageReset);
 +            }
 +            if (rifReset || memoryConsumptionReset || loadAverageReset) {
-                 getScaleCheckKnowledgeSession().setGlobal("clusterId", getClusterId());
++
++                scaleCheckKnowledgeSession.setGlobal("clusterId", clusterId);
 +                //scaleCheckKnowledgeSession.setGlobal("deploymentPolicy", deploymentPolicy);
-                 getScaleCheckKnowledgeSession().setGlobal("autoscalePolicy", autoscalePolicy);
-                 getScaleCheckKnowledgeSession().setGlobal("rifReset", rifReset);
-                 getScaleCheckKnowledgeSession().setGlobal("mcReset", memoryConsumptionReset);
-                 getScaleCheckKnowledgeSession().setGlobal("laReset", loadAverageReset);
-                 getScaleCheckKnowledgeSession().setGlobal("lbRef", lbReferenceType);
-                 getScaleCheckKnowledgeSession().setGlobal("isPrimary", false);
-                 getScaleCheckKnowledgeSession().setGlobal("primaryMembers", primaryMemberListInNetworkPartition);
++                scaleCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy);
++                scaleCheckKnowledgeSession.setGlobal("rifReset", rifReset);
++                scaleCheckKnowledgeSession.setGlobal("mcReset", memoryConsumptionReset);
++                scaleCheckKnowledgeSession.setGlobal("laReset", loadAverageReset);
++                scaleCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType);
++                scaleCheckKnowledgeSession.setGlobal("isPrimary", false);
++                scaleCheckKnowledgeSession.setGlobal("primaryMembers", primaryMemberListInNetworkPartition);
 +
 +                if (log.isDebugEnabled()) {
 +                    log.debug(String.format("Running scale check for network partition %s ", networkPartitionContext.getId()));
 +                    log.debug(" Primary members : " + primaryMemberListInNetworkPartition);
 +                }
 +
-                 scaleCheckFactHandle = AutoscalerRuleEvaluator.evaluateScaleCheck(getScaleCheckKnowledgeSession()
++                scaleCheckFactHandle = AutoscalerRuleEvaluator.evaluateScaleCheck(scaleCheckKnowledgeSession
 +                        , scaleCheckFactHandle, networkPartitionContext);
 +
 +                networkPartitionContext.setRifReset(false);
 +                networkPartitionContext.setMemoryConsumptionReset(false);
 +                networkPartitionContext.setLoadAverageReset(false);
 +            } else if (log.isDebugEnabled()) {
 +                log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " +
-                                         "cycle for network partition %s", networkPartitionContext.getId()));
-             }
++                        "cycle for network partition %s", networkPartitionContext.getId()));
++            }*/
 +        }
 +    }
 +
 +    private boolean isPrimaryMember(MemberContext memberContext) {
 +        Properties props = memberContext.getProperties();
 +        if (log.isDebugEnabled()) {
 +            log.debug(" Properties [" + props + "] ");
 +        }
 +        if (props != null && props.getProperties() != null) {
 +            for (Property prop : props.getProperties()) {
 +                if (prop.getName().equals("PRIMARY")) {
 +                    if (Boolean.parseBoolean(prop.getValue())) {
 +                        log.debug("Adding member id [" + memberContext.getMemberId() + "] " +
 +                                  "member instance id [" + memberContext.getInstanceId() + "] as a primary member");
 +                        return true;
 +                    }
 +                }
 +            }
 +        }
 +        return false;
 +    }
 +
 +    @Override
 +    protected void readConfigurations() {
 +        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
 +        int monitorInterval = conf.getInt(AutoScalerConstants.VMService_Cluster_MONITOR_INTERVAL, 90000);
 +        setMonitorIntervalMilliseconds(monitorInterval);
 +        if (log.isDebugEnabled()) {
 +            log.debug("VMServiceClusterMonitor task interval set to : " + getMonitorIntervalMilliseconds());
 +        }
 +    }
 +
 +    @Override
 +    public void destroy() {
 +        getMinCheckKnowledgeSession().dispose();
 +        getScaleCheckKnowledgeSession().dispose();
 +        setDestroyed(true);
 +        stopScheduler();
 +        if (log.isDebugEnabled()) {
 +            log.debug("VMServiceClusterMonitor Drools session has been disposed. " + this.toString());
 +        }
 +    }
 +
 +    @Override
 +    public String toString() {
 +        return "VMServiceClusterMonitor [clusterId=" + getClusterId() + ", serviceId=" + getServiceId() +
 +               ", deploymentPolicy=" + deploymentPolicy + ", autoscalePolicy=" + autoscalePolicy +
 +               ", lbReferenceType=" + lbReferenceType +
 +               ", hasPrimary=" + hasPrimary + " ]";
 +    }
 +
 +    public String getLbReferenceType() {
 +        return lbReferenceType;
 +    }
 +
 +    public void setLbReferenceType(String lbReferenceType) {
 +        this.lbReferenceType = lbReferenceType;
 +    }
 +
 +    public boolean isHasPrimary() {
 +        return hasPrimary;
 +    }
 +
 +    public void setHasPrimary(boolean hasPrimary) {
 +        this.hasPrimary = hasPrimary;
 +    }
 +
 +    @Override
-     public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException {
-         // TODO 
-         
++    public void onChildEvent(MonitorStatusEvent statusEvent) {
++
++    }
++
++    @Override
++    public void onParentEvent(MonitorStatusEvent statusEvent) {
++        // send the ClusterTerminating event
++        if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
++                ApplicationStatus.Terminating) {
++            ClusterStatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId);
++        }
 +    }
 +}


[11/50] [abbrv] renaming application.status topic to applications

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
new file mode 100644
index 0000000..9520f4e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppClusterTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppClusterTerminatingMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(AppClusterTerminatingMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppClusterTerminatingEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppClusterTerminatingEvent event = (AppClusterTerminatingEvent) Util.
+                                                jsonToObject(message, AppClusterTerminatingEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
new file mode 100644
index 0000000..1524b00
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.listener.application.status.*;
+import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
+
+/**
+ * Application Status processor chain is to handle the list processors to parse the application
+ * status.
+ */
+public class AppStatusMessageProcessorChain extends MessageProcessorChain {
+    private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
+
+    private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
+    private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
+    private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
+    private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
+    private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
+    private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor;
+    private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
+    private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor;
+    private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor;
+    private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
+    private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
+    private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
+    private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
+
+    private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
+    private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
+
+    public void initialize() {
+        // Add instance notifier event processors
+        clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor();
+        add(clusterCreatedMessageProcessor);
+
+        clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor();
+        add(clusterActivatedMessageProcessor);
+
+        clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor();
+        add(clusterInActivateMessageProcessor);
+
+        clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
+        add(clusterTerminatingMessageProcessor);
+
+        clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
+        add(clusterTerminatedMessageProcessor);
+
+        groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor();
+        add(groupCreatedMessageProcessor);
+
+        groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor();
+        add(groupActivatedMessageProcessor);
+
+        groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor();
+        add(groupInActivateMessageProcessor);
+
+        appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor();
+        add(appActivatedMessageProcessor);
+
+        applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor();
+        this.add(applicationStatusAppCreatedMessageProcessor);
+
+        applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor();
+        this.add(applicationStatusAppInActivatedMessageProcessor);
+
+        applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor();
+        this.add(applicationStatusAppTerminatedMessageProcessor);
+
+        applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor();
+        this.add(applicationStatusAppTerminatingMessageProcessor);
+
+        groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor();
+        this.add(groupTerminatedMessageProcessor);
+
+        groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor();
+        this.add(groupTerminatingMessageProcessor);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Instance notifier message processor chain initialized");
+        }
+    }
+
+    public void addEventListener(EventListener eventListener) {
+        if(eventListener instanceof AppStatusClusterCreatedEventListener) {
+            clusterCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusClusterActivatedEventListener) {
+            clusterActivatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusClusterInactivateEventListener) {
+            clusterInActivateMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusGroupCreatedEventListener) {
+            groupCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusGroupActivatedEventListener) {
+            groupActivatedMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){
+            clusterTerminatedMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){
+            clusterTerminatingMessageProcessor.addEventListener(eventListener);
+        }else if (eventListener instanceof AppStatusGroupInactivateEventListener) {
+            groupInActivateMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) {
+            appActivatedMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){
+            applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){
+            applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){
+            applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){
+            applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){
+            groupTerminatingMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){
+            groupTerminatedMessageProcessor.addEventListener(eventListener);
+        } else
+        {
+            throw new RuntimeException("Unknown event listener " + eventListener.toString());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
new file mode 100644
index 0000000..71bd50e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class ApplicationActivatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(ApplicationActivatedMessageProcessor.class);
+
+
+    private MessageProcessor nextProcessor;
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ApplicationActivatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ApplicationActivatedEvent event =
+                    (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
new file mode 100644
index 0000000..db5d777
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class ApplicationCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
+
+
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ApplicationCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ApplicationCreatedEvent event =
+                    (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
new file mode 100644
index 0000000..d8f2aac
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(ApplicationInactivatedMessageProcessor.class);
+
+
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ApplicationInactivatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ApplicationInactivatedEvent event =
+                    (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
new file mode 100644
index 0000000..a121ffb
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(ApplicationTerminatedMessageProcessor.class);
+
+
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ApplicationTerminatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ApplicationTerminatedEvent event =
+                    (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
new file mode 100644
index 0000000..280de2c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(ApplicationTerminatingMessageProcessor.class);
+
+
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ApplicationTerminatingEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ApplicationTerminatingEvent event =
+                    (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
new file mode 100644
index 0000000..02ddda8
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class GroupActivatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(GroupActivatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (GroupActivatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            GroupActivatedEvent event =
+                    (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received GroupActivatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
new file mode 100644
index 0000000..d04d7f9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class GroupCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(GroupCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (GroupCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            GroupCreatedEvent event =
+                    (GroupCreatedEvent) Util.jsonToObject(message, GroupCreatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received AppStatusGroupCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group created message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
new file mode 100644
index 0000000..6cf2587
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class GroupInactivatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(GroupInactivatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (AppStatusGroupInactivateEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            AppStatusGroupInactivateEvent event =
+                    (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received GroupInActivateEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group in activated message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
new file mode 100644
index 0000000..a917a14
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class GroupTerminatedMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(GroupTerminatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (GroupTerminatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            GroupTerminatedEvent event =
+                    (GroupTerminatedEvent) Util.jsonToObject(message, GroupTerminatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received GroupTerminatingEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group in GroupTerminatingEvent message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f0ba4beb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
new file mode 100644
index 0000000..63c055d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class GroupTerminatingMessageProcessor extends MessageProcessor {
+    private static final Log log =
+            LogFactory.getLog(GroupTerminatingMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (GroupTerminatingEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            GroupTerminatingEvent event =
+                    (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received GroupTerminatingEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(
+                        String.format("Failed to process group in GroupTerminatingEvent message " +
+                                "using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}


[37/50] [abbrv] git commit: adding service undeployment

Posted by im...@apache.org.
adding service undeployment


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

Branch: refs/heads/docker-grouping-merge
Commit: 828269f28a31a2a1a525988d2cdcc7a9f0a9fb4f
Parents: 0d726c8
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 18:13:42 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 18:13:42 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   | 11 ++++++++++-
 .../autoscaler/registry/RegistryManager.java    | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/828269f2/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index d710bf7..8c4bf2e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -324,7 +324,7 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface{
         RegistryManager.getInstance().persistServiceGroup(servicegroup);
     }
 
-    public ServiceGroup getServiceGroup(String name){
+    public ServiceGroup getServiceGroup(String name) {
         if(StringUtils.isEmpty(name)){
             return null;
         }
@@ -338,5 +338,14 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface{
         return false;
     }
 
+    public void undeployServiceGroup(String name) throws AutoScalerException {
+        try {
+            RegistryManager.getInstance().removeServiceGroup(name);
+        } catch (Exception e) {
+            throw new AutoScalerException("Error occurred while removing the service groups", e);
+        }
+
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/828269f2/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index ee8e411..0e1417e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -368,6 +368,26 @@ public class RegistryManager {
         return group;
     }
 
+    public ServiceGroup removeServiceGroup(String name) throws Exception{
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE +
+                                                    AutoScalerConstants.SERVICE_GROUP + "/" + name;
+        Object serializedObj = registryManager.retrieve(resourcePath);
+        ServiceGroup group = null;
+        if (serializedObj != null) {
+            Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+            if (dataObj instanceof ServiceGroup) {
+                group = (ServiceGroup) dataObj;
+                if(log.isDebugEnabled()) {
+                    log.debug(group.toString());
+                }
+            } else {
+                return null;
+            }
+        }
+
+        return group;
+    }
+
 	public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
 		 String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
          this.delete(resourcePath);


[32/50] [abbrv] git commit: moving application stuff to Autoscaler

Posted by im...@apache.org.
moving application stuff to Autoscaler


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

Branch: refs/heads/docker-grouping-merge
Commit: 226b8709e09e91c3f2f86eb679d7f1adbb0ce108
Parents: c42d7c1
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 16:05:28 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530

----------------------------------------------------------------------
 .../controller/topology/TopologyBuilder.java    | 103 -------------------
 .../topology/TopologyEventPublisher.java        |  12 +--
 .../StratosManagerTopologyEventReceiver.java    |  13 +--
 .../rest/endpoint/services/ServiceUtils.java    |   7 +-
 4 files changed, 17 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/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 7ee342e..5c25297 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
@@ -655,109 +655,6 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(event.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    event.getAppId()));
-            return;
-        }
-
-        Group group = application.getGroupRecursively(event.getGroupId());
-        if (group == null) {
-            log.warn(String.format("Group %s does not exist",
-                    event.getGroupId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.GroupInactivateEvent groupInActivateEvent =
-                new org.apache.stratos.messaging.event.topology.GroupInactivateEvent(
-                        event.getAppId(),
-                        event.getGroupId());
-        try {
-            TopologyManager.acquireWriteLock();
-            group.setStatus(GroupStatus.Inactive);
-            log.info("Group in-active adding status started for" + group.getUniqueIdentifier());
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendGroupInActiveEvent(groupInActivateEvent);
-    }
-
-
-    public static void handleGroupTerminatedEvent(GroupTerminatedEvent event) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(event.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    event.getAppId()));
-            return;
-        }
-
-        Group group = application.getGroupRecursively(event.getGroupId());
-        if (group == null) {
-            log.warn(String.format("Group %s does not exist",
-                    event.getGroupId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.GroupTerminatedEvent groupTerminatedTopologyEvent =
-                new org.apache.stratos.messaging.event.topology.GroupTerminatedEvent(
-                        event.getAppId(),
-                        event.getGroupId());
-        try {
-            TopologyManager.acquireWriteLock();
-            group.setStatus(GroupStatus.Terminated);
-            log.info("Group Terminated adding status started for" + group.getUniqueIdentifier());
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent);
-    }
-
-    public static void handleGroupTerminatingEvent(GroupTerminatingEvent event) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(event.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    event.getAppId()));
-            return;
-        }
-
-        Group group = application.getGroupRecursively(event.getGroupId());
-        if (group == null) {
-            log.warn(String.format("Group %s does not exist",
-                    event.getGroupId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.GroupTerminatingEvent groupTerminatingTopologyEvent =
-                new org.apache.stratos.messaging.event.topology.GroupTerminatingEvent(
-                        event.getAppId(),
-                        event.getGroupId());
-        try {
-            TopologyManager.acquireWriteLock();
-            group.setStatus(GroupStatus.Terminating);
-            log.info("Group Terminating adding status started for " + group.getUniqueIdentifier());
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
-    }
-
     public static void handleClusterTerminatedEvent(ClusterStatusClusterTerminatedEvent event) {
 
         TopologyManager.acquireWriteLock();

http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index 2e0883b..eb1fb7f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -78,12 +78,12 @@ public class TopologyEventPublisher {
     }
 
     public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
-
-        if(log.isInfoEnabled()) {
-            log.info("Publishing cluster created event: " +clusterId);
-        }
-        publishEvent(clusterCreatedEvent);
+//        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
+//
+//        if(log.isInfoEnabled()) {
+//            log.info("Publishing cluster created event: " +clusterId);
+//        }
+//        publishEvent(clusterCreatedEvent);
     }
 
     public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
index a085664..d4446c4 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
@@ -92,21 +92,22 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
 
                 ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event;
 
-                String serviceType = clustercreatedEvent.getServiceName();
+                String serviceType = clustercreatedEvent.getCluster().getServiceName();
                 //acquire read lock
                 //TopologyManager.acquireReadLock();
-                TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getServiceName(),
-                        clustercreatedEvent.getClusterId());
+                TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+                        clustercreatedEvent.getCluster().getClusterId());
 
                 try {
-                    Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clustercreatedEvent.getClusterId());
+                    Cluster cluster = TopologyManager.getTopology().getService(serviceType).
+                            getCluster(clustercreatedEvent.getCluster().getClusterId());
                     TopologyClusterInformationModel.getInstance().addCluster(cluster);
 
                 } finally {
                     //release read lock
                     //TopologyManager.releaseReadLock();
-                    TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getServiceName(),
-                            clustercreatedEvent.getClusterId());
+                    TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+                            clustercreatedEvent.getCluster().getClusterId());
                 }
 
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 9037f33..2b99f14 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -54,6 +54,7 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;
 import org.apache.stratos.rest.endpoint.bean.ApplicationBean;
@@ -1449,8 +1450,8 @@ public class ServiceUtils {
     public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext configContext) {
         ApplicationBean applicationBean = null;
         try{
-            TopologyManager.acquireReadLockForApplication(applicationId);
-            Application application = TopologyManager.getTopology().getApplication(applicationId);
+            ApplicationManager.acquireReadLockForApplication(applicationId);
+            Application application = ApplicationManager.getApplications().getApplication(applicationId);
             if(application == null){
                 return null;
             }
@@ -1480,7 +1481,7 @@ public class ServiceUtils {
                 applicationBean.addGroup(groupBean);
             }
         }finally {
-            TopologyManager.releaseReadLockForApplication(applicationId);
+            ApplicationManager.releaseReadLockForApplication(applicationId);
         }
 
 


[23/50] [abbrv] git commit: adding complete applications support

Posted by im...@apache.org.
adding complete applications support


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

Branch: refs/heads/docker-grouping-merge
Commit: 696bc0d24d25bf70a0bbcf8c1303fab7ad7e66d8
Parents: 0f7d7b0
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 14:54:25 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 14:54:34 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/grouping/topic/ClusterStatusEventPublisher.java | 4 ++--
 .../status/receiver/ApplicationStatusTopicReceiver.java        | 6 ++----
 .../stratos/cloud/controller/topology/TopologyBuilder.java     | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/696bc0d2/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
index 2a05b2e..9a43418 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
@@ -48,8 +48,8 @@ public class ClusterStatusEventPublisher {
                         log.info("Publishing Cluster created event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    ClusterStatusClusterCreatedEvent clusterCreatedEvent =
-                            new ClusterStatusClusterCreatedEvent(appId, serviceName, clusterId);
+                    ClusterStatusClusterResettedEvent clusterCreatedEvent =
+                            new ClusterStatusClusterResettedEvent(appId, serviceName, clusterId);
 
                     publishEvent(clusterCreatedEvent);
                 } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/696bc0d2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index fe97f99..d75039d 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -22,9 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.applications.*;
 import org.apache.stratos.messaging.event.cluster.status.*;
-import org.apache.stratos.messaging.listener.applications.*;
 import org.apache.stratos.messaging.listener.cluster.status.*;
 import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver;
 
@@ -66,10 +64,10 @@ public class ApplicationStatusTopicReceiver implements Runnable {
 
     private void addEventListeners() {
         // Listen to topology events that affect clusters
-        statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() {
+        statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event);
+                TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event);
             }
         });
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/696bc0d2/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 2941027..dcbeb48 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
@@ -125,7 +125,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterCreated (ClusterStatusClusterCreatedEvent event) {
+    public static void handleClusterCreated (ClusterStatusClusterResettedEvent event) {
 
         TopologyManager.acquireWriteLock();
 


[16/50] [abbrv] removing application status and adding applications, cluster status topic

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
new file mode 100644
index 0000000..69918e2
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterInactivateMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterInactivateMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterInactivateEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterInactivateEvent event = (ClusterStatusClusterInactivateEvent) Util.
+                                                jsonToObject(message, ClusterStatusClusterInactivateEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received ClusterInActivateEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
new file mode 100644
index 0000000..64b6c7b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterTerminatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterTerminatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterTerminatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterTerminatedEvent event = (ClusterStatusClusterTerminatedEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterTerminatedEvent.class);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
new file mode 100644
index 0000000..c161dd5
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterTerminatingMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterTerminatingMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterTerminatingEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterTerminatingEvent event = (ClusterStatusClusterTerminatingEvent) Util.
+                                                jsonToObject(message, ClusterStatusClusterTerminatingEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
new file mode 100644
index 0000000..29556ec
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.listener.cluster.status.*;
+import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
+
+/**
+ * This is to keep track of the processors for the cluster status topic.
+ */
+public class ClusterStatusMessageProcessorChain extends MessageProcessorChain {
+    private static final Log log = LogFactory.getLog(ClusterStatusMessageProcessorChain.class);
+
+
+    private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
+    private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
+    private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor;
+    private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
+    private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
+    @Override
+    protected void initialize() {
+        clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor();
+        add(clusterCreatedMessageProcessor);
+
+        clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor();
+        add(clusterActivatedMessageProcessor);
+
+        clusterInactivateMessageProcessor = new ClusterStatusClusterInactivateMessageProcessor();
+        add(clusterInactivateMessageProcessor);
+
+        clusterTerminatedMessageProcessor = new ClusterStatusClusterTerminatedMessageProcessor();
+        add(clusterTerminatedMessageProcessor);
+
+        clusterTerminatingMessageProcessor = new ClusterStatusClusterTerminatingMessageProcessor();
+        add(clusterTerminatingMessageProcessor);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Cluster status  message processor chain initialized");
+        }
+    }
+
+    @Override
+    public void addEventListener(EventListener eventListener) {
+        if(eventListener instanceof ClusterStatusClusterCreatedEventListener) {
+            clusterCreatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) {
+            clusterInactivateMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ClusterStatusClusterActivatedEventListener) {
+            clusterActivatedMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ClusterStatusClusterTerminatingEventListener) {
+            clusterTerminatingMessageProcessor.addEventListener(eventListener);
+        } else if (eventListener instanceof ClusterStatusClusterTerminatedEventListener) {
+            clusterTerminatedMessageProcessor.addEventListener(eventListener);
+        } else {
+            throw new RuntimeException("Unknown event listener " + eventListener.toString());
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
deleted file mode 100644
index 341b402..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor responsible to process the application activation even and update the Topology.
- */
-public class ApplicationActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(ApplicationActivatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (ApplicationActivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util.
-                    jsonToObject(message, ApplicationActivatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess(ApplicationActivatedEvent event, Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        } else {
-            // Apply changes to the topology
-            if (!application.isStateTransitionValid(ApplicationStatus.Active)) {
-                log.error("Invalid State transfer from [ " + application.getStatus() +
-                        " ] to [ " + ApplicationStatus.Active + " ]");
-            }
-            application.setStatus(ApplicationStatus.Active);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
deleted file mode 100644
index 079cb90..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-import java.util.Set;
-
-public class ApplicationCreatedMessageProcessor extends MessageProcessor {
-
-    private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-
-        Topology topology = (Topology) object;
-
-        if (ApplicationCreatedEvent.class.getName().equals(type)) {
-            if (!topology.isInitialized()) {
-                return false;
-            }
-
-            ApplicationCreatedEvent event = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
-            if (event == null) {
-                log.error("Unable to convert the JSON message to ApplicationCreatedEvent");
-                return false;
-            }
-
-            TopologyUpdater.acquireWriteLockForApplications();
-            // since the Clusters will also get modified, acquire write locks for each Service Type
-            Set<ClusterDataHolder> clusterDataHolders = event.getApplication().getClusterDataRecursively();
-            if (clusterDataHolders != null) {
-                for (ClusterDataHolder clusterData : clusterDataHolders) {
-                    TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
-                }
-            }
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                if (clusterDataHolders != null) {
-                    for (ClusterDataHolder clusterData : clusterDataHolders) {
-                        TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
-                    }
-                }
-                TopologyUpdater.releaseWriteLockForApplications();
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (ApplicationCreatedEvent event,Topology topology) {
-
-        // check if required properties are available
-        if (event.getApplication() == null) {
-            String errorMsg = "Application object of application created event is invalid";
-            log.error(errorMsg);
-            throw new RuntimeException(errorMsg);
-        }
-
-        if (event.getApplication().getUniqueIdentifier() == null || event.getApplication().getUniqueIdentifier().isEmpty()) {
-            String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getUniqueIdentifier() + " ]";
-            log.error(errorMsg);
-            throw new RuntimeException(errorMsg);
-        }
-
-        // check if an Application with same name exists in topology
-        if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) {
-            log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology");
-
-        } else {
-            // add application and the clusters to Topology
-            for(Cluster cluster: event.getClusterList()) {
-                topology.getService(cluster.getServiceName()).addCluster(cluster);
-            }
-            topology.addApplication(event.getApplication());
-        }
-
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
deleted file mode 100644
index 8c88324..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor responsible to process the application Inactivation even and update the Topology.
- */
-public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(ApplicationInactivatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (ApplicationInactivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
-                    jsonToObject(message, ApplicationInactivatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        } else {
-            // Apply changes to the topology
-            if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) {
-                log.error("Invalid State transfer from [ " + application.getStatus() +
-                        " ] to [ " + ApplicationStatus.Inactive + " ]");
-            }
-            application.setStatus(ApplicationStatus.Inactive);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
deleted file mode 100644
index 2dd3ea7..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-import java.util.Set;
-
-/**
- * This processor responsible to process the application Inactivation even and update the Topology.
- */
-public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(ApplicationTerminatedMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (ApplicationTerminatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
-                    jsonToObject(message, ApplicationTerminatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplications();
-                        Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
-            if (clusterDataHolders != null) {
-                for (ClusterDataHolder clusterData : clusterDataHolders) {
-                    TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
-                }
-            }
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplications();
-                if (clusterDataHolders != null) {
-                    for (ClusterDataHolder clusterData : clusterDataHolders) {
-                        TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
-                    }
-                }
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) {
-
-        // check if required properties are available
-        if (event.getAppId() == null) {
-            String errorMsg = "Application Id of application removed event is invalid";
-            log.error(errorMsg);
-            throw new RuntimeException(errorMsg);
-        }
-
-        if (event.getTenantDomain()== null) {
-            String errorMsg = "Application tenant domain of application removed event is invalid";
-            log.error(errorMsg);
-            throw new RuntimeException(errorMsg);
-        }
-
-        // check if an Application with same name exists in topology
-        String appId = event.getAppId();
-        if (topology.applicationExists(appId)) {
-            log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
-            topology.removeApplication(appId);
-        }
-
-        if (event.getClusterData() != null) {
-            // remove the Clusters from the Topology
-            for (ClusterDataHolder clusterData : event.getClusterData()) {
-                Service service = topology.getService(clusterData.getServiceType());
-                if (service != null) {
-                    service.removeCluster(clusterData.getClusterId());
-                    if (log.isDebugEnabled()) {
-                        log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
-                    }
-                }  else {
-                    log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
-                }
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("ApplicationRemovedMessageProcessor notifying listener ");
-        }
-
-        notifyEventListeners(event);
-        return true;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
deleted file mode 100644
index 032be79..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor responsible to process the application Inactivation even and update the Topology.
- */
-public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log =
-            LogFactory.getLog(ApplicationTerminatingMessageProcessor.class);
-
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (ApplicationTerminatingEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
-                    jsonToObject(message, ApplicationTerminatingEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        } else {
-            // Apply changes to the topology
-            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-                log.error("Invalid State transfer from [ " + application.getStatus() +
-                        " ] to [ " + ApplicationStatus.Terminating + " ]");
-            }
-            application.setStatus(ApplicationStatus.Terminating);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
deleted file mode 100644
index f368dd1..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-import java.util.Set;
-
-public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
-
-    private static final Log log = LogFactory.getLog(ApplicationUndeployedMessageProcessor.class);
-
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-
-        Topology topology = (Topology) object;
-
-        if (ApplicationUndeployedEvent.class.getName().equals(type)) {
-            if (!topology.isInitialized()) {
-                return false;
-            }
-
-            ApplicationUndeployedEvent event = (ApplicationUndeployedEvent)
-                    Util.jsonToObject(message, ApplicationUndeployedEvent.class);
-            if (event == null) {
-                log.error("Unable to convert the JSON message to ApplicationUndeployedEvent");
-                return false;
-            }
-
-            // get write lock for the application and relevant Clusters
-            TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId());
-            Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
-            if (clusterDataHolders != null) {
-                for (ClusterDataHolder clusterData : clusterDataHolders) {
-                    TopologyUpdater.acquireWriteLockForCluster(clusterData.getServiceType(),
-                            clusterData.getClusterId());
-                }
-            }
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                // remove locks
-                if (clusterDataHolders != null) {
-                    for (ClusterDataHolder clusterData : clusterDataHolders) {
-                        TopologyUpdater.releaseWriteLockForCluster(clusterData.getServiceType(),
-                                clusterData.getClusterId());
-                    }
-                }
-                TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format
-                    ("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) {
-
-        // update the application status to Terminating
-        Application application = topology.getApplication(event.getApplicationId());
-        // check and update application status to 'Terminating'
-        if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-            log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
-        }
-        // for now anyway update the status forcefully
-        application.setStatus(ApplicationStatus.Terminating);
-
-        // update all the Clusters' statuses to 'Terminating'
-        Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
-        // update the Cluster statuses to Terminating
-        for (ClusterDataHolder clusterDataHolder : clusterData) {
-            Service service = topology.getService(clusterDataHolder.getServiceType());
-            if (service != null) {
-                Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
-                if (aCluster != null) {
-                    // validate state transition
-                    if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
-                        log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
-                                + ClusterStatus.Terminating);
-                    }
-                    // for now anyway update the status forcefully
-                    aCluster.setStatus(ClusterStatus.Terminating);
-
-                } else {
-                    log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
-                            " in Topology");
-                }
-
-            } else {
-                log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
-                        " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
-            }
-        }
-
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
deleted file mode 100644
index 09b9062..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupActivatedProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupActivatedProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (GroupActivatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupActivatedEvent event = (GroupActivatedEvent) Util.
-                    jsonToObject(message, GroupActivatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (GroupActivatedEvent event,Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            // Apply changes to the topology
-            if (!group.isStateTransitionValid(GroupStatus.Active)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
-            }
-            group.setStatus(GroupStatus.Active);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
deleted file mode 100644
index d053f5d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupCreatedProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (GroupCreatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupCreatedEvent event = (GroupCreatedEvent) Util.
-                    jsonToObject(message, GroupCreatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (GroupCreatedEvent event,Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            // Apply changes to the topology
-            if (!group.isStateTransitionValid(GroupStatus.Created)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created  + " " +
-                        "for Group " + group.getAlias());
-            }
-            group.setStatus(GroupStatus.Created);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
deleted file mode 100644
index add40b4..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupInActivateProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupInActivateProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (GroupInactivateEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupInactivateEvent event = (GroupInactivateEvent) Util.
-                    jsonToObject(message, GroupInactivateEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess(GroupInactivateEvent event, Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            group.setStatus(GroupStatus.Inactive);
-            if (log.isInfoEnabled()) {
-                log.info(String.format("Group updated as in-activated : %s",
-                        group.getUniqueIdentifier()));
-            }
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
deleted file mode 100644
index 767ff71..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupTerminatedProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupTerminatedProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (GroupTerminatedEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupTerminatedEvent event = (GroupTerminatedEvent) Util.
-                    jsonToObject(message, GroupTerminatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (GroupTerminatedEvent event,Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            // Apply changes to the topology
-            if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
-            }
-            group.setStatus(GroupStatus.Terminated);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
deleted file mode 100644
index 5b15532..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupTerminatingProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupTerminatingProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Topology topology = (Topology) object;
-
-        if (GroupTerminatingEvent.class.getName().equals(type)) {
-            // Return if topology has not been initialized
-            if (!topology.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupTerminatingEvent event = (GroupTerminatingEvent) Util.
-                    jsonToObject(message, GroupTerminatingEvent.class);
-
-            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, topology);
-
-            } finally {
-                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (GroupTerminatingEvent event,Topology topology) {
-
-        // Validate event against the existing topology
-        Application application = topology.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            // Apply changes to the topology
-            if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
-            }
-            group.setStatus(GroupStatus.Terminating);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index d8d25d9..048e9a3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -22,7 +22,6 @@ package org.apache.stratos.messaging.message.processor.topology;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 
@@ -47,17 +46,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
     private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor;
     private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor;
     private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor;
-    private GroupCreatedProcessor groupCreatedProcessor;
-    private GroupActivatedProcessor groupActivatedProcessor;
-    private GroupInActivateProcessor groupInActivateProcessor;
-    private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor;
-    private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor;
-    private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor;
-    private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor;
-    private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor;
-    private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor;
-    private GroupTerminatingProcessor groupTerminatingProcessor;
-    private GroupTerminatedProcessor groupTerminatedProcessor;
     private ClusterTerminatingProcessor clusterTerminatingProcessor;
     private ClusterTerminatedProcessor clusterTerminatedProcessor;
 
@@ -111,39 +99,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
         memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor();
         add(memberTerminatedMessageProcessor);
 
-        groupCreatedProcessor = new GroupCreatedProcessor();
-        add(groupCreatedProcessor);
-
-        groupActivatedProcessor = new GroupActivatedProcessor();
-        add(groupActivatedProcessor);
-
-        groupInActivateProcessor = new GroupInActivateProcessor();
-        add(groupInActivateProcessor);
-
-        groupTerminatingProcessor = new GroupTerminatingProcessor();
-        add(groupTerminatingProcessor);
-
-        groupTerminatedProcessor = new GroupTerminatedProcessor();
-        add(groupTerminatedProcessor);
-
-        applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor();
-        add(applicationCreatedMessageProcessor);
-
-        applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor();
-        add(applicationUndeployedMessageProcessor);
-
-        applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor();
-        add(applicationActivatedMessageProcessor);
-
-        applicationInactivatedMessageProcessor = new ApplicationInactivatedMessageProcessor();
-        add(applicationInactivatedMessageProcessor);
-
-        applicationTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor();
-        add(applicationTerminatedMessageProcessor);
-
-        applicationTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor();
-        add(applicationTerminatingMessageProcessor);
-
         if (log.isDebugEnabled()) {
             log.debug("Topology message processor chain initialized X1");
         }
@@ -182,30 +137,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
             serviceRemovedMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof  MemberMaintenanceListener) {
             memberMaintenanceModeProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupActivatedEventListener) {
-            groupActivatedProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupCreatedEventListener) {
-            groupCreatedProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupInActivateEventListener) {
-            groupInActivateProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupTerminatedEventListener){
-            groupTerminatedProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupTerminatingEventListener){
-            groupTerminatingProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof ApplicationCreatedEventListener) {
-            applicationCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof ApplicationUndeployedEventListener) {
-            applicationUndeployedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof ApplicationActivatedEventListener) {
-            applicationActivatedMessageProcessor.addEventListener(eventListener);
-        } else  if (eventListener instanceof ApplicationInActivateEventListener){
-            applicationInactivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationTerminatedEventListener){
-            applicationTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationTerminatingEventListener){
-            applicationTerminatingMessageProcessor.addEventListener(eventListener);
-        }
-        else {
+        } else {
             throw new RuntimeException("Unknown event listener");
         }
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/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
deleted file mode 100644
index 9eda9e0..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.receiver.application.status;
-
-import org.apache.commons.logging.Log;
-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.AppStatusMessageProcessorChain;
-import org.apache.stratos.messaging.util.Constants;
-
-import javax.jms.TextMessage;
-
-public class ApplicationStatusEventMessageDelegator implements Runnable {
-    private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageDelegator.class);
-
-    private ApplicationStatusEventMessageQueue messageQueue;
-    private MessageProcessorChain processorChain;
-    private boolean terminated;
-
-    public ApplicationStatusEventMessageDelegator(ApplicationStatusEventMessageQueue messageQueue) {
-        this.messageQueue = messageQueue;
-        this.processorChain = new AppStatusMessageProcessorChain();
-    }
-
-    public void addEventListener(EventListener eventListener) {
-        processorChain.addEventListener(eventListener);
-    }
-
-    @Override
-    public void run() {
-        try {
-            if (log.isInfoEnabled()) {
-                log.info("Application status event message delegator started");
-            }
-
-            while (!terminated) {
-                try {
-                    TextMessage message = messageQueue.take();
-
-                    // 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));
-                    }
-
-                    // Delegate message to message processor chain
-                    if (log.isDebugEnabled()) {
-                        log.debug(String.format("Delegating application status event message: %s", type));
-                    }
-                    processorChain.process(type, json, null);
-                } catch (Exception e) {
-                    log.error("Failed to retrieve application status event message", e);
-                }
-            }
-        } catch (Exception e) {
-            if (log.isErrorEnabled()) {
-                log.error("Application status event message delegator failed", e);
-            }
-        }
-    }
-
-    /**
-     * Terminate topology event message delegator thread.
-     */
-    public void terminate() {
-        terminated = true;
-    }
-
-
-    private EventMessage jsonToEventMessage(String json) {
-
-        EventMessage event = new EventMessage();
-        String message;
-
-        //split the message to 3 parts using ':' first is class name, second contains the text 'message' and the third contains
-        //message
-        String[] MessageParts = json.split(":", 3);
-
-        String eventType = MessageParts[0].trim();
-        eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\""));
-        if(log.isDebugEnabled()){
-            log.debug(String.format("Extracted [event type] %s", eventType));
-        }
-
-        event.setEventName(eventType);
-        String messageTag = MessageParts[1];
-        messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\""));
-
-        if("message".equals(messageTag)){
-            message = MessageParts[2].trim();
-            //Remove trailing bracket twice to get the message
-            message = message.substring(0, message.lastIndexOf("}")).trim();
-            message = message.substring(0, message.lastIndexOf("}")).trim();
-            if(message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1){
-                if(log.isDebugEnabled()) {
-                    log.debug(String.format("[Extracted message] %s ", message));
-                }
-                event.setMessage(message);
-                return event;
-            }
-        }
-        return null;
-    }
-
-    private class EventMessage {
-        private String eventName;
-        private String message;
-
-        private String getEventName() {
-            return eventName;
-        }
-
-        private void setEventName(String eventName) {
-            this.eventName = eventName;
-        }
-
-        public String getMessage() {
-            return message;
-        }
-
-        public void setMessage(String message) {
-            this.message = message;
-        }
-    }
-}


[40/50] [abbrv] moving Application Parsing to Autoscaler

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java
new file mode 100644
index 0000000..963e88b
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public abstract class PayloadData implements Serializable {
+
+    private BasicPayloadData basicPayloadData;
+    private Map<String, String> completePayloadMap;
+    public PayloadData(BasicPayloadData basicPayloadData) {
+
+        this.setBasicPayloadData(basicPayloadData);
+        completePayloadMap = new HashMap<String, String>();
+    }
+
+    public void add (String payloadDataName, String payloadDataValue) {
+        completePayloadMap.put(payloadDataName, payloadDataValue);
+    }
+
+    public StringBuilder getCompletePayloadData () {
+
+        //return completePayloadMap;
+        StringBuilder completePayload = new StringBuilder();
+        completePayload.append(basicPayloadData.getPayloadData());
+        Iterator< String > iter = completePayloadMap.keySet().iterator();
+        while(iter.hasNext()) {
+            String key = iter.next();
+            String val = completePayloadMap.get(key);
+            if(completePayload.length() > 0){
+                completePayload.append(",");
+            }
+            completePayload.append(key + "=" + val);
+        }
+        return completePayload;
+    }
+
+    public BasicPayloadData getBasicPayloadData() {
+        return basicPayloadData;
+    }
+
+    public void setBasicPayloadData(BasicPayloadData basicPayloadData) {
+        this.basicPayloadData = basicPayloadData;
+    }
+
+    public String toString () {
+        return getCompletePayloadData().toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java
new file mode 100755
index 0000000..53bac96
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java
@@ -0,0 +1,59 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+
+ *  http://www.apache.org/licenses/LICENSE-2.0
+
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+
+
+public class PayloadFactory {
+
+	private static Log log = LogFactory.getLog(PayloadFactory.class);
+
+    /**
+     * Creates and returns a PayloadData instance
+     *
+     * @param cartridgeProvider Cartridge provider
+     * @param cartridgeType Cartridge type
+     * @param basicPayloadData BasicPayloadData instance
+     * @return Payload subscription
+     */
+	public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType,
+                                                     BasicPayloadData basicPayloadData)
+            throws ApplicationDefinitionException {
+
+        PayloadData payloadData = null;
+
+        //TODO: fix after adding the property Category to Cartridge Definition
+        if (cartridgeProvider.equals("data")) {
+            payloadData = new DataCartridgePayloadData(basicPayloadData);
+        } else {
+            payloadData = new FrameworkCartridgePayloadData(basicPayloadData);
+        }
+
+        if(payloadData == null) {
+            throw new ApplicationDefinitionException("Unable to find matching payload for cartridge type " + cartridgeType +
+                    ", provider " + cartridgeProvider);
+        }
+
+        return payloadData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java
new file mode 100644
index 0000000..39b8214
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class ApplicationClusterContext {
+
+    // cluster id
+    private String clusterId;
+    // cartridge type
+    private String cartridgeType;
+    // payload as a String
+    private String textPayload;
+    // host name
+    private String hostName;
+    // flag to indicate LB cluster
+    private boolean isLbCluster;
+    // autoscaling policy
+    private String autoscalePolicyName;
+    // deployment policy
+    private String deploymentPolicyName;
+    // tenant rance
+    private String tenantRange;
+
+    public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName,
+                                      String textPayload, String deploymentPolicyName, boolean isLbCluster) {
+
+        this.cartridgeType = cartridgeType;
+        this.clusterId = clusterId;
+        this.hostName = hostName;
+        this.textPayload = textPayload;
+        this.deploymentPolicyName = deploymentPolicyName;
+        this.isLbCluster = isLbCluster;
+        this.tenantRange = "*";
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getCartridgeType() {
+        return cartridgeType;
+    }
+
+    public void setCartridgeType(String cartridgeType) {
+        this.cartridgeType = cartridgeType;
+    }
+
+    public String getTextPayload() {
+        return textPayload;
+    }
+
+    public void setTextPayload(String textPayload) {
+        this.textPayload = textPayload;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public boolean isLbCluster() {
+        return isLbCluster;
+    }
+
+    public void setLbCluster(boolean lbCluster) {
+        isLbCluster = lbCluster;
+    }
+
+    public String getAutoscalePolicyName() {
+        return autoscalePolicyName;
+    }
+
+    public void setAutoscalePolicyName(String autoscalePolicyName) {
+        this.autoscalePolicyName = autoscalePolicyName;
+    }
+
+    public String getDeploymentPolicyName() {
+        return deploymentPolicyName;
+    }
+
+    public void setDeploymentPolicyName(String deploymentPolicyName) {
+        this.deploymentPolicyName = deploymentPolicyName;
+    }
+
+    public String getTenantRange() {
+        return tenantRange;
+    }
+
+    public void setTenantRange(String tenantRange) {
+        this.tenantRange = tenantRange;
+    }
+
+    public boolean equals(Object other) {
+
+        if(other == null || !(other instanceof ApplicationClusterContext)) {
+            return false;
+        }
+
+        if(this == other) {
+            return true;
+        }
+
+        ApplicationClusterContext that = (ApplicationClusterContext)other;
+
+        return this.cartridgeType.equals(that.cartridgeType) &&
+                this.clusterId.equals(that.clusterId);
+    }
+
+    public int hashCode () {
+        return this.cartridgeType.hashCode() + this.clusterId.hashCode();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
new file mode 100644
index 0000000..1b9c516
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class ApplicationContext {
+
+    private int tenantId;
+
+    private String tenantDomain;
+
+    private String teantAdminUsername;
+
+    private String applicationId;
+
+    private String alias;
+
+    private ComponentContext componentContext;
+
+    private SubscribableInfoContext[] subscribableInfoContexts;
+
+    public String getApplicationId() {
+        return applicationId;
+    }
+
+    public void setApplicationId(String applicationId) {
+        this.applicationId = applicationId;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public ComponentContext getComponents() {
+        return componentContext;
+    }
+
+    public void setComponents(ComponentContext componentContext) {
+        this.componentContext = componentContext;
+    }
+
+    public SubscribableInfoContext[] getSubscribableInfoContext() {
+        return subscribableInfoContexts;
+    }
+
+    public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) {
+        this.subscribableInfoContexts = subscribableInfoContexts;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getTenantDomain() {
+        return tenantDomain;
+    }
+
+    public void setTenantDomain(String tenantDomain) {
+        this.tenantDomain = tenantDomain;
+    }
+
+    public String getTeantAdminUsername() {
+        return teantAdminUsername;
+    }
+
+    public void setTeantAdminUsername(String teantAdminUsername) {
+        this.teantAdminUsername = teantAdminUsername;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
new file mode 100644
index 0000000..b39b07f
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class ComponentContext {
+
+    private GroupContext[] groupContexts;
+
+    private SubscribableContext[] subscribableContexts;
+
+    private DependencyContext dependencyContext;
+
+
+    public GroupContext[] getGroupContexts() {
+        return groupContexts;
+    }
+
+    public void setGroupContexts(GroupContext[] groupContexts) {
+        this.groupContexts = groupContexts;
+    }
+
+    public SubscribableContext[] getSubscribableContexts() {
+        return subscribableContexts;
+    }
+
+    public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
+        this.subscribableContexts = subscribableContexts;
+    }
+
+    public DependencyContext getDependencyContext() {
+        return dependencyContext;
+    }
+
+    public void setDependencyContext(DependencyContext dependencyContext) {
+        this.dependencyContext = dependencyContext;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
new file mode 100644
index 0000000..ccb17f0
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+
+public class DependencyContext {
+    
+    private String [] startupOrdersContexts;
+
+    private String terminationBehaviour;
+
+    public String getTerminationBehaviour() {
+        return terminationBehaviour;
+    }
+
+    public void setTerminationBehaviour(String terminationBehaviour) {
+        this.terminationBehaviour = terminationBehaviour;
+    }
+
+	public String [] getStartupOrdersContexts() {
+		return startupOrdersContexts;
+	}
+
+	public void setStartupOrdersContexts(String [] startupOrdersContexts) {
+		this.startupOrdersContexts = startupOrdersContexts;
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
new file mode 100644
index 0000000..c05a5d5
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class GroupContext {
+
+    private String name;
+
+    private String alias;
+
+    private String deploymentPolicy;
+
+    private String autoscalingPolicy;
+
+    private SubscribableContext[] subscribableContexts;
+
+    private GroupContext[] groupContexts;
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getDeploymentPolicy() {
+        return deploymentPolicy;
+    }
+
+    public void setDeploymentPolicy(String deploymentPolicy) {
+        this.deploymentPolicy = deploymentPolicy;
+    }
+
+    public String getAutoscalingPolicy() {
+        return autoscalingPolicy;
+    }
+
+    public void setAutoscalingPolicy(String autoscalingPolicy) {
+        this.autoscalingPolicy = autoscalingPolicy;
+    }
+
+    public SubscribableContext[] getSubscribableContexts() {
+        return subscribableContexts;
+    }
+
+    public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
+        this.subscribableContexts = subscribableContexts;
+    }
+
+    public GroupContext[] getGroupContexts() {
+        return groupContexts;
+    }
+
+    public void setGroupContexts(GroupContext[] groupContexts) {
+        this.groupContexts = groupContexts;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
new file mode 100644
index 0000000..7ae4864
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class SubscribableContext {
+
+    private String type;
+
+    private String alias;
+
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
new file mode 100644
index 0000000..62d32df
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.pojo;
+
+public class SubscribableInfoContext {
+
+    private String alias;
+
+    private String deploymentPolicy;
+
+    private String autoscalingPolicy;
+
+    private String repoUrl;
+
+    private boolean privateRepo;
+
+    private String repoUsername;
+
+    private String repoPassword;
+
+    private String[] dependencyAliases;
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getDeploymentPolicy() {
+        return deploymentPolicy;
+    }
+
+    public void setDeploymentPolicy(String deploymentPolicy) {
+        this.deploymentPolicy = deploymentPolicy;
+    }
+
+    public String getAutoscalingPolicy() {
+        return autoscalingPolicy;
+    }
+
+    public void setAutoscalingPolicy(String autoscalingPolicy) {
+        this.autoscalingPolicy = autoscalingPolicy;
+    }
+
+    public String getRepoUrl() {
+        return repoUrl;
+    }
+
+    public void setRepoUrl(String repoUrl) {
+        this.repoUrl = repoUrl;
+    }
+
+    public boolean isPrivateRepo() {
+        return privateRepo;
+    }
+
+    public void setPrivateRepo(boolean privateRepo) {
+        this.privateRepo = privateRepo;
+    }
+
+    public String getRepoUsername() {
+        return repoUsername;
+    }
+
+    public void setRepoUsername(String repoUsername) {
+        this.repoUsername = repoUsername;
+    }
+
+    public String getRepoPassword() {
+        return repoPassword;
+    }
+
+    public void setRepoPassword(String repoPassword) {
+        this.repoPassword = repoPassword;
+    }
+
+    public String[] getDependencyAliases() {
+        return dependencyAliases;
+    }
+
+    public void setDependencyAliases(String[] dependencyAliases) {
+        this.dependencyAliases = dependencyAliases;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index 9d4db75..07ddfb6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.applications.topic;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext;
 import org.apache.stratos.messaging.domain.applications.*;
 
 import java.util.Collection;
@@ -142,6 +143,49 @@ public class ApplicationBuilder {
 
         ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
     }*/
+    public static void handleApplicationCreated (Application application,
+                                                 Set<ApplicationClusterContext> appClusterCtxts) {
+
+        Applications applications = ApplicationHolder.getApplications();
+
+        ApplicationHolder.acquireWriteLock();
+
+        try {
+            if (applications.getApplication(application.getUniqueIdentifier()) != null) {
+                ApplicationHolder.persistApplication(application);
+            } else {
+                log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications");
+            }
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+
+        ApplicationsEventPublisher.sendApplicationCreatedEvent(application);
+    }
+
+    public static void handleApplicationUndeployed (String applicationId) {
+
+        Applications applications = ApplicationHolder.getApplications();
+
+        ApplicationHolder.acquireWriteLock();
+        Application applicationToRemove = applications.getApplication(applicationId);
+        Set<ClusterDataHolder> clusterData = null;
+
+        try {
+            if (applicationToRemove != null) {
+                clusterData = applicationToRemove.getClusterDataRecursively();
+                ApplicationHolder.removeApplication(applicationId);
+            } else {
+                log.warn("Application [ " + applicationId + " ] not found among existing Applications");
+            }
+
+        } finally {
+            ApplicationHolder.releaseWriteLock();
+        }
+
+        ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
+    }
 
     public static void handleGroupTerminatedEvent(String appId, String groupId) {
         Applications applications = ApplicationHolder.getApplications();

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index 7a1203a..7ca224e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -7,6 +7,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
 import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.apache.stratos.messaging.util.Constants;
 
@@ -23,13 +24,14 @@ public class ApplicationsEventPublisher {
         publishEvent(new CompleteApplicationsEvent(completeApplications));
     }
 
-    public static void sendCompleteTopologyEvent(Applications applications) {
-        CompleteApplicationsEvent applicationsEvent = new CompleteApplicationsEvent(applications);
+    public static void sendApplicationCreatedEvent (Application application) {
 
-        if(log.isDebugEnabled()) {
-            log.debug(String.format("Publishing complete Applications event"));
-        }
-        publishEvent(applicationsEvent);
+        publishEvent(new ApplicationCreatedEvent(application));
+    }
+
+    public static void sendApplicationUndeployedEvent (String appId, Set<ClusterDataHolder> clusterData) {
+
+        publishEvent(new ApplicationUndeployedEvent(appId, clusterData));
     }
 
     public static void sendGroupCreatedEvent(String appId, String groupId) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
index dff493d..b13465f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
@@ -25,12 +25,14 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.Constants;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.CartridgeInformationException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.exception.SpawningException;
 import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.util.ConfUtil;
 import org.apache.stratos.cloud.controller.stub.*;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
 import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 import org.apache.stratos.cloud.controller.stub.pojo.Property;
@@ -226,6 +228,20 @@ public class CloudControllerClient {
         }
     }
 
+    public CartridgeInfo getCartrdgeInformation (String cartridgeType) throws CartridgeInformationException {
 
+        try {
+            return stub.getCartridgeInfo(cartridgeType);
+
+        } catch (RemoteException e) {
+            String msg = e.getMessage();
+            log.error(msg, e);
+            throw new CartridgeInformationException(msg, e);
+        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+            String msg = e.getMessage();
+            log.error(msg, e);
+            throw new CartridgeInformationException(msg, e);
+        }
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java
new file mode 100644
index 0000000..d904e8d
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.exception;
+
+public class ApplicationDefinitionException extends Exception {
+
+    private String message;
+
+    public ApplicationDefinitionException () {
+        super();
+    }
+
+    public ApplicationDefinitionException (String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ApplicationDefinitionException (String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ApplicationDefinitionException (Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java
new file mode 100644
index 0000000..53bea79
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.exception;
+
+public class CartridgeInformationException extends Exception {
+
+    private String message;
+
+    public CartridgeInformationException () {
+        super();
+    }
+
+    public CartridgeInformationException (String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public CartridgeInformationException (String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public CartridgeInformationException (Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
index 9f289ab..74cbb56 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
@@ -21,7 +21,9 @@ package org.apache.stratos.autoscaler.interfaces;
 */
 
 
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
 import org.apache.stratos.autoscaler.exception.InvalidPartitionException;
 import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.exception.NonExistingLBException;
@@ -86,4 +88,20 @@ public interface AutoScalerServiceInterface {
     public String getDefaultLBClusterId (String deploymentPolicyName);
 
     public String getServiceLBClusterId (String serviceType, String deploymentPolicyName);
+
+    /**
+     * deploys an Application Definition
+     *
+     * @param applicationContext {@link org.apache.stratos.autoscaler.applications.pojo.ApplicationContext} object
+     * @throws ApplicationDefinitionException if an error is encountered
+     */
+    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException;
+
+    /**
+     * undeploys an Application Definition
+     *
+     * @param applicationId Id of the Application to be undeployed
+     * @throws ApplicationDefinitionException if an error is encountered
+     */
+    public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 0e1417e..5e995da 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -185,6 +185,11 @@ public class RegistryManager {
         return null;
     }
 
+    public void removeApplication (String applicationId) {
+        delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                "/" + applicationId);
+    }
+
     public void persistServiceGroup(ServiceGroup servicegroup) {
         if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){
             throw new  IllegalArgumentException("Service group or group name can not be null");

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/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 4b95118..835e284 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
@@ -72,6 +72,10 @@ public class AutoscalerUtil {
         return RegistryManager.getInstance().getApplication(appResourcePath);
     }
 
+    public static void removeApplication (String applicationId) {
+        RegistryManager.getInstance().removeApplication(applicationId);
+    }
+
     /*public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException {
         // FIXME fix the following code to correctly update
         // AutoscalerContext context = AutoscalerContext.getInstance();


[22/50] [abbrv] git commit: adding complete applications

Posted by im...@apache.org.
adding complete applications


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

Branch: refs/heads/docker-grouping-merge
Commit: 0f7d7b0d0db9f643fd232f0ef2689cf62553dee7
Parents: 7f05298
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 14:53:49 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 14:54:33 2014 +0530

----------------------------------------------------------------------
 .../domain/applications/Applications.java       |  22 ++-
 .../locking/ApplicationLockHierarchy.java       |   3 +
 .../applications/ApplicationCreatedEvent.java   |  11 +-
 .../applications/CompleteApplicationsEvent.java |  44 ++++++
 .../ClusterStatusClusterCreatedEvent.java       |  52 -------
 .../ClusterStatusClusterResettedEvent.java      |  52 +++++++
 .../event/topology/ClusterCreatedEvent.java     |  26 +---
 .../event/topology/ClusterResetEvent.java       |  56 +++++++
 .../CompleteApplicationsEventListener.java      |  26 ++++
 ...lusterStatusClusterCreatedEventListener.java |  24 ---
 .../ClusterStatusClusterResetEventListener.java |  24 +++
 .../ApplicationCreatedMessageProcessor.java     |  32 +---
 .../CompleteApplicationsMessageProcessor.java   | 111 ++++++++++++++
 .../updater/ApplicationsUpdater.java            | 140 ++++++++++++++++++
 ...terStatusClusterCreatedMessageProcessor.java |  58 --------
 ...usterStatusClusterResetMessageProcessor.java |  58 ++++++++
 .../ClusterStatusMessageProcessorChain.java     |   6 +-
 .../ClusterCreatedMessageProcessor.java         |  35 +++--
 .../topology/ClusterResetMessageProcessor.java  | 146 +++++++++++++++++++
 19 files changed, 721 insertions(+), 205 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
index 9455a4c..9e8cf3e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -32,15 +32,33 @@ public class Applications implements Serializable {
 
     private Map<String, Application> applicationMap;
 
+    private boolean initialized;
+
     public Applications () {
         this.applicationMap = new HashMap<String, Application>();
     }
 
     public void addApplication (Application application) {
-        this.applicationMap.put(application.getUniqueIdentifier(), application);
+        this.getApplications().put(application.getUniqueIdentifier(), application);
     }
 
     public Application getApplication (String appId) {
-        return this.applicationMap.get(appId);
+        return this.getApplications().get(appId);
+    }
+
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    public void setInitialized(boolean initialized) {
+        this.initialized = initialized;
+    }
+
+    public boolean applicationExists(String appId) {
+        return this.getApplications().containsKey(appId);
+    }
+
+    public Map<String, Application> getApplications() {
+        return applicationMap;
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
index 71bfe03..cc31892 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
@@ -85,4 +85,7 @@ public class ApplicationLockHierarchy {
         }
     }
 
+    public ApplicationLock getApplicationLock() {
+        return applicationLock;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
index dfb90f2..26ba7f2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
@@ -18,6 +18,7 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.event.Event;
 
 import java.io.Serializable;
@@ -28,13 +29,13 @@ import java.io.Serializable;
 public class ApplicationCreatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
-    private String appId;
+    private Application application;
 
-    public ApplicationCreatedEvent(String appId) {
-        this.appId = appId;
+    public ApplicationCreatedEvent(Application application) {
+        this.application = application;
     }
 
-    public String getAppId() {
-        return appId;
+    public Application getApplication() {
+        return application;
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java
new file mode 100644
index 0000000..25035ab
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.event.topology.TopologyEvent;
+
+import java.io.Serializable;
+
+/**
+ *  This event is fired periodically with the complete topology. It would be a
+ *  starting point for subscribers to initialize the current state of the topology
+ *  before receiving other topology events.
+ */
+public class CompleteApplicationsEvent extends TopologyEvent implements Serializable {
+    private static final long serialVersionUID = 8580862188444892004L;
+
+    private final Applications applications;
+
+    public CompleteApplicationsEvent(Applications applications) {
+        this.applications = applications;
+    }
+
+    public Applications getApplications() {
+        return applications;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
deleted file mode 100644
index d28cca1..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.cluster.status;
-
-import org.apache.stratos.messaging.event.Event;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class ClusterStatusClusterCreatedEvent extends Event {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
new file mode 100644
index 0000000..68c8e7f
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterResettedEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterResettedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java
index 70452ab..4c06f3b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java
@@ -28,31 +28,19 @@ import java.io.Serializable;
 public class ClusterCreatedEvent extends TopologyEvent implements Serializable {
     private static final long serialVersionUID = 2080623816272047762L;
 
-    private final String appId;
-    private final String serviceName;
-	private final String clusterId;
+    private final Cluster cluster;
 
-
-    public ClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        this.appId = appId;
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
+    public ClusterCreatedEvent(Cluster cluster) {
+        this.cluster = cluster;
     }
 
-    public String getServiceName() {
-        return serviceName;
-    }
-    
     @Override
     public String toString() {
-        return "ClusterCreatedEvent [serviceName=" + serviceName + ", application=" + appId + "]";
-    }
-
-    public String getClusterId() {
-        return clusterId;
+        return "ClusterCreatedEvent [serviceName=" + cluster.getServiceName() + ", " +
+                "application=" + cluster.getAppId() + " , cluster= " + cluster.getClusterId() + " ]";
     }
 
-    public String getAppId() {
-        return appId;
+    public Cluster getCluster() {
+        return cluster;
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java
new file mode 100644
index 0000000..d4d6622
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.topology;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * Cluster activated event will be sent by Autoscaler
+ */
+public class ClusterResetEvent extends Event {
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterResetEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    @Override
+    public String toString() {
+        return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" +
+                "]";
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java
new file mode 100644
index 0000000..cd1bb24
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class CompleteApplicationsEventListener extends EventListener {
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
deleted file mode 100644
index 6ca5476..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.cluster.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java
new file mode 100644
index 0000000..375ae32
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterResetEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
index 92d61ba..db8e3c8 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
@@ -21,10 +21,10 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
@@ -44,10 +44,10 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
     @Override
     public boolean process(String type, String message, Object object) {
 
-        Topology topology = (Topology) object;
+        Applications applications = (Applications) object;
 
         if (ApplicationCreatedEvent.class.getName().equals(type)) {
-            if (!topology.isInitialized()) {
+            if (!applications.isInitialized()) {
                 return false;
             }
 
@@ -58,37 +58,24 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
             }
 
             TopologyUpdater.acquireWriteLockForApplications();
-            // since the Clusters will also get modified, acquire write locks for each Service Type
-            Set<ClusterDataHolder> clusterDataHolders = event.getApplication().getClusterDataRecursively();
-            if (clusterDataHolders != null) {
-                for (ClusterDataHolder clusterData : clusterDataHolders) {
-                    TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
-                }
-            }
-
             try {
-                return doProcess(event, topology);
+                return doProcess(event, applications);
 
             } finally {
-                if (clusterDataHolders != null) {
-                    for (ClusterDataHolder clusterData : clusterDataHolders) {
-                        TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
-                    }
-                }
                 TopologyUpdater.releaseWriteLockForApplications();
             }
 
         } else {
             if (nextProcessor != null) {
                 // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, topology);
+                return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (ApplicationCreatedEvent event,Topology topology) {
+    private boolean doProcess(ApplicationCreatedEvent event, Applications topology) {
 
         // check if required properties are available
         if (event.getApplication() == null) {
@@ -109,9 +96,6 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
 
         } else {
             // add application and the clusters to Topology
-            for(Cluster cluster: event.getClusterList()) {
-                topology.getService(cluster.getServiceName()).addCluster(cluster);
-            }
             topology.addApplication(event.getApplication());
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
new file mode 100644
index 0000000..53c469b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
+import org.apache.stratos.messaging.event.applications.CompleteApplicationsEvent;
+import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
+import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
+import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter;
+import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class CompleteApplicationsMessageProcessor extends MessageProcessor {
+
+    private static final Log log = LogFactory.getLog(CompleteApplicationsMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Applications applications = (Applications) object;
+
+        if (CompleteApplicationsEvent.class.getName().equals(type)) {
+        	// Parse complete message and build event
+            CompleteApplicationsEvent event = (CompleteApplicationsEvent) Util.
+                    jsonToObject(message, CompleteApplicationsEvent.class);
+
+            if (!applications.isInitialized()) {
+                ApplicationsUpdater.acquireWriteLock();
+
+                try {
+                    doProcess(event, applications);
+
+                } finally {
+                    ApplicationsUpdater.releaseWriteLock();
+                }
+            }
+
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, applications);
+            }
+            return false;
+        }
+    }
+
+    private void doProcess (CompleteApplicationsEvent event, Applications applications) {
+    // add existing Applications to Topology
+        Collection<Application> applicationsList = event.getApplications().getApplications().values();
+        if (applicationsList != null && !applicationsList.isEmpty()) {
+            for (Application application : applicationsList) {
+                applications.addApplication(application);
+                if (log.isDebugEnabled()) {
+                    log.debug("Application with id [ " +  application.getUniqueIdentifier() + " ] added to Topology");
+                }
+            }
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("No Application information found in Complete Topology event");
+            }
+        }
+
+        if (log.isInfoEnabled()) {
+            log.info("Topology initialized");
+        }
+
+        // Set topology initialized
+        applications.setInitialized(true);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
new file mode 100644
index 0000000..bbbfbf5
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.message.processor.applications.updater;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+
+/**
+ * Used to lock the Topology for writes by messaging component
+ *
+ *  Acquire a write lock:
+ *
+ *  From root level, acquire read lock, and acquire a write lock only for the
+ *  relevant sub tree.
+ *
+ *  Example 1: Acquiring write lock for a Cluster to modify the Cluster object -
+ *           acquiring:
+ *           public static void acquireWriteLockForCluster (String serviceName, String clusterId)
+ *
+ *           releasing:
+ *           public static void releaseWriteLockForCluster (String serviceName, String clusterId)
+ *
+ *  Example 2: Acquiring write lock to add a new Cluster object -
+ *           acquiring:
+ *           public static void acquireWriteLockForService (String serviceName)
+ *
+ *           releasing:
+ *           public static void releaseWriteLockForService (String serviceName)
+ *
+ *  Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service)
+ *           acquire:
+ *           public static void acquireWriteLockForServices()
+ *
+ *           release:
+ *           public static void releaseWriteLockForServices()
+ */
+
+public class ApplicationsUpdater {
+
+    private static final Log log = LogFactory.getLog(ApplicationsUpdater.class);
+
+    private static volatile ApplicationLockHierarchy applicationLockHierarchy =
+            ApplicationLockHierarchy.getInstance();
+
+    // Top level locks - should be used to lock the entire Topology
+
+    /**
+     * Acquires write lock for the Complete Topology
+     */
+    public static void acquireWriteLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Write lock acquired for Topology");
+        }
+        applicationLockHierarchy.getApplicationLock().acquireWriteLock();
+    }
+
+    /**
+     * Releases write lock for the Complete Topology
+     */
+    public static void releaseWriteLock() {
+        if(log.isDebugEnabled()) {
+            log.debug("Write lock released for Topology");
+        }
+        applicationLockHierarchy.getApplicationLock().releaseWritelock();
+    }
+
+    /**
+     * Acquires write lock for the Application
+     *
+     * @param appId Application id
+     */
+    public static void acquireWriteLockForApplication (String appId) {
+
+        // acquire read lock for all Applications
+        TopologyManager.acquireReadLockForApplications();
+
+        ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+        if (applicationLock == null)  {
+            handleLockNotFound("Topology lock not found for Application " + appId);
+
+        } else {
+            // now, lock Application
+            applicationLock.acquireWriteLock();
+            if(log.isDebugEnabled()) {
+                log.debug("Write lock acquired for Application " + appId);
+            }
+        }
+    }
+
+    /**
+     * Releases write lock for the Application
+     *
+     * @param appId Application id
+     */
+    public static void releaseWriteLockForApplication (String appId) {
+
+        ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+        if (applicationLock == null)  {
+            handleLockNotFound("Topology lock not found for Application " + appId);
+
+        } else {
+            // release App lock
+            applicationLock.releaseWritelock();
+            if(log.isDebugEnabled()) {
+                log.debug("Write lock released for Application " + appId);
+            }
+        }
+
+        // release read lock for all Applications
+        TopologyManager.releaseReadLockForApplications();
+    }
+
+    private static void handleLockNotFound (String errorMsg) {
+        log.warn(errorMsg);
+        //throw new RuntimeException(errorMsg);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
deleted file mode 100644
index 9b4780b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.cluster.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util.
-                    jsonToObject(message, ClusterStatusClusterCreatedEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
new file mode 100644
index 0000000..b5bf301
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterResetMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterResetMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterResettedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterResettedEvent event = (ClusterStatusClusterResettedEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterResettedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
index 29556ec..42092bc 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
@@ -32,13 +32,13 @@ public class ClusterStatusMessageProcessorChain extends MessageProcessorChain {
 
 
     private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
-    private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
+    private ClusterStatusClusterResetMessageProcessor clusterCreatedMessageProcessor;
     private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor;
     private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
     private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
     @Override
     protected void initialize() {
-        clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor();
+        clusterCreatedMessageProcessor = new ClusterStatusClusterResetMessageProcessor();
         add(clusterCreatedMessageProcessor);
 
         clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor();
@@ -60,7 +60,7 @@ public class ClusterStatusMessageProcessorChain extends MessageProcessorChain {
 
     @Override
     public void addEventListener(EventListener eventListener) {
-        if(eventListener instanceof ClusterStatusClusterCreatedEventListener) {
+        if(eventListener instanceof ClusterStatusClusterResetEventListener) {
             clusterCreatedMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) {
             clusterInactivateMessageProcessor.addEventListener(eventListener);

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
index b8cd80f..0ff303c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
@@ -50,13 +50,13 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
 
             // Parse complete message and build event
             ClusterCreatedEvent event = (ClusterCreatedEvent) Util.jsonToObject(message, ClusterCreatedEvent.class);
-
-            TopologyUpdater.acquireWriteLockForService(event.getServiceName());
+            String serviceName = event.getCluster().getServiceName();
+            TopologyUpdater.acquireWriteLockForService(serviceName);
             try {
                 return doProcess(event, topology);
 
             } finally {
-                TopologyUpdater.releaseWriteLockForService(event.getServiceName());
+                TopologyUpdater.releaseWriteLockForService(serviceName);
             }
 
         } else {
@@ -70,13 +70,15 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
     }
 
     private boolean doProcess (ClusterCreatedEvent event,Topology topology) {
-
+        Cluster cluster = event.getCluster();
+        String serviceName = cluster.getServiceName();
+        String clusterId = cluster.getClusterId();
         // Apply service filter
         if (TopologyServiceFilter.getInstance().isActive()) {
-            if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
+            if (TopologyServiceFilter.getInstance().serviceNameExcluded(serviceName)) {
                 // Service is excluded, do not update topology or fire event
                 if (log.isDebugEnabled()) {
-                    log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
+                    log.debug(String.format("Service is excluded: [service] %s", serviceName));
                 }
                 return false;
             }
@@ -84,10 +86,10 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
 
         // Apply cluster filter
         if (TopologyClusterFilter.getInstance().isActive()) {
-            if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) {
+            if (TopologyClusterFilter.getInstance().clusterIdExcluded(clusterId)) {
                 // Cluster is excluded, do not update topology or fire event
                 if (log.isDebugEnabled()) {
-                    log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId()));
+                    log.debug(String.format("Cluster is excluded: [cluster] %s", clusterId));
                 }
                 return false;
             }
@@ -105,27 +107,24 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
             throw new RuntimeException("Host name/s not found in cluster created event");
         }*/
         // Validate event against the existing topology
-        Service service = topology.getService(event.getServiceName());
+        Service service = topology.getService(serviceName);
         if (service == null) {
             if (log.isWarnEnabled()) {
                 log.warn(String.format("Service does not exist: [service] %s",
-                        event.getServiceName()));
+                        serviceName));
             }
             return false;
         }
-        if (service.clusterExists(event.getClusterId())) {
+        if (service.clusterExists(clusterId)) {
             if (log.isWarnEnabled()) {
-                log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(),
-                        event.getClusterId()));
+                log.warn(String.format("Cluster already exists in service: [service] %s " +
+                                "[cluster] %s",serviceName ,
+                        clusterId));
             }
         } else {
 
             // Apply changes to the topology
-            Cluster cluster = service.getCluster(event.getClusterId());
-            if (!cluster.isStateTransitionValid(ClusterStatus.Created)) {
-                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " +
-                        "for cluster " + cluster.getClusterId());
-            }
+            service.addCluster(cluster);
             cluster.setStatus(ClusterStatus.Created);
             if (log.isInfoEnabled()) {
                 log.info(String.format("Cluster created: %s",

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f7d7b0d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
new file mode 100644
index 0000000..3cfb2dc
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.topology;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterResetEvent;
+import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
+import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+public class ClusterResetMessageProcessor extends MessageProcessor {
+
+    private static final Log log = LogFactory.getLog(ClusterResetMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+
+        Topology topology = (Topology) object;
+        if (ClusterResetEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized()) {
+                return false;
+            }
+
+            // Parse complete message and build event
+            ClusterResetEvent event = (ClusterResetEvent) Util.
+                    jsonToObject(message, ClusterResetEvent.class);
+
+            TopologyUpdater.acquireWriteLockForService(event.getServiceName());
+            try {
+                return doProcess(event, topology);
+
+            } finally {
+                TopologyUpdater.releaseWriteLockForService(event.getServiceName());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess (ClusterResetEvent event,Topology topology) {
+
+        // Apply service filter
+        if (TopologyServiceFilter.getInstance().isActive()) {
+            if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
+                // Service is excluded, do not update topology or fire event
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
+                }
+                return false;
+            }
+        }
+
+        // Apply cluster filter
+        if (TopologyClusterFilter.getInstance().isActive()) {
+            if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) {
+                // Cluster is excluded, do not update topology or fire event
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId()));
+                }
+                return false;
+            }
+        }
+
+        // Validate event properties
+        /*Cluster cluster = event.getCluster();
+
+        if(cluster == null) {
+            String msg = "Cluster object of cluster created event is null.";
+            log.error(msg);
+            throw new RuntimeException(msg);
+        }
+        if (cluster.getHostNames().isEmpty()) {
+            throw new RuntimeException("Host name/s not found in cluster created event");
+        }*/
+        // Validate event against the existing topology
+        Service service = topology.getService(event.getServiceName());
+        if (service == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Service does not exist: [service] %s",
+                        event.getServiceName()));
+            }
+            return false;
+        }
+        if (service.clusterExists(event.getClusterId())) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(),
+                        event.getClusterId()));
+            }
+        } else {
+
+            // Apply changes to the topology
+            Cluster cluster = service.getCluster(event.getClusterId());
+            if (!cluster.isStateTransitionValid(ClusterStatus.Created)) {
+                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " +
+                        "for cluster " + cluster.getClusterId());
+            }
+            cluster.setStatus(ClusterStatus.Created);
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Cluster reset as Created: %s",
+                        cluster.toString()));
+            }
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}


[10/50] [abbrv] git commit: uddating applications topic

Posted by im...@apache.org.
uddating applications topic


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

Branch: refs/heads/docker-grouping-merge
Commit: ea9337d36508111c9ad095aadf61e66c43ec4ecf
Parents: f0ba4be
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 12:23:17 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 12:23:39 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        |  1 +
 .../ApplicationStatusTopicReceiver.java         | 62 ++++++-------
 .../controller/topology/TopologyBuilder.java    | 45 ++++++----
 .../AppStatusMessageProcessorChain.java         | 94 ++++++++++----------
 .../topology/TopologyMessageProcessorChain.java |  1 +
 5 files changed, 107 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ea9337d3/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index fe4d9df..97ba3f1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -44,6 +44,7 @@ import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;

http://git-wip-us.apache.org/repos/asf/stratos/blob/ea9337d3/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index 9db0998..d83a7d3 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -22,8 +22,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.listener.application.status.*;
+import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.listener.applications.*;
 import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver;
 
 public class ApplicationStatusTopicReceiver implements Runnable {
@@ -64,74 +64,74 @@ public class ApplicationStatusTopicReceiver implements Runnable {
 
     private void addEventListeners() {
         // Listen to topology events that affect clusters
-        statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() {
+        statusEventReceiver.addEventListener(new AppClusterCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterCreated((AppStatusClusterCreatedEvent) event);
+                TopologyBuilder.handleClusterCreated((AppClusterCreatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusClusterActivatedEventListener() {
+        statusEventReceiver.addEventListener(new AppClusterActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterActivatedEvent((AppStatusClusterActivatedEvent) event);
+                TopologyBuilder.handleClusterActivatedEvent((AppClusterActivatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() {
+        statusEventReceiver.addEventListener(new AppClusterTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatedEvent((AppStatusClusterTerminatedEvent) event);
+                TopologyBuilder.handleClusterTerminatedEvent((AppClusterTerminatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){
+        statusEventReceiver.addEventListener(new AppClusterTerminatingEventListener(){
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatingEvent((AppStatusClusterTerminatingEvent) event);
+                TopologyBuilder.handleClusterTerminatingEvent((AppClusterTerminatingEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusClusterInactivateEventListener() {
+        statusEventReceiver.addEventListener(new AppClusterInactivateEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterInActivateEvent((AppStatusClusterInactivateEvent) event);
+                TopologyBuilder.handleClusterInActivateEvent((AppClusterInactivateEvent) event);
             }
         });
 
 
-        statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() {
+        statusEventReceiver.addEventListener(new GroupCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupCreated((AppStatusGroupCreatedEvent) event);
+                TopologyBuilder.handleGroupCreated((GroupCreatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusGroupActivatedEventListener() {
+        statusEventReceiver.addEventListener(new GroupActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupActivatedEvent((AppStatusGroupActivatedEvent) event);
+                TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusGroupTerminatedEventListener() {
+        statusEventReceiver.addEventListener(new GroupTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupTerminatedEvent((AppStatusGroupTerminatedEvent) event);
+                TopologyBuilder.handleGroupTerminatedEvent((GroupTerminatedEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusGroupTerminatingEventListener() {
+        statusEventReceiver.addEventListener(new GroupTerminatingEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupTerminatingEvent((AppStatusGroupTerminatingEvent) event);
+                TopologyBuilder.handleGroupTerminatingEvent((GroupTerminatingEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusGroupInactivateEventListener() {
+        statusEventReceiver.addEventListener(new GroupInactivateEventListener() {
             @Override
             protected void onEvent(Event event) {
                 TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event);
@@ -139,44 +139,44 @@ public class ApplicationStatusTopicReceiver implements Runnable {
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener() {
+        statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() {
 
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationActivatedEvent((AppStatusApplicationActivatedEvent) event);
+                TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusApplicationInactivatedEventListener() {
+        statusEventReceiver.addEventListener(new ApplicationInactivatedEventListener() {
 
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationInActivatedEvent((AppStatusApplicationInactivatedEvent) event);
+                TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusApplicationCreatedEventListener() {
+        statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationCreatedEvent((AppStatusApplicationCreatedEvent) event);
+                TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusApplicationTerminatingEventListener() {
+        statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationTerminatingEvent((AppStatusApplicationTerminatingEvent) event);
+                TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event);
 
             }
         });
 
-        statusEventReceiver.addEventListener(new AppStatusApplicationTerminatedEventListener() {
+        statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationTerminatedEvent((AppStatusApplicationTerminatedEvent) event);
+                TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event);
 
             }
         });

http://git-wip-us.apache.org/repos/asf/stratos/blob/ea9337d3/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 e31cf32..3bc7b5a 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
@@ -31,7 +31,16 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.application.status.*;
+import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
+import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
+import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent;
+import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
+import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
@@ -115,7 +124,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterCreated (AppStatusClusterCreatedEvent event) {
+    public static void handleClusterCreated (AppClusterCreatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -152,7 +161,7 @@ public class TopologyBuilder {
                 event.getClusterId());
     }
 
-    public static void handleGroupCreated (AppStatusGroupCreatedEvent event) {
+    public static void handleGroupCreated (GroupCreatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -186,7 +195,7 @@ public class TopologyBuilder {
             TopologyManager.releaseWriteLock();
         }
 
-        TopologyEventPublisher.sendGroupCreatedEvent(new GroupCreatedEvent(event.getAppId(), event.getGroupId()));
+        TopologyEventPublisher.sendGroupCreatedEvent(new org.apache.stratos.messaging.event.topology.GroupCreatedEvent(event.getAppId(), event.getGroupId()));
     }
 
     public static void handleClusterCreated(Registrant registrant, boolean isLb) {
@@ -713,7 +722,7 @@ public class TopologyBuilder {
     }
 
 
-    public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) {
+    public static void handleClusterActivatedEvent(AppClusterActivatedEvent clusterActivatedEvent) {
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(clusterActivatedEvent.getServiceName());
         //update the status of the cluster
@@ -751,7 +760,7 @@ public class TopologyBuilder {
     }
 
     public static void handleClusterInActivateEvent(
-            AppStatusClusterInactivateEvent clusterInActivateEvent) {
+            AppClusterInactivateEvent clusterInActivateEvent) {
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(clusterInActivateEvent.getServiceName());
         //update the status of the cluster
@@ -788,7 +797,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1);
     }
 
-    public static void handleGroupActivatedEvent(AppStatusGroupActivatedEvent groupActivatedEvent) {
+    public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(groupActivatedEvent.getAppId());
         //update the status of the Group
@@ -822,7 +831,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1);
     }
 
-    public static void handleApplicationActivatedEvent(AppStatusApplicationActivatedEvent applicationActivatedEvent) {
+    public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(applicationActivatedEvent.getAppId());
         //update the status of the Group
@@ -848,7 +857,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1);
     }
 
-    public static void handleApplicationInActivatedEvent(AppStatusApplicationInactivatedEvent event) {
+    public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(event.getAppId());
         //update the status of the Group
@@ -874,7 +883,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent);
     }
 
-    public static void handleApplicationCreatedEvent(AppStatusApplicationCreatedEvent event) {
+    public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(event.getAppId());
         //update the status of the Group
@@ -907,7 +916,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent);
     }
 
-    public static void handleApplicationTerminatingEvent(AppStatusApplicationTerminatingEvent event) {
+    public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
 
         String applicationId = event.getAppId();
 
@@ -956,7 +965,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminatedEvent event) {
+    public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
 
      Topology topology = TopologyManager.getTopology();
 
@@ -1018,7 +1027,7 @@ public class TopologyBuilder {
 
                 log.info("Removed application [ " + event.getAppId() + " ] from Topology");
 
-                TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(),
+                TopologyEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(event.getAppId(),
                         clusterData, tenantId, tenantDomain));
             }
 
@@ -1027,7 +1036,7 @@ public class TopologyBuilder {
         }
     }
 
-    private static void deleteAppResourcesFromMetadataService(AppStatusApplicationTerminatedEvent event) {
+    private static void deleteAppResourcesFromMetadataService(ApplicationTerminatedEvent event) {
         try {
             MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient();
             metadataClient.deleteApplicationProperties(event.getAppId());
@@ -1071,7 +1080,7 @@ public class TopologyBuilder {
     }
 
 
-    public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent event) {
+    public static void handleGroupTerminatedEvent(GroupTerminatedEvent event) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(event.getAppId());
         //update the status of the Group
@@ -1105,7 +1114,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent);
     }
 
-    public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent event) {
+    public static void handleGroupTerminatingEvent(GroupTerminatingEvent event) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(event.getAppId());
         //update the status of the Group
@@ -1139,7 +1148,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
     }
 
-    public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent event) {
+    public static void handleClusterTerminatedEvent(AppClusterTerminatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -1166,7 +1175,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent);
     }
 
-    public static void handleClusterTerminatingEvent(AppStatusClusterTerminatingEvent event) {
+    public static void handleClusterTerminatingEvent(AppClusterTerminatingEvent event) {
 
         TopologyManager.acquireWriteLock();
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ea9337d3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
index 1524b00..3705f1e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
@@ -21,7 +21,7 @@ package org.apache.stratos.messaging.message.processor.applications;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.listener.application.status.*;
+import org.apache.stratos.messaging.listener.applications.*;
 import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 
 /**
@@ -31,68 +31,68 @@ import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 public class AppStatusMessageProcessorChain extends MessageProcessorChain {
     private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
 
-    private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
-    private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
-    private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
-    private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
-    private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
-    private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor;
-    private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
-    private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor;
-    private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor;
-    private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
-    private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
-    private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
-    private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
-
-    private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
-    private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
+    private AppClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
+    private AppClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
+    private AppClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
+    private AppClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
+    private AppClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
+    private GroupCreatedMessageProcessor groupCreatedMessageProcessor;
+    private GroupActivatedMessageProcessor groupActivatedMessageProcessor;
+    private GroupInactivatedMessageProcessor groupInActivateMessageProcessor;
+    private ApplicationActivatedMessageProcessor appActivatedMessageProcessor;
+    private ApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
+    private ApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
+    private ApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
+    private ApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
+
+    private GroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
+    private GroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
 
     public void initialize() {
         // Add instance notifier event processors
-        clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor();
+        clusterCreatedMessageProcessor= new AppClusterCreatedMessageProcessor();
         add(clusterCreatedMessageProcessor);
 
-        clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor();
+        clusterActivatedMessageProcessor = new AppClusterActivatedMessageProcessor();
         add(clusterActivatedMessageProcessor);
 
-        clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor();
+        clusterInActivateMessageProcessor = new AppClusterInactivateMessageProcessor();
         add(clusterInActivateMessageProcessor);
 
-        clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
+        clusterTerminatingMessageProcessor = new AppClusterTerminatingMessageProcessor();
         add(clusterTerminatingMessageProcessor);
 
-        clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
+        clusterTerminatedMessageProcessor = new AppClusterTerminatedMessageProcessor();
         add(clusterTerminatedMessageProcessor);
 
-        groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor();
+        groupCreatedMessageProcessor = new GroupCreatedMessageProcessor();
         add(groupCreatedMessageProcessor);
 
-        groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor();
+        groupActivatedMessageProcessor = new GroupActivatedMessageProcessor();
         add(groupActivatedMessageProcessor);
 
-        groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor();
+        groupInActivateMessageProcessor = new GroupInactivatedMessageProcessor();
         add(groupInActivateMessageProcessor);
 
-        appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor();
+        appActivatedMessageProcessor = new ApplicationActivatedMessageProcessor();
         add(appActivatedMessageProcessor);
 
-        applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor();
+        applicationStatusAppCreatedMessageProcessor = new ApplicationCreatedMessageProcessor();
         this.add(applicationStatusAppCreatedMessageProcessor);
 
-        applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor();
+        applicationStatusAppInActivatedMessageProcessor = new ApplicationInactivatedMessageProcessor();
         this.add(applicationStatusAppInActivatedMessageProcessor);
 
-        applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor();
+        applicationStatusAppTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor();
         this.add(applicationStatusAppTerminatedMessageProcessor);
 
-        applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor();
+        applicationStatusAppTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor();
         this.add(applicationStatusAppTerminatingMessageProcessor);
 
-        groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor();
+        groupTerminatedMessageProcessor = new GroupTerminatedMessageProcessor();
         this.add(groupTerminatedMessageProcessor);
 
-        groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor();
+        groupTerminatingMessageProcessor = new GroupTerminatingMessageProcessor();
         this.add(groupTerminatingMessageProcessor);
 
         if (log.isDebugEnabled()) {
@@ -101,35 +101,35 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain {
     }
 
     public void addEventListener(EventListener eventListener) {
-        if(eventListener instanceof AppStatusClusterCreatedEventListener) {
+        if(eventListener instanceof AppClusterCreatedEventListener) {
             clusterCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusClusterActivatedEventListener) {
+        } else if (eventListener instanceof AppClusterActivatedEventListener) {
             clusterActivatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusClusterInactivateEventListener) {
+        } else if (eventListener instanceof AppClusterInactivateEventListener) {
             clusterInActivateMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusGroupCreatedEventListener) {
+        } else if(eventListener instanceof GroupCreatedEventListener) {
             groupCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupActivatedEventListener) {
+        } else if (eventListener instanceof GroupActivatedEventListener) {
             groupActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){
+        } else if(eventListener instanceof AppClusterTerminatedEventListener){
             clusterTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){
+        } else if(eventListener instanceof AppClusterTerminatingEventListener){
             clusterTerminatingMessageProcessor.addEventListener(eventListener);
-        }else if (eventListener instanceof AppStatusGroupInactivateEventListener) {
+        }else if (eventListener instanceof GroupInactivateEventListener) {
             groupInActivateMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) {
+        } else if (eventListener instanceof ApplicationActivatedEventListener) {
             appActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){
+        } else if(eventListener instanceof ApplicationInactivatedEventListener){
             applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){
+        } else if(eventListener instanceof ApplicationCreatedEventListener){
             applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){
+        } else if(eventListener instanceof ApplicationTerminatingEventListener){
             applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){
+        } else if(eventListener instanceof ApplicationTerminatedEventListener){
             applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){
+        } else if (eventListener instanceof GroupTerminatingEventListener){
             groupTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){
+        } else if (eventListener instanceof GroupTerminatedEventListener){
             groupTerminatedMessageProcessor.addEventListener(eventListener);
         } else
         {

http://git-wip-us.apache.org/repos/asf/stratos/blob/ea9337d3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index 1ed5576..d8d25d9 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -22,6 +22,7 @@ package org.apache.stratos.messaging.message.processor.topology;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 


[08/50] [abbrv] moving Application Strucutre related classes to applications package

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
deleted file mode 100644
index 86000e9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Abstraction for a an entity that can have child entities
- * in an Application withing the Topology
- */
-
-public abstract class ParentComponent implements Serializable {
-
-    // Dependency Order
-    private DependencyOrder dependencyOrder;
-    // Group Map, key = Group.alias
-    private Map<String, Group> aliasToGroupMap;
-    // Cluster Id map, key = subscription alias for the cartridge type
-    private Map<String, ClusterDataHolder> aliasToClusterDataMap;
-    // Application status
-
-    public ParentComponent () {
-        aliasToGroupMap = new HashMap<String, Group>();
-        aliasToClusterDataMap = new HashMap<String, ClusterDataHolder>();
-    }
-
-    /**
-     * This method should be implemented in each concrete child class
-     * to return the unique identifier for each implementation
-     * ex.: group alias for a Group, app id for an Application
-     *
-     * @return unique identifier String
-     */
-    public abstract String getUniqueIdentifier ();
-
-    /**
-     * Adds a group
-     *
-     * @param group Group instance to be added
-     */
-    public void addGroup(Group group) {
-        aliasToGroupMap.put(group.getUniqueIdentifier(), group);
-    }
-
-    /**
-     * Setter for Group alias to Group map
-     *
-     * @param groupAliasToGroup Map, key = alias given to the Group, value = Group
-     */
-    public void setGroups(Map<String, Group> groupAliasToGroup) {
-        aliasToGroupMap.putAll(groupAliasToGroup);
-    }
-
-    /**
-     * Get the Group for the given alias in the context of the parent entity.
-     * Will not search recursively in the nested levels.
-     *
-     * @param groupAlias alias of the Group
-     * @return Group, if exists for the given alias, else null
-     */
-    public Group getGroup(String groupAlias) {
-        return aliasToGroupMap.get(groupAlias);
-    }
-
-    /**
-     * Get the Group for the given alias in the context of the parent entity.
-     * Will search recursively in the nested levels.
-     *
-     * @param groupAlias alias of the Group
-     * @return Group, if exists for the given alias, else null
-     */
-    public Group getGroupRecursively(String groupAlias) {
-
-        return travereAndCheckRecursively(aliasToGroupMap, groupAlias);
-    }
-
-    private Group travereAndCheckRecursively (Map<String,Group> aliasToGroupMap, String groupAlias) {
-
-        if (aliasToGroupMap.containsKey(groupAlias)) {
-            synchronized (aliasToGroupMap) {
-                if (aliasToGroupMap.containsKey(groupAlias)) {
-                    return aliasToGroupMap.get(groupAlias);
-                }
-            }
-        } else {
-            for (Group group : aliasToGroupMap.values()) {
-                return travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias);
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Getter for alias to Group map
-     * Will not search recursively in the nested levels.
-     *
-     * @return Map, key = alias given to the Group, value = Group
-     */
-    public Map<String, Group> getAliasToGroupMap() {
-        return this.aliasToGroupMap;
-    }
-
-    /**
-     * Getter for cluster alias to ClusterData map for this level
-     *
-     * @return Map, key = alias given to the cluster, value =  ClusterData object
-     */
-    public Map<String, ClusterDataHolder> getClusterDataMap() {
-        return this.aliasToClusterDataMap;
-    }
-
-    /**
-     * Collection of Groups in this level
-     *
-     * @return Group Collection object, empty if no Groups are found
-     */
-    public Collection<Group> getGroups() {
-        return aliasToGroupMap.values();
-    }
-
-    /**
-     * Setter for Dependency Order
-     *
-     * @param dependencyOrder Dependency Order object
-     */
-    public void setDependencyOrder(DependencyOrder dependencyOrder) {
-        this.dependencyOrder = dependencyOrder;
-    }
-
-    /**
-     * Getter for Dependency Order for this level
-     *
-     * @return Dependency Order object
-     */
-    public DependencyOrder getDependencyOrder() {
-        return dependencyOrder;
-    }
-
-    /**
-     * Setter for alias to Cluster Data map
-     *
-     * @param aliasToClusterData Map, key = alias given to the cluster, value =  ClusterData object
-     */
-    public void setClusterData(Map<String, ClusterDataHolder> aliasToClusterData) {
-        this.aliasToClusterDataMap.putAll(aliasToClusterData);
-    }
-
-    /**
-     * Getter for Cluster Data instance for the given alias
-     * Will not search recursively in the nested levels.
-     *
-     * @param alias
-     * @return
-     */
-    public ClusterDataHolder getClusterData(String alias) {
-        return aliasToClusterDataMap.get(alias);
-    }
-
-    /**
-     * Collects the Cluster Data for the parent component and all the
-     * child components recursively
-     *
-     * @return Set of ClusterDataHolder objects if available, else null
-     */
-    public Set<ClusterDataHolder> getClusterDataRecursively () {
-
-        Set<ClusterDataHolder> appClusterData = new HashSet<ClusterDataHolder>();
-
-        // get top level Cluster Data
-        if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) {
-            appClusterData.addAll(this.aliasToClusterDataMap.values());
-        }
-
-        // find other nested Cluster Data (in the Groups)
-        if (getGroups() != null) {
-            getClusterData(appClusterData, getGroups());
-        }
-
-        return appClusterData;
-    }
-
-    private void getClusterData (Set<ClusterDataHolder> clusterData, Collection<Group> groups) {
-
-        for (Group group : groups) {
-            if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) {
-                clusterData.addAll(group.getClusterDataMap().values());
-                if (group.getGroups() != null) {
-                    getClusterData(clusterData, group.getGroups());
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java
deleted file mode 100644
index 4f55b6c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.domain.topology;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class StartupOrder implements Serializable {
-
-    private List<String> startList;
-
-    public StartupOrder (List<String> startList) {
-        this.startList = startList;
-    }
-
-    public List<String> getStartList() {
-        return startList;
-    }
-
-    public void setStartList(List<String> startList) {
-        this.startList = startList;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index ddd5ffa..0f128fa 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -26,6 +26,7 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
 import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
index 3fbb368..2dafcdc 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
@@ -18,7 +18,7 @@
  */
 package org.apache.stratos.messaging.event.application.status;
 
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 
 import java.io.Serializable;
 import java.util.Set;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java
index 425dd47..63b6439 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java
@@ -19,7 +19,7 @@
 
 package org.apache.stratos.messaging.event.topology;
 
-import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
index fa0cd26..4142685 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
@@ -18,7 +18,7 @@
  */
 package org.apache.stratos.messaging.event.topology;
 
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java
index ae56bb6..bd3667a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java
@@ -19,7 +19,7 @@
 
 package org.apache.stratos.messaging.event.topology;
 
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
index 064fb9c..341b402 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
@@ -20,8 +20,8 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
index 7d06fd5..079cb90 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java
@@ -22,7 +22,7 @@ package org.apache.stratos.messaging.message.processor.topology;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
index cda1d73..8c88324 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java
@@ -20,8 +20,8 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
index 3b91e3f..2dd3ea7 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
@@ -20,8 +20,8 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
index 6ad43d8..032be79 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
@@ -20,8 +20,8 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
index 04c6973..f368dd1 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java
@@ -21,6 +21,9 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
index f6af300..787ac74 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
@@ -20,6 +20,7 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
 import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
index aa050ef..09b9062 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
@@ -20,6 +20,9 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
index b6d2da9..d053f5d 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
@@ -20,12 +20,10 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
-import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
index d5dcd65..add40b4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
@@ -20,11 +20,10 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
index 5a308ba..767ff71 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
@@ -20,9 +20,9 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
index 27b5cff..5b15532 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
@@ -20,9 +20,9 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
index 8f25af1..b9b8e03 100644
--- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
+++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
@@ -19,6 +19,8 @@
 
 package org.apache.stratos.messaging.topology.locking;
 
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index d5e6882..6c8db77 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@ -32,9 +32,9 @@ import org.apache.stratos.manager.deploy.service.Service;
 import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
 import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
 import org.apache.stratos.manager.subscription.SubscriptionDomain;
-import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Group;
+import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.rest.endpoint.bean.ApplicationBean;
 import org.apache.stratos.rest.endpoint.bean.GroupBean;
 import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e1534308/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index b7b5695..9037f33 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -50,6 +50,9 @@ import org.apache.stratos.manager.subscription.SubscriptionData;
 import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
 import org.apache.stratos.manager.utils.ApplicationManagementUtil;
 import org.apache.stratos.manager.utils.CartridgeConstants;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.messaging.util.Constants;


[48/50] [abbrv] Merge branch '4.0.0-grouping' into docker-grouping-merge

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index df8cfd1,5e995da..a72e052
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@@ -32,7 -34,8 +34,9 @@@ import org.apache.stratos.autoscaler.ut
  import org.apache.stratos.autoscaler.util.Serializer;
  import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+ import org.apache.stratos.messaging.domain.applications.Application;
+ import org.apache.stratos.messaging.domain.applications.Applications;
 +import org.apache.stratos.common.kubernetes.KubernetesGroup;
  import org.wso2.carbon.registry.core.Registry;
  import org.wso2.carbon.registry.core.Resource;
  import org.wso2.carbon.registry.core.exceptions.RegistryException;
@@@ -141,6 -144,68 +145,69 @@@ public class RegistryManager 
          }
      }
  
+ 
++
+     public void persistApplication (Application application) {
+ 
+         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                 "/" + application.getUniqueIdentifier();
+         persist(application, resourcePath);
+         if(log.isDebugEnabled()) {
+             log.debug("Application [ " + application.getUniqueIdentifier() +
+                     " ] persisted successfully in the Autoscaler Registry");
+         }
+     }
+ 
+     public String [] getApplicationResourcePaths () {
+         Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE +
+                 AutoScalerConstants.APPLICATIONS_RESOURCE);
+ 
+         if (obj != null) {
+             if (obj instanceof String []) {
+                 return (String []) obj;
+             } else {
+                 log.warn("Expected object type not found for Applications in Registry");
+                 return null;
+             }
+         }
+         return null;
+     }
+ 
+     public Application getApplication (String applicationResourcePath) {
+         Object obj = retrieve(applicationResourcePath);
+ 
+         if (obj != null) {
+             if (obj instanceof Application) {
+                 return (Application) obj;
+             } else {
+                 log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry");
+                 return null;
+             }
+         }
+         return null;
+     }
+ 
+     public void removeApplication (String applicationId) {
+         delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
+                 "/" + applicationId);
+     }
+ 
+     public void persistServiceGroup(ServiceGroup servicegroup) {
+         if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){
+             throw new  IllegalArgumentException("Service group or group name can not be null");
+         }
+         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
+         persist(servicegroup, resourcePath);
+         if(log.isDebugEnabled()) {
+             log.debug(String.format("Persisted service group %s at path %s", servicegroup.getName(), resourcePath));
+         }
+     }
+ 
+     public boolean serviceGroupExist(String serviceGroupName){
+         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + serviceGroupName;
+         return this.resourceExist(resourcePath);
+     }
+     
      private Object retrieve(String resourcePath) {
          try {
              Resource resource = registryService.get(resourcePath);
@@@ -286,99 -353,91 +357,138 @@@
          return depPolicyList;
      }
  
-     public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
-         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
-         this.delete(resourcePath);
-         if (log.isDebugEnabled()) {
-             log.debug(String.format("Autoscaler policy deleted from registry: [id] %s [name] %s [description] %s",
-                     autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription()));
+     public ServiceGroup getServiceGroup(String name) throws Exception{
+         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + name;
+         Object serializedObj = registryManager.retrieve(resourcePath);
+         ServiceGroup group = null;
+         if (serializedObj != null) {
+ 
+                 Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+                 if (dataObj instanceof ServiceGroup) {
+                     group = (ServiceGroup) dataObj;
+                     if(log.isDebugEnabled()) {
+                         log.debug(group.toString());
+                     }
+                 } else {
+                     return null;
+                 }
          }
  
+         return group;
      }
  
-     public void removeDeploymentPolicy(DeploymentPolicy depPolicy) {
-         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE;
-         this.delete(resourcePath);
-         if (log.isDebugEnabled()) {
-             log.debug(String.format("Deployment policy deleted from registry: [id] %s",
-                     depPolicy.getId()));
+     public ServiceGroup removeServiceGroup(String name) throws Exception{
+         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE +
+                                                     AutoScalerConstants.SERVICE_GROUP + "/" + name;
+         Object serializedObj = registryManager.retrieve(resourcePath);
+         ServiceGroup group = null;
+         if (serializedObj != null) {
+             Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+             if (dataObj instanceof ServiceGroup) {
+                 group = (ServiceGroup) dataObj;
+                 if(log.isDebugEnabled()) {
+                     log.debug(group.toString());
+                 }
+             } else {
+                 return null;
+             }
          }
-     }
  
-     public void removeNetworkPartition(String networkPartition) {
-         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE;
-         this.delete(resourcePath);
-         if (log.isDebugEnabled()) {
-             log.debug(String.format("Network partition deleted from registry: [id] %s",
-                     networkPartition));
-         }
+         return group;
      }
  
+ 	public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
+ 		 String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
+          this.delete(resourcePath);
+ 	     if(log.isDebugEnabled()) {
+ 	          log.debug(String.format("Autoscaler policy deleted from registry: [id] %s [name] %s [description] %s",
+ 	                    autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription()));
+ 	     }
+ 		
+ 	}
+ 	
+ 	public void removeDeploymentPolicy(DeploymentPolicy depPolicy){
+ 		String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE;
+ 		this.delete(resourcePath);
+ 		if(log.isDebugEnabled()) {
+ 	          log.debug(String.format("Deployment policy deleted from registry: [id] %s" ,
+ 	        		  depPolicy.getId()));
+ 	     }
+ 	}
+ 	
+ 	public void removeNetworkPartition(String networkPartition){
+ 		String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE;
+ 		this.delete(resourcePath);
+ 		if(log.isDebugEnabled()) {
+ 	          log.debug(String.format("Network partition deleted from registry: [id] %s" ,
+ 	        		  networkPartition));
+ 	     }
+ 	}
 -	
  
 -	private void delete(String resourcePath) {
 -		 try {
 -	            registryService.beginTransaction();
 -	            registryService.delete(resourcePath);	           
 -	            registryService.commitTransaction();
 -	        } catch (RegistryException e) {
 -	            try {
 -	                registryService.rollbackTransaction();
 -	            } catch (RegistryException e1) {
 -	                if(log.isErrorEnabled()) {
 -	                    log.error("Could not rollback transaction", e);
 -	                }
 -	            }
 -	            log.error("Could not delete resource at "+ resourcePath);
 -	            throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
 -	        }
 +    private void delete(String resourcePath) {
 +        try {
 +            registryService.beginTransaction();
 +            registryService.delete(resourcePath);
 +            registryService.commitTransaction();
 +        } catch (RegistryException e) {
 +            try {
 +                registryService.rollbackTransaction();
 +            } catch (RegistryException e1) {
 +                if (log.isErrorEnabled()) {
 +                    log.error("Could not rollback transaction", e);
 +                }
 +            }
 +            log.error("Could not delete resource at " + resourcePath);
 +            throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
 +        }
 +
 +    }
  
 -	}
 +    public void persistKubernetesGroup(KubernetesGroup kubernetesGroup) {
 +        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.KUBERNETES_RESOURCE
 +                + "/" + kubernetesGroup.getGroupId();
 +        persist(kubernetesGroup, resourcePath);
 +        if (log.isDebugEnabled()) {
 +            log.debug(String.format("KubernetesGroup written to registry: [id] %s ", kubernetesGroup.getGroupId()));
 +        }
 +    }
 +
 +    public List<KubernetesGroup> retrieveKubernetesGroups() {
 +        List<KubernetesGroup> kubernetesGroupList = new ArrayList<KubernetesGroup>();
 +        RegistryManager registryManager = RegistryManager.getInstance();
 +        String[] kubernetesGroupResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.KUBERNETES_RESOURCE);
 +
 +        if (kubernetesGroupResourceList != null) {
 +            KubernetesGroup kubernetesGroup;
 +            for (String resourcePath : kubernetesGroupResourceList) {
 +                Object serializedObj = registryManager.retrieve(resourcePath);
 +                if (serializedObj != null) {
 +                    try {
 +                        Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
 +                        if (dataObj instanceof KubernetesGroup) {
 +                            kubernetesGroup = (KubernetesGroup) dataObj;
 +                            if (log.isDebugEnabled()) {
 +                                log.debug(kubernetesGroup.toString());
 +                            }
 +                            kubernetesGroupList.add(kubernetesGroup);
 +                        } else {
 +                            return null;
 +                        }
 +                    } catch (Exception e) {
 +                        String msg = "Unable to retrieve data from Registry. Hence, any historical Kubernetes groups deployments will not get reflected.";
 +                        log.warn(msg, e);
 +                    }
 +                }
 +            }
 +        }
 +        return kubernetesGroupList;
 +    }
 +
 +    public void removeKubernetesGroup(KubernetesGroup kubernetesGroup) {
 +        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.KUBERNETES_RESOURCE + "/" + kubernetesGroup.getGroupId();
 +        this.delete(resourcePath);
 +        if (log.isDebugEnabled()) {
 +            log.debug(String.format("Kubernetes group deleted from registry: [id] %s", kubernetesGroup.getGroupId()));
 +        }
 +    }
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 73d85f0,3586420..d828309
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@@ -23,9 -23,14 +23,15 @@@ import org.apache.commons.logging.LogFa
  import org.apache.stratos.autoscaler.AutoscalerContext;
  import org.apache.stratos.autoscaler.NetworkPartitionContext;
  import org.apache.stratos.autoscaler.PartitionContext;
+ import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
+ import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
+ import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
+ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
+ import org.apache.stratos.messaging.domain.applications.*;
 +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
  import org.apache.stratos.messaging.domain.topology.*;
+ import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
  import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
  
  import java.util.Map;

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
index b68f16d,3587afe..f5fede9
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
@@@ -39,18 -38,12 +39,21 @@@ public final class AutoScalerConstants 
  	public static final String NETWORK_PARTITION_LB_HOLDER_RESOURCE = "/network-partitions";
  	public static final String AS_POLICY_RESOURCE = "/policies/autoscalingPolicies";
  	public static final String DEPLOYMENT_POLICY_RESOURCE = "/policies/deploymentPolicies";
- 
+     public static final String APPLICATIONS_RESOURCE = "/applications";
  
      /**
 -     * Configs
 +     * Cluster monitoring  interval
       */
+     public static final String AUTOSCALER_MONITOR_INTERVAL = "autoscaler.monitorInterval";
+ 
+     public static final String SERVICE_GROUP = "/groups";
 +    public static final String VMService_Cluster_MONITOR_INTERVAL = "autoscaler.monitorInterval.vm.service";
 +    public static final String VMLb_Cluster_MONITOR_INTERVAL = "autoscaler.monitorInterval.vm.lb";
 +    public static final String KubernetesService_Cluster_MONITOR_INTERVAL = "autoscaler.monitorInterval.kubernetes.service";
 +
 +    /**
 +     * PortRange min max
 +     */
 +    public static final int PORT_RANGE_MAX = 65535;
 +    public static final int PORT_RANGE_MIN = 1;
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
index e7c16fe,835e284..93aa988
--- 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
@@@ -27,8 -22,15 +27,16 @@@ import javax.xml.namespace.QName
  import org.apache.axiom.om.OMElement;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
+ import org.apache.stratos.autoscaler.registry.RegistryManager;
+ import org.apache.stratos.cloud.controller.stub.pojo.Property;
  import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 +import org.apache.stratos.cloud.controller.stub.pojo.Property;
+ import org.apache.stratos.messaging.domain.applications.Application;
+ import org.apache.stratos.messaging.domain.applications.Applications;
+ 
+ 
+ import javax.xml.namespace.QName;
+ import java.util.*;
  
  /**
   * This class contains utility methods used by Autoscaler.

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
index 604aed8,8aa3d4f..19efc44
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
@@@ -79,20 -78,19 +78,25 @@@ public class CloudControllerDSComponen
              InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator();
              Thread tdelegator = new Thread(delegator);
              tdelegator.start();
 +            if(log.isInfoEnabled()) {
 +                log.info("Instance status message receiver thread started");
 +            }
  
 +            ApplicationStatusTopicReceiver applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver();
 +            Thread appThread = new Thread(applicationStatusTopicReceiver);
+             clusterStatusTopicReceiver = new ClusterStatusTopicReceiver();
+             Thread appThread = new Thread(clusterStatusTopicReceiver);
              appThread.start();
 +            if(log.isInfoEnabled()) {
 +                log.info("Application status message receiver thread started");
+             if (log.isDebugEnabled()) {
+                 log.debug("Cluster status Receiver thread started");
              }
  
 -        	
          	// Register cloud controller service
              BundleContext bundleContext = context.getBundleContext();
-             bundleContext.registerService(CloudControllerService.class.getName(), new CloudControllerServiceImpl(), null);
+             bundleContext.registerService(CloudControllerService.class.getName(),
+                     new CloudControllerServiceImpl(), null);
  
              if(log.isInfoEnabled()) {
                  log.info("Scheduling tasks");

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
index 662e481,0000000..3db9f71
mode 100644,000000..100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
@@@ -1,102 -1,0 +1,99 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *  http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +package org.apache.stratos.cloud.controller.pojo.payload;
 +
- import java.io.Serializable;
 +import java.util.Properties;
 +
 +/**
 + * Holds payload/meta data related to a cluster
 + */
 +
- public class MetaDataHolder implements Serializable {
- 
-     private static final long serialVersionUID = -3015788285718847360L;
++public class MetaDataHolder {
 +
 +    private String appId;
 +
 +    private String groupName;
 +
 +    private String clusterId;
 +
 +    private Properties properties;
 +
 +    public MetaDataHolder (String appId, String clusterId) {
 +
 +        this.appId = appId;
 +        this.clusterId = clusterId;
 +    }
 +
 +    public MetaDataHolder(String appId, String groupName, String clusterId) {
 +
 +        this.appId = appId;
 +        this.groupName = groupName;
 +        this.clusterId = clusterId;
 +    }
 +
 +    public String getAppId() {
 +        return appId;
 +    }
 +
 +    public String getGroupName() {
 +        return groupName;
 +    }
 +
 +    public String getClusterId() {
 +        return clusterId;
 +    }
 +
 +    public boolean equals(Object other) {
 +
 +        if(other == null || !(other instanceof MetaDataHolder)) {
 +            return false;
 +        }
 +
 +        if(this == other) {
 +            return true;
 +        }
 +
 +        MetaDataHolder that = (MetaDataHolder)other;
 +
 +        if (this.groupName == null || that.groupName == null) {
 +            return this.appId.equals(that.appId) && this.clusterId.equals(that.clusterId);
 +        } else {
 +            return this.appId.equals(that.appId) && this.groupName.equals(that.groupName) &&
 +                    this.clusterId.equals(that.clusterId);
 +        }
 +    }
 +
 +    public int hashCode () {
 +
 +        if (this.getGroupName() == null) {
 +            return this.appId.hashCode() + this.clusterId.hashCode();
 +        } else {
 +            return this.appId.hashCode() + this.groupName.hashCode() + this.clusterId.hashCode();
 +        }
 +    }
 +
 +    public Properties getProperties() {
 +        return properties;
 +    }
 +
 +    public void setProperties(Properties properties) {
 +        this.properties = properties;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index 2c01be7,0ec8f01..eebc077
--- 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
@@@ -23,16 -22,14 +23,15 @@@ import org.apache.commons.logging.Log
  import org.apache.commons.logging.LogFactory;
  import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
  import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
- import org.apache.stratos.cloud.controller.pojo.*;
  import org.apache.stratos.cloud.controller.pojo.Cartridge;
- import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
+ import org.apache.stratos.cloud.controller.pojo.*;
  import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher;
- import org.apache.stratos.cloud.controller.registry.RegistryManager;
  import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
  import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 +import org.apache.stratos.common.constants.StratosConstants;
  import org.apache.stratos.messaging.domain.topology.*;
- import org.apache.stratos.messaging.event.application.status.*;
+ import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
+ import org.apache.stratos.messaging.event.cluster.status.*;
  import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
  import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
  import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
@@@ -57,10 -54,10 +56,10 @@@ public class TopologyBuilder 
          Service service;
          Topology topology = TopologyManager.getTopology();
          if (cartridgeList == null) {
 -            log.warn(String.format("Cartridge list is empty"));
 -            return;
 +        	log.warn(String.format("Cartridge list is empty"));
 +        	return;
          }
-         
+ 
          try {
  
              TopologyManager.acquireWriteLock();
@@@ -168,20 -229,10 +231,19 @@@
  
          } finally {
              TopologyManager.releaseWriteLock();
-         }
-         **/
+         }*/
      }
  
 -    public static void handleClusterRemoved(ClusterContext ctxt) {
 +
 +    private static void setKubernetesCluster(Cluster cluster) {  
 +    	boolean isKubernetesCluster = (cluster.getProperties().getProperty(StratosConstants.KUBERNETES_CLUSTER_ID) != null);
 +		if (log.isDebugEnabled()) {
 +			log.debug(" Kubernetes Cluster ["+ isKubernetesCluster + "] ");
 +		}
 +		cluster.setKubernetesCluster(isKubernetesCluster);		
 +	}
 +
 +	public static void handleClusterRemoved(ClusterContext ctxt) {
          Topology topology = TopologyManager.getTopology();
          Service service = topology.getService(ctxt.getCartridgeType());
          String deploymentPolicy;
@@@ -545,122 -567,8 +607,118 @@@
          }
      }
  
-     public static synchronized void handleApplicationDeployed(Application application,
-                                                  Set<ApplicationClusterContext> applicationClusterContexts,
-                                                  Set<MetaDataHolder> metaDataHolders) {
- 
- 
+     public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) {
          Topology topology = TopologyManager.getTopology();
 +        try {
 +            TopologyManager.acquireWriteLock();
 +
 +            if (topology.applicationExists(application.getUniqueIdentifier())) {
 +                log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology");
 +                return;
 +            }
 +            List<Cluster> clusters = new ArrayList<Cluster>();
 +            for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) {
 +                Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(),
 +                        applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(),
 +                        applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier());
 +                //cluster.setStatus(Status.Created);
 +                cluster.addHostName(applicationClusterContext.getHostName());
 +                cluster.setTenantRange(applicationClusterContext.getTenantRange());
 +                cluster.setLbCluster(applicationClusterContext.isLbCluster());
 +                cluster.setKubernetesCluster(applicationClusterContext.isKubernetesCluster());
 +                cluster.setProperties(CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties()));
 +                clusters.add(cluster);
 +
 +                Service service = topology.getService(applicationClusterContext.getCartridgeType());
 +                if (service != null) {
 +                    service.addCluster(cluster);
 +                    log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier());
 +                } else {
 +                    log.error("Service " + applicationClusterContext.getCartridgeType() + " not found");
 +                    return;
 +                }
 +            }
 +
 +            // add to Topology and update
 +            topology.addApplication(application);
 +            TopologyManager.updateTopology(topology);
 +
 +            log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully");
 +            org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters);
 +            TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent);
 +
 +        } finally {
 +            TopologyManager.releaseWriteLock();
 +        }
 +    }
 +
 +    public static synchronized void handleApplicationUndeployed(String applicationId) {
 +
 +        Set<ClusterDataHolder> clusterData;
 +
 +        // update the Application and Cluster Statuses as 'Terminating'
 +        TopologyManager.acquireWriteLock();
 +
 +        try {
 +
 +            Topology topology = TopologyManager.getTopology();
 +
 +            if (!topology.applicationExists(applicationId)) {
 +                log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology");
 +                return;
 +            }
 +
 +            Application application = topology.getApplication(applicationId);
 +            // check and update application status to 'Terminating'
 +            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
 +                log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
 +            }
 +            // for now anyway update the status forcefully
 +            application.setStatus(ApplicationStatus.Terminating);
 +
 +            // update all the Clusters' statuses to 'Terminating'
 +            clusterData = application.getClusterDataRecursively();
 +            for (ClusterDataHolder clusterDataHolder : clusterData) {
 +                Service service = topology.getService(clusterDataHolder.getServiceType());
 +                if (service != null) {
 +                    Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
 +                    if (aCluster != null) {
 +                        // validate state transition
 +                        if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
 +                            log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
 +                                    + ClusterStatus.Terminating);
 +                        }
 +                        // for now anyway update the status forcefully
 +                        aCluster.setStatus(ClusterStatus.Terminating);
 +
 +                    } else {
 +                        log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
 +                        " in Topology");
 +                    }
 +
 +                } else {
 +                    log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
 +                            " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
 +                }
 +            }
 +
 +            // update all Group's statuses to 'Terminating'
 +            if (application.getGroups() != null) {
 +                updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
 +            }
 +
 +            TopologyManager.updateTopology(topology);
 +
 +        } finally {
 +            TopologyManager.releaseWriteLock();
 +        }
 +
 +        TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
 +    }
 +
 +
 +    public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) {
 +        Topology topology = TopologyManager.getTopology();
          Service service = topology.getService(clusterActivatedEvent.getServiceName());
          //update the status of the cluster
          if (service == null) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index b561afe,3f58080..aff2b6d
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@@ -44,53 -43,57 +46,70 @@@ import java.util.Set
  public class TopologyEventPublisher {
      private static final Log log = LogFactory.getLog(TopologyEventPublisher.class);
  
 -
 -    public static void sendServiceCreateEvent(List<Cartridge> cartridgeList) {
 -        ServiceCreatedEvent serviceCreatedEvent;
 -        for(Cartridge cartridge : cartridgeList) {
 -            serviceCreatedEvent = new ServiceCreatedEvent(cartridge.getType(), (cartridge.isMultiTenant() ? ServiceType.MultiTenant : ServiceType.SingleTenant));
 -
 -            // Add ports to the event
 -            Port port;
 -            List<PortMapping> portMappings = cartridge.getPortMappings();
 -            for(PortMapping portMapping : portMappings) {
 -                port = new Port(portMapping.getProtocol(),
 -                        Integer.parseInt(portMapping.getPort()),
 -                        Integer.parseInt(portMapping.getProxyPort()));
 -                serviceCreatedEvent.addPort(port);
 -            }
 -
 -            if(log.isInfoEnabled()) {
 -                log.info(String.format("Publishing service created event: [service] %s", cartridge.getType()));
 -            }
 -            publishEvent(serviceCreatedEvent);
 -        }
 -    }
 -
 -    public static void sendServiceRemovedEvent(List<Cartridge> cartridgeList) {
 -        ServiceRemovedEvent serviceRemovedEvent;
 -        for(Cartridge cartridge : cartridgeList) {
 -            serviceRemovedEvent = new ServiceRemovedEvent(cartridge.getType());
 -            if(log.isInfoEnabled()) {
 -                log.info(String.format("Publishing service removed event: [service] %s", serviceRemovedEvent.getServiceName()));
 -            }
 -            publishEvent(serviceRemovedEvent);
 -        }
 -    }
 -
 +	public static void sendServiceCreateEvent(List<Cartridge> cartridgeList) {
 +		ServiceCreatedEvent serviceCreatedEvent;
 +		for (Cartridge cartridge : cartridgeList) {
 +			serviceCreatedEvent = new ServiceCreatedEvent(cartridge.getType(),
 +					(cartridge.isMultiTenant() ? ServiceType.MultiTenant
 +							: ServiceType.SingleTenant));
 +
 +			// Add ports to the event
 +			Port port;
 +			List<PortMapping> portMappings = cartridge.getPortMappings();
 +			for (PortMapping portMapping : portMappings) {
 +				port = new Port(portMapping.getProtocol(),
 +						Integer.parseInt(portMapping.getPort()),
 +						Integer.parseInt(portMapping.getProxyPort()));
 +				serviceCreatedEvent.addPort(port);
 +			}
 +
 +			if (log.isInfoEnabled()) {
 +				log.info(String.format(
 +						"Publishing service created event: [service] %s",
 +						cartridge.getType()));
 +			}
 +			publishEvent(serviceCreatedEvent);
 +		}
 +	}
 +
 +	public static void sendServiceRemovedEvent(List<Cartridge> cartridgeList) {
 +		ServiceRemovedEvent serviceRemovedEvent;
 +		for (Cartridge cartridge : cartridgeList) {
 +			serviceRemovedEvent = new ServiceRemovedEvent(cartridge.getType());
 +			if (log.isInfoEnabled()) {
 +				log.info(String.format(
 +						"Publishing service removed event: [service] %s",
 +						serviceRemovedEvent.getServiceName()));
 +			}
 +			publishEvent(serviceRemovedEvent);
 +		}
 +	}
 +
 +	public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
 +		ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId);
 +
 +		if (log.isInfoEnabled()) {
 +			log.info("Publishing cluster created event: " + clusterId);
 +		}
 +		publishEvent(clusterCreatedEvent);
 +	}
+     public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) {
+         ClusterResetEvent clusterResetEvent = new ClusterResetEvent(appId,serviceName, clusterId);
+ 
+         if(log.isInfoEnabled()) {
+             log.info("Publishing cluster reset event: " + clusterId);
+         }
+         publishEvent(clusterResetEvent);
+     }
+ 
+     public static void sendClusterCreatedEvent(Cluster cluster) {
+         ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(cluster);
+ 
+         if(log.isInfoEnabled()) {
+             log.info("Publishing cluster created event: " + cluster.getClusterId());
+         }
+         publishEvent(clusterCreatedEvent);
+     }
  
      public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) {
  

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index c1f0df8,7e33897..27c1640
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@@ -24,14 -24,12 +24,19 @@@ import org.apache.axis2.context.Configu
  import org.apache.axis2.transport.http.HTTPConstants;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.stub.*;
 +import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup;
 +import org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost;
 +import org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster;
 +import org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.stub.*;
+ import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 +import org.apache.stratos.cloud.controller.stub.pojo.Properties;
  import org.apache.stratos.manager.internal.DataHolder;
  import org.apache.stratos.manager.utils.CartridgeConstants;
  
@@@ -220,64 -212,21 +225,83 @@@ public class AutoscalerServiceClient 
      }
  
  
+     public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws RemoteException {
+         return stub.getServiceGroup(serviceGroupDefinitionName);
+     }
+ 
+     public void deployServiceGroup(ServiceGroup serviceGroup) throws AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException {
+         stub.deployServiceGroup(serviceGroup);
+     }
+ 
+     public void deployApplication (ApplicationContext applicationContext) throws
+             AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+         stub.deployApplicationDefinition(applicationContext);
+     }
+ 
+     public void undeployApplication (String applicationId, int tenantId, String tenantDomain) throws
+             AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+         stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain);
+     }
++
++
 +    public String getServiceLBClusterId(String serviceType, String deploymentPolicy) throws RemoteException {
 +        return stub.getServiceLBClusterId(serviceType, deploymentPolicy);
 +    }
 +
 +    public boolean deployKubernetesGroup(KubernetesGroup kubernetesGroup) throws RemoteException,
 +            AutoScalerServiceInvalidKubernetesGroupExceptionException {
 +        return stub.addKubernetesGroup(kubernetesGroup);
 +    }
 +
 +    public boolean deployKubernetesHost(String kubernetesGroupId, KubernetesHost kubernetesHost)
 +            throws RemoteException, AutoScalerServiceInvalidKubernetesHostExceptionException,
 +            AutoScalerServiceNonExistingKubernetesGroupExceptionException {
 +
 +        return stub.addKubernetesHost(kubernetesGroupId, kubernetesHost);
 +    }
 +
 +    public boolean updateKubernetesMaster(KubernetesMaster kubernetesMaster)
 +            throws RemoteException, AutoScalerServiceInvalidKubernetesMasterExceptionException,
 +            AutoScalerServiceNonExistingKubernetesMasterExceptionException {
 +        return stub.updateKubernetesMaster(kubernetesMaster);
 +    }
 +
 +    public KubernetesGroup[] getAvailableKubernetesGroups() throws RemoteException {
 +        return stub.getAllKubernetesGroups();
 +    }
 +
 +    public KubernetesGroup getKubernetesGroup(String kubernetesGroupId)
 +            throws RemoteException, AutoScalerServiceNonExistingKubernetesGroupExceptionException {
 +        return stub.getKubernetesGroup(kubernetesGroupId);
 +    }
 +
 +    public boolean undeployKubernetesGroup(String kubernetesGroupId)
 +            throws RemoteException, AutoScalerServiceNonExistingKubernetesGroupExceptionException {
 +        return stub.removeKubernetesGroup(kubernetesGroupId);
 +    }
 +
 +    public boolean undeployKubernetesHost(String kubernetesHostId)
 +            throws RemoteException, AutoScalerServiceNonExistingKubernetesHostExceptionException {
 +        return stub.removeKubernetesHost(kubernetesHostId);
 +    }
 +
 +    public KubernetesHost[] getKubernetesHosts(String kubernetesGroupId)
 +            throws RemoteException, AutoScalerServiceNonExistingKubernetesGroupExceptionException {
 +        return stub.getHostsForKubernetesGroup(kubernetesGroupId);
 +    }
 +
 +    public KubernetesMaster getKubernetesMaster(String kubernetesGroupId)
 +            throws RemoteException, AutoScalerServiceNonExistingKubernetesGroupExceptionException {
 +        return stub.getMasterForKubernetesGroup(kubernetesGroupId);
 +    }
 +
 +    public boolean updateKubernetesHost(KubernetesHost kubernetesHost)
 +            throws RemoteException, AutoScalerServiceInvalidKubernetesHostExceptionException,
 +            AutoScalerServiceNonExistingKubernetesHostExceptionException {
 +        return stub.updateKubernetesHost(kubernetesHost);
 +    }
 +    
 +    public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException, AutoScalerServiceInvalidArgumentExceptionException {
 +        stub.updateClusterMonitor(clusterId, properties);
 +    }
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
index c16c248,38956be..c59dd74
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
@@@ -24,10 -24,12 +24,9 @@@ import org.apache.commons.logging.Log
  import org.apache.commons.logging.LogFactory;
  import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
  import org.apache.stratos.manager.client.CloudControllerServiceClient;
 -import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
 -import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
 -import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition;
 -import org.apache.stratos.manager.composite.application.beans.SubscribableInfo;
 +import org.apache.stratos.manager.composite.application.beans.*;
  import org.apache.stratos.manager.composite.application.structure.CompositeAppContext;
  import org.apache.stratos.manager.composite.application.structure.GroupContext;
- import org.apache.stratos.manager.composite.application.structure.StartupOrder;
  import org.apache.stratos.manager.composite.application.structure.SubscribableContext;
  import org.apache.stratos.manager.composite.application.utils.ApplicationUtils;
  import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException;
@@@ -213,17 -215,8 +211,17 @@@ public class DefaultCompositeApplicatio
              	startupOrders = startupOrderList.toArray(startupOrders);
                  compositeAppContext.setStartupOrders(startupOrders);
  
-                 compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour());
+                 compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getTerminationBehaviour());
              }
 +
 +            // Set application properties
 +            if(compositeAppDefinition.getProperty() != null) {
 +                Properties properties = new Properties();
 +                for(PropertyBean propertyBean : compositeAppDefinition.getProperty()) {
 +                     properties.put(propertyBean.getName(), propertyBean.getValue());
 +                }
 +                compositeAppContext.setProperties(properties);
 +            }
          }
  
          return compositeAppContext;

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
index 0000000,3c2814f..0ede0f1
mode 000000,100644..100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
@@@ -1,0 -1,212 +1,212 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.messaging.domain.applications;
+ 
+ import java.io.Serializable;
+ import java.util.*;
+ 
+ /**
+  * Abstraction for a an entity that can have child entities
 - * in an Application withing the Topology
++ * in an Application within the Topology
+  */
+ 
+ public abstract class ParentComponent implements Serializable {
+ 
+     // Dependency Order
+     private DependencyOrder dependencyOrder;
+     // Group Map, key = Group.alias
+     private Map<String, Group> aliasToGroupMap;
+     // Cluster Id map, key = subscription alias for the cartridge type
+     private Map<String, ClusterDataHolder> aliasToClusterDataMap;
+     // Application status
+ 
+     public ParentComponent () {
+         aliasToGroupMap = new HashMap<String, Group>();
+         aliasToClusterDataMap = new HashMap<String, ClusterDataHolder>();
+     }
+ 
+     /**
+      * This method should be implemented in each concrete child class
+      * to return the unique identifier for each implementation
+      * ex.: group alias for a Group, app id for an Application
+      *
+      * @return unique identifier String
+      */
+     public abstract String getUniqueIdentifier ();
+ 
+     /**
+      * Adds a group
+      *
+      * @param group Group instance to be added
+      */
+     public void addGroup(Group group) {
+         aliasToGroupMap.put(group.getUniqueIdentifier(), group);
+     }
+ 
+     /**
+      * Setter for Group alias to Group map
+      *
+      * @param groupAliasToGroup Map, key = alias given to the Group, value = Group
+      */
+     public void setGroups(Map<String, Group> groupAliasToGroup) {
+         aliasToGroupMap.putAll(groupAliasToGroup);
+     }
+ 
+     /**
+      * Get the Group for the given alias in the context of the parent entity.
+      * Will not search recursively in the nested levels.
+      *
+      * @param groupAlias alias of the Group
+      * @return Group, if exists for the given alias, else null
+      */
+     public Group getGroup(String groupAlias) {
+         return aliasToGroupMap.get(groupAlias);
+     }
+ 
+     /**
+      * Get the Group for the given alias in the context of the parent entity.
+      * Will search recursively in the nested levels.
+      *
+      * @param groupAlias alias of the Group
+      * @return Group, if exists for the given alias, else null
+      */
+     public Group getGroupRecursively(String groupAlias) {
+ 
+         return travereAndCheckRecursively(aliasToGroupMap, groupAlias);
+     }
+ 
+     private Group travereAndCheckRecursively (Map<String,Group> aliasToGroupMap, String groupAlias) {
+ 
+         if (aliasToGroupMap.containsKey(groupAlias)) {
+             synchronized (aliasToGroupMap) {
+                 if (aliasToGroupMap.containsKey(groupAlias)) {
+                     return aliasToGroupMap.get(groupAlias);
+                 }
+             }
+         } else {
+             for (Group group : aliasToGroupMap.values()) {
+                 return travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias);
+             }
+         }
+ 
+         return null;
+     }
+ 
+     /**
+      * Getter for alias to Group map
+      * Will not search recursively in the nested levels.
+      *
+      * @return Map, key = alias given to the Group, value = Group
+      */
+     public Map<String, Group> getAliasToGroupMap() {
+         return this.aliasToGroupMap;
+     }
+ 
+     /**
+      * Getter for cluster alias to ClusterData map for this level
+      *
+      * @return Map, key = alias given to the cluster, value =  ClusterData object
+      */
+     public Map<String, ClusterDataHolder> getClusterDataMap() {
+         return this.aliasToClusterDataMap;
+     }
+ 
+     /**
+      * Collection of Groups in this level
+      *
+      * @return Group Collection object, empty if no Groups are found
+      */
+     public Collection<Group> getGroups() {
+         return aliasToGroupMap.values();
+     }
+ 
+     /**
+      * Setter for Dependency Order
+      *
+      * @param dependencyOrder Dependency Order object
+      */
+     public void setDependencyOrder(DependencyOrder dependencyOrder) {
+         this.dependencyOrder = dependencyOrder;
+     }
+ 
+     /**
+      * Getter for Dependency Order for this level
+      *
+      * @return Dependency Order object
+      */
+     public DependencyOrder getDependencyOrder() {
+         return dependencyOrder;
+     }
+ 
+     /**
+      * Setter for alias to Cluster Data map
+      *
+      * @param aliasToClusterData Map, key = alias given to the cluster, value =  ClusterData object
+      */
+     public void setClusterData(Map<String, ClusterDataHolder> aliasToClusterData) {
+         this.aliasToClusterDataMap.putAll(aliasToClusterData);
+     }
+ 
+     /**
+      * Getter for Cluster Data instance for the given alias
+      * Will not search recursively in the nested levels.
+      *
+      * @param alias
+      * @return
+      */
+     public ClusterDataHolder getClusterData(String alias) {
+         return aliasToClusterDataMap.get(alias);
+     }
+ 
+     /**
+      * Collects the Cluster Data for the parent component and all the
+      * child components recursively
+      *
+      * @return Set of ClusterDataHolder objects if available, else null
+      */
+     public Set<ClusterDataHolder> getClusterDataRecursively () {
+ 
+         Set<ClusterDataHolder> appClusterData = new HashSet<ClusterDataHolder>();
+ 
+         // get top level Cluster Data
+         if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) {
+             appClusterData.addAll(this.aliasToClusterDataMap.values());
+         }
+ 
+         // find other nested Cluster Data (in the Groups)
+         if (getGroups() != null) {
+             getClusterData(appClusterData, getGroups());
+         }
+ 
+         return appClusterData;
+     }
+ 
+     private void getClusterData (Set<ClusterDataHolder> clusterData, Collection<Group> groups) {
+ 
+         for (Group group : groups) {
+             if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) {
+                 clusterData.addAll(group.getClusterDataMap().values());
+                 if (group.getGroups() != null) {
+                     getClusterData(clusterData, group.getGroups());
+                 }
+             }
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
index 0000000,936c174..e53e083
mode 000000,100644..100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
@@@ -1,0 -1,54 +1,74 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
 -package org.apache.stratos.messaging.message.receiver.applications;
++package org.apache.stratos.messaging.message.receiver.application.status;
+ 
++import org.apache.activemq.command.ActiveMQTextMessage;
+ import org.apache.commons.logging.Log;
+ import org.apache.commons.logging.LogFactory;
++import org.apache.stratos.messaging.util.Constants;
++import org.apache.stratos.messaging.util.Util;
++import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
++import org.eclipse.paho.client.mqttv3.MqttCallback;
++import org.eclipse.paho.client.mqttv3.MqttMessage;
+ 
+ import javax.jms.JMSException;
+ import javax.jms.Message;
+ import javax.jms.MessageListener;
+ import javax.jms.TextMessage;
+ 
 -public class ApplicationsEventMessageListener implements MessageListener {
 -    private static final Log log = LogFactory.getLog(ApplicationsEventMessageListener.class);
++public class ApplicationStatusEventMessageListener implements MqttCallback {
++    private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class);
+ 
 -    private ApplicationsEventMessageQueue messageQueue;
++    private ApplicationStatusEventMessageQueue messageQueue;
+ 
 -    public ApplicationsEventMessageListener(ApplicationsEventMessageQueue messageQueue) {
++    public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue messageQueue) {
+         this.messageQueue = messageQueue;
+     }
+ 
+     @Override
 -    public void onMessage(Message message) {
 -        if (message instanceof TextMessage) {
 -            TextMessage receivedMessage = (TextMessage) message;
 -            try {
 -                if (log.isDebugEnabled()) {
 -                    log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText()));
 -                }
 -                // Add received message to the queue
 -                messageQueue.add(receivedMessage);
 -
 -            } catch (JMSException e) {
 -                log.error(e.getMessage(), e);
++    public void connectionLost(Throwable throwable) {
++        log.warn("Connection is lost", throwable);
++    }
++
++    @Override
++    public void deliveryComplete(IMqttDeliveryToken deliveryToken) {
++        if (log.isDebugEnabled()) {
++            log.debug(String.format("Message delivery is complete: %s",
++                    ((deliveryToken != null) ? deliveryToken.toString() : "")));
++        }
++    }
++
++    @Override
++    public void messageArrived(String topicName, MqttMessage message) throws Exception {
++        TextMessage textMessage = new ActiveMQTextMessage();
++        textMessage.setText(new String(message.getPayload()));
++        textMessage.setStringProperty(Constants.EVENT_CLASS_NAME, Util.getEventNameForTopic(topicName));
++
++        try {
++            if (log.isDebugEnabled()) {
++                log.debug(String.format("Tenant message received: %s", textMessage.getText()));
+             }
++            // Add received message to the queue
++            messageQueue.add(textMessage);
++
++        } catch (JMSException e) {
++            log.error(e.getMessage(), e);
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 172f252,cb7d9b3..212a5d0
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@@ -20,16 -20,12 +20,20 @@@
  package org.apache.stratos.rest.endpoint.bean.util.converter;
  
  import org.apache.commons.lang.StringUtils;
 +import org.apache.stratos.autoscaler.stub.kubernetes.PropertiesE;
 +import org.apache.stratos.autoscaler.stub.kubernetes.PropertyE;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.ComponentContext;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.DependencyContext;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.GroupContext;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableContext;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableInfoContext;
+ import org.apache.stratos.autoscaler.applications.pojo.stub.DependencyContext;
+ import org.apache.stratos.autoscaler.applications.pojo.stub.GroupContext;
+ import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext;
+ import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableInfoContext;
  import org.apache.stratos.cloud.controller.stub.pojo.*;
  import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
  import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
@@@ -725,177 -677,16 +729,177 @@@ public class PojoConverter 
          for (Service service : services) {
              serviceDefinitionBeans.add(convertToServiceDefinitionBean(service));
          }
 -
          return serviceDefinitionBeans;
      }
 -    
 -	private static Log log = LogFactory.getLog(PojoConverter.class);
  
 -    public static org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext
 -    convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) {
 +    public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup convertToASKubernetesGroupPojo(KubernetesGroup kubernetesGroupBean) {
 +
 +        org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup = new
 +                org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup();
 +
 +        kubernetesGroup.setGroupId(kubernetesGroupBean.getGroupId());
 +        kubernetesGroup.setDescription(kubernetesGroupBean.getDescription());
 +        kubernetesGroup.setKubernetesMaster(convertToASKubernetesMasterPojo(kubernetesGroupBean.getKubernetesMaster()));
 +        kubernetesGroup.setPortRange(convertToASPortRange(kubernetesGroupBean.getPortRange()));
 +        kubernetesGroup.setKubernetesHosts(convertToASKubernetesHostsPojo(kubernetesGroupBean.getKubernetesHosts()));
 +        kubernetesGroup.setProperties((getASProperties(kubernetesGroupBean.getProperty())));
 +
 +        return kubernetesGroup;
 +    }
 +
 +    private static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[] convertToASKubernetesHostsPojo(List<KubernetesHost> kubernetesHosts) {
 +        if (kubernetesHosts == null || kubernetesHosts.isEmpty()) {
 +            return null;
 +        }
 +        int kubernetesHostCount = kubernetesHosts.size();
 +        org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[]
 +                kubernetesHostsArr = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[kubernetesHostCount];
 +        for (int i = 0; i < kubernetesHostCount; i++) {
 +            KubernetesHost kubernetesHostBean = kubernetesHosts.get(i);
 +            kubernetesHostsArr[i] = convertToASKubernetesHostPojo(kubernetesHostBean);
 +        }
 +        return kubernetesHostsArr;
 +    }
 +
 +
 +    private static org.apache.stratos.autoscaler.stub.kubernetes.PortRange convertToASPortRange(PortRange portRangeBean) {
 +        if (portRangeBean == null) {
 +            return null;
 +        }
 +        org.apache.stratos.autoscaler.stub.kubernetes.PortRange
 +                portRange = new org.apache.stratos.autoscaler.stub.kubernetes.PortRange();
 +        portRange.setLower(portRangeBean.getLower());
 +        portRange.setUpper(portRangeBean.getUpper());
 +        return portRange;
 +    }
 +
 +    public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost convertToASKubernetesHostPojo(KubernetesHost kubernetesHostBean) {
 +        if (kubernetesHostBean == null) {
 +            return null;
 +        }
 +
 +        org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost
 +                kubernetesHost = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost();
 +        kubernetesHost.setHostId(kubernetesHostBean.getHostId());
 +        kubernetesHost.setHostIpAddress(kubernetesHostBean.getHostIpAddress());
 +        kubernetesHost.setHostname(kubernetesHostBean.getHostname());
 +        kubernetesHost.setProperties(getASProperties(kubernetesHostBean.getProperty()));
 +
 +        return kubernetesHost;
 +    }
 +
 +    public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster convertToASKubernetesMasterPojo(KubernetesMaster kubernetesMasterBean) {
 +        if (kubernetesMasterBean == null) {
 +            return null;
 +        }
 +
 +        org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster
 +                kubernetesMaster = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster();
 +        kubernetesMaster.setHostId(kubernetesMasterBean.getHostId());
 +        kubernetesMaster.setHostIpAddress(kubernetesMasterBean.getHostIpAddress());
 +        kubernetesMaster.setHostname(kubernetesMasterBean.getHostname());
 +        kubernetesMaster.setEndpoint(kubernetesMasterBean.getEndpoint());
 +        kubernetesMaster.setProperties(getASProperties(kubernetesMasterBean.getProperty()));
 +
 +        return kubernetesMaster;
 +    }
 +
 +    public static KubernetesGroup[] populateKubernetesGroupsPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup[] kubernetesGroups) {
 +
 +        if (kubernetesGroups == null){
 +            return null;
 +        }
 +        KubernetesGroup[] kubernetesGroupsBean = new KubernetesGroup[kubernetesGroups.length];
 +        for (int i = 0; i < kubernetesGroups.length; i++){
 +            kubernetesGroupsBean[i] = populateKubernetesGroupPojo(kubernetesGroups[i]);
 +        }
 +        return kubernetesGroupsBean;
 +    }
 +
 +    public static KubernetesGroup populateKubernetesGroupPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup) {
 +        if (kubernetesGroup == null){
 +            return null;
 +        }
 +        KubernetesGroup kubernetesGroupBean = new KubernetesGroup();
 +        kubernetesGroupBean.setGroupId(kubernetesGroup.getGroupId());
 +        kubernetesGroupBean.setDescription(kubernetesGroup.getDescription());
 +        kubernetesGroupBean.setPortRange(populatePortRangePojo(kubernetesGroup.getPortRange()));
 +        kubernetesGroupBean.setKubernetesHosts(populateKubernetesHostsPojo(kubernetesGroup.getKubernetesHosts()));
 +        kubernetesGroupBean.setKubernetesMaster(populateKubernetesMasterPojo(kubernetesGroup.getKubernetesMaster()));
 +        kubernetesGroupBean.setProperty(populateASProperties(kubernetesGroup.getProperties()));
 +        return kubernetesGroupBean;
 +    }
 +
 +    public static KubernetesMaster populateKubernetesMasterPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster kubernetesMaster) {
 +        if (kubernetesMaster == null){
 +            return null;
 +        }
 +        KubernetesMaster kubernetesMasterBean = new KubernetesMaster();
 +        kubernetesMasterBean.setHostId(kubernetesMaster.getHostId());
 +        kubernetesMasterBean.setHostname(kubernetesMaster.getHostname());
 +        kubernetesMasterBean.setHostIpAddress(kubernetesMaster.getHostIpAddress());
 +        kubernetesMasterBean.setProperty(populateASProperties(kubernetesMaster.getProperties()));
 +        kubernetesMasterBean.setEndpoint(kubernetesMaster.getEndpoint());
 +        return kubernetesMasterBean;
 +    }
 +
 +    public static List<KubernetesHost> populateKubernetesHostsPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[] kubernetesHosts) {
 +        if (kubernetesHosts == null){
 +            return null;
 +        }
 +        List<KubernetesHost> kubernetesHostList = new ArrayList<KubernetesHost>();
 +        for (int i = 0; i < kubernetesHosts.length; i++){
 +            kubernetesHostList.add(populateKubernetesHostPojo(kubernetesHosts[i]));
 +        }
 +        return kubernetesHostList;
 +    }
 +
 +    private static KubernetesHost populateKubernetesHostPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost) {
 +        if (kubernetesHost == null){
 +            return null;
 +        }
 +        KubernetesHost kubernetesHostBean = new KubernetesHost();
 +        kubernetesHostBean.setHostId(kubernetesHost.getHostId());
 +        kubernetesHostBean.setHostname(kubernetesHost.getHostname());
 +        kubernetesHostBean.setHostIpAddress(kubernetesHost.getHostIpAddress());
 +        kubernetesHostBean.setProperty(populateASProperties(kubernetesHost.getProperties()));
 +        return kubernetesHostBean;
 +    }
 +
 +    private static List<PropertyBean> populateASProperties(PropertiesE properties) {
 +        if (properties == null || properties.getProperties() == null){
 +            return null;
 +        }
 +        List<PropertyBean> propertyBeanList = new ArrayList<PropertyBean>();
 +        for (int i = 0; i < properties.getProperties().length; i++){
 +            propertyBeanList.add(populateASProperty(properties.getProperties()[i]));
 +        }
 +        return propertyBeanList;
 +    }
 +
 +    private static PropertyBean populateASProperty(PropertyE propertyE) {
 +        if (propertyE == null){
 +            return null;
 +        }
 +        PropertyBean propertyBean = new PropertyBean();
 +        propertyBean.name = propertyE.getName();
 +        propertyBean.value = propertyE.getValue();
 +        return propertyBean;
 +    }
 +
 +    private static PortRange populatePortRangePojo(org.apache.stratos.autoscaler.stub.kubernetes.PortRange portRange) {
 +        if (portRange == null){
 +            return null;
 +        }
 +        PortRange portRangeBean = new PortRange();
 +        portRangeBean.setUpper(portRange.getUpper());
 +        portRangeBean.setLower(portRange.getLower());
 +        return portRangeBean;
 +    }
 +    
 +    public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) {
  
-         ApplicationContext applicationContext = new ApplicationContext();
+         org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext();
          applicationContext.setApplicationId(compositeAppDefinition.getApplicationId());
          applicationContext.setAlias(compositeAppDefinition.getAlias());
  

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 97eda89,a7ab51b..38880d7
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@@ -23,18 -23,16 +23,22 @@@ import org.apache.axis2.context.Configu
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.stub.*;
 +import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException;
  import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
  import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
  import org.apache.stratos.cloud.controller.stub.*;
- import org.apache.stratos.cloud.controller.stub.pojo.*;
- import org.apache.stratos.cloud.controller.stub.pojo.Properties;
+ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig;
+ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
+ import org.apache.stratos.cloud.controller.stub.pojo.Property;
++import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext;
  import org.apache.stratos.manager.client.AutoscalerServiceClient;
  import org.apache.stratos.manager.client.CloudControllerServiceClient;
 +import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager;
  import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
  import org.apache.stratos.manager.deploy.service.Service;
  import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
@@@ -135,26 -154,23 +144,27 @@@ public class ServiceUtils 
          applicationContext.setTenantDomain(tenantDomain);
          applicationContext.setTeantAdminUsername(userName);
  
 -//        try {
 -//            CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
 -//
 -//        } catch (RemoteException e) {
 -//            throw new RestAPIException(e);
 -//        } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
 -//            throw new RestAPIException(e);
 -//        } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
 -//            throw new RestAPIException(e);
 -//        }
 +        Properties properties = new Properties();
 +        if(appDefinition.getProperty() != null) {
 +            for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) {
 +                Property property = new Property();
 +                property.setName(propertyBean.getName());
 +                property.setValue(propertyBean.getValue());
 +                properties.addProperties(property);
 +            }
 +            applicationContext.setProperties(properties);
 +        }
  
          try {
-             CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
- 
+             AutoscalerServiceClient.getServiceClient().deployApplication(applicationContext);
+         } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
+             throw new RestAPIException(e);
          } catch (RemoteException e) {
              throw new RestAPIException(e);
 +        } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
 +            throw new RestAPIException(e);
 +        } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
 +            throw new RestAPIException(e);
          }
      }
  

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
----------------------------------------------------------------------


[21/50] [abbrv] git commit: adding app id to Group

Posted by im...@apache.org.
adding app id to Group


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

Branch: refs/heads/docker-grouping-merge
Commit: 7f05298c3680ad1eb72e19cde334fc2df8217514
Parents: 18f1654
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 14:33:56 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 14:33:56 2014 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.autoscaler/pom.xml       |  5 +++
 .../ApplicationSynchronizerTask.java            | 43 ++++++++++++++++++++
 .../parser/DefaultApplicationParser.java        |  2 +-
 .../messaging/domain/applications/Group.java    |  9 +++-
 4 files changed, 57 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7f05298c/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml
index 35d03da..5ba1eba 100644
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@ -170,6 +170,11 @@
             <version>${project.version}</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.ntask.core</artifactId>
+            <version>4.2.0</version>
+        </dependency>
 
 	</dependencies>
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f05298c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
new file mode 100644
index 0000000..571e7a8
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.wso2.carbon.ntask.core.Task;
+
+import java.util.Map;
+
+public class ApplicationSynchronizerTask implements Task {
+
+    @Override
+    public void setProperties(Map<String, String> stringStringMap) {
+
+    }
+
+    @Override
+    public void init() {
+
+    }
+
+    @Override
+    public void execute() {
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f05298c/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
index 000a06a..c75e883 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java
@@ -416,7 +416,7 @@ public class DefaultApplicationParser implements ApplicationParser {
                     groupCtxt.getAlias() + " is not found in the all Group Definitions collection");
         }
 
-        Group group = new Group(groupCtxt.getName(), groupCtxt.getAlias());
+        Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias());
 
         group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy());
         group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy());

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f05298c/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
index 1f4d323..da52e99 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
@@ -39,11 +39,14 @@ public class Group extends ParentComponent implements LifeCycleStateTransitionBe
     private String deploymentPolicy;
     // Group level autoscaling policy
     private String autoscalingPolicy;
+    // application id
+    private String applicationId;
     // Life cycle state manager
     protected LifeCycleStateManager<GroupStatus> groupStateManager;
 
-    public Group (String name, String alias) {
+    public Group (String applicationId, String name, String alias) {
         super();
+        this.applicationId = applicationId;
         this.name = name;
         this.alias = alias;
         this.groupStateManager = new LifeCycleStateManager<GroupStatus>(GroupStatus.Created, alias);
@@ -109,4 +112,8 @@ public class Group extends ParentComponent implements LifeCycleStateTransitionBe
     public int hashCode () {
         return name.hashCode() + alias.hashCode();
     }
+
+    public String getApplicationId() {
+        return applicationId;
+    }
 }


[28/50] [abbrv] git commit: adding service group deployment to auto scaler

Posted by im...@apache.org.
adding service group deployment to auto scaler


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

Branch: refs/heads/docker-grouping-merge
Commit: 836b71fd7a0d4258cf4b397d5cc43228c477ffa0
Parents: 686d0e0
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Oct 31 15:36:45 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Fri Oct 31 16:06:02 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   |  78 +-
 .../exception/InvalidServiceGroupException.java |  46 +
 .../stratos/autoscaler/pojo/Dependencies.java   |  46 +
 .../stratos/autoscaler/pojo/ServiceGroup.java   |  67 ++
 .../autoscaler/registry/RegistryManager.java    |  47 +-
 .../autoscaler/util/AutoScalerConstants.java    |   3 +-
 .../stratos/autoscaler/util/Deserializer.java   |  10 +-
 .../manager/client/AutoscalerServiceClient.java |  20 +-
 .../deployer/DefaultServiceGroupDeployer.java   |  39 +-
 .../pom.xml                                     |   3 +-
 .../src/main/resources/AutoScalerService.wsdl   | 892 +++++++++++--------
 11 files changed, 846 insertions(+), 405 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 897fd4e..d710bf7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -18,22 +18,25 @@
  */
 package org.apache.stratos.autoscaler.api;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.autoscaler.exception.InvalidPartitionException;
-import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
-import org.apache.stratos.autoscaler.exception.NonExistingLBException;
-import org.apache.stratos.autoscaler.exception.PartitionValidationException;
+import org.apache.stratos.autoscaler.exception.*;
 import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface;
 import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
+import org.apache.stratos.autoscaler.pojo.Dependencies;
+import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+import org.wso2.carbon.registry.api.RegistryException;
 
+import java.text.MessageFormat;
 import java.util.ArrayList;
 
 /**
@@ -268,5 +271,72 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface{
         
     }
 
+    public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException {
+
+        if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
+            String msg = "Service group can not be null service name can not be empty.";
+            log.error(msg);
+            throw new IllegalArgumentException(msg);
+
+        }
+        String name = servicegroup.getName();
+
+        if(RegistryManager.getInstance().serviceGroupExist(name)){
+            throw new InvalidServiceGroupException("Service group with the name " + name + " already exist.");
+        }
+
+        if(log.isDebugEnabled()) {
+            log.debug(MessageFormat.format("Deploying service group {0}", servicegroup.getName()));
+        }
+
+        String [] subGroups = servicegroup.getCartridges();
+
+        if(log.isDebugEnabled()) {
+            log.debug("SubGroups" + subGroups);
+            if (subGroups != null) {
+                log.debug("subGroups:size" + subGroups.length);
+            } else {
+                log.debug("subGroups: are null");
+            }
+        }
+
+
+        Dependencies dependencies = servicegroup.getDependencies();
+
+        if(log.isDebugEnabled()) {
+            log.debug("Dependencies" + dependencies);
+        }
+
+        if (dependencies != null) {
+            String [] startupOrders = dependencies.getStartupOrders();
+
+            if(log.isDebugEnabled()) {
+                log.debug("StartupOrders" + startupOrders);
+
+                if (startupOrders != null) {
+                    log.debug("StartupOrder:size" + startupOrders.length);
+                } else {
+                    log.debug("StartupOrder: is null");
+                }
+            }
+        }
+
+        RegistryManager.getInstance().persistServiceGroup(servicegroup);
+    }
+
+    public ServiceGroup getServiceGroup(String name){
+        if(StringUtils.isEmpty(name)){
+            return null;
+        }
+        try {
+            return RegistryManager.getInstance().getServiceGroup(name);
+        } catch (Exception e) {
+            throw new AutoScalerException("Error occurred while retrieving service groups", e);
+        }
+    }
+    public boolean serviceGroupExist(String serviceName){
+        return false;
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
new file mode 100644
index 0000000..d18c274
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.exception;
+
+public class InvalidServiceGroupException extends Exception {
+
+
+    private static final long serialVersionUID = 2651280146514042590L;
+
+    private String message;
+
+    public InvalidServiceGroupException(String msg) {
+        super(msg);
+        this.setMessage(msg);
+    }
+
+    public InvalidServiceGroupException(String msg, Exception ex) {
+        super(msg, ex);
+        this.setMessage(msg);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
new file mode 100644
index 0000000..4403e6c
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.pojo;
+
+import java.io.Serializable;
+
+public class Dependencies implements Serializable {
+
+    private static final long serialVersionUID = 4187267350546153680L;
+
+    private String [] startupOrders;
+
+    private String killBehaviour;
+
+    public String getKillBehaviour() {
+        return killBehaviour;
+    }
+
+    public void setKillBehaviour(String killBehaviour) {
+        this.killBehaviour = killBehaviour;
+    }
+
+    public String[] getStartupOrders() {
+        return startupOrders;
+    }
+
+    public void setStartupOrders(String[] startupOrders) {
+        this.startupOrders = startupOrders;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
new file mode 100644
index 0000000..4de6e0c
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.pojo;
+
+import java.io.Serializable;
+
+public class ServiceGroup implements Serializable {
+
+
+    private static final long serialVersionUID = -7413745300105885793L;
+
+    private String name;
+
+    private String [] subGroups;
+
+    private String [] cartridges;
+
+    private Dependencies dependencies;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String [] getSubGroups() {
+        return subGroups;
+    }
+
+    public void setSubGroups(String [] subGroups) {
+        this.subGroups = subGroups;
+    }
+
+    public String [] getCartridges() {
+        return cartridges;
+    }
+
+    public void setCartridges(String [] cartridges) {
+        this.cartridges = cartridges;
+    }
+
+    public Dependencies getDependencies() {
+        return dependencies;
+    }
+
+    public void setDependencies(Dependencies dependencies) {
+        this.dependencies = dependencies;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 25caf0e..ee8e411 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -21,11 +21,13 @@ package org.apache.stratos.autoscaler.registry;
 */
 
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
+import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.util.AutoScalerConstants;
 import org.apache.stratos.autoscaler.util.Deserializer;
@@ -142,6 +144,7 @@ public class RegistryManager {
         }
     }
 
+
     public void persistApplication (Application application) {
 
         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE +
@@ -181,13 +184,27 @@ public class RegistryManager {
         }
         return null;
     }
+
+    public void persistServiceGroup(ServiceGroup servicegroup) {
+        if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){
+            throw new  IllegalArgumentException("Service group or group name can not be null");
+        }
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
+        persist(servicegroup, resourcePath);
+        if(log.isDebugEnabled()) {
+            log.debug(String.format("Persisted service group %s at path %s", servicegroup.getName(), resourcePath));
+        }
+    }
+
+    public boolean serviceGroupExist(String serviceGroupName){
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + serviceGroupName;
+        return this.resourceExist(resourcePath);
+    }
     
     private Object retrieve(String resourcePath) {
         try {
             Resource resource = registryService.get(resourcePath);
-           
             return resource.getContent();
-
         } catch (ResourceNotFoundException ignore) {
             // this means, we've never persisted info in registry
             return null;
@@ -198,6 +215,10 @@ public class RegistryManager {
         }
     }
 
+    private boolean resourceExist(String resourcePath){
+        return  this.retrieve(resourcePath) != null;
+    }
+
     public List<Partition> retrievePartitions() {
         List<Partition> partitionList = new ArrayList<Partition>();
         RegistryManager registryManager = RegistryManager.getInstance();
@@ -327,6 +348,26 @@ public class RegistryManager {
         return depPolicyList;
     }
 
+    public ServiceGroup getServiceGroup(String name) throws Exception{
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + name;
+        Object serializedObj = registryManager.retrieve(resourcePath);
+        ServiceGroup group = null;
+        if (serializedObj != null) {
+
+                Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+                if (dataObj instanceof ServiceGroup) {
+                    group = (ServiceGroup) dataObj;
+                    if(log.isDebugEnabled()) {
+                        log.debug(group.toString());
+                    }
+                } else {
+                    return null;
+                }
+        }
+
+        return group;
+    }
+
 	public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
 		 String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
          this.delete(resourcePath);
@@ -372,6 +413,6 @@ public class RegistryManager {
 	            log.error("Could not delete resource at "+ resourcePath);
 	            throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
 	        }
-		
+
 	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
index b30e0e6..3587afe 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
@@ -44,5 +44,6 @@ public final class AutoScalerConstants {
      * Configs
      */
     public static final String AUTOSCALER_MONITOR_INTERVAL = "autoscaler.monitorInterval";
-       
+
+    public static final String SERVICE_GROUP = "/groups";
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
index 5c97143..af1c6ea 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
@@ -18,15 +18,11 @@
  */
 package org.apache.stratos.autoscaler.util;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.io.*;
+
 public class Deserializer {
     
     private static final Log log = LogFactory.getLog(Deserializer.class);
@@ -75,7 +71,7 @@ public class Deserializer {
      * @return the deserialized {@link Object}
      * @throws Exception if the deserialization is failed.
      */
-    public static Object deserializeFromByteArray(byte[] bytes) throws Exception {
+    public static Object deserializeFromByteArray(byte[] bytes) throws IOException, ClassNotFoundException {
 
         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
         ObjectInput in = null;

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index b87d0f2..731c80f 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -24,15 +24,13 @@ import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.stub.*;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.apache.stratos.manager.internal.DataHolder;
 import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceNonExistingLBExceptionException;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceStub;
 
 import java.rmi.RemoteException;
 
@@ -211,5 +209,13 @@ public class AutoscalerServiceClient {
     public String getServiceLBClusterId (String serviceType, String deploymentPolicy) throws RemoteException {
     	return stub.getServiceLBClusterId(serviceType, deploymentPolicy);
     }
-    
+
+
+    public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws RemoteException {
+        return stub.getServiceGroup(serviceGroupDefinitionName);
+    }
+
+    public void deployServiceGroup(ServiceGroup serviceGroup) throws AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException {
+        stub.deployServiceGroup(serviceGroup);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
index be0c4ee..7244de4 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
@@ -22,23 +22,21 @@ package org.apache.stratos.manager.grouping.deployer;
 import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.pojo.Dependencies;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
+import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.client.AutoscalerServiceClient;
 import org.apache.stratos.manager.client.CloudControllerServiceClient;
 import org.apache.stratos.manager.exception.ADCException;
 import org.apache.stratos.manager.exception.InvalidServiceGroupException;
 import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
 import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
-import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup;
-import org.apache.stratos.cloud.controller.stub.pojo.Dependencies;
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException;
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
 
 import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
 
@@ -155,23 +153,23 @@ public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
             }
         }
         
-        CloudControllerServiceClient ccServiceClient = null;
+        AutoscalerServiceClient asServiceClient = null;
 
         try {
-            ccServiceClient = CloudControllerServiceClient.getServiceClient();
+            asServiceClient = AutoscalerServiceClient.getServiceClient();
             
             if (log.isDebugEnabled()) {
             	log.debug("deplying to cloud controller service group " + serviceGroupDefinition.getName());
             }
-            
-            ccServiceClient.deployServiceGroup(serviceGroup);
+
+            asServiceClient.deployServiceGroup(serviceGroup);
 
         } catch (AxisFault axisFault) {
             throw new ADCException(axisFault);
         }catch (RemoteException e) {
             throw new ADCException(e);
-        } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) {
-        	throw new ADCException(e);
+        } catch (AutoScalerServiceInvalidServiceGroupExceptionException e) {
+            e.printStackTrace();
         }
     }
 
@@ -181,16 +179,16 @@ public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
         	log.debug("getting service group from cloud controller " + serviceGroupDefinitionName);
         }
     	
-    	CloudControllerServiceClient ccServiceClient = null;
+    	AutoscalerServiceClient asServiceClient = null;
 
         try {
-            ccServiceClient = CloudControllerServiceClient.getServiceClient();
+            asServiceClient = AutoscalerServiceClient.getServiceClient();
             
             if (log.isDebugEnabled()) {
             	log.debug("deploying to cloud controller service group " + serviceGroupDefinitionName);
             }
             
-            ServiceGroup serviceGroup = ccServiceClient.getServiceGroup(serviceGroupDefinitionName);
+            ServiceGroup serviceGroup = asServiceClient.getServiceGroup(serviceGroupDefinitionName);
             ServiceGroupDefinition serviceGroupDef = populateServiceGroupDefinitionPojo(serviceGroup);
             
             return serviceGroupDef;
@@ -199,10 +197,7 @@ public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
             throw new ADCException(axisFault);
         } catch (RemoteException e) {
         	throw new ADCException(e);
-		} catch (CloudControllerServiceInvalidServiceGroupExceptionException e) {
-			throw new ADCException(e);
 		}
-    	
     }
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
index 60683cc..0df7903 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
@@ -47,7 +47,7 @@
                         <configuration>
                             <tasks>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
-                                    <arg line="-uri src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.autoscaler.stub -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition" />
+                                    <arg line="-uri src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.autoscaler.stub -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition,http://pojo.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.pojo" />
                                     <classpath refid="maven.dependency.classpath" />
                                     <classpath refid="maven.compile.classpath" />
                                     <classpath refid="maven.runtime.classpath" />
@@ -93,6 +93,7 @@
                             org.apache.stratos.autoscaler.exception.*; version=${project.version},
 			    org.apache.stratos.autoscaler.partition.*; version=${project.version},
 			    org.apache.stratos.autoscaler.api.*; version=${project.version}
+			    org.apache.stratos.autoscaler.pojo.*; version=${project.version}
                         </Export-Package>
 			<Private-Package>
 			</Private-Package>


[44/50] [abbrv] more refactoring

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
index 1fc808e..72b1581 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
@@ -1,554 +1,554 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.application;
-
-import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser;
-import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
-import org.apache.stratos.cloud.controller.interfaces.ApplicationParser;
-import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.Dependencies;
-import org.apache.stratos.cloud.controller.pojo.ServiceGroup;
-import org.apache.stratos.cloud.controller.pojo.application.*;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class CompositeApplicationParseTest {
-
-    private static FasterLookUpDataHolder dataHolder = null;
-
-    @BeforeClass
-    public static void setUpBeforeClass() {
-
-        dataHolder =  FasterLookUpDataHolder.getInstance();
-        // add cartridges
-        // add php cartridge
-        dataHolder.addCartridge(new Cartridge("php", "stratos.com", "php-provider" , "1.0.0", false));
-        // add tomcat cartridge
-        dataHolder.addCartridge(new Cartridge("tomcat", "stratos.com", "apache" , "1.0.0", false));
-        // add mysql cartridge
-        dataHolder.addCartridge(new Cartridge("mysql", "stratos.com", "apache" , "1.0.0", false));
-
-        // add groups
-        // add group1
-        ServiceGroup group1 = new ServiceGroup();
-        group1.setName("group1");
-        group1.setCartridges(new String[]{"mysql"});
-        Dependencies group1Dependencies = new Dependencies();
-        group1Dependencies.setKillBehaviour("terminate-none");
-        group1.setDependencies(group1Dependencies);
-        dataHolder.addServiceGroup(group1);
-        // add group2
-        ServiceGroup group2 = new ServiceGroup();
-        group2.setName("group2");
-        group2.setCartridges(new String[]{"php"});
-        group2.setSubGroups(new String[]{"group1"});
-        Dependencies group2Dependencies = new Dependencies();
-        group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"});
-        group2Dependencies.setKillBehaviour("terminate-dependents");
-        group2.setDependencies(group2Dependencies);
-        dataHolder.addServiceGroup(group2);
-    }
-
-    @Test
-    public void testParseSimpleApplication () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test(expected = ApplicationDefinitionException.class)
-    public void testParseSimpleApplicationWithNullAppId () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // no app id
-        simpleAppCtxt.setAlias("simpleAppAlias");
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test(expected = ApplicationDefinitionException.class)
-    public void testParseSimpleApplicationWithEmptyAppId () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // empty app id
-        simpleAppCtxt.setApplicationId("");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test(expected = ApplicationDefinitionException.class)
-    public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleInvalidApp");
-        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        // give invalid cartridge type
-        simpleAppSubscribableContext.setType("php1");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test(expected = ApplicationDefinitionException.class)
-    public void testParseSimpleApplicationWithoutSubcriptionInformation() throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleInvalidApp");
-        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        // give invalid cartridge type
-        simpleAppSubscribableContext.setType("php1");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // invalid Subscription information
-        SubscribableInfoContext simpleAppEmptySubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppEmptySubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test
-    public void testParseSimpleApplicationWithMultipleSubsriptions () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleInvalidApp");
-        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext();
-        simpleAppPhpSubscribableContext.setType("php");
-        simpleAppPhpSubscribableContext.setAlias("myphp");
-        SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext();
-        simpleAppMySqlSubscribableContext.setType("mysql");
-        simpleAppMySqlSubscribableContext.setAlias("mysql1");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext,
-                simpleAppMySqlSubscribableContext});
-
-        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
-        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
-        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"});
-        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
-
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-
-        // subscribable information
-        SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppPhpSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1");
-        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2");
-        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt,
-                simpleAppMySqlSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test(expected = ApplicationDefinitionException.class)
-    public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrder () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleInvalidApp");
-        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext();
-        simpleAppPhpSubscribableContext.setType("php");
-        simpleAppPhpSubscribableContext.setAlias("myphp");
-        SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext();
-        simpleAppMySqlSubscribableContext.setType("mysql");
-        simpleAppMySqlSubscribableContext.setAlias("mysql1");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext,
-                simpleAppMySqlSubscribableContext});
-
-        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
-        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
-        // startup order is invalid, without prefix 'cartridge.' for mysql1
-        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"});
-        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
-
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-
-        // subscribable information
-        SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppPhpSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1");
-        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2");
-        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt,
-                simpleAppMySqlSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test
-    public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        // top level cartridges
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        // top level group
-        GroupContext simpleGroupContext = new GroupContext();
-        simpleGroupContext.setName("group1");
-        simpleGroupContext.setAlias("mygroup1");
-        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
-        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
-        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
-        groupSubscribableCtxt.setType("mysql");
-        groupSubscribableCtxt.setAlias("mygroup1mysql");
-        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
-        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
-        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
-        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
-                simpleAppGroupSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test (expected = ApplicationDefinitionException.class)
-    public void testAppWithOneCartridgeAndInvalidGroup () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        // top level cartridges
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        // top level group
-        GroupContext simpleGroupContext = new GroupContext();
-        // invalid Group 'group11'
-        simpleGroupContext.setName("group11");
-        simpleGroupContext.setAlias("mygroup1");
-        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
-        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
-        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
-        groupSubscribableCtxt.setType("mysql");
-        groupSubscribableCtxt.setAlias("mygroup1mysql");
-        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
-        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
-        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
-        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
-                simpleAppGroupSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test
-    public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        // top level cartridges
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        // top level group
-        GroupContext simpleGroupContext = new GroupContext();
-        simpleGroupContext.setName("group1");
-        simpleGroupContext.setAlias("mygroup1");
-        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
-        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
-        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
-        groupSubscribableCtxt.setType("mysql");
-        groupSubscribableCtxt.setAlias("mygroup1mysql");
-        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
-        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // dependencies
-        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
-        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
-        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"});
-        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
-        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
-        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
-                simpleAppGroupSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test (expected = ApplicationDefinitionException.class)
-    public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        // top level cartridges
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        // top level group
-        GroupContext simpleGroupContext = new GroupContext();
-        simpleGroupContext.setName("group1");
-        simpleGroupContext.setAlias("mygroup1");
-        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
-        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
-        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
-        groupSubscribableCtxt.setType("mysql");
-        groupSubscribableCtxt.setAlias("mygroup1mysql");
-        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
-        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // dependencies
-        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
-        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
-        // invalid startup order, starting with 'group1'
-        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"});
-        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
-        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
-        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
-                simpleAppGroupSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @Test (expected = ApplicationDefinitionException.class)
-    public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws ApplicationDefinitionException {
-
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        ApplicationContext simpleAppCtxt = new ApplicationContext();
-        // app id
-        simpleAppCtxt.setApplicationId("simpleApp");
-        simpleAppCtxt.setAlias("simpleAppAlias");
-        // tenant info
-        simpleAppCtxt.setTenantId(-1234);
-        // components
-        ComponentContext simpleAppComponentCtxt = new ComponentContext();
-        // top level cartridges
-        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
-        simpleAppSubscribableContext.setType("php");
-        simpleAppSubscribableContext.setAlias("myphp");
-        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
-        // top level group
-        GroupContext simpleGroupContext = new GroupContext();
-        simpleGroupContext.setName("group1");
-        simpleGroupContext.setAlias("mygroup1");
-        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
-        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
-        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
-        groupSubscribableCtxt.setType("mysql");
-        groupSubscribableCtxt.setAlias("mygroup1mysql");
-        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
-        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
-        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
-        // subscribable information
-        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
-        simpleAppSubscribableInfoCtxt.setAlias("myphp");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
-        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
-        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
-        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
-        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
-
-        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
-
-        // parse
-        applicationParser.parse(simpleAppCtxt);
-    }
-
-    @AfterClass
-    public static void tearDownAfterClass() {
-
-        dataHolder = null;
-    }
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements.  See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership.  The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License.  You may obtain a copy of the License at
+// *
+// *  http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing,
+// * software distributed under the License is distributed on an
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// * KIND, either express or implied.  See the License for the
+// * specific language governing permissions and limitations
+// * under the License.
+// */
+//
+//package org.apache.stratos.cloud.controller.application;
+//
+//import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser;
+//import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
+//import org.apache.stratos.cloud.controller.interfaces.ApplicationParser;
+//import org.apache.stratos.cloud.controller.pojo.Cartridge;
+//import org.apache.stratos.cloud.controller.pojo.Dependencies;
+//import org.apache.stratos.cloud.controller.pojo.ServiceGroup;
+//import org.apache.stratos.cloud.controller.pojo.application.*;
+//import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
+//import org.junit.AfterClass;
+//import org.junit.BeforeClass;
+//import org.junit.Test;
+//
+//public class CompositeApplicationParseTest {
+//
+//    private static FasterLookUpDataHolder dataHolder = null;
+//
+//    @BeforeClass
+//    public static void setUpBeforeClass() {
+//
+//        dataHolder =  FasterLookUpDataHolder.getInstance();
+//        // add cartridges
+//        // add php cartridge
+//        dataHolder.addCartridge(new Cartridge("php", "stratos.com", "php-provider" , "1.0.0", false));
+//        // add tomcat cartridge
+//        dataHolder.addCartridge(new Cartridge("tomcat", "stratos.com", "apache" , "1.0.0", false));
+//        // add mysql cartridge
+//        dataHolder.addCartridge(new Cartridge("mysql", "stratos.com", "apache" , "1.0.0", false));
+//
+//        // add groups
+//        // add group1
+//        ServiceGroup group1 = new ServiceGroup();
+//        group1.setName("group1");
+//        group1.setCartridges(new String[]{"mysql"});
+//        Dependencies group1Dependencies = new Dependencies();
+//        group1Dependencies.setKillBehaviour("terminate-none");
+//        group1.setDependencies(group1Dependencies);
+//        dataHolder.addServiceGroup(group1);
+//        // add group2
+//        ServiceGroup group2 = new ServiceGroup();
+//        group2.setName("group2");
+//        group2.setCartridges(new String[]{"php"});
+//        group2.setSubGroups(new String[]{"group1"});
+//        Dependencies group2Dependencies = new Dependencies();
+//        group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"});
+//        group2Dependencies.setKillBehaviour("terminate-dependents");
+//        group2.setDependencies(group2Dependencies);
+//        dataHolder.addServiceGroup(group2);
+//    }
+//
+//    @Test
+//    public void testParseSimpleApplication () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test(expected = ApplicationDefinitionException.class)
+//    public void testParseSimpleApplicationWithNullAppId () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // no app id
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test(expected = ApplicationDefinitionException.class)
+//    public void testParseSimpleApplicationWithEmptyAppId () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // empty app id
+//        simpleAppCtxt.setApplicationId("");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test(expected = ApplicationDefinitionException.class)
+//    public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleInvalidApp");
+//        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        // give invalid cartridge type
+//        simpleAppSubscribableContext.setType("php1");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test(expected = ApplicationDefinitionException.class)
+//    public void testParseSimpleApplicationWithoutSubcriptionInformation() throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleInvalidApp");
+//        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        // give invalid cartridge type
+//        simpleAppSubscribableContext.setType("php1");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // invalid Subscription information
+//        SubscribableInfoContext simpleAppEmptySubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppEmptySubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test
+//    public void testParseSimpleApplicationWithMultipleSubsriptions () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleInvalidApp");
+//        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext();
+//        simpleAppPhpSubscribableContext.setType("php");
+//        simpleAppPhpSubscribableContext.setAlias("myphp");
+//        SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext();
+//        simpleAppMySqlSubscribableContext.setType("mysql");
+//        simpleAppMySqlSubscribableContext.setAlias("mysql1");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext,
+//                simpleAppMySqlSubscribableContext});
+//
+//        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+//        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
+//        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"});
+//        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+//
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//
+//        // subscribable information
+//        SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppPhpSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1");
+//        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2");
+//        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt,
+//                simpleAppMySqlSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test(expected = ApplicationDefinitionException.class)
+//    public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrder () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleInvalidApp");
+//        simpleAppCtxt.setAlias("simpleInvalidAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext();
+//        simpleAppPhpSubscribableContext.setType("php");
+//        simpleAppPhpSubscribableContext.setAlias("myphp");
+//        SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext();
+//        simpleAppMySqlSubscribableContext.setType("mysql");
+//        simpleAppMySqlSubscribableContext.setAlias("mysql1");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext,
+//                simpleAppMySqlSubscribableContext});
+//
+//        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+//        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
+//        // startup order is invalid, without prefix 'cartridge.' for mysql1
+//        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"});
+//        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+//
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//
+//        // subscribable information
+//        SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppPhpSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1");
+//        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2");
+//        simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt,
+//                simpleAppMySqlSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test
+//    public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        // top level cartridges
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        // top level group
+//        GroupContext simpleGroupContext = new GroupContext();
+//        simpleGroupContext.setName("group1");
+//        simpleGroupContext.setAlias("mygroup1");
+//        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+//        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+//        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+//        groupSubscribableCtxt.setType("mysql");
+//        groupSubscribableCtxt.setAlias("mygroup1mysql");
+//        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+//        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+//        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+//        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+//                simpleAppGroupSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test (expected = ApplicationDefinitionException.class)
+//    public void testAppWithOneCartridgeAndInvalidGroup () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        // top level cartridges
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        // top level group
+//        GroupContext simpleGroupContext = new GroupContext();
+//        // invalid Group 'group11'
+//        simpleGroupContext.setName("group11");
+//        simpleGroupContext.setAlias("mygroup1");
+//        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+//        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+//        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+//        groupSubscribableCtxt.setType("mysql");
+//        groupSubscribableCtxt.setAlias("mygroup1mysql");
+//        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+//        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+//        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+//        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+//                simpleAppGroupSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test
+//    public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        // top level cartridges
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        // top level group
+//        GroupContext simpleGroupContext = new GroupContext();
+//        simpleGroupContext.setName("group1");
+//        simpleGroupContext.setAlias("mygroup1");
+//        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+//        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+//        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+//        groupSubscribableCtxt.setType("mysql");
+//        groupSubscribableCtxt.setAlias("mygroup1mysql");
+//        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+//        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // dependencies
+//        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+//        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
+//        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"});
+//        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+//        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+//        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+//                simpleAppGroupSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test (expected = ApplicationDefinitionException.class)
+//    public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        // top level cartridges
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        // top level group
+//        GroupContext simpleGroupContext = new GroupContext();
+//        simpleGroupContext.setName("group1");
+//        simpleGroupContext.setAlias("mygroup1");
+//        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+//        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+//        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+//        groupSubscribableCtxt.setType("mysql");
+//        groupSubscribableCtxt.setAlias("mygroup1mysql");
+//        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+//        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // dependencies
+//        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+//        simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents");
+//        // invalid startup order, starting with 'group1'
+//        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"});
+//        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+//        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+//        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+//                simpleAppGroupSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @Test (expected = ApplicationDefinitionException.class)
+//    public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        ApplicationContext simpleAppCtxt = new ApplicationContext();
+//        // app id
+//        simpleAppCtxt.setApplicationId("simpleApp");
+//        simpleAppCtxt.setAlias("simpleAppAlias");
+//        // tenant info
+//        simpleAppCtxt.setTenantId(-1234);
+//        // components
+//        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+//        // top level cartridges
+//        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+//        simpleAppSubscribableContext.setType("php");
+//        simpleAppSubscribableContext.setAlias("myphp");
+//        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+//        // top level group
+//        GroupContext simpleGroupContext = new GroupContext();
+//        simpleGroupContext.setName("group1");
+//        simpleGroupContext.setAlias("mygroup1");
+//        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+//        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+//        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+//        groupSubscribableCtxt.setType("mysql");
+//        groupSubscribableCtxt.setAlias("mygroup1mysql");
+//        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+//        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+//        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+//        // subscribable information
+//        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+//        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+//        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+//        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+//        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+//        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+//
+//        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
+//
+//        // parse
+//        applicationParser.parse(simpleAppCtxt);
+//    }
+//
+//    @AfterClass
+//    public static void tearDownAfterClass() {
+//
+//        dataHolder = null;
+//    }
+//}

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
index 75f48d8..a848c11 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
@@ -24,7 +24,6 @@ import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext;
 import org.apache.stratos.cloud.controller.stub.*;
 import org.apache.stratos.cloud.controller.stub.pojo.*;
 import org.apache.stratos.manager.internal.DataHolder;
@@ -130,22 +129,6 @@ public class CloudControllerServiceClient {
 
 	}
 
-
-	public void deployApplicationDefinition(ApplicationContext applicationContext)
-            throws RemoteException, 
-            CloudControllerServiceInvalidIaasProviderExceptionException, CloudControllerServiceApplicationDefinitionExceptionException {
-
-		stub.deployApplicationDefinition(applicationContext);
-
-	}
-
-    public void undeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws CloudControllerServiceApplicationDefinitionExceptionException,
-            RemoteException {
-
-        stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain);
-    }
-	
-
     @SuppressWarnings("unused")
     private Properties
         extractProperties(java.util.Properties properties) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
index 6a7e421..9f41b0e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java
@@ -30,7 +30,6 @@ public class ClusterDataHolder implements Serializable {
 
     // Service/Cartridge type
     private String serviceType;
-
     // Cluster id
     private String clusterId;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 012611f..a7ab51b 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -31,7 +31,6 @@ import org.apache.stratos.cloud.controller.stub.*;
 import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig;
 import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
 import org.apache.stratos.cloud.controller.stub.pojo.Property;
-import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext;
 import org.apache.stratos.manager.client.AutoscalerServiceClient;
 import org.apache.stratos.manager.client.CloudControllerServiceClient;
 import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;

http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
index 7aff966..e527dd4 100644
--- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
+++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
@@ -46,7 +46,7 @@
                         <configuration>
                             <tasks>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
-                                    <arg line="-uri src/main/resources/CloudControllerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.cloud.controller.stub -ns2p http://policy.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.policy,http://partition.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://exception.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.exception,http://pojo.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,,http://application.pojo.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo.application,http://impl.controller.cloud.stratos.apache.org=org.apache.stratos.cloud.controller.stub.impl" />
+                                    <arg line="-uri src/main/resources/CloudControllerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.cloud.controller.stub -ns2p http://policy.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.policy,http://partition.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://exception.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.exception,http://pojo.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://impl.controller.cloud.stratos.apache.org=org.apache.stratos.cloud.controller.stub.impl" />
                                     <classpath refid="maven.dependency.classpath" />
                                     <classpath refid="maven.compile.classpath" />
                                     <classpath refid="maven.runtime.classpath" />
@@ -89,7 +89,6 @@
                             org.apache.stratos.cloud.controller.stub.exception.*; version=${project.version},
                             org.apache.stratos.cloud.controller.stub.deployment.partition.*; version=${project.version},
                             org.apache.stratos.cloud.controller.stub.pojo.*; version=${project.version},
-			    org.apache.stratos.cloud.controller.stub.pojo.application.*; version=${project.version},
                             org.apache.stratos.cloud.controller.stub.impl.*; version=${project.version},
                             org.apache.stratos.cloud.controller.stub.*; version=${project.version}
                         </Export-Package>


[43/50] [abbrv] more refactoring

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/572cbe32/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
index 602de3f..696060a 100644
--- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
+++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
@@ -1,275 +1,213 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax220="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://impl.controller.cloud.stratos.apache.org" xmlns:ax222="http://application.pojo.controller.cloud.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax224="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://impl.controller.cloud.stratos.apache.org" xmlns:ax222="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax224="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax225="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
     <wsdl:documentation>CloudControllerService</wsdl:documentation>
     <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://application.pojo.controller.cloud.stratos.apache.org/xsd">
-            <xs:complexType name="ApplicationContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="components" nillable="true" type="ax222:ComponentContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax222:SubscribableInfoContext"></xs:element>
-                    <xs:element minOccurs="0" name="teantAdminUsername" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="ComponentContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax222:DependencyContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax222:GroupContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableContexts" nillable="true" type="ax222:SubscribableContext"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="DependencyContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="GroupContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax222:GroupContext"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableContexts" nillable="true" type="ax222:SubscribableContext"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="SubscribableContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="SubscribableInfoContext">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.controller.cloud.stratos.apache.org/xsd">
-            <xs:complexType name="ApplicationDefinitionException">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="InvalidCartridgeDefinitionException">
+            <xs:complexType name="InvalidPartitionException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidIaasProviderException">
+            <xs:complexType name="InvalidCartridgeTypeException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="UnregisteredCartridgeException">
+            <xs:complexType name="UnregisteredClusterException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidPartitionException">
+            <xs:complexType name="InvalidServiceGroupException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidCartridgeTypeException">
+            <xs:complexType name="InvalidMemberException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidServiceGroupException">
+            <xs:complexType name="InvalidClusterException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidMemberException">
+            <xs:complexType name="UnregisteredCartridgeException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidClusterException">
+            <xs:complexType name="InvalidIaasProviderException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="UnregisteredClusterException">
+            <xs:complexType name="InvalidCartridgeDefinitionException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax219="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax221="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:ax223="http://application.pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax226="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
-            <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"></xs:import>
+        <xs:schema xmlns:ax229="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax227="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax223="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
             <xs:import namespace="http://exception.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://application.pojo.controller.cloud.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:element name="getClusterContext">
+            <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:element name="CloudControllerServiceInvalidPartitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax222:InvalidPartitionException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getClusterContextResponse">
+            <xs:element name="validatePartition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:ClusterContext"></xs:element>
+                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax224:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceApplicationDefinitionException">
+            <xs:element name="validatePartitionResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax220:ApplicationDefinitionException"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplicationDefinition">
+            <xs:element name="CloudControllerServiceInvalidCartridgeTypeException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax222:ApplicationContext"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidCartridgeTypeException" nillable="true" type="ax222:InvalidCartridgeTypeException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="unDeployApplicationDefinition">
+            <xs:element name="validateDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
-                        <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax224:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidCartridgeDefinitionException">
+            <xs:element name="validateDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidCartridgeDefinitionException" nillable="true" type="ax220:InvalidCartridgeDefinitionException"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidIaasProviderException">
+            <xs:element name="CloudControllerServiceUnregisteredClusterException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidIaasProviderException" nillable="true" type="ax220:InvalidIaasProviderException"></xs:element>
+                        <xs:element minOccurs="0" name="UnregisteredClusterException" nillable="true" type="ax222:UnregisteredClusterException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployCartridgeDefinition">
+            <xs:element name="unregisterService">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax219:CartridgeConfig"></xs:element>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceUnregisteredCartridgeException">
+            <xs:element name="CloudControllerServiceInvalidServiceGroupException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="UnregisteredCartridgeException" nillable="true" type="ax220:UnregisteredCartridgeException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax222:InvalidServiceGroupException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getCartridgeInfo">
+            <xs:element name="undeployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getCartridgeInfoResponse">
+            <xs:element name="undeployCartridgeDefinition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:CartridgeInfo"></xs:element>
+                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidPartitionException">
+            <xs:element name="CloudControllerServiceInvalidMemberException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax220:InvalidPartitionException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidMemberException" nillable="true" type="ax222:InvalidMemberException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidCartridgeTypeException">
+            <xs:element name="terminateInstance">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidCartridgeTypeException" nillable="true" type="ax220:InvalidCartridgeTypeException"></xs:element>
+                        <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="validateDeploymentPolicy">
+            <xs:element name="CloudControllerServiceInvalidClusterException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax224:Partition"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidClusterException" nillable="true" type="ax222:InvalidClusterException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="validateDeploymentPolicyResponse">
+            <xs:element name="terminateAllInstances">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="undeployCartridgeDefinition">
+            <xs:element name="CloudControllerServiceUnregisteredCartridgeException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="UnregisteredCartridgeException" nillable="true" type="ax222:UnregisteredCartridgeException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidServiceGroupException">
+            <xs:element name="CloudControllerServiceInvalidIaasProviderException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax220:InvalidServiceGroupException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidIaasProviderException" nillable="true" type="ax222:InvalidIaasProviderException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployServiceGroup">
+            <xs:element name="startInstance">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax219:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="memberContext" nillable="true" type="ax225:MemberContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="undeployServiceGroup">
+            <xs:element name="startInstanceResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax225:MemberContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupSubGroups">
+            <xs:element name="registerService">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="registrant" nillable="true" type="ax225:Registrant"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupSubGroupsResponse">
+            <xs:element name="registerServiceResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupCartridges">
+            <xs:element name="getServiceGroupSubGroups">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupCartridgesResponse">
+            <xs:element name="getServiceGroupSubGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
@@ -286,49 +224,35 @@
             <xs:element name="getServiceGroupDependenciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:Dependencies"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="startInstance">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="memberContext" nillable="true" type="ax219:MemberContext"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="startInstanceResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:MemberContext"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax225:Dependencies"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidMemberException">
+            <xs:element name="getServiceGroupCartridges">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidMemberException" nillable="true" type="ax220:InvalidMemberException"></xs:element>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="terminateInstance">
+            <xs:element name="getServiceGroupCartridgesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceInvalidClusterException">
+            <xs:element name="getServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidClusterException" nillable="true" type="ax220:InvalidClusterException"></xs:element>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="terminateAllInstances">
+            <xs:element name="getServiceGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax225:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -344,87 +268,103 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="CloudControllerServiceUnregisteredClusterException">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="UnregisteredClusterException" nillable="true" type="ax220:UnregisteredClusterException"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="unregisterService">
+            <xs:element name="getClusterContext">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroup">
+            <xs:element name="getClusterContextResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax225:ClusterContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupResponse">
+            <xs:element name="getCartridgeInfo">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="validatePartition">
+            <xs:element name="getCartridgeInfoResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax224:Partition"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax225:CartridgeInfo"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="validatePartitionResponse">
+            <xs:element name="deployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax225:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="registerService">
+            <xs:element name="CloudControllerServiceInvalidCartridgeDefinitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="registrant" nillable="true" type="ax219:Registrant"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidCartridgeDefinitionException" nillable="true" type="ax222:InvalidCartridgeDefinitionException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="registerServiceResponse">
+            <xs:element name="deployCartridgeDefinition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax225:CartridgeConfig"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
-        <xs:schema xmlns:ax225="http://pojo.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:complexType name="Partition">
+        <xs:schema xmlns:ax228="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
+            <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax225:Property"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="Property">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="MemberContext">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="allocatedIpAddress" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="initTime" type="xs:long"></xs:element>
+                    <xs:element minOccurs="0" name="instanceId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="nodeId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="partition" nillable="true" type="ax224:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="privateIpAddress" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="publicIpAddress" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax227="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:complexType name="ClusterContext">
+            <xs:complexType name="Registrant">
                 <xs:sequence>
+                    <xs:element minOccurs="0" name="autoScalerPolicyName" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="lbCluster" type="xs:boolean"></xs:element>
                     <xs:element minOccurs="0" name="payload" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="timeoutInMillis" type="xs:long"></xs:element>
-                    <xs:element minOccurs="0" name="volumeRequired" type="xs:boolean"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax218:Volume"></xs:element>
+                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax225:Persistence"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="Persistence">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="persistanceRequired" type="xs:boolean"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax225:Volume"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Volume">
@@ -439,78 +379,65 @@
                     <xs:element minOccurs="0" name="volumeId" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="CartridgeConfig">
+            <xs:complexType name="Dependencies">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="ServiceGroup">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax225:Dependencies"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="ClusterContext">
                 <xs:sequence>
+                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="lbCluster" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="payload" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="timeoutInMillis" type="xs:long"></xs:element>
+                    <xs:element minOccurs="0" name="volumeRequired" type="xs:boolean"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax225:Volume"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="CartridgeInfo">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="appTypes" nillable="true" type="ax225:AppType"></xs:element>
                     <xs:element minOccurs="0" name="baseDir" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="defaultAutoscalingPolicy" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="defaultDeploymentPolicy" nillable="true" type="xs:string"></xs:element>
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="deploymentDirs" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="exportingProperties" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="iaasConfigs" nillable="true" type="ax218:IaasConfig"></xs:element>
-                    <xs:element minOccurs="0" name="lbConfig" nillable="true" type="ax218:LoadbalancerConfig"></xs:element>
+                    <xs:element minOccurs="0" name="lbConfig" nillable="true" type="ax225:LoadbalancerConfig"></xs:element>
                     <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax218:Persistence"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="portMappings" nillable="true" type="ax218:PortMapping"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax218:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax225:Persistence"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="portMappings" nillable="true" type="ax225:PortMapping"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax225:Property"></xs:element>
                     <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="serviceGroup" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="version" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="IaasConfig">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="className" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="credential" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="identity" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="imageId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="maxInstanceLimit" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="networkInterfaces" nillable="true" type="ax218:NetworkInterfaces"></xs:element>
-                    <xs:element minOccurs="0" name="payload" nillable="true" type="xs:base64Binary"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax218:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="NetworkInterfaces">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkInterfaces" nillable="true" type="ax218:NetworkInterface"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="NetworkInterface">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="fixedIp" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="networkUuid" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="portUuid" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="Properties">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax218:Property"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="Property">
+            <xs:complexType name="AppType">
                 <xs:sequence>
+                    <xs:element minOccurs="0" name="appSpecificMapping" type="xs:boolean"></xs:element>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadbalancerConfig">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax218:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
                     <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="Persistence">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="persistanceRequired" type="xs:boolean"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax218:Volume"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
             <xs:complexType name="PortMapping">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="port" nillable="true" type="xs:string"></xs:element>
@@ -518,75 +445,65 @@
                     <xs:element minOccurs="0" name="proxyPort" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="CartridgeInfo">
+            <xs:complexType name="CartridgeConfig">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="appTypes" nillable="true" type="ax218:AppType"></xs:element>
                     <xs:element minOccurs="0" name="baseDir" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="defaultAutoscalingPolicy" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="defaultDeploymentPolicy" nillable="true" type="xs:string"></xs:element>
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="deploymentDirs" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="exportingProperties" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="lbConfig" nillable="true" type="ax218:LoadbalancerConfig"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="iaasConfigs" nillable="true" type="ax225:IaasConfig"></xs:element>
+                    <xs:element minOccurs="0" name="lbConfig" nillable="true" type="ax225:LoadbalancerConfig"></xs:element>
                     <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax218:Persistence"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="portMappings" nillable="true" type="ax218:PortMapping"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax218:Property"></xs:element>
+                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax225:Persistence"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="portMappings" nillable="true" type="ax225:PortMapping"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
                     <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="serviceGroup" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="version" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="AppType">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="appSpecificMapping" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="ServiceGroup">
+            <xs:complexType name="IaasConfig">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax218:Dependencies"></xs:element>
+                    <xs:element minOccurs="0" name="className" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="credential" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="identity" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="imageId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="maxInstanceLimit" type="xs:int"></xs:element>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="networkInterfaces" nillable="true" type="ax225:NetworkInterfaces"></xs:element>
+                    <xs:element minOccurs="0" name="payload" nillable="true" type="xs:base64Binary"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="Dependencies">
+            <xs:complexType name="NetworkInterfaces">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkInterfaces" nillable="true" type="ax225:NetworkInterface"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="MemberContext">
+            <xs:complexType name="NetworkInterface">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="allocatedIpAddress" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="initTime" type="xs:long"></xs:element>
-                    <xs:element minOccurs="0" name="instanceId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="nodeId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="partition" nillable="true" type="ax224:Partition"></xs:element>
-                    <xs:element minOccurs="0" name="privateIpAddress" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax218:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="publicIpAddress" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="fixedIp" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="networkUuid" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="portUuid" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="Registrant">
+        </xs:schema>
+        <xs:schema xmlns:ax226="http://pojo.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd">
+            <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:complexType name="Partition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="autoScalerPolicyName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="payload" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="persistence" nillable="true" type="ax218:Persistence"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax218:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax225:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
@@ -633,12 +550,6 @@
     <wsdl:message name="CloudControllerServiceUnregisteredCartridgeException">
         <wsdl:part name="parameters" element="ns:CloudControllerServiceUnregisteredCartridgeException"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="unDeployApplicationDefinitionRequest">
-        <wsdl:part name="parameters" element="ns:unDeployApplicationDefinition"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="CloudControllerServiceApplicationDefinitionException">
-        <wsdl:part name="parameters" element="ns:CloudControllerServiceApplicationDefinitionException"></wsdl:part>
-    </wsdl:message>
     <wsdl:message name="getServiceGroupDependenciesRequest">
         <wsdl:part name="parameters" element="ns:getServiceGroupDependencies"></wsdl:part>
     </wsdl:message>
@@ -666,17 +577,14 @@
     <wsdl:message name="CloudControllerServiceInvalidIaasProviderException">
         <wsdl:part name="parameters" element="ns:CloudControllerServiceInvalidIaasProviderException"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="undeployServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:undeployServiceGroup"></wsdl:part>
-    </wsdl:message>
     <wsdl:message name="getCartridgeInfoRequest">
         <wsdl:part name="parameters" element="ns:getCartridgeInfo"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getCartridgeInfoResponse">
         <wsdl:part name="parameters" element="ns:getCartridgeInfoResponse"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="deployApplicationDefinitionRequest">
-        <wsdl:part name="parameters" element="ns:deployApplicationDefinition"></wsdl:part>
+    <wsdl:message name="undeployServiceGroupRequest">
+        <wsdl:part name="parameters" element="ns:undeployServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="unregisterServiceRequest">
         <wsdl:part name="parameters" element="ns:unregisterService"></wsdl:part>
@@ -741,10 +649,6 @@
             <wsdl:output message="ns:registerServiceResponse" wsaw:Action="urn:registerServiceResponse"></wsdl:output>
             <wsdl:fault message="ns:CloudControllerServiceUnregisteredCartridgeException" name="CloudControllerServiceUnregisteredCartridgeException" wsaw:Action="urn:registerServiceCloudControllerServiceUnregisteredCartridgeException"></wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="unDeployApplicationDefinition">
-            <wsdl:input message="ns:unDeployApplicationDefinitionRequest" wsaw:Action="urn:unDeployApplicationDefinition"></wsdl:input>
-            <wsdl:fault message="ns:CloudControllerServiceApplicationDefinitionException" name="CloudControllerServiceApplicationDefinitionException" wsaw:Action="urn:unDeployApplicationDefinitionCloudControllerServiceApplicationDefinitionException"></wsdl:fault>
-        </wsdl:operation>
         <wsdl:operation name="getServiceGroupDependencies">
             <wsdl:input message="ns:getServiceGroupDependenciesRequest" wsaw:Action="urn:getServiceGroupDependencies"></wsdl:input>
             <wsdl:output message="ns:getServiceGroupDependenciesResponse" wsaw:Action="urn:getServiceGroupDependenciesResponse"></wsdl:output>
@@ -765,18 +669,14 @@
             <wsdl:fault message="ns:CloudControllerServiceInvalidCartridgeDefinitionException" name="CloudControllerServiceInvalidCartridgeDefinitionException" wsaw:Action="urn:deployCartridgeDefinitionCloudControllerServiceInvalidCartridgeDefinitionException"></wsdl:fault>
             <wsdl:fault message="ns:CloudControllerServiceInvalidIaasProviderException" name="CloudControllerServiceInvalidIaasProviderException" wsaw:Action="urn:deployCartridgeDefinitionCloudControllerServiceInvalidIaasProviderException"></wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="undeployServiceGroup">
-            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"></wsdl:input>
-            <wsdl:fault message="ns:CloudControllerServiceInvalidServiceGroupException" name="CloudControllerServiceInvalidServiceGroupException" wsaw:Action="urn:undeployServiceGroupCloudControllerServiceInvalidServiceGroupException"></wsdl:fault>
-        </wsdl:operation>
         <wsdl:operation name="getCartridgeInfo">
             <wsdl:input message="ns:getCartridgeInfoRequest" wsaw:Action="urn:getCartridgeInfo"></wsdl:input>
             <wsdl:output message="ns:getCartridgeInfoResponse" wsaw:Action="urn:getCartridgeInfoResponse"></wsdl:output>
             <wsdl:fault message="ns:CloudControllerServiceUnregisteredCartridgeException" name="CloudControllerServiceUnregisteredCartridgeException" wsaw:Action="urn:getCartridgeInfoCloudControllerServiceUnregisteredCartridgeException"></wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="deployApplicationDefinition">
-            <wsdl:input message="ns:deployApplicationDefinitionRequest" wsaw:Action="urn:deployApplicationDefinition"></wsdl:input>
-            <wsdl:fault message="ns:CloudControllerServiceApplicationDefinitionException" name="CloudControllerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationDefinitionCloudControllerServiceApplicationDefinitionException"></wsdl:fault>
+        <wsdl:operation name="undeployServiceGroup">
+            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"></wsdl:input>
+            <wsdl:fault message="ns:CloudControllerServiceInvalidServiceGroupException" name="CloudControllerServiceInvalidServiceGroupException" wsaw:Action="urn:undeployServiceGroupCloudControllerServiceInvalidServiceGroupException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="unregisterService">
             <wsdl:input message="ns:unregisterServiceRequest" wsaw:Action="urn:unregisterService"></wsdl:input>
@@ -874,29 +774,8 @@
                 <soap:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="unDeployApplicationDefinition">
-            <soap:operation soapAction="urn:unDeployApplicationDefinition" style="document"></soap:operation>
-            <wsdl:input>
-                <soap:body use="literal"></soap:body>
-            </wsdl:input>
-            <wsdl:fault name="CloudControllerServiceApplicationDefinitionException">
-                <soap:fault use="literal" name="CloudControllerServiceApplicationDefinitionException"></soap:fault>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupDependencies">
-            <soap:operation soapAction="urn:getServiceGroupDependencies" style="document"></soap:operation>
-            <wsdl:input>
-                <soap:body use="literal"></soap:body>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"></soap:body>
-            </wsdl:output>
-            <wsdl:fault name="CloudControllerServiceInvalidServiceGroupException">
-                <soap:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap:fault>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupSubGroups">
-            <soap:operation soapAction="urn:getServiceGroupSubGroups" style="document"></soap:operation>
+        <wsdl:operation name="getServiceGroup">
+            <soap:operation soapAction="urn:getServiceGroup" style="document"></soap:operation>
             <wsdl:input>
                 <soap:body use="literal"></soap:body>
             </wsdl:input>
@@ -907,8 +786,8 @@
                 <soap:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getServiceGroup">
-            <soap:operation soapAction="urn:getServiceGroup" style="document"></soap:operation>
+        <wsdl:operation name="getServiceGroupDependencies">
+            <soap:operation soapAction="urn:getServiceGroupDependencies" style="document"></soap:operation>
             <wsdl:input>
                 <soap:body use="literal"></soap:body>
             </wsdl:input>
@@ -931,16 +810,16 @@
                 <soap:fault use="literal" name="CloudControllerServiceInvalidIaasProviderException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getCartridgeInfo">
-            <soap:operation soapAction="urn:getCartridgeInfo" style="document"></soap:operation>
+        <wsdl:operation name="getServiceGroupSubGroups">
+            <soap:operation soapAction="urn:getServiceGroupSubGroups" style="document"></soap:operation>
             <wsdl:input>
                 <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
                 <soap:body use="literal"></soap:body>
             </wsdl:output>
-            <wsdl:fault name="CloudControllerServiceUnregisteredCartridgeException">
-                <soap:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap:fault>
+            <wsdl:fault name="CloudControllerServiceInvalidServiceGroupException">
+                <soap:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="undeployServiceGroup">
@@ -952,13 +831,16 @@
                 <soap:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="deployApplicationDefinition">
-            <soap:operation soapAction="urn:deployApplicationDefinition" style="document"></soap:operation>
+        <wsdl:operation name="getCartridgeInfo">
+            <soap:operation soapAction="urn:getCartridgeInfo" style="document"></soap:operation>
             <wsdl:input>
                 <soap:body use="literal"></soap:body>
             </wsdl:input>
-            <wsdl:fault name="CloudControllerServiceApplicationDefinitionException">
-                <soap:fault use="literal" name="CloudControllerServiceApplicationDefinitionException"></soap:fault>
+            <wsdl:output>
+                <soap:body use="literal"></soap:body>
+            </wsdl:output>
+            <wsdl:fault name="CloudControllerServiceUnregisteredCartridgeException">
+                <soap:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="unregisterService">
@@ -1096,29 +978,8 @@
                 <soap12:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="unDeployApplicationDefinition">
-            <soap12:operation soapAction="urn:unDeployApplicationDefinition" style="document"></soap12:operation>
-            <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
-            </wsdl:input>
-            <wsdl:fault name="CloudControllerServiceApplicationDefinitionException">
-                <soap12:fault use="literal" name="CloudControllerServiceApplicationDefinitionException"></soap12:fault>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupDependencies">
-            <soap12:operation soapAction="urn:getServiceGroupDependencies" style="document"></soap12:operation>
-            <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
-            </wsdl:output>
-            <wsdl:fault name="CloudControllerServiceInvalidServiceGroupException">
-                <soap12:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap12:fault>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupSubGroups">
-            <soap12:operation soapAction="urn:getServiceGroupSubGroups" style="document"></soap12:operation>
+        <wsdl:operation name="getServiceGroup">
+            <soap12:operation soapAction="urn:getServiceGroup" style="document"></soap12:operation>
             <wsdl:input>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:input>
@@ -1129,8 +990,8 @@
                 <soap12:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getServiceGroup">
-            <soap12:operation soapAction="urn:getServiceGroup" style="document"></soap12:operation>
+        <wsdl:operation name="getServiceGroupDependencies">
+            <soap12:operation soapAction="urn:getServiceGroupDependencies" style="document"></soap12:operation>
             <wsdl:input>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:input>
@@ -1153,16 +1014,16 @@
                 <soap12:fault use="literal" name="CloudControllerServiceInvalidIaasProviderException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getCartridgeInfo">
-            <soap12:operation soapAction="urn:getCartridgeInfo" style="document"></soap12:operation>
+        <wsdl:operation name="getServiceGroupSubGroups">
+            <soap12:operation soapAction="urn:getServiceGroupSubGroups" style="document"></soap12:operation>
             <wsdl:input>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:output>
-            <wsdl:fault name="CloudControllerServiceUnregisteredCartridgeException">
-                <soap12:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap12:fault>
+            <wsdl:fault name="CloudControllerServiceInvalidServiceGroupException">
+                <soap12:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="undeployServiceGroup">
@@ -1174,13 +1035,16 @@
                 <soap12:fault use="literal" name="CloudControllerServiceInvalidServiceGroupException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="deployApplicationDefinition">
-            <soap12:operation soapAction="urn:deployApplicationDefinition" style="document"></soap12:operation>
+        <wsdl:operation name="getCartridgeInfo">
+            <soap12:operation soapAction="urn:getCartridgeInfo" style="document"></soap12:operation>
             <wsdl:input>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:input>
-            <wsdl:fault name="CloudControllerServiceApplicationDefinitionException">
-                <soap12:fault use="literal" name="CloudControllerServiceApplicationDefinitionException"></soap12:fault>
+            <wsdl:output>
+                <soap12:body use="literal"></soap12:body>
+            </wsdl:output>
+            <wsdl:fault name="CloudControllerServiceUnregisteredCartridgeException">
+                <soap12:fault use="literal" name="CloudControllerServiceUnregisteredCartridgeException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="unregisterService">
@@ -1297,23 +1161,8 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="unDeployApplicationDefinition">
-            <http:operation location="unDeployApplicationDefinition"></http:operation>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"></mime:content>
-            </wsdl:input>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupDependencies">
-            <http:operation location="getServiceGroupDependencies"></http:operation>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"></mime:content>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"></mime:content>
-            </wsdl:output>
-        </wsdl:operation>
-        <wsdl:operation name="getServiceGroupSubGroups">
-            <http:operation location="getServiceGroupSubGroups"></http:operation>
+        <wsdl:operation name="getServiceGroup">
+            <http:operation location="getServiceGroup"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
@@ -1321,8 +1170,8 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="getServiceGroup">
-            <http:operation location="getServiceGroup"></http:operation>
+        <wsdl:operation name="getServiceGroupDependencies">
+            <http:operation location="getServiceGroupDependencies"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
@@ -1336,8 +1185,8 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
         </wsdl:operation>
-        <wsdl:operation name="getCartridgeInfo">
-            <http:operation location="getCartridgeInfo"></http:operation>
+        <wsdl:operation name="getServiceGroupSubGroups">
+            <http:operation location="getServiceGroupSubGroups"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
@@ -1351,11 +1200,14 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
         </wsdl:operation>
-        <wsdl:operation name="deployApplicationDefinition">
-            <http:operation location="deployApplicationDefinition"></http:operation>
+        <wsdl:operation name="getCartridgeInfo">
+            <http:operation location="getCartridgeInfo"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"></mime:content>
+            </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="unregisterService">
             <http:operation location="unregisterService"></http:operation>
@@ -1411,22 +1263,22 @@
     </wsdl:binding>
     <wsdl:service name="CloudControllerService">
         <wsdl:port name="CloudControllerServiceHttpSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
-            <soap:address location="http://172.16.2.207:9763/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"></soap:address>
+            <soap:address location="http://192.168.56.1:9763/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"></soap:address>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
-            <soap:address location="https://172.16.2.207:9443/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"></soap:address>
+            <soap:address location="https://192.168.56.1:9443/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"></soap:address>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
-            <soap12:address location="http://172.16.2.207:9763/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"></soap12:address>
+            <soap12:address location="http://192.168.56.1:9763/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"></soap12:address>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
-            <soap12:address location="https://172.16.2.207:9443/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"></soap12:address>
+            <soap12:address location="https://192.168.56.1:9443/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"></soap12:address>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpEndpoint" binding="ns:CloudControllerServiceHttpBinding">
-            <http:address location="http://172.16.2.207:9763/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"></http:address>
+            <http:address location="http://192.168.56.1:9763/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"></http:address>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsEndpoint" binding="ns:CloudControllerServiceHttpBinding">
-            <http:address location="https://172.16.2.207:9443/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"></http:address>
+            <http:address location="https://192.168.56.1:9443/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"></http:address>
         </wsdl:port>
     </wsdl:service>
 </wsdl:definitions>
\ No newline at end of file


[03/50] [abbrv] git commit: support group/cluster created upon termination of all members when the application is not in Terminating

Posted by im...@apache.org.
support group/cluster created upon termination of all members when the application is not in Terminating


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

Branch: refs/heads/docker-grouping-merge
Commit: 38221dbd73ba241a22e49c85dca00763bd6ee0af
Parents: 65d96bc
Author: reka <rt...@gmail.com>
Authored: Thu Oct 30 18:17:58 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Oct 30 18:17:58 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    |  36 +++-
 .../status/checker/StatusChecker.java           | 179 ++++++++++---------
 2 files changed, 125 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/38221dbd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 8058c85..9b39a52 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -24,17 +24,17 @@ public class StatusEventPublisher {
             Service service = TopologyManager.getTopology().getService(serviceName);
             if (service != null) {
                 Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+                if (cluster.isStateTransitionValid(ClusterStatus.Created)) {
                     if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster activated event for [application]: " + appId +
+                        log.info("Publishing Cluster created event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    AppStatusClusterActivatedEvent clusterActivatedEvent =
-                            new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
+                    AppStatusClusterCreatedEvent clusterCreatedEvent =
+                            new AppStatusClusterCreatedEvent(appId, serviceName, clusterId);
 
-                    publishEvent(clusterActivatedEvent);
+                    publishEvent(clusterCreatedEvent);
                 } else {
-                    log.warn("Active is not in the possible state list of [cluster] " + clusterId);
+                    log.warn("Created is not in the possible state list of [cluster] " + clusterId);
                 }
             }
         } finally {
@@ -143,6 +143,30 @@ public class StatusEventPublisher {
         }
     }
 
+    public static void sendGroupCreatedEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Created)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group created event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    AppStatusGroupCreatedEvent groupCreatedEvent =
+                            new AppStatusGroupCreatedEvent(appId, groupId);
+
+                    publishEvent(groupCreatedEvent);
+                } else {
+                    log.warn("Created is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
     public static void sendGroupActivatedEvent(String appId, String groupId) {
         try {
             TopologyManager.acquireReadLockForApplication(appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/38221dbd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 97f6476..348537e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -98,18 +98,18 @@ public class StatusChecker {
                                 TopologyManager.acquireReadLockForApplication(appId);
                                 Application application = TopologyManager.getTopology().getApplication(appId);
 
-                            if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
-                                if(application.getStatus() == ApplicationStatus.Terminating) {
-                                    StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
-                                            monitor.getClusterId());
-                                } else {
-                                    StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
-                                            monitor.getClusterId());
-                                }
+                                if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
+                                    if (application.getStatus() == ApplicationStatus.Terminating) {
+                                        StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
+                                                monitor.getClusterId());
+                                    } else {
+                                        StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
+                                                monitor.getClusterId());
+                                    }
 
-                            } else {
-                                log.info("Cluster has non terminated [members] and in the [status] "
-                                        + cluster.getStatus().toString());
+                                } else {
+                                    log.info("Cluster has non terminated [members] and in the [status] "
+                                            + cluster.getStatus().toString());
 
                         /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive ||
                                 cluster.getStatus() == ClusterStatus.Terminating)) {
@@ -118,7 +118,7 @@ public class StatusChecker {
                                     monitor.getServiceId(), clusterId);
 
                         }*/
-                            }
+                                }
                             } finally {
                                 TopologyManager.releaseReadLockForApplication(appId);
                             }
@@ -182,7 +182,7 @@ public class StatusChecker {
                 String appId = monitor.getAppId();
                 if (clusterInActive) {
                     //if the monitor is dependent, temporarily pausing it
-                    if(monitor.isDependent()) {
+                    if (monitor.isDependent()) {
                         monitor.setHasFaultyMember(true);
                     }
                     //send cluster In-Active event to cluster status topic
@@ -201,7 +201,7 @@ public class StatusChecker {
         groupThread.start();
     }
 
-    private boolean getClusterInActive(AbstractClusterMonitor monitor, String  partitionId) {
+    private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) {
         boolean clusterInActive = false;
         for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
             for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
@@ -267,10 +267,6 @@ public class StatusChecker {
      */
     private boolean updateChildStatus(String appId, String id, Map<String, Group> groups,
                                       Map<String, ClusterDataHolder> clusterData, ParentComponent parent) {
-        boolean groupsActive = false;
-        boolean groupsTerminated = false;
-        boolean groupsInActive = false;
-        boolean groupsTerminating = false;
         ClusterStatus clusterStatus;
         GroupStatus groupStatus;
         boolean childFound = false;
@@ -286,42 +282,42 @@ public class StatusChecker {
             childFound = true;
             clusterStatus = getClusterStatus(clusterData);
             groupStatus = getGroupStatus(groups);
-
-            if (groups.isEmpty() && clusterStatus == ClusterStatus.Active ||
-                    clusterData.isEmpty() && groupStatus == GroupStatus.Active ||
-                    groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) {
-                //send activation event
-                if (parent instanceof Application) {
-                    //send application activated event
-                    log.info("sending app activate: " + appId);
-                    StatusEventPublisher.sendApplicationActivatedEvent(appId);
-                } else if (parent instanceof Group) {
-                    //send activation to the parent
-                    log.info("sending group activate: " + parent.getUniqueIdentifier());
-                    StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
-                }
-            } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
-                    clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
-                    groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
-                //send the in activation event
-                if (parent instanceof Application) {
-                    //send application activated event
-                    log.warn("Application can't be in in-active : " + appId);
-                    //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
-                } else if (parent instanceof Group) {
-                    //send activation to the parent
-                    log.info("sending group in-active: " + parent.getUniqueIdentifier());
-                    StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
-                }
-            } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
-                    clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
-                    groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
-                //send the terminated event
-                if (parent instanceof Application) {
-                    //validating the life cycle
-                    try {
-                        TopologyManager.acquireReadLockForApplication(appId);
-                        Application application = TopologyManager.getTopology().getApplication(appId);
+            try {
+                TopologyManager.acquireReadLockForApplication(appId);
+                Application application = TopologyManager.getTopology().getApplication(appId);
+
+                if (groups.isEmpty() && clusterStatus == ClusterStatus.Active ||
+                        clusterData.isEmpty() && groupStatus == GroupStatus.Active ||
+                        groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) {
+                    //send activation event
+                    if (parent instanceof Application) {
+                        //send application activated event
+                        log.info("sending app activate: " + appId);
+                        StatusEventPublisher.sendApplicationActivatedEvent(appId);
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group activate: " + parent.getUniqueIdentifier());
+                        StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
+                    }
+                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
+                        clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
+                        groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
+                    //send the in activation event
+                    if (parent instanceof Application) {
+                        //send application activated event
+                        log.warn("Application can't be in in-active : " + appId);
+                        //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group in-active: " + parent.getUniqueIdentifier());
+                        StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
+                    }
+                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
+                        clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
+                        groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
+                    //send the terminated event
+                    if (parent instanceof Application) {
+                        //validating the life cycle
                         if (application.getStatus().equals(ApplicationStatus.Terminating)) {
                             log.info("sending app terminated: " + appId);
                             StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
@@ -329,33 +325,38 @@ public class StatusChecker {
                             log.info("[Application] " + appId + " is in the [status] " +
                                     application.getStatus().toString() + ". Hence not sending terminated event");
                         }
-
-                    } finally {
-                        TopologyManager.releaseReadLockForApplication(appId);
+                        //StatusEventPublisher.sendApp(appId);
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group created : " + parent.getUniqueIdentifier());
+                        StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
                     }
-
-                    //StatusEventPublisher.sendApp(appId);
-                } else if (parent instanceof Group) {
-                    //send activation to the parent
-                    log.info("sending group terminated : " + parent.getUniqueIdentifier());
-                    StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier());
-                }
-            } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
-                    clusterData.isEmpty() && groupStatus == GroupStatus.Terminating ||
-                    groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) {
-                //send the terminated event
-                if (parent instanceof Application) {
-                    //send application activated event
-                    log.warn("Application can't be in terminating: " + appId);
-                    //StatusEventPublisher.sendApplicationTerminatingEvent(appId);
-                    //StatusEventPublisher.sendApp(appId);
-                } else if (parent instanceof Group) {
-                    //send activation to the parent
-                    log.info("sending group terminating : " + parent.getUniqueIdentifier());
-                    StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
+                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
+                        clusterData.isEmpty() && groupStatus == GroupStatus.Terminating ||
+                        groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) {
+                    if (parent instanceof Application) {
+                        log.info("Application can't be in terminating: " + appId);
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group terminating : " + parent.getUniqueIdentifier());
+                        StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
+                    }
+                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created ||
+                        clusterData.isEmpty() && groupStatus == GroupStatus.Created ||
+                        groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) {
+                    if (parent instanceof Application) {
+                        log.info("[Application] " + appId + "couldn't change to Created, since it is" +
+                                "already in " + application.getStatus().toString());
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group created : " + parent.getUniqueIdentifier());
+                        StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                    }
+                } else {
+                    log.warn("Clusters/groups not found in this [component] " + appId);
                 }
-            } else {
-                log.warn("Clusters/groups not found in this [component] " + appId);
+            } finally {
+                TopologyManager.releaseReadLockForApplication(appId);
             }
 
 
@@ -371,24 +372,28 @@ public class StatusChecker {
         GroupStatus status = null;
         boolean groupActive = true;
         boolean groupTerminated = true;
+        boolean groupCreated = true;
 
         for (Group group : groups.values()) {
             if (group.getStatus() == GroupStatus.Active) {
                 groupActive = groupActive && true;
-                groupTerminated =  false;
+                groupTerminated = false;
+                groupCreated = false;
             } else if (group.getStatus() == GroupStatus.Inactive) {
                 status = GroupStatus.Inactive;
                 break;
             } else if (group.getStatus() == GroupStatus.Terminated) {
                 groupActive = false;
+                groupCreated = false;
                 groupTerminated = groupTerminated && true;
             } else if (group.getStatus() == GroupStatus.Created) {
                 groupActive = false;
                 groupTerminated = false;
-                status = GroupStatus.Created;
+                groupCreated = groupCreated && true;
             } else if (group.getStatus() == GroupStatus.Terminating) {
                 groupActive = false;
                 groupTerminated = false;
+                groupCreated = false;
                 status = GroupStatus.Terminating;
 
             }
@@ -398,6 +403,8 @@ public class StatusChecker {
             status = GroupStatus.Active;
         } else if (groupTerminated) {
             status = GroupStatus.Terminated;
+        } else if(groupCreated) {
+            status = GroupStatus.Created;
         }
         return status;
 
@@ -407,28 +414,30 @@ public class StatusChecker {
         ClusterStatus status = null;
         boolean clusterActive = true;
         boolean clusterTerminated = true;
+        boolean clusterCreated = true;
         for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
             Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType());
             Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId());
             if (cluster.getStatus() == ClusterStatus.Active) {
                 clusterActive = clusterActive && true;
                 clusterTerminated = false;
+                clusterCreated = false;
             } else if (cluster.getStatus() == ClusterStatus.Inactive) {
                 status = ClusterStatus.Inactive;
-                clusterActive = false;
-                clusterTerminated = false;
                 break;
             } else if (cluster.getStatus() == ClusterStatus.Terminated) {
                 clusterActive = false;
+                clusterCreated = false;
                 clusterTerminated = clusterTerminated && true;
             } else if (cluster.getStatus() == ClusterStatus.Terminating) {
                 status = ClusterStatus.Terminating;
                 clusterActive = false;
                 clusterTerminated = false;
+                clusterCreated = false;
             } else if (cluster.getStatus() == ClusterStatus.Created) {
-                status = ClusterStatus.Created;
                 clusterActive = false;
                 clusterTerminated = false;
+                clusterCreated = clusterCreated && true;
             }
         }
 
@@ -436,6 +445,8 @@ public class StatusChecker {
             status = ClusterStatus.Active;
         } else if (clusterTerminated) {
             status = ClusterStatus.Terminated;
+        } else if(clusterCreated) {
+            status = ClusterStatus.Created;
         }
         return status;
     }


[19/50] [abbrv] git commit: removing application status and adding applications, cluster status topic

Posted by im...@apache.org.
removing application status and adding applications, cluster status topic


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

Branch: refs/heads/docker-grouping-merge
Commit: 275ba2dd6757a652450246e3843c3c25366a8327
Parents: ea9337d
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 13:20:57 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 13:20:57 2014 +0530

----------------------------------------------------------------------
 .../topic/ApplicationsEventPublisher.java       | 238 ++++++++++++
 .../topic/ClusterStatusEventPublisher.java      | 171 +++++++++
 .../grouping/topic/StatusEventPublisher.java    | 361 -------------------
 .../AutoscalerTopologyEventReceiver.java        |  25 +-
 .../monitor/ParentComponentMonitor.java         |  11 +-
 .../monitor/cluster/ClusterMonitor.java         |   5 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |   4 +-
 .../status/checker/StatusChecker.java           |  26 +-
 .../ApplicationStatusTopicReceiver.java         | 112 +-----
 .../internal/CloudControllerDSComponent.java    |   1 -
 .../controller/topology/TopologyBuilder.java    |  11 +-
 .../StratosManagerTopologyEventReceiver.java    |   6 +-
 .../applications/AppClusterActivatedEvent.java  |  50 ---
 .../applications/AppClusterCreatedEvent.java    |  50 ---
 .../applications/AppClusterInactivateEvent.java |  50 ---
 .../applications/AppClusterTerminatedEvent.java |  50 ---
 .../AppClusterTerminatingEvent.java             |  50 ---
 .../AppStatusGroupInactivateEvent.java          |   6 +-
 .../applications/ApplicationActivatedEvent.java |   4 +-
 .../applications/ApplicationCreatedEvent.java   |   4 +-
 .../ApplicationInactivatedEvent.java            |   4 +-
 .../ApplicationTerminatedEvent.java             |   3 +-
 .../ApplicationTerminatingEvent.java            |   4 +-
 .../event/applications/GroupActivatedEvent.java |   6 +-
 .../event/applications/GroupCreatedEvent.java   |   6 +-
 .../applications/GroupMaintenanceModeEvent.java |   6 +-
 .../applications/GroupReadyToShutdownEvent.java |   6 +-
 .../applications/GroupTerminatedEvent.java      |   6 +-
 .../applications/GroupTerminatingEvent.java     |   6 +-
 .../event/applications/StatusEvent.java         |  31 --
 .../ClusterStatusClusterActivatedEvent.java     |  52 +++
 .../ClusterStatusClusterCreatedEvent.java       |  52 +++
 .../ClusterStatusClusterInactivateEvent.java    |  52 +++
 .../ClusterStatusClusterTerminatedEvent.java    |  52 +++
 .../ClusterStatusClusterTerminatingEvent.java   |  52 +++
 .../AppClusterActivatedEventListener.java       |  24 --
 .../AppClusterCreatedEventListener.java         |  24 --
 .../AppClusterInactivateEventListener.java      |  24 --
 .../AppClusterTerminatedEventListener.java      |  24 --
 .../AppClusterTerminatingEventListener.java     |  24 --
 ...sterStatusClusterActivatedEventListener.java |  24 ++
 ...lusterStatusClusterCreatedEventListener.java |  24 ++
 ...terStatusClusterInactivateEventListener.java |  24 ++
 ...terStatusClusterTerminatedEventListener.java |  24 ++
 ...erStatusClusterTerminatingEventListener.java |  24 ++
 .../AppClusterActivatedMessageProcessor.java    |  57 ---
 .../AppClusterCreatedMessageProcessor.java      |  57 ---
 .../AppClusterInactivateMessageProcessor.java   |  58 ---
 .../AppClusterTerminatedMessageProcessor.java   |  58 ---
 .../AppClusterTerminatingMessageProcessor.java  |  58 ---
 .../AppStatusMessageProcessorChain.java         | 139 -------
 .../ApplicationActivatedMessageProcessor.java   |  68 +++-
 .../ApplicationCreatedMessageProcessor.java     |  92 ++++-
 .../ApplicationInactivatedMessageProcessor.java |  67 +++-
 .../ApplicationTerminatedMessageProcessor.java  |  99 ++++-
 .../ApplicationTerminatingMessageProcessor.java |  67 +++-
 .../ApplicationUndeployedMessageProcessor.java  | 139 +++++++
 .../ApplicationsMessageProcessorChain.java      | 115 ++++++
 .../GroupActivatedMessageProcessor.java         |  61 ----
 .../applications/GroupActivatedProcessor.java   | 107 ++++++
 .../GroupCreatedMessageProcessor.java           |  61 ----
 .../applications/GroupCreatedProcessor.java     | 108 ++++++
 .../applications/GroupInActivateProcessor.java  | 106 ++++++
 .../GroupInactivatedMessageProcessor.java       |  61 ----
 .../GroupTerminatedMessageProcessor.java        |  61 ----
 .../applications/GroupTerminatedProcessor.java  | 107 ++++++
 .../GroupTerminatingMessageProcessor.java       |  61 ----
 .../applications/GroupTerminatingProcessor.java | 107 ++++++
 ...rStatusClusterActivatedMessageProcessor.java |  58 +++
 ...terStatusClusterCreatedMessageProcessor.java |  58 +++
 ...StatusClusterInactivateMessageProcessor.java |  58 +++
 ...StatusClusterTerminatedMessageProcessor.java |  58 +++
 ...tatusClusterTerminatingMessageProcessor.java |  58 +++
 .../ClusterStatusMessageProcessorChain.java     |  78 ++++
 .../ApplicationActivatedMessageProcessor.java   | 104 ------
 .../ApplicationCreatedMessageProcessor.java     | 121 -------
 .../ApplicationInactivatedMessageProcessor.java | 104 ------
 .../ApplicationTerminatedMessageProcessor.java  | 136 -------
 .../ApplicationTerminatingMessageProcessor.java | 104 ------
 .../ApplicationUndeployedMessageProcessor.java  | 139 -------
 .../topology/GroupActivatedProcessor.java       | 107 ------
 .../topology/GroupCreatedProcessor.java         | 108 ------
 .../topology/GroupInActivateProcessor.java      | 106 ------
 .../topology/GroupTerminatedProcessor.java      | 107 ------
 .../topology/GroupTerminatingProcessor.java     | 107 ------
 .../topology/TopologyMessageProcessorChain.java |  70 +---
 .../ApplicationStatusEventMessageDelegator.java | 146 --------
 .../ApplicationStatusEventMessageListener.java  |  54 ---
 .../ApplicationStatusEventMessageQueue.java     |  26 --
 .../status/ApplicationStatusEventReceiver.java  |  83 -----
 .../ApplicationsEventMessageDelegator.java      | 146 ++++++++
 .../ApplicationsEventMessageListener.java       |  54 +++
 .../ApplicationsEventMessageQueue.java          |  26 ++
 .../applications/ApplicationsEventReceiver.java |  83 +++++
 .../ClusterStatusEventMessageDelegator.java     | 146 ++++++++
 .../ClusterStatusEventMessageListener.java      |  54 +++
 .../status/ClusterStatusEventMessageQueue.java  |  26 ++
 .../status/ClusterStatusEventReceiver.java      |  83 +++++
 .../stratos/messaging/util/Constants.java       |   4 +-
 99 files changed, 3004 insertions(+), 3335 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
new file mode 100644
index 0000000..1fbc143
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
@@ -0,0 +1,238 @@
+package org.apache.stratos.autoscaler.grouping.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.applications.*;
+import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.event.cluster.status.*;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.messaging.util.Constants;
+
+import java.util.Set;
+
+/**
+ * This will publish application related events to application status topic.
+ */
+public class ApplicationsEventPublisher {
+    private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class);
+
+
+    public static void sendGroupCreatedEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Created)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group created event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupCreatedEvent groupCreatedEvent =
+                            new GroupCreatedEvent(appId, groupId);
+
+                    publishEvent(groupCreatedEvent);
+                } else {
+                    log.warn("Created is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupActivatedEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group activated event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupActivatedEvent groupActivatedEvent =
+                            new GroupActivatedEvent(appId, groupId);
+
+                    publishEvent(groupActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupInActivateEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Inactive)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group in-activate event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
+                            AppStatusGroupInactivateEvent(appId, groupId);
+
+                    publishEvent(appStatusGroupInactivateEvent);
+                } else {
+                    log.warn("InActive is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupTerminatingEvent(String appId, String groupId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Terminating)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Group terminating event for [application]: " + appId +
+                                " [group]: " + groupId);
+                    }
+                    GroupTerminatingEvent groupInTerminatingEvent =
+                            new GroupTerminatingEvent(appId, groupId);
+                    publishEvent(groupInTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendGroupTerminatedEvent(String appId, String groupId) {
+
+        if (log.isInfoEnabled()) {
+            log.info("Publishing Group terminated event for [application]: " + appId +
+                    " [group]: " + groupId);
+        }
+
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                Group group = application.getGroupRecursively(groupId);
+                if (group.isStateTransitionValid(GroupStatus.Terminated)) {
+                    GroupTerminatedEvent groupInTerminatedEvent =
+                            new GroupTerminatedEvent(appId, groupId);
+                    publishEvent(groupInTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [group] " + groupId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+
+
+    }
+
+    public static void sendApplicationActivatedEvent(String appId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application activated event for [application]: " + appId);
+                    }
+                    ApplicationActivatedEvent applicationActivatedEvent =
+                            new ApplicationActivatedEvent(appId);
+
+                    publishEvent(applicationActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationInactivatedEvent(String appId) {
+        if (log.isInfoEnabled()) {
+            log.info("Publishing Application In-activated event for [application]: " + appId);
+        }
+
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
+                    ApplicationInactivatedEvent applicationInActivatedEvent =
+                            new ApplicationInactivatedEvent(appId);
+                    publishEvent(applicationInActivatedEvent);
+                } else {
+                    log.warn("Inactive is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationTerminatingEvent(String appId) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application terminated event for [application]: " + appId);
+                    }
+                    ApplicationTerminatingEvent applicationTerminatingEvent =
+                            new ApplicationTerminatingEvent(appId);
+                    publishEvent(applicationTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
+        try {
+            TopologyManager.acquireReadLockForApplication(appId);
+            Application application = TopologyManager.getTopology().getApplication(appId);
+            if (application != null) {
+                if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Application terminated event for [application]: " + appId);
+                    }
+                    ApplicationTerminatedEvent applicationTerminatedEvent =
+                            new ApplicationTerminatedEvent(appId, clusterData);
+                    publishEvent(applicationTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [application] " + appId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForApplication(appId);
+        }
+    }
+
+    public static void publishEvent(Event event) {
+        //publishing events to application status topic
+        EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATIONS_TOPIC);
+        eventPublisher.publish(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
new file mode 100644
index 0000000..2a05b2e
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.grouping.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.cluster.status.*;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.messaging.util.Constants;
+
+/**
+ * This will publish cluster status events to cluster-status topic
+ */
+public class ClusterStatusEventPublisher {
+    private static final Log log = LogFactory.getLog(ClusterStatusEventPublisher.class);
+
+
+    public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Created)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster created event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterCreatedEvent clusterCreatedEvent =
+                            new ClusterStatusClusterCreatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterCreatedEvent);
+                } else {
+                    log.warn("Created is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+        }
+    }
+
+    public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster activated event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterActivatedEvent clusterActivatedEvent =
+                            new ClusterStatusClusterActivatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterActivatedEvent);
+                } else {
+                    log.warn("Active is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+        }
+    }
+
+    public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster in-activate event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterInactivateEvent clusterInActivateEvent =
+                            new ClusterStatusClusterInactivateEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterInActivateEvent);
+                } else {
+                    log.warn("In-active is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+
+        }
+    }
+
+    public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
+
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster Terminating event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
+                            new ClusterStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+
+                    publishEvent(appStatusClusterTerminatingEvent);
+                } else {
+                    log.warn("Terminating is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+
+        }
+
+    }
+
+    public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster terminated event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
+                            new ClusterStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(appStatusClusterTerminatedEvent);
+                } else {
+                    log.warn("Terminated is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+
+        }
+    }
+
+
+    public static void publishEvent(Event event) {
+        //publishing events to application status topic
+        EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.CLUSTER_STATUS_TOPIC);
+        eventPublisher.publish(event);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
deleted file mode 100644
index c0e77de..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ /dev/null
@@ -1,361 +0,0 @@
-package org.apache.stratos.autoscaler.grouping.topic;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.applications.*;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-import org.apache.stratos.messaging.util.Constants;
-
-import java.util.Set;
-
-/**
- * This will publish application related events to application status topic.
- */
-public class StatusEventPublisher {
-    private static final Log log = LogFactory.getLog(StatusEventPublisher.class);
-
-    public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        try {
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            Service service = TopologyManager.getTopology().getService(serviceName);
-            if (service != null) {
-                Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Created)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster created event for [application]: " + appId +
-                                " [cluster]: " + clusterId);
-                    }
-                    AppClusterCreatedEvent clusterCreatedEvent =
-                            new AppClusterCreatedEvent(appId, serviceName, clusterId);
-
-                    publishEvent(clusterCreatedEvent);
-                } else {
-                    log.warn("Created is not in the possible state list of [cluster] " + clusterId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-        }
-    }
-
-    public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) {
-        try {
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            Service service = TopologyManager.getTopology().getService(serviceName);
-            if (service != null) {
-                Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster activated event for [application]: " + appId +
-                                " [cluster]: " + clusterId);
-                    }
-                    AppClusterActivatedEvent clusterActivatedEvent =
-                            new AppClusterActivatedEvent(appId, serviceName, clusterId);
-
-                    publishEvent(clusterActivatedEvent);
-                } else {
-                    log.warn("Active is not in the possible state list of [cluster] " + clusterId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-        }
-    }
-
-    public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) {
-        try {
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            Service service = TopologyManager.getTopology().getService(serviceName);
-            if (service != null) {
-                Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster in-activate event for [application]: " + appId +
-                                " [cluster]: " + clusterId);
-                    }
-                    AppClusterInactivateEvent clusterInActivateEvent =
-                            new AppClusterInactivateEvent(appId, serviceName, clusterId);
-
-                    publishEvent(clusterInActivateEvent);
-                } else {
-                    log.warn("In-active is not in the possible state list of [cluster] " + clusterId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-
-        }
-    }
-
-    public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
-
-        try {
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            Service service = TopologyManager.getTopology().getService(serviceName);
-            if (service != null) {
-                Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster Terminating event for [application]: " + appId +
-                                " [cluster]: " + clusterId);
-                    }
-                    AppClusterTerminatingEvent appStatusClusterTerminatingEvent =
-                            new AppClusterTerminatingEvent(appId, serviceName, clusterId);
-
-                    publishEvent(appStatusClusterTerminatingEvent);
-                } else {
-                    log.warn("Terminating is not in the possible state list of [cluster] " + clusterId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-
-        }
-
-    }
-
-    public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
-        try {
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            Service service = TopologyManager.getTopology().getService(serviceName);
-            if (service != null) {
-                Cluster cluster = service.getCluster(clusterId);
-                if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster terminated event for [application]: " + appId +
-                                " [cluster]: " + clusterId);
-                    }
-                    AppClusterTerminatedEvent appStatusClusterTerminatedEvent =
-                            new AppClusterTerminatedEvent(appId, serviceName, clusterId);
-
-                    publishEvent(appStatusClusterTerminatedEvent);
-                } else {
-                    log.warn("Terminated is not in the possible state list of [cluster] " + clusterId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-
-        }
-    }
-
-    public static void sendGroupCreatedEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Created)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group created event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupCreatedEvent groupCreatedEvent =
-                            new GroupCreatedEvent(appId, groupId);
-
-                    publishEvent(groupCreatedEvent);
-                } else {
-                    log.warn("Created is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupActivatedEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Active)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group activated event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupActivatedEvent groupActivatedEvent =
-                            new GroupActivatedEvent(appId, groupId);
-
-                    publishEvent(groupActivatedEvent);
-                } else {
-                    log.warn("Active is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupInActivateEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Inactive)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group in-activate event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
-                            AppStatusGroupInactivateEvent(appId, groupId);
-
-                    publishEvent(appStatusGroupInactivateEvent);
-                } else {
-                    log.warn("InActive is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupTerminatingEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Terminating)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group terminating event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupTerminatingEvent groupInTerminatingEvent =
-                            new GroupTerminatingEvent(appId, groupId);
-                    publishEvent(groupInTerminatingEvent);
-                } else {
-                    log.warn("Terminating is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupTerminatedEvent(String appId, String groupId) {
-
-        if (log.isInfoEnabled()) {
-            log.info("Publishing Group terminated event for [application]: " + appId +
-                    " [group]: " + groupId);
-        }
-
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Terminated)) {
-                    GroupTerminatedEvent groupInTerminatedEvent =
-                            new GroupTerminatedEvent(appId, groupId);
-                    publishEvent(groupInTerminatedEvent);
-                } else {
-                    log.warn("Terminated is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-
-
-    }
-
-    public static void sendApplicationActivatedEvent(String appId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Active)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application activated event for [application]: " + appId);
-                    }
-                    ApplicationActivatedEvent applicationActivatedEvent =
-                            new ApplicationActivatedEvent(appId);
-
-                    publishEvent(applicationActivatedEvent);
-                } else {
-                    log.warn("Active is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationInactivatedEvent(String appId) {
-        if (log.isInfoEnabled()) {
-            log.info("Publishing Application In-activated event for [application]: " + appId);
-        }
-
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
-                    ApplicationInactivatedEvent applicationInActivatedEvent =
-                            new ApplicationInactivatedEvent(appId);
-                    publishEvent(applicationInActivatedEvent);
-                } else {
-                    log.warn("Inactive is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationTerminatingEvent(String appId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application terminated event for [application]: " + appId);
-                    }
-                    ApplicationTerminatingEvent applicationTerminatingEvent =
-                            new ApplicationTerminatingEvent(appId);
-                    publishEvent(applicationTerminatingEvent);
-                } else {
-                    log.warn("Terminating is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application terminated event for [application]: " + appId);
-                    }
-                    ApplicationTerminatedEvent applicationTerminatedEvent =
-                            new ApplicationTerminatedEvent(appId, clusterData);
-                    publishEvent(applicationTerminatedEvent);
-                } else {
-                    log.warn("Terminated is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void publishEvent(Event event) {
-        //publishing events to application status topic
-        EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATION_STATUS_TOPIC);
-        eventPublisher.publish(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index 97ba3f1..aacc31c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -27,8 +27,9 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher;
-import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
@@ -119,7 +120,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
         });
 
 
-        topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
+        /*topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
                 try {
@@ -146,7 +147,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 }
 
             }
-        });
+        });*/
 
         topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() {
             @Override
@@ -252,7 +253,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
             }
         });
 
-        topologyEventReceiver.addEventListener(new GroupActivatedEventListener() {
+        /*topologyEventReceiver.addEventListener(new GroupActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
 
@@ -350,7 +351,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                     appMonitor.setStatus(ApplicationStatus.Active);
                 }
             }
-        });
+        });*/
 
         topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
             @Override
@@ -372,7 +373,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                                    ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId()));
                         if (clusterMonitor == null) {
                             // Cluster Monitor not found; send Cluster Terminated event to cleanup
-                            StatusEventPublisher.sendClusterTerminatedEvent(
+                            ClusterStatusEventPublisher.sendClusterTerminatedEvent(
                                     applicationUndeployedEvent.getApplicationId(),
                                     clusterDataHolder.getServiceType(),
                                     clusterDataHolder.getClusterId());
@@ -390,8 +391,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 } else {
                     // ApplicationMonitor is not found, send Terminating event to clean up
-                    StatusEventPublisher.sendApplicationTerminatedEvent(
-                                applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData());
+                    ApplicationsEventPublisher.sendApplicationTerminatedEvent(
+                            applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData());
                 }
 
 //                ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
@@ -481,7 +482,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
         });
 
 
-        topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+        /*topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
             @Override
             protected void onEvent(Event event) {
 
@@ -510,7 +511,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                             releaseReadLockForApplication(appTerminatingEvent.getAppId());
                 }
             }
-        });
+        });*/
 
 //        topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
 //            @Override
@@ -566,7 +567,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 //            }
 //        });
 
-        topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
+        /*topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
 
@@ -626,7 +627,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
             }
         });
-
+*/
         topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() {
             @Override
             protected void onEvent(Event event) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index c304027..c8f9d9c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -27,7 +27,8 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
 import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder;
 import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.applications.ParentComponent;
 
@@ -129,12 +130,12 @@ public abstract class ParentComponentMonitor extends Monitor {
             if (terminationList.size() ==
                     (this.aliasToActiveMonitorsMap.size() + this.aliasToInActiveMonitorsMap.size())) {
                 if (this.parent != null) {
-                    StatusEventPublisher.sendGroupTerminatingEvent(this.appId, this.id);
+                    ApplicationsEventPublisher.sendGroupTerminatingEvent(this.appId, this.id);
                 }
             } else {
                 //TODO application InActive
                 if (this.parent != null) {
-                    StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id);
+                    ApplicationsEventPublisher.sendGroupInActivateEvent(this.appId, this.id);
                 }
                 //Since it is reached the most independent unit and has few independent monitors,
                 // has to put the children down to terminating
@@ -149,10 +150,10 @@ public abstract class ParentComponentMonitor extends Monitor {
                         if (monitor != null) {
                             if (monitor.hasActiveMonitors()) {
                                 //it is a group
-                                StatusEventPublisher.sendGroupTerminatingEvent(this.appId,
+                                ApplicationsEventPublisher.sendGroupTerminatingEvent(this.appId,
                                         terminationContext.getId());
                             } else {
-                                StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+                                ClusterStatusEventPublisher.sendClusterTerminatingEvent(this.appId,
                                         ((AbstractClusterMonitor) monitor).getServiceId(),
                                         terminationContext.getId());
                             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 22b5e48..02c1b18 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -25,7 +25,8 @@ import org.apache.stratos.autoscaler.PartitionContext;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.TerminationException;
-import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
@@ -287,7 +288,7 @@ public class ClusterMonitor extends AbstractClusterMonitor {
         // send the ClusterTerminating event
         if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
                 ApplicationStatus.Terminating) {
-            StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId);
+            ClusterStatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/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 d48c7ae..5ee7f84 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
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.monitor.EventHandler;
 import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
 import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
@@ -104,7 +104,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
         // send the ClusterTerminating event
         if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
                 ApplicationStatus.Terminating) {
-            StatusEventPublisher.sendGroupTerminatingEvent(appId, id);
+            ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, id);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 408776f..629667a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -23,14 +23,14 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.NetworkPartitionContext;
 import org.apache.stratos.autoscaler.PartitionContext;
-import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
-import javax.net.ssl.SSLEngineResult;
 import java.util.Map;
 
 /**
@@ -71,7 +71,7 @@ public class StatusChecker {
                 if (clusterActive) {
                     //send event to cluster status topic
                     monitor.setHasFaultyMember(false);
-                    StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
+                    ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
                             monitor.getServiceId(), monitor.getClusterId());
                 }
             }
@@ -102,10 +102,10 @@ public class StatusChecker {
 
                                 if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
                                     if (application.getStatus() == ApplicationStatus.Terminating) {
-                                        StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
+                                        ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
                                                 monitor.getClusterId());
                                     } else {
-                                        StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
+                                        ClusterStatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
                                                 monitor.getClusterId());
                                     }
 
@@ -188,12 +188,12 @@ public class StatusChecker {
                         monitor.setHasFaultyMember(true);
                     }
                     //send cluster In-Active event to cluster status topic
-                    StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId);
+                    ClusterStatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId);
 
                 } else {
                     boolean clusterActive = clusterActive(monitor);
                     if (clusterActive) {
-                        StatusEventPublisher.sendClusterActivatedEvent(appId, monitor.getServiceId(), clusterId);
+                        ClusterStatusEventPublisher.sendClusterActivatedEvent(appId, monitor.getServiceId(), clusterId);
                     }
                 }
 
@@ -295,11 +295,11 @@ public class StatusChecker {
                     if (parent instanceof Application) {
                         //send application activated event
                         log.info("sending app activate: " + appId);
-                        StatusEventPublisher.sendApplicationActivatedEvent(appId);
+                        ApplicationsEventPublisher.sendApplicationActivatedEvent(appId);
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group activate: " + parent.getUniqueIdentifier());
-                        StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationsEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
                     }
                 } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
@@ -312,7 +312,7 @@ public class StatusChecker {
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group in-active: " + parent.getUniqueIdentifier());
-                        StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationsEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
                     }
                 } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
@@ -322,7 +322,7 @@ public class StatusChecker {
                         //validating the life cycle
                         if (application.getStatus().equals(ApplicationStatus.Terminating)) {
                             log.info("sending app terminated: " + appId);
-                            StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+                            ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
                         } else {
                             log.info("[Application] " + appId + " is in the [status] " +
                                     application.getStatus().toString() + ". Hence not sending terminated event");
@@ -331,7 +331,7 @@ public class StatusChecker {
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group created : " + parent.getUniqueIdentifier());
-                        StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
                     }
                 /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
                         clusterData.isEmpty() && groupStatus == GroupStatus.Terminating ||
@@ -352,7 +352,7 @@ public class StatusChecker {
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group created : " + parent.getUniqueIdentifier());
-                        StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
                     }
                 } else {
                     log.warn("Clusters/groups not found in this [component] " + appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index d83a7d3..fe97f99 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -23,17 +23,19 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.applications.*;
+import org.apache.stratos.messaging.event.cluster.status.*;
 import org.apache.stratos.messaging.listener.applications.*;
-import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver;
+import org.apache.stratos.messaging.listener.cluster.status.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver;
 
 public class ApplicationStatusTopicReceiver implements Runnable {
     private static final Log log = LogFactory.getLog(ApplicationStatusTopicReceiver.class);
 
-    private ApplicationStatusEventReceiver statusEventReceiver;
+    private ApplicationsEventReceiver statusEventReceiver;
     private boolean terminated;
 
     public ApplicationStatusTopicReceiver() {
-        this.statusEventReceiver = new ApplicationStatusEventReceiver();
+        this.statusEventReceiver = new ApplicationsEventReceiver();
         addEventListeners();
     }
 
@@ -64,124 +66,40 @@ public class ApplicationStatusTopicReceiver implements Runnable {
 
     private void addEventListeners() {
         // Listen to topology events that affect clusters
-        statusEventReceiver.addEventListener(new AppClusterCreatedEventListener() {
+        statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterCreated((AppClusterCreatedEvent) event);
+                TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppClusterActivatedEventListener() {
+        statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterActivatedEvent((AppClusterActivatedEvent) event);
+                TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppClusterTerminatedEventListener() {
+        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatedEvent((AppClusterTerminatedEvent) event);
+                TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppClusterTerminatingEventListener(){
+        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatingEvent((AppClusterTerminatingEvent) event);
+                TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent) event);
             }
         });
 
-        statusEventReceiver.addEventListener(new AppClusterInactivateEventListener() {
+        statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterInActivateEvent((AppClusterInactivateEvent) event);
+                TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent) event);
             }
         });
-
-
-        statusEventReceiver.addEventListener(new GroupCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupCreated((GroupCreatedEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new GroupActivatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new GroupTerminatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupTerminatedEvent((GroupTerminatedEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new GroupTerminatingEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupTerminatingEvent((GroupTerminatingEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new GroupInactivateEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() {
-
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ApplicationInactivatedEventListener() {
-
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event);
-
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event);
-
-            }
-        });
-
-
     }
 
     public void setTerminated(boolean terminated) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
index 5831948..222cc15 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
@@ -34,7 +34,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder;
 import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber;
-import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver;
 import org.apache.stratos.messaging.util.Constants;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/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 3bc7b5a..2941027 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
@@ -41,6 +41,7 @@ import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
 import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
 import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
 import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
+import org.apache.stratos.messaging.event.cluster.status.*;
 import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
@@ -124,7 +125,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterCreated (AppClusterCreatedEvent event) {
+    public static void handleClusterCreated (ClusterStatusClusterCreatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -722,7 +723,7 @@ public class TopologyBuilder {
     }
 
 
-    public static void handleClusterActivatedEvent(AppClusterActivatedEvent clusterActivatedEvent) {
+    public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) {
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(clusterActivatedEvent.getServiceName());
         //update the status of the cluster
@@ -760,7 +761,7 @@ public class TopologyBuilder {
     }
 
     public static void handleClusterInActivateEvent(
-            AppClusterInactivateEvent clusterInActivateEvent) {
+            ClusterStatusClusterInactivateEvent clusterInActivateEvent) {
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(clusterInActivateEvent.getServiceName());
         //update the status of the cluster
@@ -1148,7 +1149,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
     }
 
-    public static void handleClusterTerminatedEvent(AppClusterTerminatedEvent event) {
+    public static void handleClusterTerminatedEvent(ClusterStatusClusterTerminatedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -1175,7 +1176,7 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent);
     }
 
-    public static void handleClusterTerminatingEvent(AppClusterTerminatingEvent event) {
+    public static void handleClusterTerminatingEvent(ClusterStatusClusterTerminatingEvent event) {
 
         TopologyManager.acquireWriteLock();
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
index d6cc395..a085664 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
@@ -310,6 +310,7 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
         });
         
       //add listner to Complete Topology Event
+/*
         topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
@@ -367,8 +368,10 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
                 }
             }
         });
-        
+*/
+
         //add listener 
+/*
         topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
@@ -412,6 +415,7 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
                 }
             }
         });
+*/
     }
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
deleted file mode 100644
index 688b382..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppClusterActivatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppClusterActivatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
deleted file mode 100644
index 3382a34..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppClusterCreatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
deleted file mode 100644
index bf8926e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppClusterInactivateEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppClusterInactivateEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}


[35/50] [abbrv] git commit: updaing cluster status topic and refactoring

Posted by im...@apache.org.
updaing cluster status topic and refactoring


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

Branch: refs/heads/docker-grouping-merge
Commit: eb523d79e9e25539ab8448de7c3079e7e1e8f5d4
Parents: 746c37a
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 16:42:09 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 16:42:09 2014 +0530

----------------------------------------------------------------------
 .../applications/topic/ApplicationBuilder.java  |   7 --
 .../topic/ApplicationsEventPublisher.java       |   4 +-
 .../topic/ClusterStatusEventPublisher.java      |  28 ++++-
 .../status/checker/StatusChecker.java           |   2 +-
 .../ApplicationStatusTopicReceiver.java         | 113 -------------------
 .../receiver/ClusterStatusTopicReceiver.java    | 113 +++++++++++++++++++
 .../internal/CloudControllerDSComponent.java    |  13 ++-
 .../controller/topology/TopologyBuilder.java    |   8 +-
 .../event/applications/GroupCreatedEvent.java   |  48 --------
 .../event/applications/GroupResetEvent.java     |  48 ++++++++
 .../status/ClusterStatusClusterResetEvent.java  |  52 +++++++++
 .../ClusterStatusClusterResettedEvent.java      |  52 ---------
 .../applications/GroupCreatedEventListener.java |  24 ----
 .../applications/GroupResetEventListener.java   |  24 ++++
 .../ApplicationActivatedMessageProcessor.java   |   2 -
 .../ApplicationInactivatedMessageProcessor.java |   4 +-
 .../ApplicationTerminatedMessageProcessor.java  |   7 +-
 .../ApplicationTerminatingMessageProcessor.java |   4 +-
 .../ApplicationUndeployedMessageProcessor.java  |   5 +-
 .../ApplicationsMessageProcessorChain.java      |   6 +-
 .../CompleteApplicationsMessageProcessor.java   |   8 +-
 .../applications/GroupActivatedProcessor.java   |   4 +-
 .../applications/GroupCreatedProcessor.java     | 110 ------------------
 .../applications/GroupInActivateProcessor.java  |   2 -
 .../applications/GroupResetProcessor.java       | 108 ++++++++++++++++++
 .../applications/GroupTerminatedProcessor.java  |   4 +-
 .../applications/GroupTerminatingProcessor.java |   4 +-
 .../updater/ApplicationsUpdater.java            |  71 ++++++------
 ...terStatusClusterCreatedMessageProcessor.java |   1 -
 ...usterStatusClusterResetMessageProcessor.java |   8 +-
 .../topology/locking/TopologyLockingTest.java   |   4 +-
 31 files changed, 440 insertions(+), 448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index 5aa05a2..9d4db75 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -22,13 +22,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.messaging.domain.applications.*;
-import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
-import org.apache.stratos.messaging.event.topology.*;
 
 import java.util.Collection;
 import java.util.Set;

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index 0a0b261..bbeeca4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -34,8 +34,8 @@ public class ApplicationsEventPublisher {
                         log.info("Publishing Group created event for [application]: " + appId +
                                 " [group]: " + groupId);
                     }
-                    GroupCreatedEvent groupCreatedEvent =
-                            new GroupCreatedEvent(appId, groupId);
+                    GroupResetEvent groupCreatedEvent =
+                            new GroupResetEvent(appId, groupId);
 
                     publishEvent(groupCreatedEvent);
                 } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
index 9a43418..631a999 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java
@@ -48,8 +48,32 @@ public class ClusterStatusEventPublisher {
                         log.info("Publishing Cluster created event for [application]: " + appId +
                                 " [cluster]: " + clusterId);
                     }
-                    ClusterStatusClusterResettedEvent clusterCreatedEvent =
-                            new ClusterStatusClusterResettedEvent(appId, serviceName, clusterId);
+                    /*ClusterStatusClusterCreatedEvent clusterCreatedEvent =
+                            new ClusterStatusClusterCreatedEvent(appId, serviceName, clusterId);
+
+                    publishEvent(clusterCreatedEvent);*/
+                } else {
+                    log.warn("Created is not in the possible state list of [cluster] " + clusterId);
+                }
+            }
+        } finally {
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+        }
+    }
+
+    public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) {
+        try {
+            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+            Service service = TopologyManager.getTopology().getService(serviceName);
+            if (service != null) {
+                Cluster cluster = service.getCluster(clusterId);
+                if (cluster.isStateTransitionValid(ClusterStatus.Created)) {
+                    if (log.isInfoEnabled()) {
+                        log.info("Publishing Cluster created event for [application]: " + appId +
+                                " [cluster]: " + clusterId);
+                    }
+                    ClusterStatusClusterResetEvent clusterCreatedEvent =
+                            new ClusterStatusClusterResetEvent(appId, serviceName, clusterId);
 
                     publishEvent(clusterCreatedEvent);
                 } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 5468f6d..3586420 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -107,7 +107,7 @@ public class StatusChecker {
                                         ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
                                                 monitor.getClusterId());
                                     } else {
-                                        ClusterStatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(),
+                                        ClusterStatusEventPublisher.sendClusterResetEvent(appId, monitor.getServiceId(),
                                                 monitor.getClusterId());
                                     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
deleted file mode 100644
index 1fe14fd..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.application.status.receiver;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.cluster.status.*;
-import org.apache.stratos.messaging.listener.cluster.status.*;
-import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver;
-
-public class ApplicationStatusTopicReceiver implements Runnable {
-    private static final Log log = LogFactory.getLog(ApplicationStatusTopicReceiver.class);
-
-    private ApplicationsEventReceiver statusEventReceiver;
-    private boolean terminated;
-
-    public ApplicationStatusTopicReceiver() {
-        this.statusEventReceiver = new ApplicationsEventReceiver();
-        addEventListeners();
-    }
-
-    public void run() {
-        //FIXME this activated before autoscaler deployer activated.
-        try {
-            Thread.sleep(15000);
-        } catch (InterruptedException ignore) {
-        }
-        Thread thread = new Thread(statusEventReceiver);
-        thread.start();
-        if (log.isInfoEnabled()) {
-            log.info("Cloud controller application status thread started");
-        }
-
-        // Keep the thread live until terminated
-        while (!terminated) {
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException ignore) {
-            }
-        }
-        if (log.isInfoEnabled()) {
-            log.info("Cloud controller application status thread terminated");
-        }
-
-    }
-
-    private void addEventListeners() {
-        // Listen to topology events that affect clusters
-        statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent) event);
-            }
-        });
-
-        statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent) event);
-            }
-        });
-    }
-
-    public void setTerminated(boolean terminated) {
-        this.terminated = terminated;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java
new file mode 100644
index 0000000..4cc7599
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.cloud.controller.application.status.receiver;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.cluster.status.*;
+import org.apache.stratos.messaging.listener.cluster.status.*;
+import org.apache.stratos.messaging.message.receiver.cluster.status.ClusterStatusEventReceiver;
+
+public class ClusterStatusTopicReceiver implements Runnable {
+    private static final Log log = LogFactory.getLog(ClusterStatusTopicReceiver.class);
+
+    private ClusterStatusEventReceiver statusEventReceiver;
+    private boolean terminated;
+
+    public ClusterStatusTopicReceiver() {
+        this.statusEventReceiver = new ClusterStatusEventReceiver();
+        addEventListeners();
+    }
+
+    public void run() {
+        //FIXME this activated before autoscaler deployer activated.
+        try {
+            Thread.sleep(15000);
+        } catch (InterruptedException ignore) {
+        }
+        Thread thread = new Thread(statusEventReceiver);
+        thread.start();
+        if (log.isInfoEnabled()) {
+            log.info("Cloud controller application status thread started");
+        }
+
+        // Keep the thread live until terminated
+        while (!terminated) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+        }
+        if (log.isInfoEnabled()) {
+            log.info("Cloud controller application status thread terminated");
+        }
+
+    }
+
+    private void addEventListeners() {
+        // Listen to topology events that affect clusters
+        statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterReset((ClusterStatusClusterResetEvent) event);
+            }
+        });
+
+        statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event);
+            }
+        });
+
+        statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent) event);
+            }
+        });
+
+        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent) event);
+            }
+        });
+
+        statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent) event);
+            }
+        });
+
+        statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent) event);
+            }
+        });
+    }
+
+    public void setTerminated(boolean terminated) {
+        this.terminated = terminated;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
index 222cc15..8aa3d4f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
@@ -23,7 +23,7 @@ package org.apache.stratos.cloud.controller.internal;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.application.status.receiver.ApplicationStatusTopicReceiver;
+import org.apache.stratos.cloud.controller.application.status.receiver.ClusterStatusTopicReceiver;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl;
 import org.apache.stratos.cloud.controller.interfaces.CloudControllerService;
@@ -64,7 +64,7 @@ import org.wso2.carbon.utils.ConfigurationContextService;
 public class CloudControllerDSComponent {
 
     private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class);
-    private ApplicationStatusTopicReceiver applicationStatusTopicReceiver;
+    private ClusterStatusTopicReceiver clusterStatusTopicReceiver;
     protected void activate(ComponentContext context) {
         try {
                	
@@ -79,17 +79,18 @@ public class CloudControllerDSComponent {
             Thread tdelegator = new Thread(delegator);
             tdelegator.start();
 
-            applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver();
-            Thread appThread = new Thread(applicationStatusTopicReceiver);
+            clusterStatusTopicReceiver = new ClusterStatusTopicReceiver();
+            Thread appThread = new Thread(clusterStatusTopicReceiver);
             appThread.start();
             if (log.isDebugEnabled()) {
-                log.debug("Application status Receiver thread started");
+                log.debug("Cluster status Receiver thread started");
             }
 
         	
         	// Register cloud controller service
             BundleContext bundleContext = context.getBundleContext();
-            bundleContext.registerService(CloudControllerService.class.getName(), new CloudControllerServiceImpl(), null);
+            bundleContext.registerService(CloudControllerService.class.getName(),
+                    new CloudControllerServiceImpl(), null);
 
             if(log.isInfoEnabled()) {
                 log.info("Scheduling tasks");

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/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 e70d182..0ec8f01 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
@@ -27,14 +27,8 @@ import org.apache.stratos.cloud.controller.pojo.*;
 import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent;
 import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
 import org.apache.stratos.messaging.event.cluster.status.*;
 import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
@@ -154,7 +148,7 @@ public class TopologyBuilder {
     }
 
 
-    public static void handleClusterReset(ClusterStatusClusterResettedEvent event) {
+    public static void handleClusterReset(ClusterStatusClusterResetEvent event) {
 
         TopologyManager.acquireWriteLock();
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
deleted file mode 100644
index 77336d2..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-import org.apache.stratos.messaging.event.Event;
-
-import java.io.Serializable;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class GroupCreatedEvent extends Event implements Serializable {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private String groupId;
-    private String appId;
-
-    public GroupCreatedEvent(String appId, String groupId) {
-        this.appId = appId;
-        this.groupId = groupId;
-    }
-
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java
new file mode 100644
index 0000000..e0e7a91
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.applications;
+
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupResetEvent extends Event implements Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupResetEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId() {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java
new file mode 100644
index 0000000..eada57e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterResetEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterResetEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
deleted file mode 100644
index 68c8e7f..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.cluster.status;
-
-import org.apache.stratos.messaging.event.Event;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class ClusterStatusClusterResettedEvent extends Event {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public ClusterStatusClusterResettedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
deleted file mode 100644
index f13ed10..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class GroupCreatedEventListener extends EventListener {
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java
new file mode 100644
index 0000000..b4b67ed
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.applications;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class GroupResetEventListener extends EventListener {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
index da75265..0fd16b3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
@@ -23,11 +23,9 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
index e97e3fc..21a5906 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
@@ -23,11 +23,9 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**
@@ -78,7 +76,7 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (ApplicationInactivatedEvent event, Applications applications) {
+    private boolean doProcess(ApplicationInactivatedEvent event, Applications applications) {
 
         // Validate event against the existing applications
         Application application = applications.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
index 99d08fe..9ffe785 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
@@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
@@ -61,7 +60,7 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
                     jsonToObject(message, ApplicationTerminatedEvent.class);
 
             ApplicationsUpdater.acquireWriteLockForApplications();
-                        Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
+            Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
             if (clusterDataHolders != null) {
                 for (ClusterDataHolder clusterData : clusterDataHolders) {
                     TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
@@ -90,7 +89,7 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (ApplicationTerminatedEvent event, Applications applications) {
+    private boolean doProcess(ApplicationTerminatedEvent event, Applications applications) {
 
         // check if required properties are available
         if (event.getAppId() == null) {
@@ -99,7 +98,7 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
             throw new RuntimeException(errorMsg);
         }
 
-        if (event.getTenantDomain()== null) {
+        if (event.getTenantDomain() == null) {
             String errorMsg = "Application tenant domain of application removed event is invalid";
             log.error(errorMsg);
             throw new RuntimeException(errorMsg);

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
index 633e080..9b69182 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
@@ -23,11 +23,9 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**
@@ -78,7 +76,7 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (ApplicationTerminatingEvent event, Applications applications) {
+    private boolean doProcess(ApplicationTerminatingEvent event, Applications applications) {
 
         // Validate event against the existing applications
         Application application = applications.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
index e911b77..5bf0d9f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
@@ -25,7 +25,6 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
@@ -92,12 +91,12 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
                 return nextProcessor.process(type, message, applications);
             } else {
                 throw new RuntimeException(String.format
-                    ("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+                        ("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
 
-    private boolean doProcess (ApplicationUndeployedEvent event, Applications applications) {
+    private boolean doProcess(ApplicationUndeployedEvent event, Applications applications) {
 
         // update the application status to Terminating
         Application application = applications.getApplication(event.getApplicationId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
index e75b604..fb9858b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java
@@ -31,7 +31,7 @@ import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 public class ApplicationsMessageProcessorChain extends MessageProcessorChain {
     private static final Log log = LogFactory.getLog(ApplicationsMessageProcessorChain.class);
 
-    private GroupCreatedProcessor groupCreatedMessageProcessor;
+    private GroupResetProcessor groupCreatedMessageProcessor;
     private GroupActivatedProcessor groupActivatedMessageProcessor;
     private GroupInActivateProcessor groupInActivateMessageProcessor;
     private GroupTerminatedProcessor groupTerminatedProcessor;
@@ -46,7 +46,7 @@ public class ApplicationsMessageProcessorChain extends MessageProcessorChain {
     public void initialize() {
         // Add instance notifier event processors
 
-        groupCreatedMessageProcessor = new GroupCreatedProcessor();
+        groupCreatedMessageProcessor = new GroupResetProcessor();
         add(groupCreatedMessageProcessor);
 
         groupActivatedMessageProcessor = new GroupActivatedProcessor();
@@ -86,7 +86,7 @@ public class ApplicationsMessageProcessorChain extends MessageProcessorChain {
 
     public void addEventListener(EventListener eventListener) {
 
-        if(eventListener instanceof GroupCreatedEventListener) {
+        if (eventListener instanceof GroupResetEventListener) {
             groupCreatedMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof GroupInactivateEventListener) {
             groupInActivateMessageProcessor.addEventListener(eventListener);

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
index c9af67a..190188e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
@@ -44,7 +44,7 @@ public class CompleteApplicationsMessageProcessor extends MessageProcessor {
         Applications applications = (Applications) object;
 
         if (CompleteApplicationsEvent.class.getName().equals(type)) {
-        	// Parse complete message and build event
+            // Parse complete message and build event
             CompleteApplicationsEvent event = (CompleteApplicationsEvent) Util.
                     jsonToObject(message, CompleteApplicationsEvent.class);
 
@@ -72,14 +72,14 @@ public class CompleteApplicationsMessageProcessor extends MessageProcessor {
         }
     }
 
-    private void doProcess (CompleteApplicationsEvent event, Applications applications) {
-    // add existing Applications to Topology
+    private void doProcess(CompleteApplicationsEvent event, Applications applications) {
+        // add existing Applications to Topology
         Collection<Application> applicationsList = event.getApplications().getApplications().values();
         if (applicationsList != null && !applicationsList.isEmpty()) {
             for (Application application : applicationsList) {
                 applications.addApplication(application);
                 if (log.isDebugEnabled()) {
-                    log.debug("Application with id [ " +  application.getUniqueIdentifier() + " ] added to Topology");
+                    log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology");
                 }
             }
         } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
index 5c8d477..b73f703 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
@@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**
@@ -75,7 +73,7 @@ public class GroupActivatedProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (GroupActivatedEvent event, Applications applications) {
+    private boolean doProcess(GroupActivatedEvent event, Applications applications) {
 
         // Validate event against the existing topology
         Application application = applications.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
deleted file mode 100644
index 67861e4..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * This processor will act upon the Group activation events
- */
-public class GroupCreatedProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        Applications applications = (Applications) object;
-
-        if (GroupCreatedEvent.class.getName().equals(type)) {
-            // Return if applications has not been initialized
-            if (!applications.isInitialized())
-                return false;
-
-            // Parse complete message and build event
-            GroupCreatedEvent event = (GroupCreatedEvent) Util.
-                    jsonToObject(message, GroupCreatedEvent.class);
-
-            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
-
-            try {
-                return doProcess(event, applications);
-
-            } finally {
-                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, message, applications);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-
-    private boolean doProcess (GroupCreatedEvent event,Applications applications) {
-
-        // Validate event against the existing applications
-        Application application = applications.getApplication(event.getAppId());
-        if (application == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Application does not exist: [service] %s",
-                        event.getAppId()));
-            }
-            return false;
-        }
-        Group group = application.getGroupRecursively(event.getGroupId());
-
-        if (group == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
-                        event.getGroupId()));
-            }
-        } else {
-            // Apply changes to the applications
-            if (!group.isStateTransitionValid(GroupStatus.Created)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created  + " " +
-                        "for Group " + group.getAlias());
-            }
-            group.setStatus(GroupStatus.Created);
-
-        }
-
-        // Notify event listeners
-        notifyEventListeners(event);
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
index 4f2e581..5df4a62 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
@@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java
new file mode 100644
index 0000000..5c50e0b
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import org.apache.stratos.messaging.event.applications.GroupResetEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * This processor will act upon the Group activation events
+ */
+public class GroupResetProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(GroupResetProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        Applications applications = (Applications) object;
+
+        if (GroupResetEvent.class.getName().equals(type)) {
+            // Return if applications has not been initialized
+            if (!applications.isInitialized())
+                return false;
+
+            // Parse complete message and build event
+            GroupResetEvent event = (GroupResetEvent) Util.
+                    jsonToObject(message, GroupResetEvent.class);
+
+            ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, applications);
+
+            } finally {
+                ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
+            }
+
+        } else {
+            if (nextProcessor != null) {
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, applications);
+            } else {
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+
+    private boolean doProcess(GroupResetEvent event, Applications applications) {
+
+        // Validate event against the existing applications
+        Application application = applications.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        }
+        Group group = application.getGroupRecursively(event.getGroupId());
+
+        if (group == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(),
+                        event.getGroupId()));
+            }
+        } else {
+            // Apply changes to the applications
+            if (!group.isStateTransitionValid(GroupStatus.Created)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " +
+                        "for Group " + group.getAlias());
+            }
+            group.setStatus(GroupStatus.Created);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
index 6e985b7..f03c21e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
@@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**
@@ -75,7 +73,7 @@ public class GroupTerminatedProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (GroupTerminatedEvent event, Applications applications) {
+    private boolean doProcess(GroupTerminatedEvent event, Applications applications) {
 
         // Validate event against the existing applications
         Application application = applications.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
index c9a136f..ccc7b8f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
@@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.Group;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
 /**
@@ -75,7 +73,7 @@ public class GroupTerminatingProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (GroupTerminatingEvent event,Applications applications) {
+    private boolean doProcess(GroupTerminatingEvent event, Applications applications) {
 
         // Validate event against the existing applications
         Application application = applications.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
index e987abf..5a45ff0 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
@@ -24,36 +24,35 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
 import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
 import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
 /**
  * Used to lock the Topology for writes by messaging component
- *
- *  Acquire a write lock:
- *
- *  From root level, acquire read lock, and acquire a write lock only for the
- *  relevant sub tree.
- *
- *  Example 1: Acquiring write lock for a Cluster to modify the Cluster object -
- *           acquiring:
- *           public static void acquireWriteLockForCluster (String serviceName, String clusterId)
- *
- *           releasing:
- *           public static void releaseWriteLockForCluster (String serviceName, String clusterId)
- *
- *  Example 2: Acquiring write lock to add a new Cluster object -
- *           acquiring:
- *           public static void acquireWriteLockForService (String serviceName)
- *
- *           releasing:
- *           public static void releaseWriteLockForService (String serviceName)
- *
- *  Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service)
- *           acquire:
- *           public static void acquireWriteLockForServices()
- *
- *           release:
- *           public static void releaseWriteLockForServices()
+ * <p/>
+ * Acquire a write lock:
+ * <p/>
+ * From root level, acquire read lock, and acquire a write lock only for the
+ * relevant sub tree.
+ * <p/>
+ * Example 1: Acquiring write lock for a Cluster to modify the Cluster object -
+ * acquiring:
+ * public static void acquireWriteLockForCluster (String serviceName, String clusterId)
+ * <p/>
+ * releasing:
+ * public static void releaseWriteLockForCluster (String serviceName, String clusterId)
+ * <p/>
+ * Example 2: Acquiring write lock to add a new Cluster object -
+ * acquiring:
+ * public static void acquireWriteLockForService (String serviceName)
+ * <p/>
+ * releasing:
+ * public static void releaseWriteLockForService (String serviceName)
+ * <p/>
+ * Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service)
+ * acquire:
+ * public static void acquireWriteLockForServices()
+ * <p/>
+ * release:
+ * public static void releaseWriteLockForServices()
  */
 
 public class ApplicationsUpdater {
@@ -69,7 +68,7 @@ public class ApplicationsUpdater {
      * Acquires write lock for all Applications
      */
     public static void acquireWriteLockForApplications() {
-        if(log.isDebugEnabled()) {
+        if (log.isDebugEnabled()) {
             log.debug("Write lock acquired for Applications");
         }
         applicationLockHierarchy.getApplicationLock().acquireWriteLock();
@@ -79,7 +78,7 @@ public class ApplicationsUpdater {
      * Releases write lock for all Applications
      */
     public static void releaseWriteLockForApplications() {
-        if(log.isDebugEnabled()) {
+        if (log.isDebugEnabled()) {
             log.debug("Write lock released for Applications");
         }
         applicationLockHierarchy.getApplicationLock().releaseWritelock();
@@ -90,19 +89,19 @@ public class ApplicationsUpdater {
      *
      * @param appId Application id
      */
-    public static void acquireWriteLockForApplication (String appId) {
+    public static void acquireWriteLockForApplication(String appId) {
 
         // acquire read lock for all Applications
         ApplicationManager.acquireReadLockForApplications();
 
         ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
-        if (applicationLock == null)  {
+        if (applicationLock == null) {
             handleLockNotFound("Topology lock not found for Application " + appId);
 
         } else {
             // now, lock Application
             applicationLock.acquireWriteLock();
-            if(log.isDebugEnabled()) {
+            if (log.isDebugEnabled()) {
                 log.debug("Write lock acquired for Application " + appId);
             }
         }
@@ -113,16 +112,16 @@ public class ApplicationsUpdater {
      *
      * @param appId Application id
      */
-    public static void releaseWriteLockForApplication (String appId) {
+    public static void releaseWriteLockForApplication(String appId) {
 
         ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
-        if (applicationLock == null)  {
+        if (applicationLock == null) {
             handleLockNotFound("Topology lock not found for Application " + appId);
 
         } else {
             // release App lock
             applicationLock.releaseWritelock();
-            if(log.isDebugEnabled()) {
+            if (log.isDebugEnabled()) {
                 log.debug("Write lock released for Application " + appId);
             }
         }
@@ -131,7 +130,7 @@ public class ApplicationsUpdater {
         ApplicationManager.releaseReadLockForApplications();
     }
 
-    private static void handleLockNotFound (String errorMsg) {
+    private static void handleLockNotFound(String errorMsg) {
         log.warn(errorMsg);
         //throw new RuntimeException(errorMsg);
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
index d6bdcd7..cae1e1b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
@@ -21,7 +21,6 @@ package org.apache.stratos.messaging.message.processor.cluster.status;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent;
-import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.util.Util;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
index 75bc007..668493e 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
@@ -20,7 +20,7 @@ package org.apache.stratos.messaging.message.processor.cluster.status;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResetEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.util.Util;
 
@@ -36,10 +36,10 @@ public class ClusterStatusClusterResetMessageProcessor extends MessageProcessor
 
     @Override
     public boolean process(String type, String message, Object object) {
-        if (ClusterStatusClusterResettedEvent.class.getName().equals(type)) {
+        if (ClusterStatusClusterResetEvent.class.getName().equals(type)) {
             // Parse complete message and build event
-            ClusterStatusClusterResettedEvent event = (ClusterStatusClusterResettedEvent) Util.
-                    jsonToObject(message, ClusterStatusClusterResettedEvent.class);
+            ClusterStatusClusterResetEvent event = (ClusterStatusClusterResetEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterResetEvent.class);
 
             if(log.isDebugEnabled()) {
                 log.debug("Received ClusterStatusClusterResettedEvent: " + event.toString());

http://git-wip-us.apache.org/repos/asf/stratos/blob/eb523d79/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
index b9b8e03..6363307 100644
--- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
+++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java
@@ -33,7 +33,7 @@ public class TopologyLockingTest {
 
     private static Topology topology;
 
-    @BeforeClass
+    /*@BeforeClass
     public static void setUpBeforeClass() {
         System.out.println("Setting up TopologyLockingTest");
         topology = TopologyManager.getTopology();
@@ -206,5 +206,5 @@ public class TopologyLockingTest {
     public static void tearDownAfterClass() {
         System.out.println("Cleaning up TopologyLockingTest");
         topology = null;
-    }
+    }*/
 }


[25/50] [abbrv] adding application builder

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
deleted file mode 100644
index 3197fb9..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency.context;
-
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * This is to keep track of the
- */
-public abstract class ApplicationContext {
-    private List<ApplicationContext> applicationContextList;
-
-    private String id;
-    protected boolean started;
-    private boolean terminated;
-
-    private ClusterStatus status;
-
-    private Stack<ClusterStatus> statusLifeCycle;
-
-    protected boolean isDependent;
-
-    public ApplicationContext(String id, boolean killDependent) {
-        applicationContextList = new ArrayList<ApplicationContext>();
-        statusLifeCycle = new Stack<ClusterStatus>();
-        this.setDependent(killDependent);
-        this.id = id;
-    }
-
-    public List<ApplicationContext> getApplicationContextList() {
-        return applicationContextList;
-    }
-
-    public void setApplicationContextList(List<ApplicationContext> applicationContextList) {
-        this.applicationContextList = applicationContextList;
-    }
-
-    public void addApplicationContext(ApplicationContext applicationContext) {
-        applicationContextList.add(applicationContext);
-
-    }
-
-    public void addStatusToLIfeCycle(ClusterStatus status) {
-       this.statusLifeCycle.push(status);
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public ClusterStatus getCurrentStatus() {
-        return status;
-    }
-
-    public void setCurrentStatus(ClusterStatus status) {
-        this.status = status;
-    }
-
-    public List<ClusterStatus> getStatusLifeCycle() {
-        return statusLifeCycle;
-    }
-
-    public boolean hasChild() {
-        boolean hasChild;
-        if(this.applicationContextList.isEmpty()) {
-            hasChild = false;
-        } else {
-            hasChild = true;
-        }
-        return hasChild;
-    }
-
-
-    public boolean isTerminated() {
-        return terminated;
-    }
-
-    public void setTerminated(boolean terminated) {
-        this.terminated = terminated;
-    }
-
-    public boolean isDependent() {
-        return isDependent;
-    }
-
-    public void setDependent(boolean isDependent) {
-        this.isDependent = isDependent;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
deleted file mode 100644
index 3ea4cd5..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency.context;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.Constants;
-import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.applications.ParentComponent;
-
-/**
- * Factory to create new GroupContext or ClusterContext
- */
-public class ApplicationContextFactory {
-    private static final Log log = LogFactory.getLog(ApplicationContextFactory.class);
-
-    /**
-     * Will return the GroupContext/ClusterContext based on the type in start order
-     *
-     * @param startOrder      reference of group/cluster in the start order
-     * @param component       The component which used to build the dependency
-     * @param tree kill dependent behaviour of this component
-     * @return Context
-     */
-    public static ApplicationContext getApplicationContext(String startOrder,
-                                                           ParentComponent component,
-                                                           DependencyTree tree) {
-        String id;
-        ApplicationContext applicationContext = null;
-        boolean isDependent = tree.isKillDependent() || tree.isKillAll();
-        if (startOrder.startsWith(Constants.GROUP + ".")) {
-            //getting the group alias
-            id = getGroupFromStartupOrder(startOrder);
-            applicationContext = getGroupContext(id, isDependent);
-        } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) {
-            //getting the cluster alias
-            id = getClusterFromStartupOrder(startOrder);
-            //getting the cluster-id from cluster alias
-            ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id);
-            applicationContext = getClusterContext(clusterDataHolder, isDependent);
-
-        } else {
-            log.warn("[Startup Order]: " + startOrder + " contains unknown reference");
-        }
-        return applicationContext;
-
-    }
-
-    /**
-     * Utility method to get the group alias from the startup order Eg: group.mygroup
-     *
-     * @param startupOrder startup order
-     * @return group alias
-     */
-    public static String getGroupFromStartupOrder(String startupOrder) {
-        return startupOrder.substring(Constants.GROUP.length() + 1);
-    }
-
-    /**
-     * Utility method to get the cluster alias from startup order Eg: cartridge.myphp
-     *
-     * @param startupOrder startup order
-     * @return cluster alias
-     */
-    public static String getClusterFromStartupOrder(String startupOrder) {
-        return startupOrder.substring(Constants.CARTRIDGE.length() + 1);
-    }
-
-    public static ApplicationContext getClusterContext(ClusterDataHolder dataHolder,
-                                                       boolean isKillDependent) {
-        ApplicationContext applicationContext;
-        applicationContext = new ClusterContext(dataHolder.getClusterId(),
-                isKillDependent);
-        ((ClusterContext) applicationContext).setServiceName(dataHolder.getServiceType());
-        return  applicationContext;
-    }
-
-    public static ApplicationContext getGroupContext(String id, boolean isDependent) {
-        ApplicationContext applicationContext;
-        applicationContext = new GroupContext(id,
-                isDependent);
-        return applicationContext;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java
deleted file mode 100644
index d11389d..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency.context;
-
-/**
- * ClusterContext to keep cluster level context information
- */
-public class ClusterContext extends ApplicationContext {
-    private String serviceName;
-
-    public ClusterContext(String id, boolean killDependent) {
-        super(id ,killDependent);
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
deleted file mode 100644
index 408272a..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.grouping.dependency.context;
-
-public class GroupContext extends ApplicationContext {
-    public GroupContext(String id, boolean killDependent) {
-        super(id ,killDependent);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
deleted file mode 100644
index 1fbc143..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java
+++ /dev/null
@@ -1,238 +0,0 @@
-package org.apache.stratos.autoscaler.grouping.topic;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.applications.*;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.event.cluster.status.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-import org.apache.stratos.messaging.util.Constants;
-
-import java.util.Set;
-
-/**
- * This will publish application related events to application status topic.
- */
-public class ApplicationsEventPublisher {
-    private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class);
-
-
-    public static void sendGroupCreatedEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Created)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group created event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupCreatedEvent groupCreatedEvent =
-                            new GroupCreatedEvent(appId, groupId);
-
-                    publishEvent(groupCreatedEvent);
-                } else {
-                    log.warn("Created is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupActivatedEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Active)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group activated event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupActivatedEvent groupActivatedEvent =
-                            new GroupActivatedEvent(appId, groupId);
-
-                    publishEvent(groupActivatedEvent);
-                } else {
-                    log.warn("Active is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupInActivateEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Inactive)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group in-activate event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
-                            AppStatusGroupInactivateEvent(appId, groupId);
-
-                    publishEvent(appStatusGroupInactivateEvent);
-                } else {
-                    log.warn("InActive is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupTerminatingEvent(String appId, String groupId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Terminating)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Group terminating event for [application]: " + appId +
-                                " [group]: " + groupId);
-                    }
-                    GroupTerminatingEvent groupInTerminatingEvent =
-                            new GroupTerminatingEvent(appId, groupId);
-                    publishEvent(groupInTerminatingEvent);
-                } else {
-                    log.warn("Terminating is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendGroupTerminatedEvent(String appId, String groupId) {
-
-        if (log.isInfoEnabled()) {
-            log.info("Publishing Group terminated event for [application]: " + appId +
-                    " [group]: " + groupId);
-        }
-
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                Group group = application.getGroupRecursively(groupId);
-                if (group.isStateTransitionValid(GroupStatus.Terminated)) {
-                    GroupTerminatedEvent groupInTerminatedEvent =
-                            new GroupTerminatedEvent(appId, groupId);
-                    publishEvent(groupInTerminatedEvent);
-                } else {
-                    log.warn("Terminated is not in the possible state list of [group] " + groupId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-
-
-    }
-
-    public static void sendApplicationActivatedEvent(String appId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Active)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application activated event for [application]: " + appId);
-                    }
-                    ApplicationActivatedEvent applicationActivatedEvent =
-                            new ApplicationActivatedEvent(appId);
-
-                    publishEvent(applicationActivatedEvent);
-                } else {
-                    log.warn("Active is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationInactivatedEvent(String appId) {
-        if (log.isInfoEnabled()) {
-            log.info("Publishing Application In-activated event for [application]: " + appId);
-        }
-
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
-                    ApplicationInactivatedEvent applicationInActivatedEvent =
-                            new ApplicationInactivatedEvent(appId);
-                    publishEvent(applicationInActivatedEvent);
-                } else {
-                    log.warn("Inactive is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationTerminatingEvent(String appId) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application terminated event for [application]: " + appId);
-                    }
-                    ApplicationTerminatingEvent applicationTerminatingEvent =
-                            new ApplicationTerminatingEvent(appId);
-                    publishEvent(applicationTerminatingEvent);
-                } else {
-                    log.warn("Terminating is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
-        try {
-            TopologyManager.acquireReadLockForApplication(appId);
-            Application application = TopologyManager.getTopology().getApplication(appId);
-            if (application != null) {
-                if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Application terminated event for [application]: " + appId);
-                    }
-                    ApplicationTerminatedEvent applicationTerminatedEvent =
-                            new ApplicationTerminatedEvent(appId, clusterData);
-                    publishEvent(applicationTerminatedEvent);
-                } else {
-                    log.warn("Terminated is not in the possible state list of [application] " + appId);
-                }
-            }
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-    }
-
-    public static void publishEvent(Event event) {
-        //publishing events to application status topic
-        EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATIONS_TOPIC);
-        eventPublisher.publish(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index 4678250..18929ed 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -27,21 +27,19 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
-import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.event.topology.*;

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index debcf93..1e64d78 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -30,9 +30,9 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.exception.PolicyValidationException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext;
-import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index c8f9d9c..5938077 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -24,10 +24,10 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.exception.PolicyValidationException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder;
-import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.applications.dependency.DependencyBuilder;
+import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.applications.ParentComponent;

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 02c1b18..560300c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -25,7 +25,6 @@ import org.apache.stratos.autoscaler.PartitionContext;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.TerminationException;
-import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/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 5ee7f84..1648402 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
@@ -20,9 +20,10 @@ package org.apache.stratos.autoscaler.monitor.group;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.monitor.EventHandler;
 import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
 import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
@@ -104,7 +105,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
         // send the ClusterTerminating event
         if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
                 ApplicationStatus.Terminating) {
-            ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, id);
+            ApplicationBuilder.handleGroupTerminatingEvent(appId, id);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 629667a..eafa269 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -23,7 +23,8 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.NetworkPartitionContext;
 import org.apache.stratos.autoscaler.PartitionContext;
-import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
 import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
@@ -288,41 +289,30 @@ public class StatusChecker {
                 TopologyManager.acquireReadLockForApplication(appId);
                 Application application = TopologyManager.getTopology().getApplication(appId);
 
-                if (groups.isEmpty() && getClusterAllInSameState(clusterData,ClusterStatus.Active) ||
-                        clusterData.isEmpty() && groupStatus == GroupStatus.Active ||
-                        groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) {
+                if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) ||
+                        clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) ||
+                        getAllClusterInSameState(clusterData,ClusterStatus.Active) &&
+                                getAllGroupInSameState(groups, GroupStatus.Active)) {
                     //send activation event
                     if (parent instanceof Application) {
                         //send application activated event
                         log.info("sending app activate: " + appId);
-                        ApplicationsEventPublisher.sendApplicationActivatedEvent(appId);
+                        ApplicationBuilder.handleApplicationActivatedEvent(appId);
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group activate: " + parent.getUniqueIdentifier());
-                        ApplicationsEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationBuilder.handleGroupActivatedEvent(appId, parent.getUniqueIdentifier());
                     }
-                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
-                        clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
-                        groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
-                    //send the in activation event
-                    if (parent instanceof Application) {
-                        //send application activated event
-                        log.warn("Application can't be in in-active : " + appId);
-                        //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
-                    } else if (parent instanceof Group) {
-                        //send activation to the parent
-                        log.info("sending group in-active: " + parent.getUniqueIdentifier());
-                        ApplicationsEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
-                    }
-                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
-                        clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
-                        groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
+                } else if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Terminated) ||
+                        clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Terminated) ||
+                        getAllClusterInSameState(clusterData, ClusterStatus.Terminated) &&
+                                getAllGroupInSameState(groups, GroupStatus.Terminated)) {
                     //send the terminated event
                     if (parent instanceof Application) {
                         //validating the life cycle
                         if (application.getStatus().equals(ApplicationStatus.Terminating)) {
                             log.info("sending app terminated: " + appId);
-                            ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+                            ApplicationBuilder.handleApplicationTerminatedEvent(appId);
                         } else {
                             log.info("[Application] " + appId + " is in the [status] " +
                                     application.getStatus().toString() + ". Hence not sending terminated event");
@@ -331,28 +321,32 @@ public class StatusChecker {
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group created : " + parent.getUniqueIdentifier());
-                        ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationBuilder.handleGroupTerminatedEvent(appId, parent.getUniqueIdentifier());
                     }
-                /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating ||
-                        clusterData.isEmpty() && groupStatus == GroupStatus.Terminating ||
-                        groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) {
-                    if (parent instanceof Application) {
-                        log.info("Application can't be in terminating: " + appId);
-                    } else if (parent instanceof Group) {
-                        //send activation to the parent
-                        log.info("sending group terminating : " + parent.getUniqueIdentifier());
-                        StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
-                    }*/
-                } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created ||
-                        clusterData.isEmpty() && groupStatus == GroupStatus.Created ||
-                        groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) {
+                } else if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Created) ||
+                        clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Created) ||
+                        getAllClusterInSameState(clusterData,ClusterStatus.Created) &&
+                                getAllGroupInSameState(groups, GroupStatus.Created)) {
                     if (parent instanceof Application) {
                         log.info("[Application] " + appId + "couldn't change to Created, since it is" +
                                 "already in " + application.getStatus().toString());
                     } else if (parent instanceof Group) {
                         //send activation to the parent
                         log.info("sending group created : " + parent.getUniqueIdentifier());
-                        ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                        ApplicationBuilder.handleGroupCreatedEvent(appId, parent.getUniqueIdentifier());
+                    }
+                } else if (groups.isEmpty() && getAllClusterInActive(clusterData) ||
+                        clusterData.isEmpty() && getAllGroupInActive(groups) ||
+                        getAllClusterInActive(clusterData) && getAllGroupInActive(groups)) {
+                    //send the in activation event
+                    if (parent instanceof Application) {
+                        //send application activated event
+                        log.warn("Application can't be in in-active : " + appId);
+                        //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
+                    } else if (parent instanceof Group) {
+                        //send activation to the parent
+                        log.info("sending group in-active: " + parent.getUniqueIdentifier());
+                        ApplicationBuilder.handleGroupInActivateEvent(appId, parent.getUniqueIdentifier());
                     }
                 } else {
                     log.warn("Clusters/groups not found in this [component] " + appId);
@@ -370,7 +364,7 @@ public class StatusChecker {
         return childFound;
     }
 
-    private boolean getGroupInActive(Map<String, Group> groups) {
+    private boolean getAllGroupInActive(Map<String, Group> groups) {
         boolean groupStat = false;
         for (Group group : groups.values()) {
             if (group.getStatus() == GroupStatus.Inactive) {
@@ -383,7 +377,7 @@ public class StatusChecker {
         return groupStat;
     }
 
-    private boolean allGroupInSameState(Map<String, Group> groups, GroupStatus status) {
+    private boolean getAllGroupInSameState(Map<String, Group> groups, GroupStatus status) {
         boolean groupStat = false;
         for (Group group : groups.values()) {
             if (group.getStatus() == status) {
@@ -397,7 +391,7 @@ public class StatusChecker {
     }
 
 
-    private boolean getClusterInActive(Map<String, ClusterDataHolder> clusterData) {
+    private boolean getAllClusterInActive(Map<String, ClusterDataHolder> clusterData) {
         boolean clusterStat = false;
         for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
             Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType());
@@ -413,7 +407,7 @@ public class StatusChecker {
         return clusterStat;
     }
 
-    private boolean getClusterAllInSameState(Map<String, ClusterDataHolder> clusterData,
+    private boolean getAllClusterInSameState(Map<String, ClusterDataHolder> clusterData,
                                              ClusterStatus status) {
         boolean clusterStat = false;
         for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 0c27316..ca2cc1e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -1403,16 +1403,16 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                     applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster()));
         }
 
-        TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
+        /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
                 applicationParser.getPayloadData());
-
+*/
         persist();
     }
 
     @Override
     public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
 
-        TopologyBuilder.handleApplicationUndeployed(applicationId);
+        //TopologyBuilder.handleApplicationUndeployed(applicationId);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/686d0e06/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 dcbeb48..7ee342e 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
@@ -22,23 +22,17 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
 import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
-import org.apache.stratos.cloud.controller.pojo.*;
 import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
+import org.apache.stratos.cloud.controller.pojo.*;
 import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher;
-import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
-import org.apache.stratos.messaging.domain.applications.*;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Group;
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent;
 import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.applications.GroupActivatedEvent;
-import org.apache.stratos.messaging.event.applications.GroupCreatedEvent;
 import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent;
 import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent;
 import org.apache.stratos.messaging.event.cluster.status.*;
@@ -49,9 +43,9 @@ import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
 import org.apache.stratos.messaging.event.topology.*;
 import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient;
 import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import java.util.*;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 /**
@@ -69,7 +63,7 @@ public class TopologyBuilder {
             log.warn(String.format("Cartridge list is empty"));
             return;
         }
-        
+
         try {
 
             TopologyManager.acquireWriteLock();
@@ -104,7 +98,7 @@ public class TopologyBuilder {
     public static void handleServiceRemoved(List<Cartridge> cartridgeList) {
         Topology topology = TopologyManager.getTopology();
 
-        for (Cartridge cartridge : cartridgeList) { 
+        for (Cartridge cartridge : cartridgeList) {
             if (topology.getService(cartridge.getType()).getClusters().size() == 0) {
                 if (topology.serviceExists(cartridge.getType())) {
                     try {
@@ -125,7 +119,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterCreated (ClusterStatusClusterResettedEvent event) {
+    public static void handleClusterCreated(ClusterStatusClusterResettedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -146,9 +140,9 @@ public class TopologyBuilder {
             }
 
             // update the cluster status to Created
-            if (!cluster.isStateTransitionValid(ClusterStatus.Created))  {
-                 log.error("Invalid state transition from " + cluster.getStatus() + " to " +
-                         ClusterStatus.Created + " for cluster id " + event.getClusterId());
+            if (!cluster.isStateTransitionValid(ClusterStatus.Created)) {
+                log.error("Invalid state transition from " + cluster.getStatus() + " to " +
+                        ClusterStatus.Created + " for cluster id " + event.getClusterId());
             }
             // forcefully update the status
             cluster.setStatus(ClusterStatus.Created);
@@ -162,42 +156,6 @@ public class TopologyBuilder {
                 event.getClusterId());
     }
 
-    public static void handleGroupCreated (GroupCreatedEvent event) {
-
-        TopologyManager.acquireWriteLock();
-
-        try {
-            Topology topology = TopologyManager.getTopology();
-
-            Application application = topology.getApplication(event.getAppId());
-            if (application == null) {
-                log.error("Application " + event.getAppId() +
-                        " not found in Topology, unable to update the Group status to Created");
-                return;
-            }
-
-            Group group = application.getGroupRecursively(event.getGroupId());
-            if (group == null) {
-                log.error("Group " + event.getGroupId() +
-                        " not found in Topology, unable to update the Group status to Created");
-                return;
-            }
-
-            // update the cluster status to Created
-            if (!group.isStateTransitionValid(GroupStatus.Created))  {
-                log.error("Invalid state transition from " + group.getStatus() + " to " +
-                        GroupStatus.Created + " for group " + event.getGroupId());
-            }
-            // forcefully update the status
-            group.setStatus(GroupStatus.Created);
-            TopologyManager.updateTopology(topology);
-
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-
-        TopologyEventPublisher.sendGroupCreatedEvent(new org.apache.stratos.messaging.event.topology.GroupCreatedEvent(event.getAppId(), event.getGroupId()));
-    }
 
     public static void handleClusterCreated(Registrant registrant, boolean isLb) {
         /*Topology topology = TopologyManager.getTopology();
@@ -478,7 +436,7 @@ public class TopologyBuilder {
             return;
         }
 
-        
+
         Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId());
         if (member == null) {
             log.warn(String.format("Member %s does not exist",
@@ -612,117 +570,6 @@ public class TopologyBuilder {
         }
     }
 
-    public static synchronized void handleApplicationDeployed(Application application,
-                                                 Set<ApplicationClusterContext> applicationClusterContexts,
-                                                 Set<MetaDataHolder> metaDataHolders) {
-
-
-        Topology topology = TopologyManager.getTopology();
-        try {
-            TopologyManager.acquireWriteLock();
-
-            if (topology.applicationExists(application.getUniqueIdentifier())) {
-                log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology");
-                return;
-            }
-            List<Cluster> clusters = new ArrayList<Cluster>();
-            for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) {
-                Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(),
-                        applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(),
-                        applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier());
-                //cluster.setStatus(Status.Created);
-                cluster.addHostName(applicationClusterContext.getHostName());
-                cluster.setTenantRange(applicationClusterContext.getTenantRange());
-                clusters.add(cluster);
-
-                Service service = topology.getService(applicationClusterContext.getCartridgeType());
-                if (service != null) {
-                    service.addCluster(cluster);
-                    log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier());
-                } else {
-                    log.error("Service " + applicationClusterContext.getCartridgeType() + " not found");
-                    return;
-                }
-            }
-
-            // add to Topology and update
-            topology.addApplication(application);
-            TopologyManager.updateTopology(topology);
-
-            log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully");
-            org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters);
-            TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent);
-
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-    }
-
-    public static synchronized void handleApplicationUndeployed(String applicationId) {
-
-        Set<ClusterDataHolder> clusterData;
-
-        // update the Application and Cluster Statuses as 'Terminating'
-        TopologyManager.acquireWriteLock();
-
-        try {
-
-            Topology topology = TopologyManager.getTopology();
-
-            if (!topology.applicationExists(applicationId)) {
-                log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology");
-                return;
-            }
-
-            Application application = topology.getApplication(applicationId);
-            // check and update application status to 'Terminating'
-            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-                log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
-            }
-            // for now anyway update the status forcefully
-            application.setStatus(ApplicationStatus.Terminating);
-
-            // update all the Clusters' statuses to 'Terminating'
-            clusterData = application.getClusterDataRecursively();
-            for (ClusterDataHolder clusterDataHolder : clusterData) {
-                Service service = topology.getService(clusterDataHolder.getServiceType());
-                if (service != null) {
-                    Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
-                    if (aCluster != null) {
-                        // validate state transition
-                        if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
-                            log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
-                                    + ClusterStatus.Terminating);
-                        }
-                        // for now anyway update the status forcefully
-                        aCluster.setStatus(ClusterStatus.Terminating);
-
-                    } else {
-                        log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
-                        " in Topology");
-                    }
-
-                } else {
-                    log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
-                            " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
-                }
-            }
-
-            // update all Group's statuses to 'Terminating'
-            if (application.getGroups() != null) {
-                updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
-            }
-
-            TopologyManager.updateTopology(topology);
-
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-
-        TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData);
-    }
-
-
     public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) {
         Topology topology = TopologyManager.getTopology();
         Service service = topology.getService(clusterActivatedEvent.getServiceName());
@@ -798,251 +645,13 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1);
     }
 
-    public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(groupActivatedEvent.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    groupActivatedEvent.getAppId()));
-            return;
-        }
-
-        Group group = application.getGroupRecursively(groupActivatedEvent.getGroupId());
-        if (group == null) {
-            log.warn(String.format("Group %s does not exist",
-                    groupActivatedEvent.getGroupId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.GroupActivatedEvent groupActivatedEvent1 =
-                new org.apache.stratos.messaging.event.topology.GroupActivatedEvent(
-                        groupActivatedEvent.getAppId(),
-                        groupActivatedEvent.getGroupId());
-        try {
-            TopologyManager.acquireWriteLock();
-            group.setStatus(GroupStatus.Active);
-            log.info("Group activated adding status started for " + group.getUniqueIdentifier());
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1);
-    }
-
-    public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(applicationActivatedEvent.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    applicationActivatedEvent.getAppId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent applicationActivatedEvent1 =
-                new org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent(
-                        applicationActivatedEvent.getAppId());
-        try {
-            TopologyManager.acquireWriteLock();
-            application.setStatus(ApplicationStatus.Active);
-            log.info("Application activated adding status started for Topology");
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1);
-    }
-
-    public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(event.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    event.getAppId()));
-            return;
-        }
-
-        org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent applicationActivatedEvent =
-                new org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent(
-                        event.getAppId());
-        try {
-            TopologyManager.acquireWriteLock();
-            application.setStatus(ApplicationStatus.Inactive);
-            log.info("Application inactivated adding status started for Topology");
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent);
-    }
-
-    public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) {
-        Topology topology = TopologyManager.getTopology();
-        Application application = topology.getApplication(event.getAppId());
-        //update the status of the Group
-        if (application == null) {
-            log.warn(String.format("Application %s does not exist",
-                    event.getAppId()));
-            return;
-        }
-        List<Cluster> clusters = new ArrayList<Cluster>();
-        Set<ClusterDataHolder> allClusters  = application.getClusterDataRecursively();
-
-        for(ClusterDataHolder clusterDataHolder : allClusters){
-            String clusterId = clusterDataHolder.getClusterId();
-            String serviceName = clusterDataHolder.getServiceType();
-            clusters.add(TopologyManager.getTopology().getService(serviceName).getCluster(clusterId));
-        }
-        org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationActivatedEvent =
-                new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(
-                        application, clusters);
-        try {
-            TopologyManager.acquireWriteLock();
-            application.setStatus(ApplicationStatus.Created);
-            log.info("Application created adding status started for Topology");
-
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        //publishing data
-        TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent);
-    }
-
-    public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
-
-        String applicationId = event.getAppId();
-
-        // update the Application Status as 'Terminating'
-        TopologyManager.acquireWriteLock();
-
-        try {
-
-            Topology topology = TopologyManager.getTopology();
-
-            if (!topology.applicationExists(applicationId)) {
-                log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology");
-                return;
-            }
-
-            Application application = topology.getApplication(applicationId);
-            // check and update application status to 'Terminating'
-            if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
-                log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
-            }
-            // for now anyway update the status forcefully
-            application.setStatus(ApplicationStatus.Terminating);
-            log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
-
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-
-        TopologyEventPublisher.sendApplicationTerminatingEvent(
-                new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(applicationId));
-    }
-
-    private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection<Group> groups) {
-
-        for (Group group : groups) {
-            if (!group.isStateTransitionValid(groupStatus)) {
-                log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus);
-            }
-            // force update for now
-            group.setStatus(groupStatus);
-
-            // go recursively and update
-            if (group.getGroups() != null) {
-                updateGroupStatusesRecursively(groupStatus, group.getGroups());
-            }
-        }
-    }
-
-    public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
-
-     Topology topology = TopologyManager.getTopology();
-
-        try {
-            TopologyManager.acquireWriteLock();
-
-            if (!topology.applicationExists(event.getAppId())) {
-                log.warn("Application with id [ " + event.getAppId() + " ] doesn't exist in Topology");
-                //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain);
-
-            } else {
-                Application application = topology.getApplication(event.getAppId());
-
-                if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) {
-                    log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated);
-                }
-                // forcefully set status for now
-                application.setStatus(ApplicationStatus.Terminated);
-
-                int tenantId = application.getTenantId();
-                String tenantDomain = application.getTenantDomain();
-                Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
-                // remove clusters
-                for (ClusterDataHolder clusterDataHolder : clusterData) {
-                    Service service = topology.getService(clusterDataHolder.getServiceType());
-                    if (service != null) {
-                        // remove Cluster
-                        service.removeCluster(clusterDataHolder.getClusterId());
-
-                        if (log.isDebugEnabled()) {
-                            log.debug("Removed cluster with id " + clusterDataHolder.getClusterId());
-                        }
-                    } else {
-                        log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
-                                " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
-                    }
-
-                    // remove runtime data
-                    FasterLookUpDataHolder dataHolder =  FasterLookUpDataHolder.getInstance();
-                    dataHolder.removeClusterContext(clusterDataHolder.getClusterId());
-                    if(log.isDebugEnabled()) {
-                        log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId());
-                    }
-
-                    try {
-                        RegistryManager.getInstance().persist(dataHolder);
-                    } catch (RegistryException e) {
-                        log.error("Unable to persist data in Registry", e);
-                    }
-                }
-
-
-
-                // remove application
-                topology.removeApplication(event.getAppId());
-                TopologyManager.updateTopology(topology);
-
-                deleteAppResourcesFromMetadataService(event);
-
-                log.info("Removed application [ " + event.getAppId() + " ] from Topology");
-
-                TopologyEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(event.getAppId(),
-                        clusterData, tenantId, tenantDomain));
-            }
-
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-    }
 
     private static void deleteAppResourcesFromMetadataService(ApplicationTerminatedEvent event) {
         try {
             MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient();
             metadataClient.deleteApplicationProperties(event.getAppId());
         } catch (Exception e) {
-            log.error("Error occurred while deleting the application resources frm metadata service " , e);
+            log.error("Error occurred while deleting the application resources frm metadata service ", e);
         }
     }
 


[33/50] [abbrv] git commit: ApplicationSynchronizerTask initial impl.

Posted by im...@apache.org.
ApplicationSynchronizerTask initial impl.


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

Branch: refs/heads/docker-grouping-merge
Commit: ff2e971d6dfad83fbc29d5d5380bf3af6fe4d98c
Parents: 226b870
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 16:21:22 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:21:22 2014 +0530

----------------------------------------------------------------------
 .../applications/ApplicationSynchronizerTask.java           | 9 ++++++++-
 .../applications/topic/ApplicationsEventPublisher.java      | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ff2e971d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
index 571e7a8..a8ce042 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java
@@ -19,6 +19,9 @@
 
 package org.apache.stratos.autoscaler.applications;
 
+import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
 import org.wso2.carbon.ntask.core.Task;
 
 import java.util.Map;
@@ -38,6 +41,10 @@ public class ApplicationSynchronizerTask implements Task {
     @Override
     public void execute() {
 
-
+        Applications applications = ApplicationManager.getApplications();
+        if (applications != null) {
+            // publish complete Applications event
+            ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/ff2e971d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index bdbffc0..0a0b261 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -18,6 +18,10 @@ import java.util.Set;
 public class ApplicationsEventPublisher {
     private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class);
 
+    public static void sendCompleteApplicationsEvent (Applications completeApplications) {
+
+        publishEvent(new CompleteApplicationsEvent(completeApplications));
+    }
 
     public static void sendGroupCreatedEvent(String appId, String groupId) {
         try {


[18/50] [abbrv] removing application status and adding applications, cluster status topic

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
deleted file mode 100644
index d269d38..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppClusterTerminatedEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
deleted file mode 100644
index 547a681..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class AppClusterTerminatingEvent extends StatusEvent {
-    private static final long serialVersionUID = 2625412714611885089L;
-
-    private final String serviceName;
-    private final String clusterId;
-    private String appId;
-
-    public AppClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.appId = appId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
index 6eeb2dc..07eb674 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java
@@ -19,11 +19,15 @@
 
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by cartridge agent when it has started the server and
  * applications are ready to serve the incoming requests.
  */
-public class AppStatusGroupInactivateEvent extends StatusEvent {
+public class AppStatusGroupInactivateEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String groupId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
index 7e6a8b4..7825850 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java
@@ -18,12 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
 import java.io.Serializable;
 
 /**
  * This event will be fired upon the application activated is detected.
  */
-public class ApplicationActivatedEvent extends StatusEvent implements Serializable {
+public class ApplicationActivatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
index 5d220fa..dfb90f2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java
@@ -18,12 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
 import java.io.Serializable;
 
 /**
  * This event will be fired upon the application created is detected.
  */
-public class ApplicationCreatedEvent extends StatusEvent implements Serializable {
+public class ApplicationCreatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
index 8ff0db3..3006225 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java
@@ -18,12 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
 import java.io.Serializable;
 
 /**
  * This event will be fired upon the application inactivated is detected.
  */
-public class ApplicationInactivatedEvent extends StatusEvent implements Serializable {
+public class ApplicationInactivatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
index 024327a..eaa54e3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java
@@ -19,6 +19,7 @@
 package org.apache.stratos.messaging.event.applications;
 
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.event.Event;
 
 import java.io.Serializable;
 import java.util.Set;
@@ -26,7 +27,7 @@ import java.util.Set;
 /**
  * This event will be fired upon the application terminated is detected.
  */
-public class ApplicationTerminatedEvent extends StatusEvent implements Serializable {
+public class ApplicationTerminatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
index e81b988..2a434a4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java
@@ -18,12 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
 import java.io.Serializable;
 
 /**
  * This event will be fired upon the application terminating is detected.
  */
-public class ApplicationTerminatingEvent extends StatusEvent implements Serializable {
+public class ApplicationTerminatingEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
index c200217..a587bef 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java
@@ -19,11 +19,15 @@
 
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by cartridge agent when it has started the server and
  * applications are ready to serve the incoming requests.
  */
-public class GroupActivatedEvent extends StatusEvent {
+public class GroupActivatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String groupId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
index 8b622c5..77336d2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java
@@ -19,11 +19,15 @@
 
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by cartridge agent when it has started the server and
  * applications are ready to serve the incoming requests.
  */
-public class GroupCreatedEvent extends StatusEvent {
+public class GroupCreatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String groupId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
index 5723305..4c1e2f0 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java
@@ -18,10 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event will be fired upon the instability of group detection by autoscaler.
  */
-public class GroupMaintenanceModeEvent extends StatusEvent {
+public class GroupMaintenanceModeEvent extends Event implements Serializable {
     private String groupId;
     private String appId;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
index 8099015..b2d5d57 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java
@@ -18,10 +18,14 @@
  */
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by autoscaler before actually terminate a group.
  */
-public class GroupReadyToShutdownEvent extends StatusEvent {
+public class GroupReadyToShutdownEvent extends Event implements Serializable {
     private String groupId;
     private String appId;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
index 6cfa888..2a38caf 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java
@@ -19,11 +19,15 @@
 
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by cartridge agent when it has started the server and
  * applications are ready to serve the incoming requests.
  */
-public class GroupTerminatedEvent extends StatusEvent {
+public class GroupTerminatedEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String groupId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
index ba6f979..c526a35 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java
@@ -19,11 +19,15 @@
 
 package org.apache.stratos.messaging.event.applications;
 
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
 /**
  * This event is fired by cartridge agent when it has started the server and
  * applications are ready to serve the incoming requests.
  */
-public class GroupTerminatingEvent extends StatusEvent {
+public class GroupTerminatingEvent extends Event implements Serializable {
     private static final long serialVersionUID = 2625412714611885089L;
 
     private String groupId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
deleted file mode 100644
index 91dbab3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.applications;
-
-import org.apache.stratos.messaging.event.Event;
-
-import java.io.Serializable;
-
-/**
- * Represents all instance status events.
- */
-public abstract class StatusEvent extends Event implements Serializable {
-    private static final long serialVersionUID = -4790128084271867615L;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java
new file mode 100644
index 0000000..1e00bd5
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterActivatedEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
new file mode 100644
index 0000000..d28cca1
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterCreatedEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java
new file mode 100644
index 0000000..34fad5a
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterInactivateEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java
new file mode 100644
index 0000000..48ecb68
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterTerminatedEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java
new file mode 100644
index 0000000..df6eba9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterTerminatingEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterStatusClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
deleted file mode 100644
index f99e15b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppClusterActivatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
deleted file mode 100644
index d43f360..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppClusterCreatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
deleted file mode 100644
index 1adaeef..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppClusterInactivateEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
deleted file mode 100644
index 89a66e9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppClusterTerminatedEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
deleted file mode 100644
index 9cd9a5d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.applications;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class AppClusterTerminatingEventListener extends EventListener{
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java
new file mode 100644
index 0000000..c2a1eef
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterActivatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
new file mode 100644
index 0000000..6ca5476
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java
new file mode 100644
index 0000000..3af6d9d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterInactivateEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java
new file mode 100644
index 0000000..04b54ba
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterTerminatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java
new file mode 100644
index 0000000..d007d7f
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterTerminatingEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
deleted file mode 100644
index 920f94e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppClusterActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppClusterActivatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppClusterActivatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppClusterActivatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppClusterActivatedEvent event = (AppClusterActivatedEvent) Util.jsonToObject(message, AppClusterActivatedEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received ClusterActivatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
deleted file mode 100644
index 9caa79c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppClusterCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppClusterCreatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppClusterCreatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppClusterCreatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppClusterCreatedEvent event = (AppClusterCreatedEvent) Util.jsonToObject(message, AppClusterCreatedEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
deleted file mode 100644
index d9fb0e9..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppClusterInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppClusterInactivateMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppClusterInactivateMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppClusterInactivateEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppClusterInactivateEvent event = (AppClusterInactivateEvent) Util.
-                                                jsonToObject(message, AppClusterInactivateEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received ClusterInActivateEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
deleted file mode 100644
index 843d355..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppClusterTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppClusterTerminatedMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppClusterTerminatedMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppClusterTerminatedEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppClusterTerminatedEvent event = (AppClusterTerminatedEvent) Util.
-                    jsonToObject(message, AppClusterTerminatedEvent.class);
-
-            if (log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
deleted file mode 100644
index 9520f4e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.AppClusterTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class AppClusterTerminatingMessageProcessor extends MessageProcessor {
-    private static final Log log = LogFactory.getLog(AppClusterTerminatingMessageProcessor.class);
-    private MessageProcessor nextProcessor;
-
-    @Override
-    public void setNext(MessageProcessor nextProcessor) {
-        this.nextProcessor = nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String message, Object object) {
-        if (AppClusterTerminatingEvent.class.getName().equals(type)) {
-            // Parse complete message and build event
-            AppClusterTerminatingEvent event = (AppClusterTerminatingEvent) Util.
-                                                jsonToObject(message, AppClusterTerminatingEvent.class);
-
-            if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString());
-            }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
-        } else {
-            if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
-            } else {
-                throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
deleted file mode 100644
index 3705f1e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.applications;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.listener.applications.*;
-import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
-
-/**
- * Application Status processor chain is to handle the list processors to parse the application
- * status.
- */
-public class AppStatusMessageProcessorChain extends MessageProcessorChain {
-    private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
-
-    private AppClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
-    private AppClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
-    private AppClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
-    private AppClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
-    private AppClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
-    private GroupCreatedMessageProcessor groupCreatedMessageProcessor;
-    private GroupActivatedMessageProcessor groupActivatedMessageProcessor;
-    private GroupInactivatedMessageProcessor groupInActivateMessageProcessor;
-    private ApplicationActivatedMessageProcessor appActivatedMessageProcessor;
-    private ApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
-    private ApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
-    private ApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
-    private ApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
-
-    private GroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
-    private GroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
-
-    public void initialize() {
-        // Add instance notifier event processors
-        clusterCreatedMessageProcessor= new AppClusterCreatedMessageProcessor();
-        add(clusterCreatedMessageProcessor);
-
-        clusterActivatedMessageProcessor = new AppClusterActivatedMessageProcessor();
-        add(clusterActivatedMessageProcessor);
-
-        clusterInActivateMessageProcessor = new AppClusterInactivateMessageProcessor();
-        add(clusterInActivateMessageProcessor);
-
-        clusterTerminatingMessageProcessor = new AppClusterTerminatingMessageProcessor();
-        add(clusterTerminatingMessageProcessor);
-
-        clusterTerminatedMessageProcessor = new AppClusterTerminatedMessageProcessor();
-        add(clusterTerminatedMessageProcessor);
-
-        groupCreatedMessageProcessor = new GroupCreatedMessageProcessor();
-        add(groupCreatedMessageProcessor);
-
-        groupActivatedMessageProcessor = new GroupActivatedMessageProcessor();
-        add(groupActivatedMessageProcessor);
-
-        groupInActivateMessageProcessor = new GroupInactivatedMessageProcessor();
-        add(groupInActivateMessageProcessor);
-
-        appActivatedMessageProcessor = new ApplicationActivatedMessageProcessor();
-        add(appActivatedMessageProcessor);
-
-        applicationStatusAppCreatedMessageProcessor = new ApplicationCreatedMessageProcessor();
-        this.add(applicationStatusAppCreatedMessageProcessor);
-
-        applicationStatusAppInActivatedMessageProcessor = new ApplicationInactivatedMessageProcessor();
-        this.add(applicationStatusAppInActivatedMessageProcessor);
-
-        applicationStatusAppTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor();
-        this.add(applicationStatusAppTerminatedMessageProcessor);
-
-        applicationStatusAppTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor();
-        this.add(applicationStatusAppTerminatingMessageProcessor);
-
-        groupTerminatedMessageProcessor = new GroupTerminatedMessageProcessor();
-        this.add(groupTerminatedMessageProcessor);
-
-        groupTerminatingMessageProcessor = new GroupTerminatingMessageProcessor();
-        this.add(groupTerminatingMessageProcessor);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Instance notifier message processor chain initialized");
-        }
-    }
-
-    public void addEventListener(EventListener eventListener) {
-        if(eventListener instanceof AppClusterCreatedEventListener) {
-            clusterCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppClusterActivatedEventListener) {
-            clusterActivatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof AppClusterInactivateEventListener) {
-            clusterInActivateMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof GroupCreatedEventListener) {
-            groupCreatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupActivatedEventListener) {
-            groupActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppClusterTerminatedEventListener){
-            clusterTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof AppClusterTerminatingEventListener){
-            clusterTerminatingMessageProcessor.addEventListener(eventListener);
-        }else if (eventListener instanceof GroupInactivateEventListener) {
-            groupInActivateMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof ApplicationActivatedEventListener) {
-            appActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationInactivatedEventListener){
-            applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationCreatedEventListener){
-            applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationTerminatingEventListener){
-            applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if(eventListener instanceof ApplicationTerminatedEventListener){
-            applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupTerminatingEventListener){
-            groupTerminatingMessageProcessor.addEventListener(eventListener);
-        } else if (eventListener instanceof GroupTerminatedEventListener){
-            groupTerminatedMessageProcessor.addEventListener(eventListener);
-        } else
-        {
-            throw new RuntimeException("Unknown event listener " + eventListener.toString());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/275ba2dd/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
index 71bd50e..6c82925 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
@@ -20,43 +20,85 @@ package org.apache.stratos.messaging.message.processor.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
 
+/**
+ * This processor responsible to process the application activation even and update the Topology.
+ */
 public class ApplicationActivatedMessageProcessor extends MessageProcessor {
     private static final Log log =
             LogFactory.getLog(ApplicationActivatedMessageProcessor.class);
 
 
     private MessageProcessor nextProcessor;
+
     @Override
     public void setNext(MessageProcessor nextProcessor) {
         this.nextProcessor = nextProcessor;
-
     }
 
+
     @Override
     public boolean process(String type, String message, Object object) {
+        Topology topology = (Topology) object;
+
         if (ApplicationActivatedEvent.class.getName().equals(type)) {
+            // Return if topology has not been initialized
+            if (!topology.isInitialized())
+                return false;
+
             // Parse complete message and build event
-            ApplicationActivatedEvent event =
-                    (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class);
+            ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util.
+                    jsonToObject(message, ApplicationActivatedEvent.class);
+
+            TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+
+            try {
+                return doProcess(event, topology);
 
-            if (log.isDebugEnabled()) {
-                log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString());
+            } finally {
+                TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
             }
-            // Notify event listeners
-            notifyEventListeners(event);
-            return true;
+
         } else {
             if (nextProcessor != null) {
-                return nextProcessor.process(type, message, object);
+                // ask the next processor to take care of the message.
+                return nextProcessor.process(type, message, topology);
             } else {
-                throw new RuntimeException(
-                        String.format("Failed to process group activated message " +
-                                "using available message processors: [type] %s [body] %s", type, message));
+                throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
             }
         }
     }
+
+    private boolean doProcess(ApplicationActivatedEvent event, Topology topology) {
+
+        // Validate event against the existing topology
+        Application application = topology.getApplication(event.getAppId());
+        if (application == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Application does not exist: [service] %s",
+                        event.getAppId()));
+            }
+            return false;
+        } else {
+            // Apply changes to the topology
+            if (!application.isStateTransitionValid(ApplicationStatus.Active)) {
+                log.error("Invalid State transfer from [ " + application.getStatus() +
+                        " ] to [ " + ApplicationStatus.Active + " ]");
+            }
+            application.setStatus(ApplicationStatus.Active);
+
+        }
+
+        // Notify event listeners
+        notifyEventListeners(event);
+        return true;
+
+    }
 }


[38/50] [abbrv] adding undeploy service group

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d7cd50d/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
index d0665cf..b76e02a 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
@@ -1,369 +1,390 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax28="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax25="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax216="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax212="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.ap
 ache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax27="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax25="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax210="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.ap
 ache.org">
     <wsdl:documentation>AutoScalerService</wsdl:documentation>
     <wsdl:types>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="AutoScalerException">
+                <xs:complexContent>
+                    <xs:extension base="xs:RuntimeException">
+                        <xs:sequence></xs:sequence>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
             <xs:complexType name="InvalidServiceGroupException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="NonExistingLBException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidPartitionException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd">
             <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax25:Property"/>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax27:Property"></xs:element>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Property">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax214="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax217="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
-            <xs:import namespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://model.policy.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
+        <xs:schema xmlns:ax217="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax219="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://exception.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
+            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://model.policy.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:element name="AutoScalerServiceAutoScalerException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax23:AutoScalerException"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="undeployServiceGroup">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="serviceGroupExist">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="serviceGroupExistResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getValidDeploymentPoliciesforCartridge">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getValidDeploymentPoliciesforCartridgeResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceLBClusterId">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceType" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="serviceType" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceLBClusterIdResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax212:ServiceGroup"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax214:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="groupId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="groupId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionsOfDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionGroups">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax28:PartitionGroup"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax217:PartitionGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="partitionId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getPartitionResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax26:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDefaultLBClusterId">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getDefaultLBClusterIdResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax217:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllDeploymentPolicies">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllDeploymentPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAvailablePartitions">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAvailablePartitionsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:Partition"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAutoScalingPolicy">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAllAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax217:AutoscalePolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax219:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceInvalidServiceGroupException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax219:InvalidServiceGroupException"/>
+                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax23:InvalidServiceGroupException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="deployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax212:ServiceGroup"/>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax214:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkServiceLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkServiceLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceNonExistingLBException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="NonExistingLBException" nillable="true" type="ax219:NonExistingLBException"/>
+                        <xs:element minOccurs="0" name="NonExistingLBException" nillable="true" type="ax23:NonExistingLBException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="lbClusterId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkDefaultLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkDefaultLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkClusterLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="checkClusterLBExistenceAgainstPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceInvalidPartitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax219:InvalidPartitionException"/>
+                        <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax23:InvalidPartitionException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addPartition">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax24:Partition"/>
+                        <xs:element minOccurs="0" name="partition" nillable="true" type="ax26:Partition"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addPartitionResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="AutoScalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax219:InvalidPolicyException"/>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax23:InvalidPolicyException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addDeploymentPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="depPolicy" nillable="true" type="ax23:DeploymentPolicy"/>
+                        <xs:element minOccurs="0" name="depPolicy" nillable="true" type="ax25:DeploymentPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addDeploymentPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="aspolicy" nillable="true" type="ax217:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="aspolicy" nillable="true" type="ax219:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -371,957 +392,991 @@
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="ServiceGroup">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax212:Dependencies"/>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax214:Dependencies"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Dependencies">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax29="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
+        <xs:schema xmlns:ax211="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="PartitionGroup">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax29:Partition"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax211:Partition"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://model.policy.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="AutoscalePolicy">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax216:LoadThresholds"/>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax218:LoadThresholds"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax216:LoadAverageThresholds"/>
-                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax216:MemoryConsumptionThresholds"/>
-                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax216:RequestsInFlightThresholds"/>
+                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax218:LoadAverageThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax218:MemoryConsumptionThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax218:RequestsInFlightThresholds"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadAverageThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="MemoryConsumptionThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="RequestsInFlightThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"/>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"/>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax27="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax210="http://partition.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"/>
+        <xs:schema xmlns:ax29="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax212="http://partition.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="DeploymentPolicy">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax27:Partition"/>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax28:PartitionGroup"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax29:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax212:PartitionGroup"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax26="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"/>
+        <xs:schema xmlns:ax28="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd">
+            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="Partition">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"/>
-                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"/>
-                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"/>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
     </wsdl:types>
     <wsdl:message name="getPartitionsOfDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicy"/>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfDeploymentPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getDefaultLBClusterIdRequest">
-        <wsdl:part name="parameters" element="ns:getDefaultLBClusterId"/>
+        <wsdl:part name="parameters" element="ns:getDefaultLBClusterId"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getDefaultLBClusterIdResponse">
-        <wsdl:part name="parameters" element="ns:getDefaultLBClusterIdResponse"/>
+        <wsdl:part name="parameters" element="ns:getDefaultLBClusterIdResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfGroupRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroup"/>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionsOfGroupResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionsOfGroupResponse"/>
+        <wsdl:part name="parameters" element="ns:getPartitionsOfGroupResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getAllAutoScalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"/>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getDeploymentPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistRequest">
-        <wsdl:part name="parameters" element="ns:serviceGroupExist"/>
+        <wsdl:part name="parameters" element="ns:serviceGroupExist"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistResponse">
-        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"/>
+        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidPolicyException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"/>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:getServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupResponse">
-        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllDeploymentPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPolicies"/>
+        <wsdl:part name="parameters" element="ns:getAllDeploymentPolicies"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllDeploymentPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getAllDeploymentPoliciesResponse"/>
+        <wsdl:part name="parameters" element="ns:getAllDeploymentPoliciesResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getValidDeploymentPoliciesforCartridgeRequest">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridge"/>
+        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridge"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getValidDeploymentPoliciesforCartridgeResponse">
-        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridgeResponse"/>
+        <wsdl:part name="parameters" element="ns:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="undeployServiceGroupRequest">
+        <wsdl:part name="parameters" element="ns:undeployServiceGroup"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="AutoScalerServiceAutoScalerException">
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceAutoScalerException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllAvailablePartitionsRequest">
-        <wsdl:part name="parameters" element="ns:getAllAvailablePartitions"/>
+        <wsdl:part name="parameters" element="ns:getAllAvailablePartitions"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAllAvailablePartitionsResponse">
-        <wsdl:part name="parameters" element="ns:getAllAvailablePartitionsResponse"/>
+        <wsdl:part name="parameters" element="ns:getAllAvailablePartitionsResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkClusterLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicy"/>
+        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkClusterLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:checkClusterLBExistenceAgainstPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkDefaultLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicy"/>
+        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkDefaultLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:checkDefaultLBExistenceAgainstPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionRequest">
-        <wsdl:part name="parameters" element="ns:getPartition"/>
+        <wsdl:part name="parameters" element="ns:getPartition"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionResponse"/>
+        <wsdl:part name="parameters" element="ns:getPartitionResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addPartitionRequest">
-        <wsdl:part name="parameters" element="ns:addPartition"/>
+        <wsdl:part name="parameters" element="ns:addPartition"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addPartitionResponse">
-        <wsdl:part name="parameters" element="ns:addPartitionResponse"/>
+        <wsdl:part name="parameters" element="ns:addPartitionResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidPartitionException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPartitionException"/>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPartitionException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkServiceLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicy"/>
+        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkServiceLBExistenceAgainstPolicyResponse">
-        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:checkServiceLBExistenceAgainstPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addDeploymentPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicy"/>
+        <wsdl:part name="parameters" element="ns:addDeploymentPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addDeploymentPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addDeploymentPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:addDeploymentPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceLBClusterIdRequest">
-        <wsdl:part name="parameters" element="ns:getServiceLBClusterId"/>
+        <wsdl:part name="parameters" element="ns:getServiceLBClusterId"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceLBClusterIdResponse">
-        <wsdl:part name="parameters" element="ns:getServiceLBClusterIdResponse"/>
+        <wsdl:part name="parameters" element="ns:getServiceLBClusterIdResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="deployServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:deployServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:deployServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceInvalidServiceGroupException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidServiceGroupException"/>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidServiceGroupException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionGroupsRequest">
-        <wsdl:part name="parameters" element="ns:getPartitionGroups"/>
+        <wsdl:part name="parameters" element="ns:getPartitionGroups"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getPartitionGroupsResponse">
-        <wsdl:part name="parameters" element="ns:getPartitionGroupsResponse"/>
+        <wsdl:part name="parameters" element="ns:getPartitionGroupsResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="checkLBExistenceAgainstPolicyRequest">
-        <wsdl:part name="parameters" element="ns:checkLBExistenceAgainstPolicy"/>
+        <wsdl:part name="parameters" element="ns:checkLBExistenceAgainstPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoScalerServiceNonExistingLBException">
-        <wsdl:part name="parameters" element="ns:AutoScalerServiceNonExistingLBException"/>
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceNonExistingLBException"></wsdl:part>
     </wsdl:message>
     <wsdl:portType name="AutoScalerServicePortType">
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <wsdl:input message="ns:getPartitionsOfDeploymentPolicyRequest" wsaw:Action="urn:getPartitionsOfDeploymentPolicy"/>
-            <wsdl:output message="ns:getPartitionsOfDeploymentPolicyResponse" wsaw:Action="urn:getPartitionsOfDeploymentPolicyResponse"/>
+            <wsdl:input message="ns:getPartitionsOfDeploymentPolicyRequest" wsaw:Action="urn:getPartitionsOfDeploymentPolicy"></wsdl:input>
+            <wsdl:output message="ns:getPartitionsOfDeploymentPolicyResponse" wsaw:Action="urn:getPartitionsOfDeploymentPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <wsdl:input message="ns:getDefaultLBClusterIdRequest" wsaw:Action="urn:getDefaultLBClusterId"/>
-            <wsdl:output message="ns:getDefaultLBClusterIdResponse" wsaw:Action="urn:getDefaultLBClusterIdResponse"/>
+            <wsdl:input message="ns:getDefaultLBClusterIdRequest" wsaw:Action="urn:getDefaultLBClusterId"></wsdl:input>
+            <wsdl:output message="ns:getDefaultLBClusterIdResponse" wsaw:Action="urn:getDefaultLBClusterIdResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <wsdl:input message="ns:getPartitionsOfGroupRequest" wsaw:Action="urn:getPartitionsOfGroup"/>
-            <wsdl:output message="ns:getPartitionsOfGroupResponse" wsaw:Action="urn:getPartitionsOfGroupResponse"/>
+            <wsdl:input message="ns:getPartitionsOfGroupRequest" wsaw:Action="urn:getPartitionsOfGroup"></wsdl:input>
+            <wsdl:output message="ns:getPartitionsOfGroupResponse" wsaw:Action="urn:getPartitionsOfGroupResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <wsdl:input message="ns:getAllAutoScalingPolicyRequest" wsaw:Action="urn:getAllAutoScalingPolicy"/>
-            <wsdl:output message="ns:getAllAutoScalingPolicyResponse" wsaw:Action="urn:getAllAutoScalingPolicyResponse"/>
+            <wsdl:input message="ns:getAllAutoScalingPolicyRequest" wsaw:Action="urn:getAllAutoScalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:getAllAutoScalingPolicyResponse" wsaw:Action="urn:getAllAutoScalingPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"/>
-            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"/>
+            <wsdl:input message="ns:getDeploymentPolicyRequest" wsaw:Action="urn:getDeploymentPolicy"></wsdl:input>
+            <wsdl:output message="ns:getDeploymentPolicyResponse" wsaw:Action="urn:getDeploymentPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"/>
-            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"/>
+            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"></wsdl:input>
+            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"/>
-            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"/>
+            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
-            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"/>
-            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"/>
+            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"></wsdl:input>
+            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllDeploymentPolicies">
-            <wsdl:input message="ns:getAllDeploymentPoliciesRequest" wsaw:Action="urn:getAllDeploymentPolicies"/>
-            <wsdl:output message="ns:getAllDeploymentPoliciesResponse" wsaw:Action="urn:getAllDeploymentPoliciesResponse"/>
+            <wsdl:input message="ns:getAllDeploymentPoliciesRequest" wsaw:Action="urn:getAllDeploymentPolicies"></wsdl:input>
+            <wsdl:output message="ns:getAllDeploymentPoliciesResponse" wsaw:Action="urn:getAllDeploymentPoliciesResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <wsdl:input message="ns:getValidDeploymentPoliciesforCartridgeRequest" wsaw:Action="urn:getValidDeploymentPoliciesforCartridge"/>
-            <wsdl:output message="ns:getValidDeploymentPoliciesforCartridgeResponse" wsaw:Action="urn:getValidDeploymentPoliciesforCartridgeResponse"/>
+            <wsdl:input message="ns:getValidDeploymentPoliciesforCartridgeRequest" wsaw:Action="urn:getValidDeploymentPoliciesforCartridge"></wsdl:input>
+            <wsdl:output message="ns:getValidDeploymentPoliciesforCartridgeResponse" wsaw:Action="urn:getValidDeploymentPoliciesforCartridgeResponse"></wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="undeployServiceGroup">
+            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"></wsdl:input>
+            <wsdl:fault message="ns:AutoScalerServiceAutoScalerException" name="AutoScalerServiceAutoScalerException" wsaw:Action="urn:undeployServiceGroupAutoScalerServiceAutoScalerException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getAllAvailablePartitions">
-            <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"/>
-            <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"/>
+            <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"></wsdl:input>
+            <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"/>
-            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"/>
+            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkClusterLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkClusterLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicy"/>
-            <wsdl:output message="ns:checkClusterLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicyResponse"/>
+            <wsdl:input message="ns:checkClusterLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicy"></wsdl:input>
+            <wsdl:output message="ns:checkClusterLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkClusterLBExistenceAgainstPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkDefaultLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkDefaultLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicy"/>
-            <wsdl:output message="ns:checkDefaultLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicyResponse"/>
+            <wsdl:input message="ns:checkDefaultLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicy"></wsdl:input>
+            <wsdl:output message="ns:checkDefaultLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkDefaultLBExistenceAgainstPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartition">
-            <wsdl:input message="ns:getPartitionRequest" wsaw:Action="urn:getPartition"/>
-            <wsdl:output message="ns:getPartitionResponse" wsaw:Action="urn:getPartitionResponse"/>
+            <wsdl:input message="ns:getPartitionRequest" wsaw:Action="urn:getPartition"></wsdl:input>
+            <wsdl:output message="ns:getPartitionResponse" wsaw:Action="urn:getPartitionResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addPartition">
-            <wsdl:input message="ns:addPartitionRequest" wsaw:Action="urn:addPartition"/>
-            <wsdl:output message="ns:addPartitionResponse" wsaw:Action="urn:addPartitionResponse"/>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPartitionException" name="AutoScalerServiceInvalidPartitionException" wsaw:Action="urn:addPartitionAutoScalerServiceInvalidPartitionException"/>
+            <wsdl:input message="ns:addPartitionRequest" wsaw:Action="urn:addPartition"></wsdl:input>
+            <wsdl:output message="ns:addPartitionResponse" wsaw:Action="urn:addPartitionResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPartitionException" name="AutoScalerServiceInvalidPartitionException" wsaw:Action="urn:addPartitionAutoScalerServiceInvalidPartitionException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="checkServiceLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkServiceLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicy"/>
-            <wsdl:output message="ns:checkServiceLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicyResponse"/>
+            <wsdl:input message="ns:checkServiceLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicy"></wsdl:input>
+            <wsdl:output message="ns:checkServiceLBExistenceAgainstPolicyResponse" wsaw:Action="urn:checkServiceLBExistenceAgainstPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addDeploymentPolicy">
-            <wsdl:input message="ns:addDeploymentPolicyRequest" wsaw:Action="urn:addDeploymentPolicy"/>
-            <wsdl:output message="ns:addDeploymentPolicyResponse" wsaw:Action="urn:addDeploymentPolicyResponse"/>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addDeploymentPolicyAutoScalerServiceInvalidPolicyException"/>
+            <wsdl:input message="ns:addDeploymentPolicyRequest" wsaw:Action="urn:addDeploymentPolicy"></wsdl:input>
+            <wsdl:output message="ns:addDeploymentPolicyResponse" wsaw:Action="urn:addDeploymentPolicyResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addDeploymentPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceLBClusterId">
-            <wsdl:input message="ns:getServiceLBClusterIdRequest" wsaw:Action="urn:getServiceLBClusterId"/>
-            <wsdl:output message="ns:getServiceLBClusterIdResponse" wsaw:Action="urn:getServiceLBClusterIdResponse"/>
+            <wsdl:input message="ns:getServiceLBClusterIdRequest" wsaw:Action="urn:getServiceLBClusterId"></wsdl:input>
+            <wsdl:output message="ns:getServiceLBClusterIdResponse" wsaw:Action="urn:getServiceLBClusterIdResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="deployServiceGroup">
-            <wsdl:input message="ns:deployServiceGroupRequest" wsaw:Action="urn:deployServiceGroup"/>
-            <wsdl:fault message="ns:AutoScalerServiceInvalidServiceGroupException" name="AutoScalerServiceInvalidServiceGroupException" wsaw:Action="urn:deployServiceGroupAutoScalerServiceInvalidServiceGroupException"/>
+            <wsdl:input message="ns:deployServiceGroupRequest" wsaw:Action="urn:deployServiceGroup"></wsdl:input>
+            <wsdl:fault message="ns:AutoScalerServiceInvalidServiceGroupException" name="AutoScalerServiceInvalidServiceGroupException" wsaw:Action="urn:deployServiceGroupAutoScalerServiceInvalidServiceGroupException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getPartitionGroups">
-            <wsdl:input message="ns:getPartitionGroupsRequest" wsaw:Action="urn:getPartitionGroups"/>
-            <wsdl:output message="ns:getPartitionGroupsResponse" wsaw:Action="urn:getPartitionGroupsResponse"/>
+            <wsdl:input message="ns:getPartitionGroupsRequest" wsaw:Action="urn:getPartitionGroups"></wsdl:input>
+            <wsdl:output message="ns:getPartitionGroupsResponse" wsaw:Action="urn:getPartitionGroupsResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkLBExistenceAgainstPolicy">
-            <wsdl:input message="ns:checkLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkLBExistenceAgainstPolicy"/>
-            <wsdl:fault message="ns:AutoScalerServiceNonExistingLBException" name="AutoScalerServiceNonExistingLBException" wsaw:Action="urn:checkLBExistenceAgainstPolicyAutoScalerServiceNonExistingLBException"/>
+            <wsdl:input message="ns:checkLBExistenceAgainstPolicyRequest" wsaw:Action="urn:checkLBExistenceAgainstPolicy"></wsdl:input>
+            <wsdl:fault message="ns:AutoScalerServiceNonExistingLBException" name="AutoScalerServiceNonExistingLBException" wsaw:Action="urn:checkLBExistenceAgainstPolicyAutoScalerServiceNonExistingLBException"></wsdl:fault>
         </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="AutoScalerServiceSoap11Binding" type="ns:AutoScalerServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <soap:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"/>
+            <soap:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <soap:operation soapAction="urn:getDefaultLBClusterId" style="document"/>
+            <soap:operation soapAction="urn:getDefaultLBClusterId" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <soap:operation soapAction="urn:getPartitionsOfGroup" style="document"/>
+            <soap:operation soapAction="urn:getPartitionsOfGroup" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <soap:operation soapAction="urn:getAllAutoScalingPolicy" style="document"/>
+            <soap:operation soapAction="urn:getAllAutoScalingPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"/>
+            <soap:operation soapAction="urn:getDeploymentPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <soap:operation soapAction="urn:serviceGroupExist" style="document"/>
+            <soap:operation soapAction="urn:serviceGroupExist" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"/>
+            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"/>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
-            <soap:operation soapAction="urn:getServiceGroup" style="document"/>
+            <soap:operation soapAction="urn:getServiceGroup" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllDeploymentPolicies">
-            <soap:operation soapAction="urn:getAllDeploymentPolicies" style="document"/>
+            <soap:operation soapAction="urn:getAllDeploymentPolicies" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getValidDeploymentPoliciesforCartridge">
-            <soap:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"/>
+            <soap:operation soapAction="urn:getValidDeploymentPoliciesforCartridge" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="undeployServiceGroup">
+            <soap:operation soapAction="urn:undeployServiceGroup" style="document"></soap:operation>
+            <wsdl:input>
+                <soap:body use="literal"></soap:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceAutoScalerException">
+                <soap:fault use="literal" name="AutoScalerServiceAutoScalerException"></soap:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getAllAvailablePartitions">
-            <soap:operation soapAction="urn:getAllAvailablePartitions" style="document"/>
+            <soap:operation soapAction="urn:getAllAvailablePartitions" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"/>
+            <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkDefaultLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"/>
+            <soap:operation soapAction="urn:checkDefaultLBExistenceAgainstPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="checkClusterLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"/>
+            <soap:operation soapAction="urn:checkClusterLBExistenceAgainstPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartition">
-            <soap:operation soapAction="urn:getPartition" style="document"/>
+            <soap:operation soapAction="urn:getPartition" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addPartition">
-            <soap:operation soapAction="urn:addPartition" style="document"/>
+            <soap:operation soapAction="urn:addPartition" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPartitionException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPartitionException"/>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPartitionException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="checkServiceLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"/>
+            <soap:operation soapAction="urn:checkServiceLBExistenceAgainstPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addDeploymentPolicy">
-            <soap:operation soapAction="urn:addDeploymentPolicy" style="document"/>
+            <soap:operation soapAction="urn:addDeploymentPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoScalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"/>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceLBClusterId">
-            <soap:operation soapAction="urn:getServiceLBClusterId" style="document"/>
+            <soap:operation soapAction="urn:getServiceLBClusterId" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionGroups">
-            <soap:operation soapAction="urn:getPartitionGroups" style="document"/>
+            <soap:operation soapAction="urn:getPartitionGroups" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="deployServiceGroup">
-            <soap:operation soapAction="urn:deployServiceGroup" style="document"/>
+            <soap:operation soapAction="urn:deployServiceGroup" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:fault name="AutoScalerServiceInvalidServiceGroupException">
-                <soap:fault use="literal" name="AutoScalerServiceInvalidServiceGroupException"/>
+                <soap:fault use="literal" name="AutoScalerServiceInvalidServiceGroupException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="checkLBExistenceAgainstPolicy">
-            <soap:operation soapAction="urn:checkLBExistenceAgainstPolicy" style="document"/>
+            <soap:operation soapAction="urn:checkLBExistenceAgainstPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:fault name="AutoScalerServiceNonExistingLBException">
-                <soap:fault use="literal" name="AutoScalerServiceNonExistingLBException"/>
+                <soap:fault use="literal" name="AutoScalerServiceNonExistingLBException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
     </wsdl:binding>
     <wsdl:binding name="AutoScalerServiceSoap12Binding" type="ns:AutoScalerServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap12:binding>
         <wsdl:operation name="getPartitionsOfDeploymentPolicy">
-            <soap12:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"/>
+            <soap12:operation soapAction="urn:getPartitionsOfDeploymentPolicy" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDefaultLBClusterId">
-            <soap12:operation soapAction="urn:getDefaultLBClusterId" style="document"/>
+            <soap12:operation soapAction="urn:getDefaultLBClusterId" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getPartitionsOfGroup">
-            <soap12:operation soapAction="urn:getPartitionsOfGroup" style="document"/>
+            <soap12:operation soapAction="urn:getPartitionsOfGroup" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getAllAutoScalingPolicy">
-            <soap12:operation soapAction="urn:getAllAutoScalingPolicy" style="document"/>
+            <soap12:operation soapAction="urn:getAllAutoScalingPolicy" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getDeploymentPolicy">
-            <soap12:operation soapAction="urn:getDeploymentPolicy" style="document"/>
+            <soap12:operation soapAction="urn:getDeploymentPolicy" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <soap12:operation soapAction="urn:serviceGroupExist" style="document"/>
+            <soap12:operation soapAction="urn:serviceGroupExist" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:output>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <soap12:operation soapAction="urn:addAutoScalingPolicy" style="document"/>
+            <soap12:operation soapAction="urn:addAutoScalingPolicy" style="document"></soap12:operation>
             <wsdl:input>
-                <soap12:body use="literal"/>
+                <soap12:body use="literal"></soap12:body>
             </wsdl:input>
             <wsdl:out

<TRUNCATED>

[29/50] [abbrv] git commit: removing Application from Topology - I

Posted by im...@apache.org.
removing Application from Topology - I


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

Branch: refs/heads/docker-grouping-merge
Commit: d4f90be212976c529b6970c673b4eddf6461e0a4
Parents: 836b71f
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 14:55:36 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530

----------------------------------------------------------------------
 .../domain/applications/Applications.java       |  13 ++-
 .../messaging/domain/topology/Topology.java     | 111 -------------------
 2 files changed, 11 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d4f90be2/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
index 9e8cf3e..e5a7921 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -21,6 +21,8 @@ package org.apache.stratos.messaging.domain.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -38,8 +40,10 @@ public class Applications implements Serializable {
         this.applicationMap = new HashMap<String, Application>();
     }
 
-    public void addApplication (Application application) {
-        this.getApplications().put(application.getUniqueIdentifier(), application);
+    public synchronized void addApplication (Application application) {
+        this.applicationMap.put(application.getUniqueIdentifier(), application);
+        ApplicationLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(),
+                new ApplicationLock());
     }
 
     public Application getApplication (String appId) {
@@ -61,4 +65,9 @@ public class Applications implements Serializable {
     public Map<String, Application> getApplications() {
         return applicationMap;
     }
+
+    public synchronized void removeApplication (String appId) {
+        this.applicationMap.remove(appId);
+        ApplicationLockHierarchy.getInstance().removeLock(appId);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4f90be2/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index 0f128fa..a5780bb 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -37,42 +37,12 @@ public class Topology implements Serializable {
     private static final long serialVersionUID = -2453583548027402122L;
     // Key: Service.serviceName
     private Map<String, Service> serviceMap;
-    //Grouping
-    private Map<String, CompositeApplication> compositeApplicationMap;
-    // grouping_poc private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
-    // Key: Application.id
-    private Map<String, Application> applicationMap;
 
     private boolean initialized;
     private static Log log = LogFactory.getLog(Topology.class);
 
     public Topology() {
         this.serviceMap = new HashMap<String, Service>();
-        this.compositeApplicationMap = new HashMap<String, CompositeApplication>();
-        // grouping_poc this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
-        this.applicationMap = new HashMap<String, Application>();
-    }
-
-    public void addApplication (Application application) {
-        this.applicationMap.put(application.getUniqueIdentifier(), application);
-        TopologyLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(), new TopologyLock());
-    }
-
-    public Application getApplication (String applicationId) {
-        return applicationMap.get(applicationId);
-    }
-
-    public void removeApplication (String applicationId) {
-        applicationMap.remove(applicationId);
-        TopologyLockHierarchy.getInstance().removeTopologyLockForApplication(applicationId);
-    }
-
-    public Collection<Application> getApplications () {
-        return applicationMap.values();
-    }
-
-    public boolean applicationExists (String applicationId) {
-        return this.applicationMap.containsKey(applicationId);
     }
 
     public Collection<Service> getServices() {
@@ -111,87 +81,6 @@ public class Topology implements Serializable {
     public void clear() {
         this.serviceMap.clear();
     }
-    
-    // Grouping
-    public Collection<CompositeApplication> getCompositeApplication() {
-        return this.compositeApplicationMap.values();
-    }
-
-    public void addCompositeApplication(String alias, CompositeApplication app) {
-        this.compositeApplicationMap.put(alias, app);
-    }
-
-    public void removeCompositeApplication(String alias) {
-        this.compositeApplicationMap.remove(alias);
-    }
-    
- /* grouping_poc 
-    public Collection<ConfigCompositeApplication> getConfigCompositeApplication() {
-        
-        if (this.configCompositeApplicationMap == null) {
-    		log.info("adding new config comp in topology while retrieving it, ConfigCompositeApplication is  null");
-    		this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
-    	} 
-        return this.configCompositeApplicationMap.values();
-    }
-    
-    public void addConfigCompositeApplication(String alias, ConfigCompositeApplication configApp) {
-    	log.info("adding config comp in topology" + alias + " / " + configApp);
-    	if (this.configCompositeApplicationMap != null) {
-    		log.info("adding config comp in topology, ConfigCompositeApplication is not null");
-    		this.configCompositeApplicationMap.put(alias, configApp);
-    		log.info("successful config comp in topology, ConfigCompositeApplication is not null");
-    	} else {
-    		log.info("adding config comp in topology, ConfigCompositeApplication is null, adding one");
-    		this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
-    		this.configCompositeApplicationMap.put(alias, configApp);
-    	}
-    }
-
-    public void removeConfigCompositeApplication(String alias) {
-        this.configCompositeApplicationMap.remove(alias);
-    }
-
-    public void removeAllCompositeApplication() {
-    	java.util.Set<String> keys = this.compositeApplicationMap.keySet();
-    	for (String key : keys) {
-    		compositeApplicationMap.remove(key);
-    	}
-    }
-    
-    public void removeAllConfigCompositeApplication() {
-    	java.util.Set<String> keys = this.configCompositeApplicationMap.keySet();
-    	for (String key : keys) {
-    		configCompositeApplicationMap.remove(key);
-    	}
-    }
-
-    public CompositeApplication getCompositeApplication(String appAlias) {
-        return this.compositeApplicationMap.get(appAlias);
-    }
-
-    public boolean compositeApplicationExists(String appAlias) {
-        return this.compositeApplicationMap.containsKey(appAlias);
-    }
-    
-    public ConfigCompositeApplication getConfigCompositeApplication(String appAlias) {
-        return this.configCompositeApplicationMap.get(appAlias);
-    }
-
-    public boolean configCompositeApplicationExists(String appAlias) {
-        return this.configCompositeApplicationMap.containsKey(appAlias);
-    }
-
-
-    public Map<String, ConfigCompositeApplication> getConfigCompositeApplicationMap() {
-		return configCompositeApplicationMap;
-	}
-    
-    public void setConfigCompositeApplicationMap(Map<String, ConfigCompositeApplication> configCompositeApplicationMap) {
-		this.configCompositeApplicationMap = configCompositeApplicationMap;
-	}
-	
-	*/
 
 	public void setInitialized(boolean initialized) {
         this.initialized = initialized;


[04/50] [abbrv] git commit: resetting Cluster and Group statuses to Created from Terminating in Topology

Posted by im...@apache.org.
resetting Cluster and Group statuses to Created from Terminating in Topology


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

Branch: refs/heads/docker-grouping-merge
Commit: db1fd260a24dfceeb4b85312f7588defe4e4f30f
Parents: 38221db
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Thu Oct 30 18:25:30 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Thu Oct 30 18:25:30 2014 +0530

----------------------------------------------------------------------
 .../ApplicationStatusTopicReceiver.java         | 15 ++++
 .../controller/topology/TopologyBuilder.java    | 74 ++++++++++++++++++++
 .../topology/TopologyEventPublisher.java        |  9 +++
 .../ClusterCreatedMessageProcessor.java         |  9 +--
 .../topology/GroupCreatedProcessor.java         |  3 +-
 5 files changed, 105 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/db1fd260/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index 4d52fce..e155875 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -64,6 +64,13 @@ public class ApplicationStatusTopicReceiver implements Runnable {
 
     private void addEventListeners() {
         // Listen to topology events that affect clusters
+        statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterReset((AppStatusClusterCreatedEvent) event);
+            }
+        });
+
         statusEventReceiver.addEventListener(new AppStatusClusterActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
@@ -92,6 +99,14 @@ public class ApplicationStatusTopicReceiver implements Runnable {
             }
         });
 
+
+        statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleGroupReset((AppStatusGroupCreatedEvent) event);
+            }
+        });
+
         statusEventReceiver.addEventListener(new AppStatusGroupActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/db1fd260/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 1daec32..5d14971 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
@@ -114,6 +114,80 @@ public class TopologyBuilder {
         }
     }
 
+    public static void handleClusterReset (AppStatusClusterCreatedEvent event) {
+
+        TopologyManager.acquireWriteLock();
+
+        try {
+            Topology topology = TopologyManager.getTopology();
+            Service service = topology.getService(event.getServiceName());
+            if (service == null) {
+                log.error("Service " + event.getServiceName() +
+                        " not found in Topology, unable to update the cluster status to Created");
+                return;
+            }
+
+            Cluster cluster = service.getCluster(event.getClusterId());
+            if (cluster == null) {
+                log.error("Cluster " + event.getClusterId() + " not found in Topology, unable to update " +
+                        "status to Created");
+                return;
+            }
+
+            // update the cluster status to Created
+            if (!cluster.isStateTransitionValid(ClusterStatus.Created))  {
+                 log.error("Invalid state transition from " + cluster.getStatus() + " to " +
+                         ClusterStatus.Created + " for cluster id " + event.getClusterId());
+            }
+            // forcefully update the status
+            cluster.setStatus(ClusterStatus.Created);
+            TopologyManager.updateTopology(topology);
+
+        } finally {
+            TopologyManager.releaseWriteLock();
+        }
+
+        TopologyEventPublisher.sendClusterCreatedEvent(event.getAppId(), event.getServiceName(),
+                event.getClusterId());
+    }
+
+    public static void handleGroupReset (AppStatusGroupCreatedEvent event) {
+
+        TopologyManager.acquireWriteLock();
+
+        try {
+            Topology topology = TopologyManager.getTopology();
+
+            Application application = topology.getApplication(event.getAppId());
+            if (application == null) {
+                log.error("Application " + event.getAppId() +
+                        " not found in Topology, unable to update the Group status to Created");
+                return;
+            }
+
+            Group group = application.getGroupRecursively(event.getGroupId());
+            if (group == null) {
+                log.error("Group " + event.getGroupId() +
+                        " not found in Topology, unable to update the Group status to Created");
+                return;
+            }
+
+            // update the cluster status to Created
+            if (!group.isStateTransitionValid(GroupStatus.Created))  {
+                log.error("Invalid state transition from " + group.getStatus() + " to " +
+                        GroupStatus.Created + " for group " + event.getGroupId());
+            }
+            // forcefully update the status
+            group.setStatus(GroupStatus.Created);
+            TopologyManager.updateTopology(topology);
+
+        } finally {
+            TopologyManager.releaseWriteLock();
+        }
+
+        TopologyEventPublisher.sendGroupCreatedEvent(new GroupCreatedEvent(event.getAppId(), event.getGroupId()));
+    }
+
     public static void handleClusterCreated(Registrant registrant, boolean isLb) {
         /*Topology topology = TopologyManager.getTopology();
         Service service;

http://git-wip-us.apache.org/repos/asf/stratos/blob/db1fd260/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index a3feb4d..c9337d2 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -188,6 +188,15 @@ public class TopologyEventPublisher {
         publishEvent(memberMaintenanceModeEvent);
     }
 
+    public static void sendGroupCreatedEvent (GroupCreatedEvent groupCreatedEvent) {
+
+        if(log.isInfoEnabled()) {
+            log.info(String.format("Publishing group created event: [appId] %s [group] %s",
+                    groupCreatedEvent.getAppId(), groupCreatedEvent.getGroupId()));
+        }
+        publishEvent(groupCreatedEvent);
+    }
+
     public static void sendGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) {
         if(log.isInfoEnabled()) {
             log.info(String.format("Publishing group activated event: [appId] %s [group] %s",

http://git-wip-us.apache.org/repos/asf/stratos/blob/db1fd260/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
index 613c5df..b8cd80f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
@@ -20,10 +20,7 @@ package org.apache.stratos.messaging.message.processor.topology;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
 import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
 import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
@@ -125,6 +122,10 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
 
             // Apply changes to the topology
             Cluster cluster = service.getCluster(event.getClusterId());
+            if (!cluster.isStateTransitionValid(ClusterStatus.Created)) {
+                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " +
+                        "for cluster " + cluster.getClusterId());
+            }
             cluster.setStatus(ClusterStatus.Created);
             if (log.isInfoEnabled()) {
                 log.info(String.format("Cluster created: %s",

http://git-wip-us.apache.org/repos/asf/stratos/blob/db1fd260/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
index 4a8a744..b6d2da9 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java
@@ -96,7 +96,8 @@ public class GroupCreatedProcessor extends MessageProcessor {
         } else {
             // Apply changes to the topology
             if (!group.isStateTransitionValid(GroupStatus.Created)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created  + " " +
+                        "for Group " + group.getAlias());
             }
             group.setStatus(GroupStatus.Created);
 


[41/50] [abbrv] git commit: moving Application Parsing to Autoscaler

Posted by im...@apache.org.
moving Application Parsing to Autoscaler


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

Branch: refs/heads/docker-grouping-merge
Commit: b9aabfdcaca069ae77b3977c361215da80c53265
Parents: 7d7cd50
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 18:47:32 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 18:49:07 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   |  27 +-
 .../applications/ApplicationHolder.java         |  15 +-
 .../ApplicationSynchronizeTask.java             |   2 +-
 .../applications/ApplicationUtils.java          | 289 ++++++++
 .../applications/ClusterInformation.java        |  27 +
 .../applications/MTClusterInformation.java      |  47 ++
 .../applications/STClusterInformation.java      |  57 ++
 .../applications/parser/ApplicationParser.java  |  51 ++
 .../parser/DefaultApplicationParser.java        | 657 +++++++++++++++++++
 .../applications/parser/ParserUtils.java        | 142 ++++
 .../ApplicationCartridgePayloadData.java        |  27 +
 .../applications/payload/BasicPayloadData.java  | 311 +++++++++
 .../payload/DataCartridgePayloadData.java       |  27 +
 .../payload/FrameworkCartridgePayloadData.java  |  27 +
 .../LoadBalancerCartridgePayloadData.java       |  27 +
 .../applications/payload/PayloadData.java       |  69 ++
 .../applications/payload/PayloadFactory.java    |  59 ++
 .../pojo/ApplicationClusterContext.java         | 137 ++++
 .../applications/pojo/ApplicationContext.java   |  93 +++
 .../applications/pojo/ComponentContext.java     |  54 ++
 .../applications/pojo/DependencyContext.java    |  44 ++
 .../applications/pojo/GroupContext.java         |  84 +++
 .../applications/pojo/SubscribableContext.java  |  44 ++
 .../pojo/SubscribableInfoContext.java           | 103 +++
 .../applications/topic/ApplicationBuilder.java  |  44 ++
 .../topic/ApplicationsEventPublisher.java       |  14 +-
 .../cloud/controller/CloudControllerClient.java |  16 +
 .../ApplicationDefinitionException.java         |  48 ++
 .../CartridgeInformationException.java          |  47 ++
 .../interfaces/AutoScalerServiceInterface.java  |  18 +
 .../autoscaler/registry/RegistryManager.java    |   5 +
 .../stratos/autoscaler/util/AutoscalerUtil.java |   4 +
 32 files changed, 2603 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 8c4bf2e..4938b4c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -22,6 +22,10 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
+import org.apache.stratos.autoscaler.applications.parser.ApplicationParser;
+import org.apache.stratos.autoscaler.applications.parser.DefaultApplicationParser;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.*;
@@ -34,7 +38,7 @@ import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
-import org.wso2.carbon.registry.api.RegistryException;
+import org.apache.stratos.messaging.domain.applications.Application;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -248,8 +252,25 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface{
 
         return null;
     }
-	
-	public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) {
+
+    @Override
+    public void deployApplicationDefinition(ApplicationContext applicationContext)
+            throws ApplicationDefinitionException {
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        Application application = applicationParser.parse(applicationContext);
+        ApplicationBuilder.handleApplicationCreated(application,
+                applicationParser.getApplicationClusterContexts());
+    }
+
+    @Override
+    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain)
+            throws ApplicationDefinitionException {
+
+        ApplicationBuilder.handleApplicationUndeployed(applicationId);
+    }
+
+    public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) {
 
         for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
index e147d1b..6d16677 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java
@@ -94,9 +94,6 @@ public class ApplicationHolder {
     public static void persistApplication (Application application) {
 
         synchronized (ApplicationHolder.class) {
-            if (log.isDebugEnabled()) {
-                log.debug("Updating topology");
-            }
             applications.addApplication(application);
             AutoscalerUtil.persistApplication(application);
             if (log.isDebugEnabled()) {
@@ -106,6 +103,18 @@ public class ApplicationHolder {
 
     }
 
+    public static void removeApplication (String applicationId) {
+
+        synchronized (ApplicationHolder.class) {
+            applications.removeApplication(applicationId);
+            AutoscalerUtil.removeApplication(applicationId);
+            if (log.isDebugEnabled()) {
+                log.debug("Application [ " + applicationId + " ] removed from Applications");
+            }
+        }
+
+    }
+
     private static String toJson(Object object) {
         Gson gson = new Gson();
         return gson.toJson(object);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
index e18cd12..9f0ca8c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java
@@ -36,7 +36,7 @@ public class ApplicationSynchronizeTask implements Task {
         }
         // publish to the topic
         if (ApplicationHolder.getApplications() != null) {
-            ApplicationsEventPublisher.sendCompleteTopologyEvent(ApplicationHolder.getApplications());
+            ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java
new file mode 100644
index 0000000..e82882c
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.payload.BasicPayloadData;
+import org.apache.stratos.autoscaler.applications.payload.PayloadData;
+import org.apache.stratos.autoscaler.applications.payload.PayloadFactory;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
+import org.apache.stratos.cloud.controller.stub.pojo.PortMapping;
+import org.apache.stratos.cloud.controller.stub.pojo.Property;
+
+import java.util.*;
+import java.util.regex.Pattern;
+
+public class ApplicationUtils {
+    private static final Log log = LogFactory.getLog(ApplicationUtils.class);
+
+    public static boolean isAliasValid (String alias) {
+
+        String patternString = "([a-z0-9]+([-][a-z0-9])*)+";
+        Pattern pattern = Pattern.compile(patternString);
+
+        return pattern.matcher(alias).matches();
+    }
+
+    public static boolean isValid (String arg) {
+
+        if (arg == null || arg.isEmpty()) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    public static Properties getGlobalPayloadData () {
+
+        Properties globalProperties = new Properties();
+
+        if (System.getProperty("puppet.ip") != null) {
+            globalProperties.setProperty("PUPPET_IP", System.getProperty("puppet.ip"));
+        }
+        if (System.getProperty("puppet.hostname") != null) {
+            globalProperties.setProperty("PUPPET_HOSTNAME", System.getProperty("puppet.hostname"));
+        }
+        if (System.getProperty("puppet.env") != null) {
+            globalProperties.setProperty("PUPPET_ENV", System.getProperty("puppet.env"));
+        }
+        if (System.getProperty("puppet.dns.available") != null) {
+            globalProperties.setProperty("PUPPET_DNS_AVAILABLE", System.getProperty("puppet.dns.available"));
+        }
+
+        return globalProperties;
+    }
+
+//    public static MetaDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key,
+//                                                                String hostname, String tenantRange, String clusterId,
+//                                                                SubscribableContext subscribableCtxt,
+//                                                                SubscribableInfoContext subscribableInfoCtxt,
+//                                                                Cartridge cartridge) {
+//
+//        MetaDataHolder metaDataHolder;
+//        if (groupName != null) {
+//            metaDataHolder = new MetaDataHolder(appId, groupName, clusterId);
+//        } else {
+//            metaDataHolder = new MetaDataHolder(appId, clusterId);
+//        }
+//
+//        Properties clusterLevelPayloadProperties = new Properties();
+//        // app id
+//        clusterLevelPayloadProperties.setProperty("APP_ID", appId);
+//        // group name
+//        if (groupName != null) {
+//            clusterLevelPayloadProperties.setProperty("GROUP_NAME", groupName);
+//        }
+//        // service name
+//        if (subscribableCtxt.getType() != null) {
+//            clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType());
+//        }
+//        // host name
+//        if  (hostname != null) {
+//            clusterLevelPayloadProperties.put("HOST_NAME", hostname);
+//        }
+//        // multi tenant
+//        clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant()));
+//        // tenant range
+//        if (tenantRange != null) {
+//            clusterLevelPayloadProperties.put("TENANT_RANGE", tenantRange);
+//        }
+//        // cartridge alias
+//        if (subscribableCtxt.getAlias() != null) {
+//            clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias());
+//        }
+//        // cluster id
+//        if (clusterId != null) {
+//            clusterLevelPayloadProperties.put("CLUSTER_ID", clusterId);
+//        }
+//        // repo url
+//        if (subscribableInfoCtxt.getRepoUrl() != null) {
+//            clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl());
+//        }
+//        // ports
+////        if (createPortMappingPayloadString(cartridge) != null) {
+////            clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge));
+////        }
+//        // provider
+//        if (cartridge.getProvider() != null) {
+//            clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider());
+//        }
+//        // tenant id
+//        clusterLevelPayloadProperties.setProperty("TENANT_ID", String.valueOf(tenantId));
+//        // cartridge key
+//        clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key);
+//        // get global payload params
+//        //clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData());
+//
+//        metaDataHolder.setProperties(clusterLevelPayloadProperties);
+//        return metaDataHolder;
+//    }
+
+    private static String createPortMappingPayloadString (CartridgeInfo cartridge) {
+
+        // port mappings
+        StringBuilder portMapBuilder = new StringBuilder();
+        PortMapping[] portMappings = cartridge.getPortMappings();
+        for (PortMapping portMapping : portMappings) {
+            String port = portMapping.getPort();
+            portMapBuilder.append(port).append("|");
+        }
+
+        // remove last "|" character
+        String portMappingString = portMapBuilder.toString().replaceAll("\\|$", "");
+
+        return portMappingString;
+    }
+
+    public static StringBuilder getTextPayload (String appId, String groupName, String clusterId) {
+
+        StringBuilder payloadBuilder = new StringBuilder();
+        payloadBuilder.append("APP_ID=" + appId);
+        if (groupName != null) {
+            payloadBuilder.append(",");
+            payloadBuilder.append("GROUP_NAME=" + groupName);
+        }
+        payloadBuilder.append(",");
+        payloadBuilder.append("CLUSTER_ID=" + clusterId);
+        // puppet related
+        if (System.getProperty("puppet.ip") != null) {
+            payloadBuilder.append(",");
+            payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip"));
+        }
+        if (System.getProperty("puppet.hostname") != null) {
+            payloadBuilder.append(",");
+            payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname"));
+        }
+        if (System.getProperty("puppet.env") != null) {
+            payloadBuilder.append(",");
+            payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.env"));
+        }
+        if (System.getProperty("puppet.dns.available") != null) {
+            payloadBuilder.append(",");
+            payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.dns.available"));
+        }
+        // meta data endpoint
+       // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) {
+            // TODO
+            //payloadBuilder.append(",");
+            //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl());
+       // }
+        payloadBuilder.append(",");
+
+        return payloadBuilder;
+    }
+
+    public static PayloadData createPayload(String appId, String groupName, CartridgeInfo cartridgeInfo, String subscriptionKey, int tenantId, String clusterId,
+                                            String hostName, String repoUrl, String alias, Map<String, String> customPayloadEntries, String[] dependencyAliases)
+            throws ApplicationDefinitionException {
+
+        //Create the payload
+        BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridgeInfo, subscriptionKey,
+                clusterId, hostName, repoUrl, alias, tenantId, dependencyAliases);
+        //Populate the basic payload details
+        basicPayloadData.populatePayload();
+
+        PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridgeInfo.getProvider(),
+                cartridgeInfo.getType(), basicPayloadData);
+
+        boolean isDeploymentParam = false;
+        // get the payload parameters defined in the cartridgeInfo definition file for this cartridgeInfo type
+        if (cartridgeInfo.getProperties() != null && cartridgeInfo.getProperties().length != 0) {
+
+            for (Property propertyEntry : cartridgeInfo.getProperties()) {
+                // check if a property is related to the payload. Currently this is done by checking if the
+                // property name starts with 'payload_parameter.' suffix. If so the payload param name will
+                // be taken as the substring from the index of '.' to the end of the property name.
+                if (propertyEntry.getName()
+                        .startsWith("payload_parameter.")) {
+                    String payloadParamName = propertyEntry.getName();
+                    String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1);
+                    if("DEPLOYMENT".equals(payloadParamSubstring)) {
+                        isDeploymentParam = true;
+                    }
+                    payloadData.add(payloadParamSubstring, propertyEntry.getValue());
+                }
+            }
+        }
+
+        // DEPLOYMENT payload param must be set because its used by puppet agent
+        // to generate the hostname. Therefore, if DEPLOYMENT is not set in cartridgeInfo properties,
+        // adding the DEPLOYMENT="default" param
+        if(!isDeploymentParam) {
+            payloadData.add("DEPLOYMENT", "default");
+        }
+        //check if there are any custom payload entries defined
+        if (customPayloadEntries != null) {
+            //add them to the payload
+            Set<Map.Entry<String,String>> entrySet = customPayloadEntries.entrySet();
+            for (Map.Entry<String, String> entry : entrySet) {
+                payloadData.add(entry.getKey(), entry.getValue());
+            }
+        }
+
+        return payloadData;
+    }
+
+    private static BasicPayloadData createBasicPayload(String appId, String groupName, CartridgeInfo cartridge,
+                                                       String subscriptionKey, String clusterId,
+                                                       String hostName, String repoUrl, String alias,
+                                                       int tenantId, String[] dependencyAliases) {
+
+        BasicPayloadData basicPayloadData = new BasicPayloadData();
+        basicPayloadData.setAppId(appId);
+        basicPayloadData.setGroupName(groupName);
+        basicPayloadData.setApplicationPath(cartridge.getBaseDir());
+        basicPayloadData.setSubscriptionKey(subscriptionKey);
+        //basicPayloadData.setDeployment("default");//currently hard coded to default
+        basicPayloadData.setMultitenant(String.valueOf(cartridge.getMultiTenant()));
+        basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridge));
+        basicPayloadData.setServiceName(cartridge.getType());
+        basicPayloadData.setProvider(cartridge.getProvider());
+
+        if(repoUrl != null) {
+            basicPayloadData.setGitRepositoryUrl(repoUrl);
+        }
+
+        if (clusterId != null) {
+            basicPayloadData.setClusterId(clusterId);
+        }
+
+        if (hostName != null) {
+            basicPayloadData.setHostName(hostName);
+        }
+
+        if (alias != null) {
+            basicPayloadData.setSubscriptionAlias(alias);
+        }
+
+        basicPayloadData.setTenantId(tenantId);
+
+        basicPayloadData.setTenantRange("*");
+        basicPayloadData.setDependencyAliases(dependencyAliases);
+//        if(cartridge.getExportingProperties() != null){
+//            basicPayloadData.setExportingProperties(cartridge.getExportingProperties());
+//            log.info("testing1 getExportingProperties " + cartridge.getExportingProperties());
+//
+//        }
+
+        return basicPayloadData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java
new file mode 100644
index 0000000..5fd6d57
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.application;
+
+public interface ClusterInformation {
+
+    public String getClusterId (String alias, String cartridgeType);
+
+    public String getHostName (String alias, String cartridgeDefinitionHostName);
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java
new file mode 100644
index 0000000..a0a59d4
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.apache.stratos.cloud.controller.application.ClusterInformation;
+
+public class MTClusterInformation implements ClusterInformation {
+
+    @Override
+    public String getClusterId(String alias, String cartridgeType) {
+
+        if (!ApplicationUtils.isValid(cartridgeType))  {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]");
+        }
+
+        return cartridgeType + ".domain";
+    }
+
+    @Override
+    public String getHostName(String alias, String cartridgeDefinitionHostName) {
+
+        if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]");
+        }
+
+        return cartridgeDefinitionHostName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java
new file mode 100644
index 0000000..9a5bea8
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications;
+
+import org.apache.stratos.cloud.controller.application.ClusterInformation;
+
+public class STClusterInformation implements ClusterInformation {
+
+    @Override
+    public String getClusterId(String alias, String cartridgeType) {
+
+        if (!ApplicationUtils.isValid(alias)) {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]");
+        }
+
+        if (!ApplicationUtils.isValid(cartridgeType))  {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]");
+        }
+
+        return alias + "." + cartridgeType + ".domain";
+    }
+
+    @Override
+    public String getHostName(String alias, String cartridgeDefinitionHostName) {
+
+        if (!ApplicationUtils.isValid(alias)) {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]");
+        }
+
+        if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) {
+            // cannot happen
+            throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]");
+        }
+
+        return alias + "." + cartridgeDefinitionHostName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
new file mode 100644
index 0000000..529c1f8
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.parser;
+
+
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+import org.apache.stratos.messaging.domain.applications.Application;
+
+import java.util.Set;
+
+
+public interface ApplicationParser {
+
+    /**
+     * Parses the Application Definition
+     *
+     * @param obj Object with the Application Definition. An Object is used here since there can be
+     *            significant changes between the way composite Applications are defined in different
+     *            conventions
+     * @return Application structure denoting the parsed Application
+     * @throws ApplicationDefinitionException If the Application Definition is invalid
+     */
+    public Application parse (Object obj) throws ApplicationDefinitionException;
+
+    /**
+     * Returns a set of ApplicationClusterContext which will comprise of cluster related information
+     * extracted from the Application definition
+     *
+     * @return  Set of ApplicationClusterContext objects
+     * @throws ApplicationDefinitionException if any error occurs
+     */
+    public Set<ApplicationClusterContext> getApplicationClusterContexts() throws ApplicationDefinitionException;
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
new file mode 100644
index 0000000..8184743
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -0,0 +1,657 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.parser;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.ApplicationUtils;
+import org.apache.stratos.autoscaler.applications.MTClusterInformation;
+import org.apache.stratos.autoscaler.applications.STClusterInformation;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.pojo.GroupContext;
+import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext;
+import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext;
+import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+import org.apache.stratos.autoscaler.exception.CartridgeInformationException;
+import org.apache.stratos.autoscaler.pojo.ServiceGroup;
+import org.apache.stratos.autoscaler.registry.RegistryManager;
+import org.apache.stratos.cloud.controller.application.ClusterInformation;
+import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext;
+import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
+import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.DependencyOrder;
+import org.apache.stratos.messaging.domain.applications.Group;
+
+import java.util.*;
+
+public class DefaultApplicationParser implements ApplicationParser {
+
+    private static Log log = LogFactory.getLog(DefaultApplicationParser.class);
+
+//    private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
+
+    private Set<ApplicationClusterContext> applicationClusterContexts;
+
+    public DefaultApplicationParser () {
+
+        this.applicationClusterContexts = new HashSet<ApplicationClusterContext>();
+    }
+
+    @Override
+    public Application parse(Object obj) throws ApplicationDefinitionException {
+
+        ApplicationContext applicationCtxt = (ApplicationContext) obj;
+
+        if (applicationCtxt == null) {
+            handleError("Invalid Composite Application Definition");
+        }
+
+        assert applicationCtxt != null;
+        if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) {
+            handleError("Invalid alias specified");
+        }
+
+        if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) {
+            handleError("Invalid Composite App id specified");
+        }
+
+        // get the defined groups
+        Map<String, GroupContext> definedGroups = getDefinedGroups(applicationCtxt);
+        if (log.isDebugEnabled()) {
+            if (definedGroups != null) {
+                Set<Map.Entry<String, GroupContext>> groupEntries = definedGroups.entrySet();
+                log.debug("Defined Groups: [ ");
+                for (Map.Entry<String, GroupContext> groupEntry : groupEntries) {
+                    log.debug("Group alias: " + groupEntry.getKey());
+                }
+                log.debug(" ]");
+            } else {
+                log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId());
+            }
+        }
+
+        // get the Subscribables Information
+        Map<String, SubscribableInfoContext> subscribablesInfo = getSubscribableInformation(applicationCtxt);
+        if (log.isDebugEnabled()) {
+            Set<Map.Entry<String, SubscribableInfoContext>> subscribableInfoCtxtEntries = subscribablesInfo.entrySet();
+            log.debug("Defined Subscribable Information: [ ");
+            for (Map.Entry<String, SubscribableInfoContext> subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) {
+                log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey());
+            }
+            log.debug(" ]");
+        }
+
+        if (subscribablesInfo == null) {
+            handleError("Invalid Composite Application Definition, no Subscribable Information specified");
+        }
+
+        return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo);
+    }
+
+    @Override
+    public Set<ApplicationClusterContext> getApplicationClusterContexts() throws ApplicationDefinitionException {
+        return applicationClusterContexts;
+    }
+
+    /**
+     * Extract Group information from Application Definition
+     *
+     * @param appCtxt ApplicationContext object with Application information
+     * @return Map [group alias -> Group]
+     *
+     * @throws ApplicationDefinitionException if the Group information is invalid
+     */
+    private Map<String, GroupContext> getDefinedGroups (ApplicationContext appCtxt) throws
+            ApplicationDefinitionException {
+
+        // map [group alias -> Group Definition]
+        Map<String, GroupContext> definedGroups = null;
+
+        if (appCtxt.getComponents() != null) {
+            if (appCtxt.getComponents().getGroupContexts() != null) {
+                definedGroups = new HashMap<String, GroupContext>();
+
+                for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) {
+
+                    // check validity of group name
+                    if (StringUtils.isEmpty(groupContext.getName())) {
+                        handleError("Invalid Group name specified");
+                    }
+
+                    // check if group is deployed
+                    if(!isGroupDeployed(groupContext.getName())) {
+                        handleError("Group with name " + groupContext.getName() + " not deployed");
+                    }
+
+                    // check validity of group alias
+
+                    if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) {
+                        handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]");
+                    }
+
+                    // check if a group is already defined under the same alias
+                    if(definedGroups.get(groupContext.getAlias()) != null) {
+                        // a group with same alias already exists, can't continue
+                        handleError("A Group with alias " + groupContext.getAlias() + " already exists");
+                    }
+
+                    definedGroups.put(groupContext.getAlias(), groupContext);
+                    if (log.isDebugEnabled()) {
+                        log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]");
+                    }
+                }
+            }
+        }
+
+        return definedGroups;
+    }
+
+    /**
+     * Extract Subscription Information from the Application Definition
+     *
+     * @param appCtxt ApplicationContext object with Application information
+     * @return Map [cartridge alias -> Group]
+     *
+     * @throws ApplicationDefinitionException if the Subscription information is invalid
+     */
+    private Map<String, SubscribableInfoContext> getSubscribableInformation (ApplicationContext appCtxt) throws
+            ApplicationDefinitionException {
+
+        // map [cartridge alias -> Subscribable Information]
+        Map<String, SubscribableInfoContext> subscribableInformation = null;
+
+        if (appCtxt.getSubscribableInfoContext() != null) {
+            subscribableInformation = new HashMap<String, SubscribableInfoContext>();
+
+            for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) {
+
+                if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) ||
+                        !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) {
+                    handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]");
+                }
+
+                // check if a group is already defined under the same alias
+                if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) {
+                    // a group with same alias already exists, can't continue
+                    handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists");
+                }
+
+                subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt);
+                if (log.isDebugEnabled()) {
+                    log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]");
+                }
+            }
+        }
+
+        return subscribableInformation;
+    }
+
+    /**
+     * Check if a Group Definition is deployed
+     *
+     * @param serviceGroupName Group name
+     * @return true if the Group is deployed, else false
+     *
+     * @throws ApplicationDefinitionException
+     */
+    private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException {
+
+        try {
+            return RegistryManager.getInstance().getServiceGroup(serviceGroupName) != null;
+        } catch (Exception e) {
+            String errorMsg = "Error in checking if Service Group Definition [ " + serviceGroupName
+                    + " ] already exists";
+            log.error(errorMsg, e);
+            throw new ApplicationDefinitionException(errorMsg, e);
+        }
+    }
+
+    /**
+     * Builds the Application structure
+     *
+     * @param appCtxt ApplicationContext object with Application information
+     * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information
+     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+     * @return Application Application object denoting the Application structure
+     *
+     * @throws ApplicationDefinitionException If an error occurs in building the Application structure
+     */
+    private Application buildCompositeAppStructure (ApplicationContext appCtxt,
+                                                            Map<String, GroupContext> definedGroupCtxts,
+                                                            Map<String, SubscribableInfoContext> subscribableInfoCtxts)
+            throws ApplicationDefinitionException {
+
+        Application application = new Application(appCtxt.getApplicationId());
+
+        // set tenant related information
+        application.setTenantId(appCtxt.getTenantId());
+        application.setTenantDomain(appCtxt.getTenantDomain());
+        application.setTenantAdminUserName(appCtxt.getTeantAdminUsername());
+
+        // following keeps track of all Clusters created for this application
+        //Set<Cluster> clusters = new HashSet<Cluster>();
+        //ClusterDataHolder clusterDataHolder = null;
+        Map<String, ClusterDataHolder> clusterDataMap;
+
+        if (appCtxt.getComponents() != null) {
+            // get top level Subscribables
+            if (appCtxt.getComponents().getSubscribableContexts() != null) {
+                clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(),
+                        application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()),
+                        subscribableInfoCtxts);
+                application.setClusterData(clusterDataMap);
+                //clusters.addAll(clusterDataHolder.getApplicationClusterContexts());
+            }
+
+            // get Groups
+            if (appCtxt.getComponents().getGroupContexts() != null) {
+                application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(),
+                        application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()),
+                        subscribableInfoCtxts, definedGroupCtxts));
+            }
+
+            // get top level Dependency definitions
+            if (appCtxt.getComponents().getDependencyContext() != null) {
+                DependencyOrder appDependencyOrder = new DependencyOrder();
+                String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts();
+                if (startupOrders != null) {
+                	if (log.isDebugEnabled()) {
+                    	log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + 
+                    				appCtxt.getAlias() + " #: " + startupOrders.length);
+                    }
+                    appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders));
+                } else {
+                	if (log.isDebugEnabled()) {
+                    	log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias());
+                    }
+                }
+                String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour();
+                validateTerminationBehavior(terminationBehavior);
+                appDependencyOrder.setTerminationBehaviour(terminationBehavior);
+
+                application.setDependencyOrder(appDependencyOrder);
+            }
+        }
+
+        log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully");
+
+        return application;
+    }
+
+    /**
+     * Validates terminationBehavior. The terminationBehavior should be one of the following:
+     *      1. terminate-none
+     *      2. terminate-dependents
+     *      3. terminate-all
+     *
+     * @throws ApplicationDefinitionException if terminationBehavior is different to what is
+     * listed above
+     */
+    private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException {
+
+        if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) ||
+                "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) {
+            throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " +
+                    terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " +
+                    " 'terminate-all' ");
+        }
+    }
+
+    /**
+     * Parse Group information
+     *
+     * @param appId Application id
+     * @param tenantId tenant id of tenant which deployed the Application
+     * @param key Generated key for the Application
+     * @param groupCtxts  Group information
+     * @param subscribableInformation Subscribable Information
+     * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
+     * @return Map [alias -> Group]
+     *
+     * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
+     */
+    private Map<String, Group> parseGroups (String appId, int tenantId, String key, List<GroupContext> groupCtxts,
+                                           Map<String, SubscribableInfoContext> subscribableInformation,
+                                           Map<String, GroupContext> definedGroupCtxts)
+            throws ApplicationDefinitionException {
+
+        Map<String, Group> groupAliasToGroup = new HashMap<String, Group>();
+
+        for (GroupContext groupCtxt : groupCtxts) {
+            Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts);
+            groupAliasToGroup.put(group.getAlias(), group);
+        }
+
+        //Set<GroupContext> topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup);
+        Set<Group> nestedGroups = new HashSet<Group>();
+        getNestedGroupContexts(nestedGroups, groupAliasToGroup.values());
+        filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups);
+
+        return groupAliasToGroup;
+    }
+
+    /**
+     * Extracts nested Group information recursively
+     *
+     * @param nestedGroups Nested Groups set to be populated recursively
+     * @param groups Collection of Groups
+     */
+    private void getNestedGroupContexts (Set<Group> nestedGroups, Collection<Group> groups) {
+
+        if (groups != null) {
+            for (Group group : groups) {
+                if (group.getGroups() != null) {
+                    nestedGroups.addAll(group.getGroups());
+                    getNestedGroupContexts(nestedGroups, group.getGroups());
+                }
+            }
+        }
+    }
+
+    /**
+     * Filters duplicated Groups from top level
+     *
+     * @param topLevelGroups Top level Groups
+     * @param nestedGroups nested Groups
+     */
+    private void filterDuplicatedGroupContexts (Collection<Group> topLevelGroups, Set<Group> nestedGroups) {
+
+        for (Group nestedGroup : nestedGroups) {
+            filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup);
+        }
+    }
+
+    private void filterNestedGroupFromTopLevel (Collection<Group> topLevelGroups, Group nestedGroup) {
+
+        Iterator<Group> parentIterator = topLevelGroups.iterator();
+        while (parentIterator.hasNext()) {
+            Group parentGroup = parentIterator.next();
+            // if there is an exactly similar nested Group Context and a top level Group Context
+            // it implies that they are duplicates. Should be removed from top level.
+            if (parentGroup.equals(nestedGroup)) {
+                parentIterator.remove();
+            }
+        }
+    }
+
+    /**
+     * Parses an individual Group
+     *
+     * @param appId Application id
+     * @param tenantId tenant id of tenant which deployed the Application
+     * @param key Generated key for the Application
+     * @param groupCtxt Group definition information
+     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+     * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
+     * @return  Group object
+     *
+     * @throws ApplicationDefinitionException if unable to parse
+     */
+    private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt,
+                             Map<String, SubscribableInfoContext> subscribableInfoCtxts,
+                             Map<String, GroupContext> definedGroupCtxts)
+            throws ApplicationDefinitionException {
+
+        // check if are in the defined Group set
+        GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias());
+        if (definedGroupDef == null) {
+            handleError("Group Definition with name: " + groupCtxt.getName() + ", alias: " +
+                    groupCtxt.getAlias() + " is not found in the all Group Definitions collection");
+        }
+
+        Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias());
+
+        group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy());
+        group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy());
+        DependencyOrder dependencyOrder = new DependencyOrder();
+        // create the Dependency Ordering
+        String []  startupOrders = getStartupOrderForGroup(groupCtxt);
+        if (startupOrders != null) {
+            dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt));
+        }
+        dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName()));
+        group.setDependencyOrder(dependencyOrder);
+
+        Map<String, ClusterDataHolder> clusterDataMap;
+
+        // get group level Subscribables
+        if (groupCtxt.getSubscribableContexts() != null) {
+            clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(),
+                    Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts);
+            group.setClusterData(clusterDataMap);
+        }
+
+        // get nested groups
+        if (groupCtxt.getGroupContexts() != null) {
+            Map<String, Group> nestedGroups = new HashMap<String, Group>();
+            // check sub groups
+            for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) {
+                // get the complete Group Definition
+                subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias());
+                Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt,
+                        subscribableInfoCtxts,
+                        definedGroupCtxts);
+                nestedGroups.put(nestedGroup.getAlias(), nestedGroup);
+            }
+
+            group.setGroups(nestedGroups);
+        }
+
+        return group;
+    }
+
+    /**
+     * Find the startup order
+     *
+     * @param groupContext GroupContext with Group defintion information
+     * @return Set of Startup Orders which are defined in the Group
+     *
+     * @throws ApplicationDefinitionException
+     */
+    private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
+
+        ServiceGroup serviceGroup = null;
+        try {
+            serviceGroup = RegistryManager.getInstance().getServiceGroup(groupContext.getName());
+        } catch (Exception e) {
+            String errorMsg = "Error in getting Service Group Definition for [ " + groupContext.getName() +
+                    " ] from Registry";
+            log.error(errorMsg, e);
+            throw new ApplicationDefinitionException(errorMsg, e);
+        }
+
+        if (serviceGroup == null) {
+            handleError("Service Group Definition not found for name " + groupContext.getName());
+        }
+        
+        if (log.isDebugEnabled()) {
+        	log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName());
+        }
+
+        assert serviceGroup != null;
+        if (serviceGroup.getDependencies() != null) {
+        	if (log.isDebugEnabled()) {
+            	log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " );
+            }
+            if (serviceGroup.getDependencies().getStartupOrders() != null) {
+            	
+            	String [] startupOrders = serviceGroup.getDependencies().getStartupOrders();
+            	if (log.isDebugEnabled()) {
+                	log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " +  startupOrders.length);
+                }
+                return startupOrders;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Get kill behaviour related to a Group
+     *
+     * @param serviceGroupName Group name
+     * @return String indicating the kill behavior
+     *
+     * @throws ApplicationDefinitionException if an error occurs
+     */
+    private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException {
+
+        ServiceGroup serviceGroup = null;
+        try {
+            serviceGroup = RegistryManager.getInstance().getServiceGroup(serviceGroupName);
+        } catch (Exception e) {
+            String errorMsg = "Error in getting Service Group Definition for [ " + serviceGroupName +
+                    " ] from Registry";
+            log.error(errorMsg, e);
+            throw new ApplicationDefinitionException(errorMsg, e);
+        }
+
+        if (serviceGroup == null) {
+            handleError("Service Group Definition not found for name " + serviceGroupName);
+        }
+
+        assert serviceGroup != null;
+        if (serviceGroup.getDependencies() != null) {
+            return serviceGroup.getDependencies().getKillBehaviour();
+        }
+
+        return null;
+
+    }
+
+    /**
+     * Parse Subscription Information
+     *
+     * @param appId Application id
+     * @param tenantId Tenant id of tenant which deployed the Application
+     * @param key Generated key for the Application
+     * @param groupName Group name (if relevant)
+     * @param subscribableCtxts Subscribable Information
+     * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+     * @return Map [subscription alias -> ClusterDataHolder]
+     *
+     * @throws ApplicationDefinitionException
+     */
+    private Map<String, ClusterDataHolder> parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName,
+                                                                 List<SubscribableContext> subscribableCtxts,
+                                                                 Map<String, SubscribableInfoContext> subscribableInfoCtxts)
+            throws ApplicationDefinitionException {
+
+        Map<String, ClusterDataHolder> clusterDataMap = new HashMap<String, ClusterDataHolder>();
+
+        for (SubscribableContext subscribableCtxt : subscribableCtxts) {
+
+            // check is there is a related Subscribable Information
+            SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias());
+            if (subscribableInfoCtxt == null) {
+                handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: "
+                        + subscribableCtxt.getAlias());
+            }
+
+            // check if Cartridge Type is valid
+            if (StringUtils.isEmpty(subscribableCtxt.getType())) {
+                handleError("Invalid Cartridge Type specified : [ "
+                        + subscribableCtxt.getType() + " ]");
+            }
+
+            // check if a cartridgeInfo with relevant type is already deployed. else, can't continue
+            CartridgeInfo cartridgeInfo =  getCartridge(subscribableCtxt.getType());
+            if (cartridgeInfo == null) {
+                handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() +
+                        " ] for Composite Application");
+            }
+
+            // get hostname and cluster id
+            ClusterInformation clusterInfo;
+            assert cartridgeInfo != null;
+            if (cartridgeInfo.getMultiTenant()) {
+                clusterInfo = new MTClusterInformation();
+            } else {
+                clusterInfo = new STClusterInformation();
+            }
+
+            String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridgeInfo.getHostName());
+            String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType());
+
+            // create and collect this cluster's information
+            assert subscribableInfoCtxt != null;
+            ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridgeInfo,
+                    key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(),
+                    clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases());
+
+            appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy());
+            this.applicationClusterContexts.add(appClusterCtxt);
+
+            // add relevant information to the map
+            clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId));
+        }
+
+        return clusterDataMap;
+    }
+
+    /**
+     * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
+     *
+     * @param appId Application id
+     * @param groupName Group name
+     * @param cartridgeInfo Cartridge information
+     * @param subscriptionKey Generated key for the Application
+     * @param tenantId Tenant Id of the tenant which deployed the Application
+     * @param repoUrl Repository URL
+     * @param alias alias specified for this Subscribable in the Application Definition
+     * @param clusterId Cluster id
+     * @param hostname Hostname
+     * @param deploymentPolicy Deployment policy used
+     * @param isLB if this cluster is an LB
+     * @return ApplicationClusterContext object with relevant information
+     *
+     * @throws ApplicationDefinitionException If any error occurs
+     */
+    private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, CartridgeInfo cartridgeInfo,
+                                                                       String subscriptionKey, int tenantId, String repoUrl,
+                                                                       String alias, String clusterId, String hostname,
+                                                                       String deploymentPolicy, boolean isLB, String[] dependencyAliases)
+            throws ApplicationDefinitionException {
+
+        // Create text payload
+        String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridgeInfo, subscriptionKey, tenantId, clusterId,
+                hostname, repoUrl, alias, null, dependencyAliases).toString();
+
+        return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB);
+    }
+
+    private CartridgeInfo getCartridge (String cartridgeType) throws ApplicationDefinitionException {
+
+        try {
+            return CloudControllerClient.getInstance().getCartrdgeInformation(cartridgeType);
+        } catch (CartridgeInformationException e) {
+            throw new ApplicationDefinitionException(e);
+        }
+    }
+
+    private void handleError (String errorMsg) throws ApplicationDefinitionException {
+        log.error(errorMsg);
+        throw new ApplicationDefinitionException(errorMsg);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
new file mode 100644
index 0000000..162ead7
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.parser;
+
+import org.apache.stratos.autoscaler.applications.pojo.GroupContext;
+import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext;
+import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+import org.apache.stratos.messaging.domain.applications.StartupOrder;
+
+import java.util.*;
+
+public class ParserUtils {
+
+    public static Set<StartupOrder> convert (String [] startupOrderArr) throws ApplicationDefinitionException {
+
+        Set<StartupOrder> startupOrders = new HashSet<StartupOrder>();
+
+        if (startupOrderArr == null) {
+            return startupOrders;
+        }
+
+        for (String commaSeparatedStartupOrder : startupOrderArr) {
+            startupOrders.add(getStartupOrder(commaSeparatedStartupOrder));
+        }
+
+        return startupOrders;
+    }
+
+    private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) throws ApplicationDefinitionException{
+
+        List<String> startupOrders = new ArrayList<String>();
+
+        for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) {
+            startupOrder = startupOrder.trim();
+            if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group.")) {
+                throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.' or 'group.'");
+            }
+
+            startupOrders.add(startupOrder);
+        }
+
+        return new StartupOrder(startupOrders);
+    }
+
+    public static Set<StartupOrder> convert (String [] startupOrderArr, GroupContext groupContext)
+            throws ApplicationDefinitionException {
+
+        Set<StartupOrder> startupOrders = new HashSet<StartupOrder>();
+
+        if (startupOrderArr == null) {
+            return startupOrders;
+        }
+
+
+        for (String commaSeparatedStartupOrder : startupOrderArr) {
+            // convert all Startup Orders to aliases-based
+            List<String> components = Arrays.asList(commaSeparatedStartupOrder.split(","));
+            startupOrders.add(getStartupOrder(components, groupContext));
+        }
+
+        return startupOrders;
+    }
+
+    private static StartupOrder getStartupOrder (List<String> components, GroupContext groupContext)
+            throws ApplicationDefinitionException {
+
+        List<String> aliasBasedComponents = new ArrayList<String>();
+
+        for (String component : components) {
+            component = component.trim();
+
+            String aliasBasedComponent;
+            if (component.startsWith("cartridge.")) {
+                String cartridgeType = component.substring(10);
+                aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext);
+                if (aliasBasedComponent == null) {
+                    throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " +
+                            "cannot find the matching alias for Service type " + cartridgeType);
+                }
+
+                aliasBasedComponent = "cartridge.".concat(aliasBasedComponent);
+
+            } else if (component.startsWith("group.")) {
+                String groupName = component.substring(6);
+                aliasBasedComponent = getAliasForGroupName(groupName, groupContext);
+                if (aliasBasedComponent == null) {
+                    throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " +
+                            "cannot find the matching alias for Group name " + groupName);
+                }
+
+                aliasBasedComponent = "group.".concat(aliasBasedComponent);
+
+            } else {
+                throw new ApplicationDefinitionException("Incorrect Startup Order specified, " +
+                        "should start with 'cartridge.' or 'group.'");
+            }
+            aliasBasedComponents.add(aliasBasedComponent);
+        }
+
+        return new StartupOrder(aliasBasedComponents);
+    }
+
+    private static String getAliasForGroupName (String groupName, GroupContext groupContext) {
+
+        for (GroupContext groupCtxt : groupContext.getGroupContexts()) {
+            if (groupName.equals(groupCtxt.getName())) {
+                return groupCtxt.getAlias();
+            }
+        }
+
+        return null;
+    }
+
+
+    private static String getAliasForServiceType (String serviceType, GroupContext groupContext) {
+
+        for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) {
+            if (serviceType.equals(subCtxt.getType())) {
+                return subCtxt.getAlias();
+            }
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java
new file mode 100644
index 0000000..d80894a
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+public class ApplicationCartridgePayloadData extends PayloadData {
+
+    public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) {
+        super(basicPayloadData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java
new file mode 100644
index 0000000..b0e4588
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+
+/**
+ * Contains basic payload data fields
+ */
+public class BasicPayloadData implements Serializable {
+
+    private static Log log = LogFactory.getLog(BasicPayloadData.class);
+
+    private String appId;
+    private String groupName;
+    private String serviceName;
+    private String clusterId;
+    private String hostName;
+    private int tenantId;
+    private String tenantRange;
+    private String subscriptionAlias;
+    private String deployment;
+    private String puppetIp;
+    private String puppetHostName;
+    private String puppetEnvironment;
+    private String subscriptionKey;
+    private String applicationPath;
+    private String gitRepositoryUrl;
+    private String portMappings;
+    private String multitenant;
+    private String provider;
+    private String[] dependencyAliases;
+    private String[] exportingProperties;
+
+    protected StringBuilder payloadBuilder;
+
+    public BasicPayloadData() {
+
+    }
+
+    public void populatePayload () {
+
+        payloadBuilder = new StringBuilder();
+
+        payloadBuilder.append("APP_ID=" + getAppId());
+        payloadBuilder.append(",");
+        payloadBuilder.append("GROUP_NAME=" + getGroupName());
+        payloadBuilder.append(",");
+        payloadBuilder.append("SERVICE_NAME=" + getServiceName());
+        payloadBuilder.append(",");
+        payloadBuilder.append("HOST_NAME=" + getHostName());
+        payloadBuilder.append(",");
+        payloadBuilder.append("MULTITENANT=" + getMultitenant());
+        payloadBuilder.append(",");
+        payloadBuilder.append("TENANT_ID=" + getTenantId());
+        payloadBuilder.append(",");
+        payloadBuilder.append("TENANT_RANGE=" + getTenantRange());
+        payloadBuilder.append(",");
+        payloadBuilder.append("CARTRIDGE_ALIAS=" + getSubscriptionAlias());
+        payloadBuilder.append(",");
+        payloadBuilder.append("CLUSTER_ID=" + getClusterId());
+        payloadBuilder.append(",");
+        payloadBuilder.append("CARTRIDGE_KEY=" + getSubscriptionKey());
+        payloadBuilder.append(",");
+        //payloadBuilder.append("DEPLOYMENT=" + getDeployment());
+        //payloadBuilder.append(",");
+        //payloadBuilder.append("APP_PATH=" + getApplicationPath());
+        //payloadBuilder.append(",");
+        payloadBuilder.append("REPO_URL=" + getGitRepositoryUrl());
+        payloadBuilder.append(",");
+        payloadBuilder.append("PORTS=" + getPortMappings());
+        payloadBuilder.append(",");
+        payloadBuilder.append("PROVIDER=" + getProvider());
+
+        //Payload Data exposed as system variables
+        payloadBuilder.append(",");
+        payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip"));
+        payloadBuilder.append(",");
+        payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname"));
+        payloadBuilder.append(",");
+        payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env"));
+        payloadBuilder.append(",");
+        payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available"));
+        payloadBuilder.append(",");
+        if(getDependencyAliasesPayloadString() != null){
+            payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString());
+        }
+        payloadBuilder.append(",");
+        if(getExportingPropertiesPayloadString() != null){
+            payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString());
+        }
+
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getTenantRange() {
+        return tenantRange;
+    }
+
+    public void setTenantRange(String tenantRange) {
+        this.tenantRange = tenantRange;
+    }
+
+    public String getSubscriptionAlias() {
+        return subscriptionAlias;
+    }
+
+    public void setSubscriptionAlias(String subscriptionAlias) {
+        this.subscriptionAlias = subscriptionAlias;
+    }
+
+    public String getDeployment() {
+        return deployment;
+    }
+
+    public void setDeployment(String deployment) {
+        this.deployment = deployment;
+    }
+
+    public String getPuppetIp() {
+        return puppetIp;
+    }
+
+    public void setPuppetIp(String puppetIp) {
+        this.puppetIp = puppetIp;
+    }
+
+    public String getSubscriptionKey() {
+        return subscriptionKey;
+    }
+
+    public void setSubscriptionKey(String subscriptionKey) {
+        this.subscriptionKey = subscriptionKey;
+    }
+
+    public StringBuilder getPayloadData () {
+
+        return payloadBuilder;
+    }
+
+    public String getApplicationPath() {
+        return applicationPath;
+    }
+
+    public void setApplicationPath(String applicationPath) {
+        this.applicationPath = applicationPath;
+    }
+
+    public String getGitRepositoryUrl() {
+        return gitRepositoryUrl;
+    }
+
+    public void setGitRepositoryUrl(String gitRepositoryUrl) {
+        this.gitRepositoryUrl = gitRepositoryUrl;
+    }
+
+    public String getPortMappings() {
+        return portMappings;
+    }
+
+    public void setPortMappings(String portMappings) {
+        this.portMappings = portMappings;
+    }
+
+    public String getMultitenant() {
+        return multitenant;
+    }
+
+    public void setMultitenant(String multitenant) {
+        this.multitenant = multitenant;
+    }
+
+    public String getPuppetHostName() {
+        return puppetHostName;
+    }
+
+    public void setPuppetHostName(String puppetHostName) {
+        this.puppetHostName = puppetHostName;
+    }
+
+    public String getPuppetEnvironment() {
+        return puppetEnvironment;
+    }
+
+    public void setPuppetEnvironment(String puppetEnvironment) {
+        this.puppetEnvironment = puppetEnvironment;
+    }
+
+    public String getProvider() {
+        return provider;
+    }
+
+    public void setProvider(String provider) {
+        this.provider = provider;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String[] getDependencyAliases() {
+        return dependencyAliases;
+    }
+
+    public void setDependencyAliases(String[] dependencyAliases) {
+        this.dependencyAliases = dependencyAliases;
+    }
+
+    private String getDependencyAliasesPayloadString(){
+        if(dependencyAliases == null){
+            return null;
+        }
+
+        StringBuilder dependencyAliasesPayload = new StringBuilder();
+        for(int i=0; i< dependencyAliases.length; i++){
+            dependencyAliasesPayload.append(dependencyAliases[i]);
+            if(i != dependencyAliases.length -1){
+                dependencyAliasesPayload.append("|");
+            }
+        }
+        log.info("testing1 getDependencyAliasesPayloadString " + dependencyAliasesPayload);
+        return dependencyAliasesPayload.toString();
+    }
+
+    private String getExportingPropertiesPayloadString(){
+        if(exportingProperties == null){
+            return null;
+        }
+
+        StringBuilder exportingPropertiesPayload = new StringBuilder();
+        for(int i=0; i< exportingProperties.length; i++){
+            exportingPropertiesPayload.append(exportingProperties[i]);
+            if(i != exportingProperties.length -1){
+                exportingPropertiesPayload.append("|");
+            }
+        }
+        log.info("testing1 getExportingPropertiesPayloadString " + exportingPropertiesPayload);
+        return exportingPropertiesPayload.toString();
+    }
+
+    public String[] getExportingProperties() {
+        return exportingProperties;
+    }
+
+    public void setExportingProperties(String[] exportingProperties) {
+        this.exportingProperties = exportingProperties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java
new file mode 100644
index 0000000..84ef25a
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+public class DataCartridgePayloadData extends PayloadData {
+
+    public DataCartridgePayloadData(BasicPayloadData basicPayloadData) {
+        super(basicPayloadData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java
new file mode 100644
index 0000000..03b2ed1
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+public class FrameworkCartridgePayloadData extends PayloadData {
+
+    public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) {
+        super(basicPayloadData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b9aabfdc/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java
new file mode 100644
index 0000000..d4949cc
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.applications.payload;
+
+public class LoadBalancerCartridgePayloadData extends PayloadData {
+
+    public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) {
+        super(basicPayloadData);
+    }
+}


[42/50] [abbrv] git commit: moving app deployment to Autoscaler

Posted by im...@apache.org.
moving app deployment to Autoscaler


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

Branch: refs/heads/docker-grouping-merge
Commit: 16f9ec30c20424875becc7cf2a8ab63d9408a9c5
Parents: b9aabfd
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 19:44:44 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 19:44:44 2014 +0530

----------------------------------------------------------------------
 .../parser/DefaultApplicationParser.java        |   6 +-
 .../manager/client/AutoscalerServiceClient.java |  11 +
 .../bean/util/converter/PojoConverter.java      |  16 +-
 .../rest/endpoint/services/ServiceUtils.java    |  31 +-
 .../pom.xml                                     |   7 +-
 .../src/main/resources/AutoScalerService.wsdl   | 342 +++++++++++++------
 6 files changed, 292 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index 8184743..a2c8ce5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -25,17 +25,13 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.ApplicationUtils;
 import org.apache.stratos.autoscaler.applications.MTClusterInformation;
 import org.apache.stratos.autoscaler.applications.STClusterInformation;
-import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
-import org.apache.stratos.autoscaler.applications.pojo.GroupContext;
-import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext;
-import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext;
+import org.apache.stratos.autoscaler.applications.pojo.*;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
 import org.apache.stratos.autoscaler.exception.CartridgeInformationException;
 import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.application.ClusterInformation;
-import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext;
 import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index 731c80f..7e33897 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -24,6 +24,7 @@ import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.stub.*;
@@ -218,4 +219,14 @@ public class AutoscalerServiceClient {
     public void deployServiceGroup(ServiceGroup serviceGroup) throws AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException {
         stub.deployServiceGroup(serviceGroup);
     }
+
+    public void deployApplication (ApplicationContext applicationContext) throws
+            AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+        stub.deployApplicationDefinition(applicationContext);
+    }
+
+    public void undeployApplication (String applicationId, int tenantId, String tenantDomain) throws
+            AutoScalerServiceApplicationDefinitionExceptionException, RemoteException {
+        stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 6c8db77..cb7d9b3 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@ -22,8 +22,11 @@ package org.apache.stratos.rest.endpoint.bean.util.converter;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.applications.pojo.stub.DependencyContext;
+import org.apache.stratos.autoscaler.applications.pojo.stub.GroupContext;
+import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext;
+import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableInfoContext;
 import org.apache.stratos.cloud.controller.stub.pojo.*;
-import org.apache.stratos.cloud.controller.stub.pojo.application.*;
 import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
 import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
 import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition;
@@ -680,15 +683,16 @@ public class PojoConverter {
     
 	private static Log log = LogFactory.getLog(PojoConverter.class);
 
-    public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) {
+    public static org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext
+    convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) {
 
-        ApplicationContext applicationContext = new ApplicationContext();
+        org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext();
         applicationContext.setApplicationId(compositeAppDefinition.getApplicationId());
         applicationContext.setAlias(compositeAppDefinition.getAlias());
 
         // convert and set components
         if (compositeAppDefinition.getComponents() != null) {
-            ComponentContext componentContext = new ComponentContext();
+            org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext componentContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext();
             // top level subscribables
             if (compositeAppDefinition.getComponents().getSubscribables() != null) {
                 componentContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions(
@@ -736,7 +740,7 @@ public class PojoConverter {
     private static DependencyContext getDependencyContextFromDependencyDefinition (DependencyDefinitions dependencyDefinitions) {
 
         DependencyContext dependencyContext = new DependencyContext();
-        dependencyContext.setKillBehaviour(dependencyDefinitions.getTerminationBehaviour());
+        dependencyContext.setTerminationBehaviour(dependencyDefinitions.getTerminationBehaviour());
         
         if (dependencyDefinitions != null && dependencyDefinitions.getStartupOrders() != null) {
         	String [] startupOrders = new String [dependencyDefinitions.getStartupOrders().size()];
@@ -771,7 +775,7 @@ public class PojoConverter {
         return groupContexts;
     }
 
-    private static SubscribableContext [] getSubscribableContextArrayFromSubscribableDefinitions(List<SubscribableDefinition> subscribableDefinitions) {
+    private static org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext [] getSubscribableContextArrayFromSubscribableDefinitions(List<SubscribableDefinition> subscribableDefinitions) {
 
         SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()];
         int i = 0;

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 2b99f14..012611f 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -24,6 +24,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException;
 import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
 import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
 import org.apache.stratos.cloud.controller.stub.*;
@@ -148,19 +149,28 @@ public class ServiceUtils {
             throw new RestAPIException(e1);
         }
     	
-        ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition);
+        org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext =
+                PojoConverter.convertApplicationBeanToApplicationContext(appDefinition);
         applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
         applicationContext.setTenantDomain(tenantDomain);
         applicationContext.setTeantAdminUsername(userName);
 
-        try {
-            CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
+//        try {
+//            CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
+//
+//        } catch (RemoteException e) {
+//            throw new RestAPIException(e);
+//        } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
+//            throw new RestAPIException(e);
+//        } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+//            throw new RestAPIException(e);
+//        }
 
-        } catch (RemoteException e) {
-            throw new RestAPIException(e);
-        } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
+        try {
+            AutoscalerServiceClient.getServiceClient().deployApplication(applicationContext);
+        } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
             throw new RestAPIException(e);
-        } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+        } catch (RemoteException e) {
             throw new RestAPIException(e);
         }
     }
@@ -179,12 +189,13 @@ public class ServiceUtils {
 
         try {
         	int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
-            CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain);
+            //CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain);
+            AutoscalerServiceClient.getServiceClient().undeployApplication(appId, tenantId, tenantDomain);
 
-        } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
-            throw new RestAPIException(e);
         } catch (RemoteException e) {
             throw new RestAPIException(e);
+        } catch (AutoScalerServiceApplicationDefinitionExceptionException e) {
+            throw new RestAPIException(e);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
index 0df7903..05f3d50 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
@@ -47,7 +47,7 @@
                         <configuration>
                             <tasks>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
-                                    <arg line="-uri src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.autoscaler.stub -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition,http://pojo.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.pojo" />
+                                    <arg line="-uri src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.autoscaler.stub -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition,http://pojo.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.pojo,http://pojo.applications.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.applications.pojo.stub" />
                                     <classpath refid="maven.dependency.classpath" />
                                     <classpath refid="maven.compile.classpath" />
                                     <classpath refid="maven.runtime.classpath" />
@@ -92,8 +92,9 @@
                             org.apache.stratos.autoscaler.policy.model.*; version=${project.version},
                             org.apache.stratos.autoscaler.exception.*; version=${project.version},
 			    org.apache.stratos.autoscaler.partition.*; version=${project.version},
-			    org.apache.stratos.autoscaler.api.*; version=${project.version}
-			    org.apache.stratos.autoscaler.pojo.*; version=${project.version}
+			    org.apache.stratos.autoscaler.api.*; version=${project.version},
+			    org.apache.stratos.autoscaler.pojo.*; version=${project.version},
+			    org.apache.stratos.autoscaler.applications.pojo.*; version=${project.version}
                         </Export-Package>
 			<Private-Package>
 			</Private-Package>

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9ec30/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
index b76e02a..5d64615 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
@@ -1,58 +1,157 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax27="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax25="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax210="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.ap
 ache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax27="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ns="http://api.autoscaler.stratos.apache.org" xmlns:ax25="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax218="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax220="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax210="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xm
 lsoap.org/wsdl/soap12/" targetNamespace="http://api.autoscaler.stratos.apache.org">
     <wsdl:documentation>AutoScalerService</wsdl:documentation>
     <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
-            <xs:complexType name="AutoScalerException">
-                <xs:complexContent>
-                    <xs:extension base="xs:RuntimeException">
-                        <xs:sequence></xs:sequence>
-                    </xs:extension>
-                </xs:complexContent>
+        <xs:schema xmlns:ax29="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax212="http://partition.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:complexType name="DeploymentPolicy">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax29:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax212:PartitionGroup"></xs:element>
+                </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidServiceGroupException">
+        </xs:schema>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="ApplicationContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="components" nillable="true" type="ax220:ComponentContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax220:SubscribableInfoContext"></xs:element>
+                    <xs:element minOccurs="0" name="teantAdminUsername" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="NonExistingLBException">
+            <xs:complexType name="ComponentContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax220:DependencyContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax220:GroupContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableContexts" nillable="true" type="ax220:SubscribableContext"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidPartitionException">
+            <xs:complexType name="DependencyContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="InvalidPolicyException">
+            <xs:complexType name="GroupContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax220:GroupContext"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribableContexts" nillable="true" type="ax220:SubscribableContext"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd">
-            <xs:complexType name="Properties">
+            <xs:complexType name="SubscribableContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax27:Property"></xs:element>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="Property">
+            <xs:complexType name="SubscribableInfoContext">
                 <xs:sequence>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="ServiceGroup">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax214:Dependencies"></xs:element>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="Dependencies">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax217="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax219="http://model.policy.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://exception.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://model.policy.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="AutoscalePolicy">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax218:LoadThresholds"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="LoadThresholds">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax218:LoadAverageThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax218:MemoryConsumptionThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax218:RequestsInFlightThresholds"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="LoadAverageThresholds">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="MemoryConsumptionThresholds">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="RequestsInFlightThresholds">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema xmlns:ax211="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:complexType name="PartitionGroup">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax211:Partition"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema xmlns:ax28="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd">
+            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
+            <xs:complexType name="Partition">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema xmlns:ax215="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax221="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://policy.deployment.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://partition.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax219="http://model.policy.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://api.autoscaler.stratos.apache.org">
             <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://model.policy.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:element name="AutoScalerServiceAutoScalerException">
                 <xs:complexType>
                     <xs:sequence>
@@ -67,6 +166,22 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
+            <xs:element name="AutoScalerServiceApplicationDefinitionException">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax23:ApplicationDefinitionException"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="unDeployApplicationDefinition">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
+                        <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="serviceGroupExist">
                 <xs:complexType>
                     <xs:sequence>
@@ -273,6 +388,13 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
+            <xs:element name="deployApplicationDefinition">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax220:ApplicationContext"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
             <xs:element name="checkServiceLBExistenceAgainstPolicy">
                 <xs:complexType>
                     <xs:sequence>
@@ -389,92 +511,53 @@
                 </xs:complexType>
             </xs:element>
         </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
-            <xs:complexType name="ServiceGroup">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax214:Dependencies"></xs:element>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="subGroups" nillable="true" type="xs:string"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="Dependencies">
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd">
+            <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax27:Property"></xs:element>
+                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax211="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:complexType name="PartitionGroup">
+            <xs:complexType name="Property">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax211:Partition"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="nameSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="valueSpecified" type="xs:boolean"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://model.policy.autoscaler.stratos.apache.org/xsd">
-            <xs:complexType name="AutoscalePolicy">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax218:LoadThresholds"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="LoadThresholds">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="loadAverage" nillable="true" type="ax218:LoadAverageThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="memoryConsumption" nillable="true" type="ax218:MemoryConsumptionThresholds"></xs:element>
-                    <xs:element minOccurs="0" name="requestsInFlight" nillable="true" type="ax218:RequestsInFlightThresholds"></xs:element>
-                </xs:sequence>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="AutoScalerException">
+                <xs:complexContent>
+                    <xs:extension base="xs:RuntimeException">
+                        <xs:sequence></xs:sequence>
+                    </xs:extension>
+                </xs:complexContent>
             </xs:complexType>
-            <xs:complexType name="LoadAverageThresholds">
+            <xs:complexType name="ApplicationDefinitionException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="MemoryConsumptionThresholds">
+            <xs:complexType name="InvalidServiceGroupException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="RequestsInFlightThresholds">
+            <xs:complexType name="NonExistingLBException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="lowerLimit" type="xs:float"></xs:element>
-                    <xs:element minOccurs="0" name="upperLimit" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax29="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd" xmlns:ax212="http://partition.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://partition.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:complexType name="DeploymentPolicy">
+            <xs:complexType name="InvalidPartitionException">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="allPartitions" nillable="true" type="ax29:Partition"></xs:element>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax212:PartitionGroup"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax28="http://pojo.stub.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://pojo.stub.controller.cloud.stratos.apache.org/xsd"></xs:import>
-            <xs:complexType name="Partition">
+            <xs:complexType name="InvalidPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="idSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMax" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMaxSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMin" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="partitionMinSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"></xs:element>
-                    <xs:element minOccurs="0" name="propertiesSpecified" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="providerSpecified" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
@@ -524,6 +607,12 @@
     <wsdl:message name="AutoScalerServiceInvalidPolicyException">
         <wsdl:part name="parameters" element="ns:AutoScalerServiceInvalidPolicyException"></wsdl:part>
     </wsdl:message>
+    <wsdl:message name="unDeployApplicationDefinitionRequest">
+        <wsdl:part name="parameters" element="ns:unDeployApplicationDefinition"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="AutoScalerServiceApplicationDefinitionException">
+        <wsdl:part name="parameters" element="ns:AutoScalerServiceApplicationDefinitionException"></wsdl:part>
+    </wsdl:message>
     <wsdl:message name="getServiceGroupRequest">
         <wsdl:part name="parameters" element="ns:getServiceGroup"></wsdl:part>
     </wsdl:message>
@@ -554,6 +643,9 @@
     <wsdl:message name="getAllAvailablePartitionsResponse">
         <wsdl:part name="parameters" element="ns:getAllAvailablePartitionsResponse"></wsdl:part>
     </wsdl:message>
+    <wsdl:message name="deployApplicationDefinitionRequest">
+        <wsdl:part name="parameters" element="ns:deployApplicationDefinition"></wsdl:part>
+    </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyRequest">
         <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"></wsdl:part>
     </wsdl:message>
@@ -653,6 +745,10 @@
             <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"></wsdl:output>
             <wsdl:fault message="ns:AutoScalerServiceInvalidPolicyException" name="AutoScalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoScalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="unDeployApplicationDefinition">
+            <wsdl:input message="ns:unDeployApplicationDefinitionRequest" wsaw:Action="urn:unDeployApplicationDefinition"></wsdl:input>
+            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:unDeployApplicationDefinitionAutoScalerServiceApplicationDefinitionException"></wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
             <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"></wsdl:input>
             <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"></wsdl:output>
@@ -673,6 +769,10 @@
             <wsdl:input message="ns:getAllAvailablePartitionsRequest" wsaw:Action="urn:getAllAvailablePartitions"></wsdl:input>
             <wsdl:output message="ns:getAllAvailablePartitionsResponse" wsaw:Action="urn:getAllAvailablePartitionsResponse"></wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="deployApplicationDefinition">
+            <wsdl:input message="ns:deployApplicationDefinitionRequest" wsaw:Action="urn:deployApplicationDefinition"></wsdl:input>
+            <wsdl:fault message="ns:AutoScalerServiceApplicationDefinitionException" name="AutoScalerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationDefinitionAutoScalerServiceApplicationDefinitionException"></wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
             <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"></wsdl:input>
             <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"></wsdl:output>
@@ -788,6 +888,15 @@
                 <soap:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="unDeployApplicationDefinition">
+            <soap:operation soapAction="urn:unDeployApplicationDefinition" style="document"></soap:operation>
+            <wsdl:input>
+                <soap:body use="literal"></soap:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceApplicationDefinitionException">
+                <soap:fault use="literal" name="AutoScalerServiceApplicationDefinitionException"></soap:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
             <soap:operation soapAction="urn:getServiceGroup" style="document"></soap:operation>
             <wsdl:input>
@@ -833,6 +942,15 @@
                 <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="deployApplicationDefinition">
+            <soap:operation soapAction="urn:deployApplicationDefinition" style="document"></soap:operation>
+            <wsdl:input>
+                <soap:body use="literal"></soap:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceApplicationDefinitionException">
+                <soap:fault use="literal" name="AutoScalerServiceApplicationDefinitionException"></soap:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
             <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"></soap:operation>
             <wsdl:input>
@@ -1007,6 +1125,15 @@
                 <soap12:fault use="literal" name="AutoScalerServiceInvalidPolicyException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="unDeployApplicationDefinition">
+            <soap12:operation soapAction="urn:unDeployApplicationDefinition" style="document"></soap12:operation>
+            <wsdl:input>
+                <soap12:body use="literal"></soap12:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceApplicationDefinitionException">
+                <soap12:fault use="literal" name="AutoScalerServiceApplicationDefinitionException"></soap12:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
             <soap12:operation soapAction="urn:getServiceGroup" style="document"></soap12:operation>
             <wsdl:input>
@@ -1052,6 +1179,15 @@
                 <soap12:body use="literal"></soap12:body>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="deployApplicationDefinition">
+            <soap12:operation soapAction="urn:deployApplicationDefinition" style="document"></soap12:operation>
+            <wsdl:input>
+                <soap12:body use="literal"></soap12:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoScalerServiceApplicationDefinitionException">
+                <soap12:fault use="literal" name="AutoScalerServiceApplicationDefinitionException"></soap12:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
             <soap12:operation soapAction="urn:getAutoscalingPolicy" style="document"></soap12:operation>
             <wsdl:input>
@@ -1223,6 +1359,12 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="unDeployApplicationDefinition">
+            <http:operation location="unDeployApplicationDefinition"></http:operation>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"></mime:content>
+            </wsdl:input>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
             <http:operation location="getServiceGroup"></http:operation>
             <wsdl:input>
@@ -1265,6 +1407,12 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="deployApplicationDefinition">
+            <http:operation location="deployApplicationDefinition"></http:operation>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"></mime:content>
+            </wsdl:input>
+        </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
             <http:operation location="getAutoscalingPolicy"></http:operation>
             <wsdl:input>
@@ -1361,22 +1509,22 @@
     </wsdl:binding>
     <wsdl:service name="AutoScalerService">
         <wsdl:port name="AutoScalerServiceHttpSoap11Endpoint" binding="ns:AutoScalerServiceSoap11Binding">
-            <soap:address location="http://10.100.1.142:9763/services/AutoScalerService.AutoScalerServiceHttpSoap11Endpoint/"></soap:address>
+            <soap:address location="http://192.168.56.1:9763/services/AutoScalerService.AutoScalerServiceHttpSoap11Endpoint/"></soap:address>
         </wsdl:port>
         <wsdl:port name="AutoScalerServiceHttpsSoap11Endpoint" binding="ns:AutoScalerServiceSoap11Binding">
-            <soap:address location="https://10.100.1.142:9443/services/AutoScalerService.AutoScalerServiceHttpsSoap11Endpoint/"></soap:address>
+            <soap:address location="https://192.168.56.1:9443/services/AutoScalerService.AutoScalerServiceHttpsSoap11Endpoint/"></soap:address>
         </wsdl:port>
         <wsdl:port name="AutoScalerServiceHttpsSoap12Endpoint" binding="ns:AutoScalerServiceSoap12Binding">
-            <soap12:address location="https://10.100.1.142:9443/services/AutoScalerService.AutoScalerServiceHttpsSoap12Endpoint/"></soap12:address>
+            <soap12:address location="https://192.168.56.1:9443/services/AutoScalerService.AutoScalerServiceHttpsSoap12Endpoint/"></soap12:address>
         </wsdl:port>
         <wsdl:port name="AutoScalerServiceHttpSoap12Endpoint" binding="ns:AutoScalerServiceSoap12Binding">
-            <soap12:address location="http://10.100.1.142:9763/services/AutoScalerService.AutoScalerServiceHttpSoap12Endpoint/"></soap12:address>
+            <soap12:address location="http://192.168.56.1:9763/services/AutoScalerService.AutoScalerServiceHttpSoap12Endpoint/"></soap12:address>
         </wsdl:port>
         <wsdl:port name="AutoScalerServiceHttpEndpoint" binding="ns:AutoScalerServiceHttpBinding">
-            <http:address location="http://10.100.1.142:9763/services/AutoScalerService.AutoScalerServiceHttpEndpoint/"></http:address>
+            <http:address location="http://192.168.56.1:9763/services/AutoScalerService.AutoScalerServiceHttpEndpoint/"></http:address>
         </wsdl:port>
         <wsdl:port name="AutoScalerServiceHttpsEndpoint" binding="ns:AutoScalerServiceHttpBinding">
-            <http:address location="https://10.100.1.142:9443/services/AutoScalerService.AutoScalerServiceHttpsEndpoint/"></http:address>
+            <http:address location="https://192.168.56.1:9443/services/AutoScalerService.AutoScalerServiceHttpsEndpoint/"></http:address>
         </wsdl:port>
     </wsdl:service>
 </wsdl:definitions>
\ No newline at end of file


[50/50] [abbrv] git commit: Merge branch '4.0.0-grouping' into docker-grouping-merge

Posted by im...@apache.org.
Merge branch '4.0.0-grouping' into docker-grouping-merge

Conflicts:
	components/org.apache.stratos.autoscaler/pom.xml
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
	components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
	components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
	components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
	components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java
	components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
	components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
	components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
	components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
	components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java
	components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
	components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
	components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
	service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
	service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl
	service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
	service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl


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

Branch: refs/heads/docker-grouping-merge
Commit: 89fb37afb2e80aabf1aa1d393e2185c34f7a1298
Parents: a61fc9d 14f5fe0
Author: Imesh Gunaratne <im...@apache.org>
Authored: Mon Nov 3 13:01:54 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Nov 3 13:01:54 2014 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.autoscaler/pom.xml       |    8 +
 .../apache/stratos/autoscaler/Constants.java    |   10 +-
 .../stratos/autoscaler/PartitionContext.java    |  106 +-
 .../autoscaler/api/AutoScalerServiceImpl.java   |  126 +-
 .../applications/ApplicationHolder.java         |  122 ++
 .../ApplicationSynchronizeTask.java             |   53 +
 .../ApplicationSynchronizerTaskScheduler.java   |   87 ++
 .../applications/ApplicationUtils.java          |  289 +++++
 .../applications/ClusterInformation.java        |   27 +
 .../applications/MTClusterInformation.java      |   47 +
 .../applications/STClusterInformation.java      |   57 +
 .../dependency/DependencyBuilder.java           |  156 +++
 .../applications/dependency/DependencyTree.java |  290 +++++
 .../dependency/context/ApplicationContext.java  |  113 ++
 .../context/ApplicationContextFactory.java      |  101 ++
 .../dependency/context/ClusterContext.java      |   38 +
 .../dependency/context/GroupContext.java        |   25 +
 .../applications/parser/ApplicationParser.java  |   53 +
 .../parser/DefaultApplicationParser.java        |  679 +++++++++++
 .../applications/parser/ParserUtils.java        |  142 +++
 .../ApplicationCartridgePayloadData.java        |   27 +
 .../applications/payload/BasicPayloadData.java  |  311 +++++
 .../payload/DataCartridgePayloadData.java       |   27 +
 .../payload/FrameworkCartridgePayloadData.java  |   27 +
 .../LoadBalancerCartridgePayloadData.java       |   27 +
 .../applications/payload/PayloadData.java       |   69 ++
 .../applications/payload/PayloadFactory.java    |   59 +
 .../pojo/ApplicationClusterContext.java         |  137 +++
 .../applications/pojo/ApplicationContext.java   |  112 ++
 .../applications/pojo/ComponentContext.java     |   58 +
 .../applications/pojo/DependencyContext.java    |   48 +
 .../applications/pojo/GroupContext.java         |   88 ++
 .../applications/pojo/SubscribableContext.java  |   47 +
 .../pojo/SubscribableInfoContext.java           |  107 ++
 .../applications/topic/ApplicationBuilder.java  |  664 +++++++++++
 .../topic/ApplicationsEventPublisher.java       |  251 ++++
 .../cloud/controller/CloudControllerClient.java |   78 +-
 .../ApplicationDefinitionException.java         |   48 +
 .../CartridgeInformationException.java          |   47 +
 .../exception/InvalidServiceGroupException.java |   46 +
 .../grouping/dependency/DependencyBuilder.java  |  158 ---
 .../grouping/dependency/DependencyTree.java     |  291 -----
 .../dependency/context/ApplicationContext.java  |  113 --
 .../context/ApplicationContextFactory.java      |  102 --
 .../dependency/context/ClusterContext.java      |   38 -
 .../dependency/context/GroupContext.java        |   25 -
 .../topic/ClusterStatusEventPublisher.java      |  195 +++
 .../grouping/topic/StatusEventPublisher.java    |  312 -----
 .../interfaces/AutoScalerServiceInterface.java  |   26 +-
 .../internal/AutoscalerServerComponent.java     |   37 +-
 .../AutoscalerTopologyEventReceiver.java        |  731 ++++++++----
 .../monitor/AbstractClusterMonitor.java         |  277 +++++
 .../monitor/MonitorStatusEventBuilder.java      |    4 +-
 .../monitor/ParentComponentMonitor.java         |  106 +-
 .../monitor/application/ApplicationMonitor.java |   24 +-
 .../application/ApplicationMonitorFactory.java  |   33 +-
 .../cluster/VMServiceClusterMonitor.java        |  147 ++-
 .../monitor/events/ApplicationStatusEvent.java  |    2 +-
 .../monitor/events/GroupStatusEvent.java        |    2 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |   39 +-
 .../stratos/autoscaler/pojo/Dependencies.java   |   46 +
 .../stratos/autoscaler/pojo/ServiceGroup.java   |   67 ++
 .../autoscaler/registry/RegistryManager.java    |  150 ++-
 .../status/checker/StatusChecker.java           |  287 +++--
 .../autoscaler/util/AutoScalerConstants.java    |    5 +-
 .../stratos/autoscaler/util/AutoscalerUtil.java |  222 ++++
 .../stratos/autoscaler/util/Deserializer.java   |   10 +-
 .../autoscaler/util/ServiceReferenceHolder.java |   12 +-
 .../application/ApplicationUtils.java           |  291 -----
 .../application/ClusterInformation.java         |   27 -
 .../application/MTClusterInformation.java       |   45 -
 .../application/STClusterInformation.java       |   55 -
 .../parser/DefaultApplicationParser.java        |  619 ----------
 .../application/parser/ParserUtils.java         |  142 ---
 .../ApplicationCartridgePayloadData.java        |   27 -
 .../application/payload/BasicPayloadData.java   |  311 -----
 .../payload/DataCartridgePayloadData.java       |   27 -
 .../payload/FrameworkCartridgePayloadData.java  |   27 -
 .../LoadBalancerCartridgePayloadData.java       |   27 -
 .../application/payload/PayloadData.java        |   69 --
 .../application/payload/PayloadFactory.java     |   59 -
 .../ApplicationStatusTopicReceiver.java         |  175 ---
 .../receiver/ClusterStatusTopicReceiver.java    |  113 ++
 .../interfaces/ApplicationParser.java           |   53 -
 .../interfaces/CloudControllerService.java      |   17 -
 .../internal/CloudControllerDSComponent.java    |   12 +-
 .../pojo/application/ApplicationContext.java    |  112 --
 .../pojo/application/ComponentContext.java      |   58 -
 .../pojo/application/DependencyContext.java     |   48 -
 .../pojo/application/GroupContext.java          |   88 --
 .../pojo/application/SubscribableContext.java   |   47 -
 .../application/SubscribableInfoContext.java    |  107 --
 .../controller/pojo/payload/MetaDataHolder.java |    5 +-
 .../controller/topology/TopologyBuilder.java    |  483 ++------
 .../topology/TopologyEventPublisher.java        |   28 +
 .../CompositeApplicationParseTest.java          | 1108 +++++++++---------
 .../manager/client/AutoscalerServiceClient.java |   24 +
 .../client/CloudControllerServiceClient.java    |   16 -
 .../DefaultCompositeApplicationParser.java      |    6 +-
 .../definitions/DependencyDefinitions.java      |   10 +-
 .../deployer/DefaultServiceGroupDeployer.java   |   70 +-
 .../StratosManagerTopologyEventReceiver.java    |   21 +-
 .../domain/applications/Application.java        |  124 ++
 .../domain/applications/ApplicationStatus.java  |   74 ++
 .../domain/applications/Applications.java       |   73 ++
 .../domain/applications/ClusterDataHolder.java  |   50 +
 .../domain/applications/DependencyOrder.java    |   52 +
 .../messaging/domain/applications/Group.java    |  119 ++
 .../domain/applications/GroupStatus.java        |   73 ++
 .../domain/applications/ParentComponent.java    |  212 ++++
 .../domain/applications/StartupOrder.java       |   40 +
 .../applications/locking/ApplicationLock.java   |   59 +
 .../locking/ApplicationLockHierarchy.java       |   91 ++
 .../messaging/domain/topology/Application.java  |  123 --
 .../domain/topology/ApplicationStatus.java      |   74 --
 .../messaging/domain/topology/Cluster.java      |    6 +-
 .../domain/topology/ClusterDataHolder.java      |   51 -
 .../domain/topology/ClusterStatus.java          |    2 +-
 .../domain/topology/DependencyOrder.java        |   54 -
 .../messaging/domain/topology/Group.java        |  111 --
 .../messaging/domain/topology/GroupStatus.java  |   73 --
 .../domain/topology/ParentComponent.java        |  212 ----
 .../messaging/domain/topology/StartupOrder.java |   40 -
 .../messaging/domain/topology/Topology.java     |  112 +-
 .../topology/locking/TopologyLockHierarchy.java |   42 -
 .../AppStatusApplicationActivatedEvent.java     |   38 -
 .../AppStatusApplicationCreatedEvent.java       |   38 -
 .../AppStatusApplicationInactivatedEvent.java   |   38 -
 .../AppStatusApplicationTerminatedEvent.java    |   47 -
 .../AppStatusApplicationTerminatingEvent.java   |   38 -
 .../status/AppStatusClusterActivatedEvent.java  |   50 -
 .../status/AppStatusClusterInactivateEvent.java |   50 -
 .../AppStatusClusterMaintenanceModeEvent.java   |   49 -
 .../AppStatusClusterReadyToShutdownEvent.java   |   47 -
 .../status/AppStatusClusterTerminatedEvent.java |   50 -
 .../AppStatusClusterTerminatingEvent.java       |   50 -
 .../status/AppStatusGroupActivatedEvent.java    |   44 -
 .../status/AppStatusGroupInactivateEvent.java   |   44 -
 .../AppStatusGroupMaintenanceModeEvent.java     |   41 -
 .../AppStatusGroupReadyToShutdownEvent.java     |   40 -
 .../status/AppStatusGroupTerminatedEvent.java   |   44 -
 .../status/AppStatusGroupTerminatingEvent.java  |   44 -
 .../event/application/status/StatusEvent.java   |   31 -
 .../AppStatusGroupInactivateEvent.java          |   48 +
 .../applications/ApplicationActivatedEvent.java |   40 +
 .../applications/ApplicationCreatedEvent.java   |   41 +
 .../ApplicationInactivatedEvent.java            |   40 +
 .../ApplicationTerminatedEvent.java             |   48 +
 .../ApplicationTerminatingEvent.java            |   40 +
 .../applications/CompleteApplicationsEvent.java |   44 +
 .../event/applications/GroupActivatedEvent.java |   48 +
 .../applications/GroupMaintenanceModeEvent.java |   45 +
 .../applications/GroupReadyToShutdownEvent.java |   44 +
 .../event/applications/GroupResetEvent.java     |   48 +
 .../applications/GroupTerminatedEvent.java      |   48 +
 .../applications/GroupTerminatingEvent.java     |   48 +
 .../ClusterStatusClusterActivatedEvent.java     |   52 +
 .../ClusterStatusClusterCreatedEvent.java       |   85 ++
 .../ClusterStatusClusterInactivateEvent.java    |   52 +
 .../status/ClusterStatusClusterResetEvent.java  |   52 +
 .../ClusterStatusClusterTerminatedEvent.java    |   52 +
 .../ClusterStatusClusterTerminatingEvent.java   |   52 +
 .../event/topology/ApplicationCreatedEvent.java |    2 +-
 .../topology/ApplicationTerminatedEvent.java    |    2 +-
 .../topology/ApplicationUndeployedEvent.java    |    2 +-
 .../event/topology/ClusterCreatedEvent.java     |   26 +-
 .../event/topology/ClusterResetEvent.java       |   56 +
 .../event/topology/GroupCreatedEvent.java       |   43 +
 ...StatusApplicationActivatedEventListener.java |   27 -
 ...ppStatusApplicationCreatedEventListener.java |   27 -
 ...atusApplicationInactivatedEventListener.java |   27 -
 ...tatusApplicationTerminatedEventListener.java |   27 -
 ...atusApplicationTerminatingEventListener.java |   27 -
 .../AppStatusClusterActivatedEventListener.java |   24 -
 ...AppStatusClusterInactivateEventListener.java |   24 -
 ...AppStatusClusterTerminatedEventListener.java |   24 -
 ...ppStatusClusterTerminatingEventListener.java |   24 -
 .../AppStatusGroupActivatedEventListener.java   |   24 -
 .../AppStatusGroupInactivateEventListener.java  |   24 -
 .../AppStatusGroupTerminatedEventListener.java  |   24 -
 .../AppStatusGroupTerminatingEventListener.java |   24 -
 .../ApplicationActivatedEventListener.java      |   27 +
 .../ApplicationCreatedEventListener.java        |   27 +
 .../ApplicationInactivatedEventListener.java    |   27 +
 .../ApplicationTerminatedEventListener.java     |   27 +
 .../ApplicationTerminatingEventListener.java    |   27 +
 .../ApplicationUndeployedEventListener.java     |   26 +
 .../CompleteApplicationsEventListener.java      |   26 +
 .../GroupActivatedEventListener.java            |   24 +
 .../GroupInactivateEventListener.java           |   24 +
 .../applications/GroupResetEventListener.java   |   24 +
 .../GroupTerminatedEventListener.java           |   24 +
 .../GroupTerminatingEventListener.java          |   24 +
 ...sterStatusClusterActivatedEventListener.java |   24 +
 ...lusterStatusClusterCreatedEventListener.java |   24 +
 ...terStatusClusterInactivateEventListener.java |   24 +
 .../ClusterStatusClusterResetEventListener.java |   24 +
 ...terStatusClusterTerminatedEventListener.java |   24 +
 ...erStatusClusterTerminatingEventListener.java |   24 +
 .../ApplicationActivatedEventListener.java      |   27 -
 .../ApplicationCreatedEventListener.java        |   26 -
 .../ApplicationInActivateEventListener.java     |   27 -
 .../ApplicationTerminatedEventListener.java     |   27 -
 .../ApplicationTerminatingEventListener.java    |   27 -
 .../ApplicationUndeployedEventListener.java     |   26 -
 .../topology/ClusterResetEventListener.java     |   24 +
 .../topology/GroupActivatedEventListener.java   |   27 -
 .../topology/GroupInActivateEventListener.java  |   27 -
 .../topology/GroupTerminatedEventListener.java  |   27 -
 .../topology/GroupTerminatingEventListener.java |   27 -
 ...tusApplicationActivatedMessageProcessor.java |   62 -
 ...tatusApplicationCreatedMessageProcessor.java |   63 -
 ...sApplicationInactivatedMessageProcessor.java |   63 -
 ...usApplicationTerminatedMessageProcessor.java |   63 -
 ...sApplicationTerminatingMessageProcessor.java |   63 -
 ...pStatusClusterActivatedMessageProcessor.java |   57 -
 ...StatusClusterInactivateMessageProcessor.java |   58 -
 ...StatusClusterTerminatedMessageProcessor.java |   58 -
 ...tatusClusterTerminatingMessageProcessor.java |   58 -
 ...AppStatusGroupActivatedMessageProcessor.java |   61 -
 ...pStatusGroupInactivatedMessageProcessor.java |   61 -
 ...ppStatusGroupTerminatedMessageProcessor.java |   61 -
 ...pStatusGroupTerminatingMessageProcessor.java |   61 -
 .../status/AppStatusMessageProcessorChain.java  |  126 --
 .../ApplicationActivatedMessageProcessor.java   |  104 ++
 .../ApplicationCreatedMessageProcessor.java     |  101 ++
 .../ApplicationInactivatedMessageProcessor.java |  104 ++
 .../ApplicationTerminatedMessageProcessor.java  |  138 +++
 .../ApplicationTerminatingMessageProcessor.java |  104 ++
 .../ApplicationUndeployedMessageProcessor.java  |  141 +++
 .../ApplicationsMessageProcessorChain.java      |  115 ++
 .../CompleteApplicationsMessageProcessor.java   |   98 ++
 .../applications/GroupActivatedProcessor.java   |  107 ++
 .../applications/GroupInActivateProcessor.java  |  106 ++
 .../applications/GroupResetProcessor.java       |  108 ++
 .../applications/GroupTerminatedProcessor.java  |  107 ++
 .../applications/GroupTerminatingProcessor.java |  107 ++
 .../updater/ApplicationsUpdater.java            |  138 +++
 ...rStatusClusterActivatedMessageProcessor.java |   58 +
 ...terStatusClusterCreatedMessageProcessor.java |   58 +
 ...StatusClusterInactivateMessageProcessor.java |   58 +
 ...usterStatusClusterResetMessageProcessor.java |   58 +
 ...StatusClusterTerminatedMessageProcessor.java |   58 +
 ...tatusClusterTerminatingMessageProcessor.java |   58 +
 .../ClusterStatusMessageProcessorChain.java     |   84 ++
 .../ApplicationActivatedMessageProcessor.java   |  104 --
 .../ApplicationCreatedMessageProcessor.java     |  121 --
 .../ApplicationInactivatedMessageProcessor.java |  104 --
 .../ApplicationTerminatedMessageProcessor.java  |  136 ---
 .../ApplicationTerminatingMessageProcessor.java |  104 --
 .../ApplicationUndeployedMessageProcessor.java  |  136 ---
 .../ClusterCreatedMessageProcessor.java         |   36 +-
 .../topology/ClusterResetMessageProcessor.java  |  146 +++
 .../CompleteTopologyMessageProcessor.java       |   16 +-
 .../topology/GroupActivatedProcessor.java       |  104 --
 .../topology/GroupInActivateProcessor.java      |  107 --
 .../topology/GroupTerminatedProcessor.java      |  107 --
 .../topology/GroupTerminatingProcessor.java     |  107 --
 .../topology/TopologyMessageProcessorChain.java |   69 +-
 .../topology/updater/TopologyUpdater.java       |   68 +-
 .../ApplicationStatusEventMessageDelegator.java |  146 ---
 .../ApplicationStatusEventMessageListener.java  |   74 --
 .../ApplicationStatusEventMessageQueue.java     |   26 -
 .../status/ApplicationStatusEventReceiver.java  |   83 --
 .../applications/ApplicationManager.java        |  119 ++
 .../ApplicationsEventMessageDelegator.java      |  146 +++
 .../ApplicationsEventMessageListener.java       |   74 ++
 .../ApplicationsEventMessageQueue.java          |   26 +
 .../applications/ApplicationsEventReceiver.java |   83 ++
 .../ClusterStatusEventMessageDelegator.java     |  146 +++
 .../ClusterStatusEventMessageListener.java      |   54 +
 .../status/ClusterStatusEventMessageQueue.java  |   26 +
 .../status/ClusterStatusEventReceiver.java      |   83 ++
 .../receiver/topology/TopologyManager.java      |   67 +-
 .../topology/locking/TopologyLockingTest.java   |    6 +-
 .../bean/util/converter/PojoConverter.java      |   16 +-
 .../rest/endpoint/services/ServiceUtils.java    |   35 +-
 .../webapp/stratos/WEB-INF/schemas/schema.xsd   |    2 +-
 278 files changed, 13054 insertions(+), 9921 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/pom.xml
index 6fcd1f0,5ba1eba..27ef199
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@@ -149,14 -150,9 +150,15 @@@
  			<groupId>org.apache.stratos</groupId>
  			<artifactId>org.apache.stratos.messaging</artifactId>
  			<version>${project.version}</version>
+ 			<scope>provided</scope>
  		</dependency>
          <dependency>
 +            <groupId>org.apache.stratos</groupId>
 +            <artifactId>org.apache.stratos.common</artifactId>
 +            <version>${project.version}</version>
 +            <scope>provided</scope>
 +        </dependency>
 +        <dependency>
              <groupId>org.wso2.carbon</groupId>
              <artifactId>org.wso2.carbon.utils</artifactId>
              <version>4.2.0</version>

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
index 520cf86,467bbc2..b008ec4
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
@@@ -26,26 -26,11 +26,26 @@@ import org.apache.stratos.cloud.control
  import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
  
  import java.io.Serializable;
 +import java.util.ArrayList;
 +import java.util.HashSet;
 +import java.util.Iterator;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Properties;
 +import java.util.Set;
+ import java.util.*;
  import java.util.concurrent.ConcurrentHashMap;
  import java.util.concurrent.CopyOnWriteArrayList;
  
 +import org.apache.commons.configuration.XMLConfiguration;
 +import org.apache.commons.logging.Log;
 +import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.util.ConfUtil;
 +import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 +import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 +import org.apache.stratos.common.constants.StratosConstants;
  
- 
  /**
   * This is an object that inserted to the rules engine.
   * Holds information about a partition.

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 3066034,4938b4c..fda23ca
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@@ -18,26 -18,29 +18,36 @@@
   */
  package org.apache.stratos.autoscaler.api;
  
+ import org.apache.commons.lang.StringUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.AutoscalerContext;
  import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
+ import org.apache.stratos.autoscaler.applications.parser.ApplicationParser;
+ import org.apache.stratos.autoscaler.applications.parser.DefaultApplicationParser;
+ import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
+ import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
  import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
  import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
  import org.apache.stratos.autoscaler.exception.*;
  import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface;
 +import org.apache.stratos.autoscaler.kubernetes.KubernetesManager;
 +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
  import org.apache.stratos.autoscaler.partition.PartitionGroup;
  import org.apache.stratos.autoscaler.partition.PartitionManager;
+ import org.apache.stratos.autoscaler.pojo.Dependencies;
+ import org.apache.stratos.autoscaler.pojo.ServiceGroup;
  import org.apache.stratos.autoscaler.policy.PolicyManager;
  import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.registry.RegistryManager;
  import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 +import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 +import org.apache.stratos.common.kubernetes.KubernetesGroup;
 +import org.apache.stratos.common.kubernetes.KubernetesHost;
 +import org.apache.stratos.common.kubernetes.KubernetesMaster;
+ import org.apache.stratos.messaging.domain.applications.Application;
  
+ import java.text.MessageFormat;
  import java.util.ArrayList;
  
  /**
@@@ -271,8 -209,8 +281,25 @@@ public class AutoScalerServiceImpl impl
  
          return null;
      }
 -	
 -	public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId) {
++    
++    @Override
++    public void deployApplicationDefinition(ApplicationContext applicationContext)
++            throws ApplicationDefinitionException {
++
++        ApplicationParser applicationParser = new DefaultApplicationParser();
++        Application application = applicationParser.parse(applicationContext);
++        ApplicationBuilder.handleApplicationCreated(application,
++                applicationParser.getApplicationClusterContexts());
++    }
 +
++    @Override
++    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain)
++            throws ApplicationDefinitionException {
++
++        ApplicationBuilder.handleApplicationUndeployed(applicationId);
++    }
++    
 +    public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId) {
  
          for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) {
  
@@@ -314,42 -252,121 +341,117 @@@
  
          return null;
      }
--
-     public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) {
 -    @Override
 -    public void deployApplicationDefinition(ApplicationContext applicationContext)
 -            throws ApplicationDefinitionException {
 -
 -        ApplicationParser applicationParser = new DefaultApplicationParser();
 -        Application application = applicationParser.parse(applicationContext);
 -        ApplicationBuilder.handleApplicationCreated(application,
 -                applicationParser.getApplicationClusterContexts());
 -    }
 -
 -    @Override
 -    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain)
 -            throws ApplicationDefinitionException {
 -
 -        ApplicationBuilder.handleApplicationUndeployed(applicationId);
 -    }
 -
 -    public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) {
++	
++	public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) {
  
          for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) {
  
-             NetworkPartitionLbHolder nwPartitionLbHolder = partitionManager.getNetworkPartitionLbHolder(partitionGroup.getId());
+                         NetworkPartitionLbHolder nwPartitionLbHolder = partitionManager.getNetworkPartitionLbHolder(partitionGroup.getId());
  
-             if (!nwPartitionLbHolder.isClusterLBExist(clusterId)) {
-                 if (log.isDebugEnabled()) {
-                     log.debug("Cluster LB [cluster id] " + clusterId + " does not exist in [network partition] " +
-                             nwPartitionLbHolder.getNetworkPartitionId() + " of [Deployment Policy] " +
-                             deploymentPolicyId);
+                 if (!nwPartitionLbHolder.isClusterLBExist(clusterId)) {
+                     if (log.isDebugEnabled()) {
+                         log.debug("Cluster LB [cluster id] "+clusterId+" does not exist in [network partition] " +
+                                   nwPartitionLbHolder.getNetworkPartitionId() + " of [Deployment Policy] " +
+                                   deploymentPolicyId);
  
+                     }
+                     return false;
                  }
-                 return false;
-             }
  
          }
- 
+         
          return true;
- 
+         
      }
  
 +    public void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException {
 +        if (log.isDebugEnabled()) {
 +            log.debug(String.format("Updating Cluster monitor [Cluster id] %s ", clusterId));
 +        }
 +        AutoscalerContext asCtx = AutoscalerContext.getInstance();
 +        AbstractClusterMonitor monitor = asCtx.getClusterMonitor(clusterId);
 +        
 +        if (monitor != null) {
 +            monitor.handleDynamicUpdates(properties);
 +        } else {
 +            log.debug(String.format("Updating Cluster monitor failed: Cluster monitor [Cluster id] %s not found.", 
 +                    clusterId));
 +        }
 +    }
++    
+     public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException {
+ 
+         if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
+             String msg = "Service group can not be null service name can not be empty.";
+             log.error(msg);
+             throw new IllegalArgumentException(msg);
+ 
+         }
+         String name = servicegroup.getName();
+ 
+         if(RegistryManager.getInstance().serviceGroupExist(name)){
+             throw new InvalidServiceGroupException("Service group with the name " + name + " already exist.");
+         }
+ 
+         if(log.isDebugEnabled()) {
+             log.debug(MessageFormat.format("Deploying service group {0}", servicegroup.getName()));
+         }
+ 
+         String [] subGroups = servicegroup.getCartridges();
+ 
+         if(log.isDebugEnabled()) {
+             log.debug("SubGroups" + subGroups);
+             if (subGroups != null) {
+                 log.debug("subGroups:size" + subGroups.length);
+             } else {
+                 log.debug("subGroups: are null");
+             }
+         }
+ 
+ 
+         Dependencies dependencies = servicegroup.getDependencies();
+ 
+         if(log.isDebugEnabled()) {
+             log.debug("Dependencies" + dependencies);
+         }
+ 
+         if (dependencies != null) {
+             String [] startupOrders = dependencies.getStartupOrders();
+ 
+             if(log.isDebugEnabled()) {
+                 log.debug("StartupOrders" + startupOrders);
+ 
+                 if (startupOrders != null) {
+                     log.debug("StartupOrder:size" + startupOrders.length);
+                 } else {
+                     log.debug("StartupOrder: is null");
+                 }
+             }
+         }
+ 
+         RegistryManager.getInstance().persistServiceGroup(servicegroup);
+     }
+ 
+     public ServiceGroup getServiceGroup(String name) {
+         if(StringUtils.isEmpty(name)){
+             return null;
+         }
+         try {
+             return RegistryManager.getInstance().getServiceGroup(name);
+         } catch (Exception e) {
+             throw new AutoScalerException("Error occurred while retrieving service groups", e);
+         }
+     }
+     public boolean serviceGroupExist(String serviceName){
+         return false;
+     }
  
+     public void undeployServiceGroup(String name) throws AutoScalerException {
+         try {
+             RegistryManager.getInstance().removeServiceGroup(name);
+         } catch (Exception e) {
+             throw new AutoScalerException("Error occurred while removing the service groups", e);
+         }
+ 
+     }
 -
 -
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index 0000000,fa31385..16a14de
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@@ -1,0 -1,655 +1,679 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
 -package org.apache.stratos.autoscaler.applications.parser;
++package org.apache.stratos.cloud.controller.application.parser;
+ 
+ import org.apache.commons.lang.StringUtils;
+ import org.apache.commons.logging.Log;
+ import org.apache.commons.logging.LogFactory;
+ import org.apache.stratos.autoscaler.applications.ApplicationUtils;
+ import org.apache.stratos.autoscaler.applications.MTClusterInformation;
+ import org.apache.stratos.autoscaler.applications.STClusterInformation;
+ import org.apache.stratos.autoscaler.applications.pojo.*;
+ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException;
+ import org.apache.stratos.autoscaler.exception.CartridgeInformationException;
+ import org.apache.stratos.autoscaler.pojo.ServiceGroup;
+ import org.apache.stratos.autoscaler.registry.RegistryManager;
+ import org.apache.stratos.cloud.controller.application.ClusterInformation;
++import org.apache.stratos.cloud.controller.application.MTClusterInformation;
++import org.apache.stratos.cloud.controller.application.STClusterInformation;
++import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException;
++import org.apache.stratos.cloud.controller.interfaces.ApplicationParser;
++import org.apache.stratos.cloud.controller.pojo.*;
++import org.apache.stratos.cloud.controller.pojo.Cartridge;
++import org.apache.stratos.cloud.controller.pojo.Properties;
++import org.apache.stratos.cloud.controller.pojo.application.*;
++import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
++import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
++import org.apache.stratos.common.constants.StratosConstants;
++import org.apache.stratos.messaging.domain.topology.*;
+ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
+ import org.apache.stratos.messaging.domain.applications.Application;
+ import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+ import org.apache.stratos.messaging.domain.applications.DependencyOrder;
+ import org.apache.stratos.messaging.domain.applications.Group;
+ 
+ import java.util.*;
+ 
+ /**
+  * Default implementation of the Application Parser. One Application should be processed by one
+  * instance of the DefaultApplicationParser.
+  */
+ public class DefaultApplicationParser implements ApplicationParser {
+ 
+     private static Log log = LogFactory.getLog(DefaultApplicationParser.class);
+ 
+     private Set<ApplicationClusterContext> applicationClusterContexts;
+ 
+     public DefaultApplicationParser () {
+ 
+         this.applicationClusterContexts = new HashSet<ApplicationClusterContext>();
+     }
+ 
+     @Override
+     public Application parse(Object obj) throws ApplicationDefinitionException {
+ 
+         ApplicationContext applicationCtxt = (ApplicationContext) obj;
+ 
+         if (applicationCtxt == null) {
+             handleError("Invalid Composite Application Definition");
+         }
+ 
+         assert applicationCtxt != null;
+         if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) {
+             handleError("Invalid alias specified");
+         }
+ 
+         if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) {
+             handleError("Invalid Composite App id specified");
+         }
+ 
+         // get the defined groups
+         Map<String, GroupContext> definedGroups = getDefinedGroups(applicationCtxt);
+         if (log.isDebugEnabled()) {
+             if (definedGroups != null) {
+                 Set<Map.Entry<String, GroupContext>> groupEntries = definedGroups.entrySet();
+                 log.debug("Defined Groups: [ ");
+                 for (Map.Entry<String, GroupContext> groupEntry : groupEntries) {
+                     log.debug("Group alias: " + groupEntry.getKey());
+                 }
+                 log.debug(" ]");
+             } else {
+                 log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId());
+             }
+         }
+ 
+         // get the Subscribables Information
+         Map<String, SubscribableInfoContext> subscribablesInfo = getSubscribableInformation(applicationCtxt);
+         if (log.isDebugEnabled()) {
+             Set<Map.Entry<String, SubscribableInfoContext>> subscribableInfoCtxtEntries = subscribablesInfo.entrySet();
+             log.debug("Defined Subscribable Information: [ ");
+             for (Map.Entry<String, SubscribableInfoContext> subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) {
+                 log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey());
+             }
+             log.debug(" ]");
+         }
+ 
+         if (subscribablesInfo == null) {
+             handleError("Invalid Composite Application Definition, no Subscribable Information specified");
+         }
+ 
+         return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo);
+     }
+ 
+     @Override
+     public Set<ApplicationClusterContext> getApplicationClusterContexts() throws ApplicationDefinitionException {
+         return applicationClusterContexts;
+     }
+ 
++    @Override
++    public Set<MetaDataHolder> getPayloadData() throws ApplicationDefinitionException {
++        return metaDataHolders;
++    }
++
+     /**
+      * Extract Group information from Application Definition
+      *
+      * @param appCtxt ApplicationContext object with Application information
+      * @return Map [group alias -> Group]
+      *
+      * @throws ApplicationDefinitionException if the Group information is invalid
+      */
+     private Map<String, GroupContext> getDefinedGroups (ApplicationContext appCtxt) throws
+             ApplicationDefinitionException {
+ 
+         // map [group alias -> Group Definition]
+         Map<String, GroupContext> definedGroups = null;
+ 
+         if (appCtxt.getComponents() != null) {
+             if (appCtxt.getComponents().getGroupContexts() != null) {
+                 definedGroups = new HashMap<String, GroupContext>();
+ 
+                 for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) {
+ 
+                     // check validity of group name
+                     if (StringUtils.isEmpty(groupContext.getName())) {
+                         handleError("Invalid Group name specified");
+                     }
+ 
+                     // check if group is deployed
+                     if(!isGroupDeployed(groupContext.getName())) {
+                         handleError("Group with name " + groupContext.getName() + " not deployed");
+                     }
+ 
+                     // check validity of group alias
+ 
+                     if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) {
+                         handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]");
+                     }
+ 
+                     // check if a group is already defined under the same alias
+                     if(definedGroups.get(groupContext.getAlias()) != null) {
+                         // a group with same alias already exists, can't continue
+                         handleError("A Group with alias " + groupContext.getAlias() + " already exists");
+                     }
+ 
+                     definedGroups.put(groupContext.getAlias(), groupContext);
+                     if (log.isDebugEnabled()) {
+                         log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]");
+                     }
+                 }
+             }
+         }
+ 
+         return definedGroups;
+     }
+ 
+     /**
+      * Extract Subscription Information from the Application Definition
+      *
+      * @param appCtxt ApplicationContext object with Application information
+      * @return Map [cartridge alias -> Group]
+      *
+      * @throws ApplicationDefinitionException if the Subscription information is invalid
+      */
+     private Map<String, SubscribableInfoContext> getSubscribableInformation (ApplicationContext appCtxt) throws
+             ApplicationDefinitionException {
+ 
+         // map [cartridge alias -> Subscribable Information]
+         Map<String, SubscribableInfoContext> subscribableInformation = null;
+ 
+         if (appCtxt.getSubscribableInfoContext() != null) {
+             subscribableInformation = new HashMap<String, SubscribableInfoContext>();
+ 
+             for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) {
+ 
+                 if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) ||
+                         !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) {
+                     handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]");
+                 }
+ 
+                 // check if a group is already defined under the same alias
+                 if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) {
+                     // a group with same alias already exists, can't continue
+                     handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists");
+                 }
+ 
+                 subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt);
+                 if (log.isDebugEnabled()) {
+                     log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]");
+                 }
+             }
+         }
+ 
+         return subscribableInformation;
+     }
+ 
+     /**
+      * Check if a Group Definition is deployed
+      *
+      * @param serviceGroupName Group name
+      * @return true if the Group is deployed, else false
+      *
+      * @throws ApplicationDefinitionException
+      */
+     private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException {
+ 
+         try {
+             return RegistryManager.getInstance().getServiceGroup(serviceGroupName) != null;
+         } catch (Exception e) {
+             String errorMsg = "Error in checking if Service Group Definition [ " + serviceGroupName
+                     + " ] already exists";
+             log.error(errorMsg, e);
+             throw new ApplicationDefinitionException(errorMsg, e);
+         }
+     }
+ 
+     /**
+      * Builds the Application structure
+      *
+      * @param appCtxt ApplicationContext object with Application information
+      * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information
+      * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+      * @return Application Application object denoting the Application structure
+      *
+      * @throws ApplicationDefinitionException If an error occurs in building the Application structure
+      */
+     private Application buildCompositeAppStructure (ApplicationContext appCtxt,
+                                                             Map<String, GroupContext> definedGroupCtxts,
+                                                             Map<String, SubscribableInfoContext> subscribableInfoCtxts)
+             throws ApplicationDefinitionException {
+ 
+         Application application = new Application(appCtxt.getApplicationId());
+ 
+         // set tenant related information
+         application.setTenantId(appCtxt.getTenantId());
+         application.setTenantDomain(appCtxt.getTenantDomain());
+         application.setTenantAdminUserName(appCtxt.getTeantAdminUsername());
+ 
+         // following keeps track of all Clusters created for this application
+         //Set<Cluster> clusters = new HashSet<Cluster>();
+         //ClusterDataHolder clusterDataHolder = null;
+         Map<String, ClusterDataHolder> clusterDataMap;
+ 
+         if (appCtxt.getComponents() != null) {
+             // get top level Subscribables
+             if (appCtxt.getComponents().getSubscribableContexts() != null) {
+                 clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(),
+                         application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()),
 -                        subscribableInfoCtxts);
++                        subscribableInfoCtxts, appCtxt.getProperties());
+                 application.setClusterData(clusterDataMap);
+                 //clusters.addAll(clusterDataHolder.getApplicationClusterContexts());
+             }
+ 
+             // get Groups
+             if (appCtxt.getComponents().getGroupContexts() != null) {
+                 application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(),
+                         application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()),
 -                        subscribableInfoCtxts, definedGroupCtxts));
++                        subscribableInfoCtxts, definedGroupCtxts, appCtxt.getProperties()));
+             }
+ 
+             // get top level Dependency definitions
+             if (appCtxt.getComponents().getDependencyContext() != null) {
+                 DependencyOrder appDependencyOrder = new DependencyOrder();
+                 String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts();
+                 if (startupOrders != null) {
+                 	if (log.isDebugEnabled()) {
+                     	log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + 
+                     				appCtxt.getAlias() + " #: " + startupOrders.length);
+                     }
+                     appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders));
+                 } else {
+                 	if (log.isDebugEnabled()) {
+                     	log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias());
+                     }
+                 }
+                 String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour();
+                 validateTerminationBehavior(terminationBehavior);
+                 appDependencyOrder.setTerminationBehaviour(terminationBehavior);
+ 
+                 application.setDependencyOrder(appDependencyOrder);
+             }
+         }
+ 
+         log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully");
+ 
+         return application;
+     }
+ 
+     /**
+      * Validates terminationBehavior. The terminationBehavior should be one of the following:
+      *      1. terminate-none
+      *      2. terminate-dependents
+      *      3. terminate-all
+      *
+      * @throws ApplicationDefinitionException if terminationBehavior is different to what is
+      * listed above
+      */
+     private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException {
+ 
+         if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) ||
+                 "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) {
+             throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " +
+                     terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " +
+                     " 'terminate-all' ");
+         }
+     }
+ 
+     /**
+      * Parse Group information
+      *
+      * @param appId Application id
+      * @param tenantId tenant id of tenant which deployed the Application
+      * @param key Generated key for the Application
+      * @param groupCtxts  Group information
+      * @param subscribableInformation Subscribable Information
+      * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
+      * @return Map [alias -> Group]
+      *
+      * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
+      */
+     private Map<String, Group> parseGroups (String appId, int tenantId, String key, List<GroupContext> groupCtxts,
+                                            Map<String, SubscribableInfoContext> subscribableInformation,
 -                                           Map<String, GroupContext> definedGroupCtxts)
++                                           Map<String, GroupContext> definedGroupCtxts, Properties properties)
+             throws ApplicationDefinitionException {
+ 
+         Map<String, Group> groupAliasToGroup = new HashMap<String, Group>();
+ 
+         for (GroupContext groupCtxt : groupCtxts) {
 -            Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts);
++            Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts, properties);
+             groupAliasToGroup.put(group.getAlias(), group);
+         }
+ 
+         //Set<GroupContext> topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup);
+         Set<Group> nestedGroups = new HashSet<Group>();
+         getNestedGroupContexts(nestedGroups, groupAliasToGroup.values());
+         filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups);
+ 
+         return groupAliasToGroup;
+     }
+ 
+     /**
+      * Extracts nested Group information recursively
+      *
+      * @param nestedGroups Nested Groups set to be populated recursively
+      * @param groups Collection of Groups
+      */
+     private void getNestedGroupContexts (Set<Group> nestedGroups, Collection<Group> groups) {
+ 
+         if (groups != null) {
+             for (Group group : groups) {
+                 if (group.getGroups() != null) {
+                     nestedGroups.addAll(group.getGroups());
+                     getNestedGroupContexts(nestedGroups, group.getGroups());
+                 }
+             }
+         }
+     }
+ 
+     /**
+      * Filters duplicated Groups from top level
+      *
+      * @param topLevelGroups Top level Groups
+      * @param nestedGroups nested Groups
+      */
+     private void filterDuplicatedGroupContexts (Collection<Group> topLevelGroups, Set<Group> nestedGroups) {
+ 
+         for (Group nestedGroup : nestedGroups) {
+             filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup);
+         }
+     }
+ 
+     private void filterNestedGroupFromTopLevel (Collection<Group> topLevelGroups, Group nestedGroup) {
+ 
+         Iterator<Group> parentIterator = topLevelGroups.iterator();
+         while (parentIterator.hasNext()) {
+             Group parentGroup = parentIterator.next();
+             // if there is an exactly similar nested Group Context and a top level Group Context
+             // it implies that they are duplicates. Should be removed from top level.
+             if (parentGroup.equals(nestedGroup)) {
+                 parentIterator.remove();
+             }
+         }
+     }
+ 
+     /**
+      * Parses an individual Group
+      *
+      * @param appId Application id
+      * @param tenantId tenant id of tenant which deployed the Application
+      * @param key Generated key for the Application
+      * @param groupCtxt Group definition information
+      * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+      * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
+      * @return  Group object
+      *
+      * @throws ApplicationDefinitionException if unable to parse
+      */
+     private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt,
+                              Map<String, SubscribableInfoContext> subscribableInfoCtxts,
 -                             Map<String, GroupContext> definedGroupCtxts)
++                             Map<String, GroupContext> definedGroupCtxts, Properties properties)
+             throws ApplicationDefinitionException {
+ 
+         // check if are in the defined Group set
+         GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias());
+         if (definedGroupDef == null) {
+             handleError("Group Definition with name: " + groupCtxt.getName() + ", alias: " +
+                     groupCtxt.getAlias() + " is not found in the all Group Definitions collection");
+         }
+ 
+         Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias());
+ 
+         group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy());
+         group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy());
+         DependencyOrder dependencyOrder = new DependencyOrder();
+         // create the Dependency Ordering
+         String []  startupOrders = getStartupOrderForGroup(groupCtxt);
+         if (startupOrders != null) {
+             dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt));
+         }
+         dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName()));
+         group.setDependencyOrder(dependencyOrder);
+ 
+         Map<String, ClusterDataHolder> clusterDataMap;
+ 
+         // get group level Subscribables
+         if (groupCtxt.getSubscribableContexts() != null) {
+             clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(),
 -                    Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts);
++                    Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts, properties);
+             group.setClusterData(clusterDataMap);
+         }
+ 
+         // get nested groups
+         if (groupCtxt.getGroupContexts() != null) {
+             Map<String, Group> nestedGroups = new HashMap<String, Group>();
+             // check sub groups
+             for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) {
+                 // get the complete Group Definition
+                 subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias());
+                 Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt,
+                         subscribableInfoCtxts,
 -                        definedGroupCtxts);
++                        definedGroupCtxts, properties);
+                 nestedGroups.put(nestedGroup.getAlias(), nestedGroup);
+             }
+ 
+             group.setGroups(nestedGroups);
+         }
+ 
+         return group;
+     }
+ 
+     /**
+      * Find the startup order
+      *
+      * @param groupContext GroupContext with Group defintion information
+      * @return Set of Startup Orders which are defined in the Group
+      *
+      * @throws ApplicationDefinitionException
+      */
+     private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
+ 
+         ServiceGroup serviceGroup;
+         try {
+             serviceGroup = RegistryManager.getInstance().getServiceGroup(groupContext.getName());
+         } catch (Exception e) {
+             String errorMsg = "Error in getting Service Group Definition for [ " + groupContext.getName() +
+                     " ] from Registry";
+             log.error(errorMsg, e);
+             throw new ApplicationDefinitionException(errorMsg, e);
+         }
+ 
+         if (serviceGroup == null) {
+             handleError("Service Group Definition not found for name " + groupContext.getName());
+         }
+         
+         if (log.isDebugEnabled()) {
+         	log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName());
+         }
+ 
+         assert serviceGroup != null;
+         if (serviceGroup.getDependencies() != null) {
+         	if (log.isDebugEnabled()) {
+             	log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " );
+             }
+             if (serviceGroup.getDependencies().getStartupOrders() != null) {
+             	
+             	String [] startupOrders = serviceGroup.getDependencies().getStartupOrders();
+             	if (log.isDebugEnabled()) {
+                 	log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " +  startupOrders.length);
+                 }
+                 return startupOrders;
+             }
+         }
+ 
+         return null;
+     }
+ 
+     /**
+      * Get kill behaviour related to a Group
+      *
+      * @param serviceGroupName Group name
+      * @return String indicating the kill behavior
+      *
+      * @throws ApplicationDefinitionException if an error occurs
+      */
+     private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException {
+ 
+         ServiceGroup serviceGroup;
+         try {
+             serviceGroup = RegistryManager.getInstance().getServiceGroup(serviceGroupName);
+         } catch (Exception e) {
+             String errorMsg = "Error in getting Service Group Definition for [ " + serviceGroupName +
+                     " ] from Registry";
+             log.error(errorMsg, e);
+             throw new ApplicationDefinitionException(errorMsg, e);
+         }
+ 
+         if (serviceGroup == null) {
+             handleError("Service Group Definition not found for name " + serviceGroupName);
+         }
+ 
+         assert serviceGroup != null;
+         if (serviceGroup.getDependencies() != null) {
+             return serviceGroup.getDependencies().getKillBehaviour();
+         }
+ 
+         return null;
+ 
+     }
+ 
+     /**
+      * Parse Subscription Information
+      *
+      * @param appId Application id
+      * @param tenantId Tenant id of tenant which deployed the Application
+      * @param key Generated key for the Application
+      * @param groupName Group name (if relevant)
+      * @param subscribableCtxts Subscribable Information
+      * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
+      * @return Map [subscription alias -> ClusterDataHolder]
+      *
+      * @throws ApplicationDefinitionException
+      */
+     private Map<String, ClusterDataHolder> parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName,
+                                                                  List<SubscribableContext> subscribableCtxts,
 -                                                                 Map<String, SubscribableInfoContext> subscribableInfoCtxts)
++                                                                 Map<String, SubscribableInfoContext> subscribableInfoCtxts,
++                                                                 Properties properties)
+             throws ApplicationDefinitionException {
+ 
+         Map<String, ClusterDataHolder> clusterDataMap = new HashMap<String, ClusterDataHolder>();
+ 
+         for (SubscribableContext subscribableCtxt : subscribableCtxts) {
+ 
+             // check is there is a related Subscribable Information
+             SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias());
+             if (subscribableInfoCtxt == null) {
+                 handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: "
+                         + subscribableCtxt.getAlias());
+             }
+ 
+             // check if Cartridge Type is valid
+             if (StringUtils.isEmpty(subscribableCtxt.getType())) {
+                 handleError("Invalid Cartridge Type specified : [ "
+                         + subscribableCtxt.getType() + " ]");
+             }
+ 
+             // check if a cartridgeInfo with relevant type is already deployed. else, can't continue
+             CartridgeInfo cartridgeInfo =  getCartridge(subscribableCtxt.getType());
+             if (cartridgeInfo == null) {
+                 handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() +
+                         " ] for Composite Application");
+             }
+ 
+             // get hostname and cluster id
+             ClusterInformation clusterInfo;
+             assert cartridgeInfo != null;
+             if (cartridgeInfo.getMultiTenant()) {
+                 clusterInfo = new MTClusterInformation();
+             } else {
+                 clusterInfo = new STClusterInformation();
+             }
+ 
+             String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridgeInfo.getHostName());
+             String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType());
++            boolean isKubernetesCluster = StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType());
+ 
+             // create and collect this cluster's information
+             assert subscribableInfoCtxt != null;
+             ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridgeInfo,
+                     key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(),
 -                    clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases());
++                    clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(),
++                    false, isKubernetesCluster, subscribableInfoCtxt.getDependencyAliases(), properties);
+ 
+             appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy());
+             this.applicationClusterContexts.add(appClusterCtxt);
+ 
+             // add relevant information to the map
+             clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId));
+         }
+ 
+         return clusterDataMap;
+     }
+ 
+     /**
+      * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
+      *
+      * @param appId Application id
+      * @param groupName Group name
+      * @param cartridgeInfo Cartridge information
+      * @param subscriptionKey Generated key for the Application
+      * @param tenantId Tenant Id of the tenant which deployed the Application
+      * @param repoUrl Repository URL
+      * @param alias alias specified for this Subscribable in the Application Definition
+      * @param clusterId Cluster id
+      * @param hostname Hostname
+      * @param deploymentPolicy Deployment policy used
 -     * @param isLB if this cluster is an LB
++     * @param isLBCluster if this cluster is an LB
++     * @param isKubernetesCluster if this cluster is a Kubernetes cluster
+      * @return ApplicationClusterContext object with relevant information
+      *
+      * @throws ApplicationDefinitionException If any error occurs
+      */
+     private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, CartridgeInfo cartridgeInfo,
+                                                                        String subscriptionKey, int tenantId, String repoUrl,
+                                                                        String alias, String clusterId, String hostname,
 -                                                                       String deploymentPolicy, boolean isLB, String[] dependencyAliases)
++                                                                       String deploymentPolicy, boolean isLBCluster,
++                                                                       boolean isKubernetesCluster, String[] dependencyAliases,
++                                                                       Properties properties)
+             throws ApplicationDefinitionException {
+ 
+         // Create text payload
+         String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridgeInfo, subscriptionKey, tenantId, clusterId,
+                 hostname, repoUrl, alias, null, dependencyAliases).toString();
+ 
 -        return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB);
++        return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, 
++                isLB, isKubernetesCluster, properties);
+     }
+ 
+     private CartridgeInfo getCartridge (String cartridgeType) throws ApplicationDefinitionException {
+ 
+         try {
+             return CloudControllerClient.getInstance().getCartrdgeInformation(cartridgeType);
+         } catch (CartridgeInformationException e) {
+             throw new ApplicationDefinitionException(e);
+         }
+     }
+ 
+     private void handleError (String errorMsg) throws ApplicationDefinitionException {
+         log.error(errorMsg);
+         throw new ApplicationDefinitionException(errorMsg);
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
index 0000000,1b9c516..b3560c3
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
@@@ -1,0 -1,93 +1,112 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
 -public class ApplicationContext {
++import org.apache.stratos.cloud.controller.pojo.Properties;
++
++import java.io.Serializable;
++
++public class ApplicationContext implements Serializable {
++
++    private static final long serialVersionUID = 6704036501869668646L;
+ 
+     private int tenantId;
+ 
+     private String tenantDomain;
+ 
+     private String teantAdminUsername;
+ 
+     private String applicationId;
+ 
+     private String alias;
+ 
+     private ComponentContext componentContext;
+ 
+     private SubscribableInfoContext[] subscribableInfoContexts;
+ 
++    private Properties properties;
++
++    public ApplicationContext() {
++    }
++
+     public String getApplicationId() {
+         return applicationId;
+     }
+ 
+     public void setApplicationId(String applicationId) {
+         this.applicationId = applicationId;
+     }
+ 
+     public String getAlias() {
+         return alias;
+     }
+ 
+     public void setAlias(String alias) {
+         this.alias = alias;
+     }
+ 
+     public ComponentContext getComponents() {
+         return componentContext;
+     }
+ 
+     public void setComponents(ComponentContext componentContext) {
+         this.componentContext = componentContext;
+     }
+ 
+     public SubscribableInfoContext[] getSubscribableInfoContext() {
+         return subscribableInfoContexts;
+     }
+ 
+     public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) {
+         this.subscribableInfoContexts = subscribableInfoContexts;
+     }
+ 
+     public int getTenantId() {
+         return tenantId;
+     }
+ 
+     public void setTenantId(int tenantId) {
+         this.tenantId = tenantId;
+     }
+ 
+     public String getTenantDomain() {
+         return tenantDomain;
+     }
+ 
+     public void setTenantDomain(String tenantDomain) {
+         this.tenantDomain = tenantDomain;
+     }
+ 
+     public String getTeantAdminUsername() {
+         return teantAdminUsername;
+     }
+ 
+     public void setTeantAdminUsername(String teantAdminUsername) {
+         this.teantAdminUsername = teantAdminUsername;
+     }
++
++    public Properties getProperties() {
++        return properties;
++    }
++
++    public void setProperties(Properties properties) {
++        this.properties = properties;
++    }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
index 0000000,b39b07f..2816f4e
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java
@@@ -1,0 -1,54 +1,58 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
 -public class ComponentContext {
++import java.io.Serializable;
++
++public class ComponentContext implements Serializable {
++
++    private static final long serialVersionUID = -3841830873207967496L;
+ 
+     private GroupContext[] groupContexts;
+ 
+     private SubscribableContext[] subscribableContexts;
+ 
+     private DependencyContext dependencyContext;
+ 
+ 
+     public GroupContext[] getGroupContexts() {
+         return groupContexts;
+     }
+ 
+     public void setGroupContexts(GroupContext[] groupContexts) {
+         this.groupContexts = groupContexts;
+     }
+ 
+     public SubscribableContext[] getSubscribableContexts() {
+         return subscribableContexts;
+     }
+ 
+     public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
+         this.subscribableContexts = subscribableContexts;
+     }
+ 
+     public DependencyContext getDependencyContext() {
+         return dependencyContext;
+     }
+ 
+     public void setDependencyContext(DependencyContext dependencyContext) {
+         this.dependencyContext = dependencyContext;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
index 0000000,ccb17f0..57a57d1
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java
@@@ -1,0 -1,44 +1,48 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
+ 
 -public class DependencyContext {
 -    
++import java.io.Serializable;
++
++public class DependencyContext implements Serializable {
++
++    private static final long serialVersionUID = 6211713487242343226L;
++
+     private String [] startupOrdersContexts;
+ 
+     private String terminationBehaviour;
+ 
+     public String getTerminationBehaviour() {
+         return terminationBehaviour;
+     }
+ 
+     public void setTerminationBehaviour(String terminationBehaviour) {
+         this.terminationBehaviour = terminationBehaviour;
+     }
+ 
+ 	public String [] getStartupOrdersContexts() {
+ 		return startupOrdersContexts;
+ 	}
+ 
+ 	public void setStartupOrdersContexts(String [] startupOrdersContexts) {
+ 		this.startupOrdersContexts = startupOrdersContexts;
+ 	}
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
index 0000000,c05a5d5..885cccc
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java
@@@ -1,0 -1,84 +1,88 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
 -public class GroupContext {
++import java.io.Serializable;
++
++public class GroupContext implements Serializable{
++
++    private static final long serialVersionUID = 1595266728968445926L;
+ 
+     private String name;
+ 
+     private String alias;
+ 
+     private String deploymentPolicy;
+ 
+     private String autoscalingPolicy;
+ 
+     private SubscribableContext[] subscribableContexts;
+ 
+     private GroupContext[] groupContexts;
+ 
+ 
+     public String getName() {
+         return name;
+     }
+ 
+     public void setName(String name) {
+         this.name = name;
+     }
+ 
+     public String getAlias() {
+         return alias;
+     }
+ 
+     public void setAlias(String alias) {
+         this.alias = alias;
+     }
+ 
+     public String getDeploymentPolicy() {
+         return deploymentPolicy;
+     }
+ 
+     public void setDeploymentPolicy(String deploymentPolicy) {
+         this.deploymentPolicy = deploymentPolicy;
+     }
+ 
+     public String getAutoscalingPolicy() {
+         return autoscalingPolicy;
+     }
+ 
+     public void setAutoscalingPolicy(String autoscalingPolicy) {
+         this.autoscalingPolicy = autoscalingPolicy;
+     }
+ 
+     public SubscribableContext[] getSubscribableContexts() {
+         return subscribableContexts;
+     }
+ 
+     public void setSubscribableContexts(SubscribableContext[] subscribableContexts) {
+         this.subscribableContexts = subscribableContexts;
+     }
+ 
+     public GroupContext[] getGroupContexts() {
+         return groupContexts;
+     }
+ 
+     public void setGroupContexts(GroupContext[] groupContexts) {
+         this.groupContexts = groupContexts;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
index 0000000,7ae4864..7a73976
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java
@@@ -1,0 -1,44 +1,47 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
 -public class SubscribableContext {
++import java.io.Serializable;
++
++public class SubscribableContext implements Serializable {
++
++    private static final long serialVersionUID = 3853456523070318925L;
+ 
+     private String type;
+ 
+     private String alias;
+ 
 -
+     public String getType() {
+         return type;
+     }
+ 
+     public void setType(String type) {
+         this.type = type;
+     }
+ 
+     public String getAlias() {
+         return alias;
+     }
+ 
+     public void setAlias(String alias) {
+         this.alias = alias;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fb37af/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
index 0000000,62d32df..20cf3f8
mode 000000,100644..100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java
@@@ -1,0 -1,103 +1,107 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.applications.pojo;
+ 
 -public class SubscribableInfoContext {
++import java.io.Serializable;
++
++public class SubscribableInfoContext implements Serializable {
++
++    private static final long serialVersionUID = -6874644941002783034L;
+ 
+     private String alias;
+ 
+     private String deploymentPolicy;
+ 
+     private String autoscalingPolicy;
+ 
+     private String repoUrl;
+ 
+     private boolean privateRepo;
+ 
+     private String repoUsername;
+ 
+     private String repoPassword;
+ 
+     private String[] dependencyAliases;
+ 
+     public String getAlias() {
+         return alias;
+     }
+ 
+     public void setAlias(String alias) {
+         this.alias = alias;
+     }
+ 
+     public String getDeploymentPolicy() {
+         return deploymentPolicy;
+     }
+ 
+     public void setDeploymentPolicy(String deploymentPolicy) {
+         this.deploymentPolicy = deploymentPolicy;
+     }
+ 
+     public String getAutoscalingPolicy() {
+         return autoscalingPolicy;
+     }
+ 
+     public void setAutoscalingPolicy(String autoscalingPolicy) {
+         this.autoscalingPolicy = autoscalingPolicy;
+     }
+ 
+     public String getRepoUrl() {
+         return repoUrl;
+     }
+ 
+     public void setRepoUrl(String repoUrl) {
+         this.repoUrl = repoUrl;
+     }
+ 
+     public boolean isPrivateRepo() {
+         return privateRepo;
+     }
+ 
+     public void setPrivateRepo(boolean privateRepo) {
+         this.privateRepo = privateRepo;
+     }
+ 
+     public String getRepoUsername() {
+         return repoUsername;
+     }
+ 
+     public void setRepoUsername(String repoUsername) {
+         this.repoUsername = repoUsername;
+     }
+ 
+     public String getRepoPassword() {
+         return repoPassword;
+     }
+ 
+     public void setRepoPassword(String repoPassword) {
+         this.repoPassword = repoPassword;
+     }
+ 
+     public String[] getDependencyAliases() {
+         return dependencyAliases;
+     }
+ 
+     public void setDependencyAliases(String[] dependencyAliases) {
+         this.dependencyAliases = dependencyAliases;
+     }
+ }


[34/50] [abbrv] git commit: fixing merge issue

Posted by im...@apache.org.
fixing merge issue


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

Branch: refs/heads/docker-grouping-merge
Commit: 746c37ae022c5771b406b92e249cc4cb23f5515a
Parents: ff2e971
Author: reka <rt...@gmail.com>
Authored: Fri Oct 31 16:25:24 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Oct 31 16:25:24 2014 +0530

----------------------------------------------------------------------
 .../ApplicationStatusTopicReceiver.java         |  7 ++
 .../controller/topology/TopologyBuilder.java    | 71 ++++++++--------
 .../topology/TopologyEventPublisher.java        | 23 ++++--
 .../messaging/domain/topology/Cluster.java      |  6 +-
 .../ClusterStatusClusterCreatedEvent.java       | 85 ++++++++++++++++++++
 ...lusterStatusClusterCreatedEventListener.java | 24 ++++++
 ...rStatusClusterActivatedMessageProcessor.java |  2 +-
 ...terStatusClusterCreatedMessageProcessor.java | 59 ++++++++++++++
 ...StatusClusterInactivateMessageProcessor.java |  2 +-
 ...usterStatusClusterResetMessageProcessor.java |  2 +-
 ...StatusClusterTerminatedMessageProcessor.java |  2 +-
 ...tatusClusterTerminatingMessageProcessor.java |  2 +-
 .../ClusterStatusMessageProcessorChain.java     | 16 ++--
 13 files changed, 249 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index d75039d..1fe14fd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -71,6 +71,13 @@ public class ApplicationStatusTopicReceiver implements Runnable {
             }
         });
 
+        statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event);
+            }
+        });
+
         statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/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 5c25297..e70d182 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
@@ -119,7 +119,42 @@ public class TopologyBuilder {
         }
     }
 
-    public static void handleClusterCreated(ClusterStatusClusterResettedEvent event) {
+    public static void handleClusterCreated(ClusterStatusClusterCreatedEvent event) {
+        TopologyManager.acquireWriteLock();
+        Cluster cluster;
+
+        try {
+            Topology topology = TopologyManager.getTopology();
+            Service service = topology.getService(event.getServiceName());
+            if (service == null) {
+                log.error("Service " + event.getServiceName() +
+                        " not found in Topology, unable to update the cluster status to Created");
+                return;
+            }
+
+            if (service.clusterExists(event.getClusterId())) {
+                log.warn("Cluster " + event.getClusterId() + " is already in the Topology ");
+                return;
+            } else {
+                cluster = new Cluster(event.getServiceName(),
+                        event.getClusterId(), event.getDeploymentPolicyName(),
+                        event.getAutosScalePolicyName(), event.getAppId());
+                //cluster.setStatus(Status.Created);
+                cluster.setHostNames(event.getHostNames());
+                cluster.setTenantRange(event.getTenantRange());
+                cluster.setStatus(ClusterStatus.Created);
+                service.addCluster(cluster);
+                TopologyManager.updateTopology(topology);
+            }
+        } finally {
+            TopologyManager.releaseWriteLock();
+        }
+
+        TopologyEventPublisher.sendClusterCreatedEvent(cluster);
+    }
+
+
+    public static void handleClusterReset(ClusterStatusClusterResettedEvent event) {
 
         TopologyManager.acquireWriteLock();
 
@@ -152,7 +187,7 @@ public class TopologyBuilder {
             TopologyManager.releaseWriteLock();
         }
 
-        TopologyEventPublisher.sendClusterCreatedEvent(event.getAppId(), event.getServiceName(),
+        TopologyEventPublisher.sendClusterResetEvent(event.getAppId(), event.getServiceName(),
                 event.getClusterId());
     }
 
@@ -231,38 +266,6 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy);
     }
 
-    /*public static void handleClusterMaintenanceMode(ClusterContext ctxt) {
-
-        Topology topology = TopologyManager.getTopology();
-        Service service = topology.getService(ctxt.getCartridgeType());
-        if (service == null) {
-            log.warn(String.format("Service %s does not exist",
-                    ctxt.getCartridgeType()));
-            return;
-        }
-
-        if (!service.clusterExists(ctxt.getClusterId())) {
-            log.warn(String.format("Cluster %s does not exist for service %s",
-                    ctxt.getClusterId(),
-                    ctxt.getCartridgeType()));
-            return;
-        }
-
-        try {
-            TopologyManager.acquireWriteLock();
-            Cluster cluster = service.getCluster(ctxt.getClusterId());
-            if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
-                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive);
-            }
-            cluster.setStatus(ClusterStatus.Inactive);
-            TopologyManager.updateTopology(topology);
-        } finally {
-            TopologyManager.releaseWriteLock();
-        }
-        TopologyEventPublisher.sendClusterMaintenanceModeEvent(ctxt);
-    }*/
-
-
     public static void handleMemberSpawned(String serviceName,
                                            String clusterId, String partitionId,
                                            String privateIp, String publicIp, MemberContext context) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index eb1fb7f..3f58080 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -77,13 +77,22 @@ public class TopologyEventPublisher {
         }
     }
 
-    public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-//        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
-//
-//        if(log.isInfoEnabled()) {
-//            log.info("Publishing cluster created event: " +clusterId);
-//        }
-//        publishEvent(clusterCreatedEvent);
+    public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) {
+        ClusterResetEvent clusterResetEvent = new ClusterResetEvent(appId,serviceName, clusterId);
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing cluster reset event: " + clusterId);
+        }
+        publishEvent(clusterResetEvent);
+    }
+
+    public static void sendClusterCreatedEvent(Cluster cluster) {
+        ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(cluster);
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing cluster created event: " + cluster.getClusterId());
+        }
+        publishEvent(clusterCreatedEvent);
     }
 
     public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/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 1f69fd6..eef5a76 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
@@ -65,7 +65,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
         this.clusterId = clusterId;
         this.deploymentPolicyName = deploymentPolicyName;
         this.autoscalePolicyName = autoscalePolicyName;
-        this.hostNames = new ArrayList<String>();
+        this.setHostNames(new ArrayList<String>());
         this.memberMap = new HashMap<String, Member>();
         this.appId = appId;
         this.clusterStateManager = new LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created, clusterId);
@@ -250,6 +250,10 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
         return appId;
     }
 
+    public void setHostNames(List<String> hostNames) {
+        this.hostNames = hostNames;
+    }
+
 //    public ClusterStatus getTempStatus() {
 //        return status;
 //    }

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
new file mode 100644
index 0000000..5004cd8
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+import java.util.List;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterStatusClusterCreatedEvent extends Event {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+    private String autosScalePolicyName;
+    private String deploymentPolicyName;
+    private List<String> hostNames;
+    private String tenantRange;
+
+    public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId,
+                                            String autosScalePolicyName, String deploymentPolicyName) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+        this.deploymentPolicyName = deploymentPolicyName;
+        this.autosScalePolicyName = autosScalePolicyName;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public String getAutosScalePolicyName() {
+        return autosScalePolicyName;
+    }
+
+    public String getDeploymentPolicyName() {
+        return deploymentPolicyName;
+    }
+
+    public List<String> getHostNames() {
+        return hostNames;
+    }
+
+    public void setHostNames(List<String> hostNames) {
+        this.hostNames = hostNames;
+    }
+
+    public String getTenantRange() {
+        return tenantRange;
+    }
+
+    public void setTenantRange(String tenantRange) {
+        this.tenantRange = tenantRange;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
new file mode 100644
index 0000000..6ca5476
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.cluster.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
index 694c3f3..92fe910 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java
@@ -42,7 +42,7 @@ public class ClusterStatusClusterActivatedMessageProcessor extends MessageProces
                     jsonToObject(message, ClusterStatusClusterActivatedEvent.class);
 
             if(log.isDebugEnabled()) {
-                log.debug("Received ClusterActivatedEvent: " + event.toString());
+                log.debug("Received ClusterStatusClusterActivatedEvent: " + event.toString());
             }
             // Notify event listeners
             notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
new file mode 100644
index 0000000..d6bdcd7
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.cluster.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor {
+    private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class);
+    private MessageProcessor nextProcessor;
+
+    @Override
+    public void setNext(MessageProcessor nextProcessor) {
+        this.nextProcessor = nextProcessor;
+    }
+
+    @Override
+    public boolean process(String type, String message, Object object) {
+        if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) {
+            // Parse complete message and build event
+            ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util.
+                    jsonToObject(message, ClusterStatusClusterCreatedEvent.class);
+
+            if(log.isDebugEnabled()) {
+                log.debug("Received ClusterStatusClusterCreatedEvent: " + event.toString());
+            }
+            // Notify event listeners
+            notifyEventListeners(event);
+            return true;
+        } else {
+            if (nextProcessor != null) {
+                return nextProcessor.process(type, message, object);
+            } else {
+                throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
index 69918e2..f169fa2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java
@@ -42,7 +42,7 @@ public class ClusterStatusClusterInactivateMessageProcessor extends MessageProce
                                                 jsonToObject(message, ClusterStatusClusterInactivateEvent.class);
 
             if(log.isDebugEnabled()) {
-                log.debug("Received ClusterInActivateEvent: " + event.toString());
+                log.debug("Received ClusterStatusClusterInactivateEvent: " + event.toString());
             }
             // Notify event listeners
             notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
index b5bf301..75bc007 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java
@@ -42,7 +42,7 @@ public class ClusterStatusClusterResetMessageProcessor extends MessageProcessor
                     jsonToObject(message, ClusterStatusClusterResettedEvent.class);
 
             if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterCreatedEvent: " + event.toString());
+                log.debug("Received ClusterStatusClusterResettedEvent: " + event.toString());
             }
             // Notify event listeners
             notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
index 64b6c7b..04c09db 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
@@ -42,7 +42,7 @@ public class ClusterStatusClusterTerminatedMessageProcessor extends MessageProce
                     jsonToObject(message, ClusterStatusClusterTerminatedEvent.class);
 
             if (log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
+                log.debug("Received ClusterStatusClusterTerminatedEvent: " + event.toString());
             }
             // Notify event listeners
             notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
index c161dd5..0db1896 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java
@@ -42,7 +42,7 @@ public class ClusterStatusClusterTerminatingMessageProcessor extends MessageProc
                                                 jsonToObject(message, ClusterStatusClusterTerminatingEvent.class);
 
             if(log.isDebugEnabled()) {
-                log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString());
+                log.debug("Received ClusterStatusClusterTerminatingEvent: " + event.toString());
             }
             // Notify event listeners
             notifyEventListeners(event);

http://git-wip-us.apache.org/repos/asf/stratos/blob/746c37ae/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
index 42092bc..28689fb 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java
@@ -20,6 +20,7 @@ package org.apache.stratos.messaging.message.processor.cluster.status;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent;
 import org.apache.stratos.messaging.listener.EventListener;
 import org.apache.stratos.messaging.listener.cluster.status.*;
 import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
@@ -30,17 +31,20 @@ import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
 public class ClusterStatusMessageProcessorChain extends MessageProcessorChain {
     private static final Log log = LogFactory.getLog(ClusterStatusMessageProcessorChain.class);
 
-
+    private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
     private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
-    private ClusterStatusClusterResetMessageProcessor clusterCreatedMessageProcessor;
+    private ClusterStatusClusterResetMessageProcessor clusterResetMessageProcessor;
     private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor;
     private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
     private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
     @Override
     protected void initialize() {
-        clusterCreatedMessageProcessor = new ClusterStatusClusterResetMessageProcessor();
+        clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor();
         add(clusterCreatedMessageProcessor);
 
+        clusterResetMessageProcessor = new ClusterStatusClusterResetMessageProcessor();
+        add(clusterResetMessageProcessor);
+
         clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor();
         add(clusterActivatedMessageProcessor);
 
@@ -60,8 +64,10 @@ public class ClusterStatusMessageProcessorChain extends MessageProcessorChain {
 
     @Override
     public void addEventListener(EventListener eventListener) {
-        if(eventListener instanceof ClusterStatusClusterResetEventListener) {
-            clusterCreatedMessageProcessor.addEventListener(eventListener);
+        if(eventListener instanceof ClusterStatusClusterCreatedEventListener) {
+            clusterResetMessageProcessor.addEventListener(eventListener);
+        } else if(eventListener instanceof ClusterStatusClusterResetEventListener) {
+            clusterResetMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) {
             clusterInactivateMessageProcessor.addEventListener(eventListener);
         } else if (eventListener instanceof ClusterStatusClusterActivatedEventListener) {