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 <[email protected]> Authored: Fri Oct 31 13:20:57 2014 +0530 Committer: reka <[email protected]> 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; - } -}
