stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] adding application builder
Date Fri, 31 Oct 2014 10:25:37 GMT
Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 4de85b55b -> 686d0e063


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);
         }
     }
 


Mime
View raw message