You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/10/30 05:13:41 UTC
[17/50] [abbrv] git commit: more cleanup of grouping pco artifacts
more cleanup of grouping pco artifacts
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5efc0252
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5efc0252
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5efc0252
Branch: refs/heads/docker-grouping-merge
Commit: 5efc02521c90c08e0c9928f63242acb23c667910
Parents: d7d226c
Author: Martin Eppel <me...@cisco..com>
Authored: Mon Oct 27 19:44:28 2014 -0700
Committer: Martin Eppel <me...@cisco..com>
Committed: Mon Oct 27 19:46:59 2014 -0700
----------------------------------------------------------------------
.../autoscaler/ComplexApplicationContext.java | 916 -------------------
.../impl/CloudControllerServiceImpl.java | 1 -
.../controller/topology/TopologyBuilder.java | 109 +--
.../controller/topology/TopologyManager.java | 2 -
.../application/utils/ApplicationUtils.java | 2 -
.../messaging/domain/topology/Topology.java | 7 +-
.../util/CompositeApplicationBuilder.java | 226 -----
...ompositeApplicationCreatedEventListener.java | 26 -
...ompositeApplicationRemovedEventListener.java | 26 -
...ositeApplicationCreatedMessageProcessor.java | 98 --
...ositeApplicationRemovedMessageProcessor.java | 100 --
11 files changed, 10 insertions(+), 1503 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
deleted file mode 100644
index 84df0fb..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
+++ /dev/null
@@ -1,916 +0,0 @@
-package org.apache.stratos.autoscaler;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-import java.util.*;
-
-
-public class ComplexApplicationContext {
-
- static {
- is_kill_all_enabled_flag = new HashMap<String, Boolean>();
- is_in_kill_all_transition = new HashSet<String>();
- }
-
- private static Map<String, Boolean> is_kill_all_enabled_flag;
- private static HashSet<String> is_in_kill_all_transition;
-
-
-
- private static final Log log = LogFactory.getLog(ComplexApplicationContext.class);
-
- // return value of true will bring up new instance (all startup dependencies are up and active)
- public static boolean checkStartupDependencies (String clusterId) {
- String serviceType = "undefined";
- if (log.isDebugEnabled()) {
- log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkServiceDependencies (serviceType, clusterId, false);
- }
-
-
- public boolean checkStartupDependencies (String serviceType, String clusterId) {
- if (log.isDebugEnabled()) {
- log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkServiceDependencies (serviceType, clusterId, false);
- }
-
-
- // return false will terminate instances
- public boolean checkKillDependencies (String clusterId) {
- String serviceType = "undefined";
- if (log.isDebugEnabled()) {
- log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkKillTerminateDependencies (serviceType, clusterId, true);
- }
-
- public boolean checkKillDependencies (String serviceType, String clusterId) {
- if (log.isDebugEnabled()) {
- log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkKillTerminateDependencies (serviceType, clusterId, true);
- }
-
-
- public static boolean checkServiceDependencies(String serviceType, String clusterId, boolean kill_flag) {
-
-
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:checkServiceDependencies for service with XY " +
- " serviceType " + serviceType +
- " clusterId: " + clusterId + " kill_flag: " + kill_flag);
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null);
-
-
- // no app configured
- if (complexApplication == null) {
- return true;
- }
-
- String aServiceId = serviceType;
- if (log.isDebugEnabled()) {
- log.debug("checking dependencies for service alias " + aServiceId);
- }
-
- if (aServiceId == null) {
- if (log.isDebugEnabled()) {
- log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)");
- }
- return true;
- }
-
- List<GroupTemp> service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType);
-
- String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId);
-
- if (clusterGroupFromClusterId == null) {
- if (log.isDebugEnabled()) {
- log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping dependency check (return true)");
- }
- }
-
- for (GroupTemp service_type_groupTemp : service_type_groupTemps) {
- // check if cluster is in the group
- if (log.isDebugEnabled()) {
- log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() +
- "extracted group from clusterId is " + clusterGroupFromClusterId);
- }
- if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) {
- boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_groupTemp);
- if (log.isDebugEnabled()) {
- log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and startup dependency check is " + result_flag);
- }
- return result_flag;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("no matching group found for cluster " + clusterId + " skipping dependency check (return true)" );
- }
-
- return true;
-
- }
-
- public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, GroupTemp home_groupTemp) {
-
- String aServiceId = serviceType;
-
- if (home_groupTemp == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no dependency check)" );
- }
- return true;
- }
-
-
- if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_groupTemp.getAlias()))) {
- if (log.isDebugEnabled()) {
- log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" );
- }
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" subscribable " + aServiceId + " is not inKillAll transition, continue with dependenciy check" );
- }
- }
-
- Map<String, String> downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId);
-
-
- if (downstreamDependencies == null || downstreamDependencies.size() == 0) {
- if (log.isDebugEnabled()) {
- log.debug("serviceType " + aServiceId + " has no dependencies, returning true (no kill)");
- }
- return true;
- }
-
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("downstreamdependencies list: [ ");
-
-
- Set<String> downstream_keys = downstreamDependencies.keySet();
- for (String c : downstream_keys) {
- String d = downstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(downstreamDependencies.get(d));
- }
-
- buf.append("] ").append(" serviceId ").append(aServiceId);
- log.debug(buf.toString());
- }
-
-
- List<String> in_active_downstreams = getServiceSet_StateInActive(downstreamDependencies);
- if (in_active_downstreams.size() > 0) {
- if (log.isDebugEnabled()) {
- log.debug("found inactive downstream dependencies for serviceType " + aServiceId + " returning false");
- for (String in_active : in_active_downstreams) {
- log.debug("inactive downstream dependency " + in_active + " for " + aServiceId);
- }
- }
-
- return false;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("returning true for dependency check on serviceType " + serviceType);
- }
- return true;
- }
-
- // return false will terminate instances
- public boolean checkKillTerminateDependencies (String serviceType, String clusterId, boolean kill_flag) {
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:checkKillTerminateDependencies for service with X " +
- " serviceType " + serviceType +
- " clusterId: " + clusterId + " kill_flag: " + kill_flag);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting app from builder ");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null);
-
- String aServiceId = serviceType;
- if (log.isDebugEnabled()) {
- log.debug("checking dependencies for service alias " +
- aServiceId);
- }
-
- if (aServiceId == null) {
- if (log.isDebugEnabled()) {
- log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)");
- }
- return true;
- }
-
-
- // no app configured, don't terminate
- if (complexApplication == null) {
- return true;
- }
-
- List<GroupTemp> service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType);
-
- String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId);
-
- if (clusterGroupFromClusterId == null) {
- if (log.isDebugEnabled()) {
- log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping terminate dependency check (return true)");
- }
- }
-
- for (GroupTemp service_type_groupTemp : service_type_groupTemps) {
- // check if cluster is in the group
- if (log.isDebugEnabled()) {
- log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() +
- "extracted group from clusterId is " + clusterGroupFromClusterId);
- }
- if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) {
- boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag,
- service_type_groupTemp, complexApplication);
- if (log.isDebugEnabled()) {
- log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and kill dependency check is " + result_flag);
- }
- return result_flag;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("no matching group found for cluster " + clusterId + " skipping terminate dependency check (return true)" );
- }
-
- return true;
- }
-
- // return false will terminate instances
- public boolean checkKillTerminateDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag,
- GroupTemp home_groupTemp, CompositeApplication complexApplication ) {
-
- String aServiceId = serviceType;
-
- if (home_groupTemp == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without top level group " + aServiceId + "skip checking and return true (no kill)" );
- }
- return true;
- } else if (home_groupTemp.findGroup(aServiceId) == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no kill)" );
- }
- return true;
- }
-
-
- //Group home_group = complexApplication.getTop_level().findGroup(aServiceId);
-
- if (log.isDebugEnabled()) {
- log.debug("checking downstream dependencies for " + aServiceId );
- }
- Map<String, String> downstreamDependencies = null;
- downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId);
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("downstreamdependencies list: [ ");
-
- if (downstreamDependencies != null && downstreamDependencies.keySet().size() > 0) {
- Set<String> downstream_keys = downstreamDependencies.keySet();
- for (String c : downstream_keys) {
- String d = downstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(d).append(" ");
- }
- buf.append("] ").append(" serviceId ").append(aServiceId);
- } else {
- buf.append(" downstreamDependencies is null ");
- }
- log.debug(buf.toString());
- }
-
-
-
- if (log.isDebugEnabled()) {
- log.debug("checking upstream dependencies for " + aServiceId );
- }
- // 2. get upstream dependencies
- Map<String, String> upstreamDependencies = home_groupTemp.getUpstreamDependenciesAsMap(aServiceId);
-
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("upstreamdependencies list: [ ");
-
- if (upstreamDependencies != null && upstreamDependencies.keySet().size() > 0) {
- Set<String> upstream_keys = upstreamDependencies.keySet();
- for (String c : upstream_keys) {
- String d = upstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(upstreamDependencies.get(d)).append(" ");
- }
-
- buf.append("] ").append(" serviceId ").append(aServiceId);
- } else {
- buf.append(" upstreamDependencies is null ");
- }
- log.debug(buf.toString());
- }
-;
- List<String> in_active_upstreams = this.getServiceSet_StateInActive(upstreamDependencies);
-
- if (log.isDebugEnabled()) {
- log.debug("getting list of InActive upstream dependencies for " + aServiceId + " with size of " + in_active_upstreams.size());
- }
-
- String kill_behavior = Dependencies.KILL_UNDEFINED;
- // return false if instances should be terminated, true if not
- for (String serviceTypeAlias : in_active_upstreams) {
- String gr_alias = upstreamDependencies.get(serviceTypeAlias);
- GroupTemp gr = complexApplication.getGroupFromGroupAlias(gr_alias);
- if (gr != null) {
-
- kill_behavior = gr.getDependencies().getKill_behavior();
- if (kill_behavior.equals(Dependencies.KILL_ALL)) {
- if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is enabled on upstream (kill) for group " + gr.getAlias() + ", disabling kilAll and preventing " +
- " serviceType " + aServiceId + " in group " + gr.getAlias() +
- " to spin up a new instance (setting killAllTransitionFlag) ");
- }
- // adding to the killalltransition flag
- // building key from alias + group alias
- ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias,gr.getAlias()));
- // building key from alias + group alias
- ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId, home_groupTemp.getAlias()));
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is disabled on upstream (no kill) for group " + gr.getAlias() );
- }
- return true;
- }
- } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else if (kill_behavior.equals(Dependencies.KILL_NONE)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- //continue to check
- }
- } else {
- // skip
- if (log.isDebugEnabled()) {
- log.debug(" no group found for " + serviceTypeAlias + " while loopig over in_active_upstreams" );
- }
- }
-
- }
-
- // check kill_all_enabled flag
- Map<String, String> all = complexApplication.getAllInPathOfAsMap(aServiceId, home_groupTemp);
- String [] group_with_kill_all_aliases = home_groupTemp.findAllGroupsWithKill2(all, Dependencies.KILL_ALL);
- // "persistent flag for each group"
- this.updateEnableKillAllFlag(all, group_with_kill_all_aliases);
-
- //List<String> in_active_downstreams = this.getClusterSet_StateInActive(dependeciesAliasArray);jj
- List<String> in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies);
-
- if (log.isDebugEnabled()) {
- log.debug("getting list of InActive downstream dependencies for " + aServiceId + " with size of " + in_active_downstreams.size());
- }
-
- kill_behavior = Dependencies.KILL_UNDEFINED;
- for (String alias : in_active_downstreams) {
- GroupTemp gr = home_groupTemp.findGroup(alias);
- if (gr !=null) {
- kill_behavior = gr.getDependencies().getKill_behavior();
- if (kill_behavior.equals(Dependencies.KILL_ALL) ) {
- if (log.isDebugEnabled()) {
- log.debug(" return true on downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is enabled on downstream (kill) for group " + gr.getAlias() +
- " setting killAllTransitionFlag for" + alias);
- }
- // adding to the killalltransition flag
- ComplexApplicationContext.setKillAllTransitionFlag(alias);
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is disabled on downstream (no kill) for group " + gr.getAlias() );
- }
- return true;
- }
- } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- //log.debug(" continue downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- log.debug(" downstream service(s) is inactive for aServiceId " + aServiceId +
- " returning false (kill) and terminating cluster members" );
- }
- return false;
- } else if (kill_behavior.equals(Dependencies.KILL_NONE)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue downstream to check for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" continue downstream to check for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- //continue to check
- }
- } else {
- // skip
- if (log.isDebugEnabled()) {
- log.debug(" no group found for " + alias + " while loopig over in_active_downstreams" );
- }
- }
-
- }
-
- // this cluster
- GroupTemp gr = home_groupTemp.findGroup(aServiceId);
- if (gr == null) {
- if (log.isDebugEnabled()) {
- log.debug(" cluster without group, should not reach this code ? for " + aServiceId );
- }
- return true;
- }
-
- kill_behavior = gr.getDependencies().getKill_behavior();
-
- if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- log.debug(Dependencies.KILL_DEPENDENTS + " check if any downstream cluster is inactive for aServiceId " + aServiceId );
- }
- if (in_active_downstreams.size() > 0) {
- if (log.isDebugEnabled()) {
- log.debug(" downstream cluster(s) is inactive for aServiceId " + aServiceId +
- " returning false (kill) and terminating cluster members" );
- }
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" no downstream cluster(s) is inactive for aServiceId " + aServiceId +
- " returning true (no kill)" );
- }
- return true;
- }
- }
-
-
- if (log.isDebugEnabled()) {
- log.debug("returning true (no kill) for down and upstream dependency check on clusterId " + aServiceId);
- }
- return true;
- }
-
-
- private static boolean hasClusterActiveMember (Cluster cluster) {
- boolean flag = false;
- if(cluster.isLbCluster()){
- if (log.isDebugEnabled()) {
- log.debug("cluster member is lbCluster, not checking " + cluster);
- }
- }else{
- if (log.isDebugEnabled()) {
- log.debug("checking member acitve for " +
- " clusterId: " + cluster.getClusterId() +
- " serviceId: " + cluster.getServiceName());
- }
-
- Collection<Member> members = cluster.getMembers();
- for (Member member:members) {
- if (log.isDebugEnabled()) {
- log.debug("listing members while checking if active" +
- member.getMemberId() +
- " private Ip: " + member.getMemberIp() +
- " public Ip:" + member.getMemberPublicIp() +
- " member state: " + member.getStatus());
- }
- if (member.getStatus().equals(MemberStatus.Activated)) {
- log.debug("member ACTIVE found :" + member.getMemberId());
- flag = true;
- break;
- }
- }
-
- }
- return flag;
- }
-
-
-
- private static String extractAlias(String clusterId) {
- String [] s = clusterId.split("\\.");
- if (log.isDebugEnabled()) {
- log.debug("clusterId alias is " + clusterId + " size: " + s.length);
- }
- if (s.length == 0) {
- return null;
- }
- if (log.isDebugEnabled()) {
- log.debug("clusterId alias is " + clusterId + " alias: " + s[0]);
- }
- return s[0];
- }
-
- private static String extractClusterGroupFromClusterId(String clusterId) {
- String sub1 = extractAlias(clusterId);
- if (sub1 == null) {
- return null;
- }
-
- String [] s = sub1.split("-");
- if (log.isDebugEnabled()) {
- log.debug("clusterGroup alias is " + sub1 + " size: " + s.length);
- }
- if (s.length == 0) {
- return null;
- }
- if (log.isDebugEnabled()) {
- log.debug("cluster " + clusterId + " is in group " + s[0]);
- }
- return s[0];
- }
-
-
-
- private void updateEnableKillAllFlag(Map<String, String>all_dependencies, String [] group_with_kill_all_aliases) {
- if (log.isDebugEnabled()) {
- log.debug("updating enable_kill_flag ");
- }
- if (group_with_kill_all_aliases == null) {
- return;
- }
- //if (isClusterSet_StateActive(all_dependencies)) { //
- if (isServiceSet_StateActive(all_dependencies)) {
- for (String alias : group_with_kill_all_aliases) {
- ComplexApplicationContext.setKillAllEnabled(alias);
- if (log.isDebugEnabled()) {
- log.debug("enable enable_kill_flag for subscribable" + alias);
- }
- }
- //} else if (isClusterSet_StateInActive(all_dependencies)) {
- } else if (isServiceSet_StateInActive(all_dependencies)) {
- for (String alias : group_with_kill_all_aliases) {
- ComplexApplicationContext.resetKillAllEnabled(alias);
- if (log.isDebugEnabled()) {
- log.debug("disable enable_kill_flag for subscribable" + alias);
- }
- }
-
- // resetting killalltransition flag for all subscribables
- Set<String> key_set = all_dependencies.keySet();
- for (String serviceTypeAlias : key_set) {
- String group_alias = all_dependencies.get(serviceTypeAlias);
- ComplexApplicationContext.resetKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias, group_alias));
- if (log.isDebugEnabled()) {
- log.debug("resetting enable_kill_flag, is_in_kill_all_transition for subscribable " + serviceTypeAlias + " in group " + group_alias);
- }
- }
-
- } else {
- // do nothing
- if (log.isDebugEnabled()) {
- log.debug("leaving enable_kill_flag, is_in_kill_all_transition unchanged ");
- }
- }
-
- }
-
- private static String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) {
- return serviceTypeAlias + gr_alias;
- }
-
-
- private boolean isServiceSet_StateActive(Map<String, String>serviceTypes) {
- List<String> result = getServiceSet_StateActive(serviceTypes);
- if (result.size() == serviceTypes.size()) {
- return true;
- }
-
- return false;
- }
-
- private boolean isServiceSet_StateInActive(Map<String, String> serviceTypes) {
- List<String> result = getServiceSet_StateInActive(serviceTypes);
- if (result.size() == serviceTypes.size()) {
- return true;
- }
-
- return false;
- }
-
-
- private static List<String> getServiceSet_StateInActive(Map<String, String> serviceTypesMap) {
- List<String> result = new ArrayList<String> ();
-
- if (log.isDebugEnabled()) {
- log.debug("checking ServiceSet_StateInActive " + serviceTypesMap.size());
- }
-
- if (serviceTypesMap == null) {
- if (log.isDebugEnabled()) {
- log.debug("skipping getting set of InActive services, serviceTypes is null ");
- }
- return result;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting set of InActive clusters for serviceTypes (length)" + serviceTypesMap.size());
- }
-
-
- Collection<Service> services = TopologyManager.getTopology().getServices();
-
- Set<String> serviceTypes = serviceTypesMap.keySet();
-
- for (String serviceType : serviceTypes) {
- boolean hasServiceFound = false;
- for(Service service : services) {
- String serviceTypeGroup = serviceTypesMap.get(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("checking inactive state for service " + service.getServiceName() +
- " with nr_of_clusters: " + service.getClusters().size() +
- " against serviceType " + serviceType + " in group " + serviceTypeGroup);
- }
- if (serviceType.equals(service.getServiceName())) {
- // matching service type - check if has active cluster
- if (log.isDebugEnabled()) {
- log.debug("matching service types, checking clusters for service " + serviceType);
- }
- hasServiceFound = true;
- Collection<Cluster> clusters = service.getClusters();
- boolean hasClusterWithActiveMember = false;
- if (clusters.size() > 0) {
- // at least one cluster has to exist for service to exist
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has at least 1 cluster ");
- }
- for (Cluster cluster : clusters) {
- String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId());
- if (log.isDebugEnabled()) {
- log.debug("checking (inactive) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" +
- " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")");
- }
- // TODO if (hasClusterActiveMember (cluster)) {
- // check group cluster is in
-
- if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup)) {
- if (hasClusterActiveMember (cluster)) {
- hasClusterWithActiveMember = true;
- if (log.isDebugEnabled()) {
- log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup);
- }
- break;
- }
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " in group " + serviceTypeGroup + " has no cluster, adding as inactive service ");
- hasClusterWithActiveMember = false;
- }
- }
-
- if (!hasClusterWithActiveMember) {
- result.add(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("service has not a clutser with active member, adding " + serviceType + " as inactive");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search ");
- }
- }
-
- }
- // covers the case that service hasn't be deployed yet
- if (!hasServiceFound) {
- result.add(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("no matching service found for " + serviceType + " adding as inactive");
- }
- }
- }
-
- return result;
- }
-
-
- private List<String> getServiceSet_StateActive (Map<String, String> serviceTypesMap) {
- List<String> result = new ArrayList<String> ();
-
- if (log.isDebugEnabled()) {
- log.debug("checking ServiceSet_StateActive " + serviceTypesMap.size());
- }
-
- if (serviceTypesMap == null) {
- if (log.isDebugEnabled()) {
- log.debug("skipping getting set of Active services, serviceTypes is null ");
- }
- return result;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting set of Active clusters for serviceTypes (length)" + serviceTypesMap.size());
- }
-
-
- Collection<Service> services = TopologyManager.getTopology().getServices();
-
- Set<String> serviceTypes = serviceTypesMap.keySet();
-
- for (String serviceType : serviceTypes) {
- boolean hasServiceFound = false;
- for(Service service : services) {
- String serviceTypeGroup = serviceTypesMap.get(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("checking active state for service " + service.getServiceName() +
- " with nr_of_clusters: " + service.getClusters().size() +
- " against serviceType " + serviceType + " in group " + serviceTypeGroup);
- }
- if (serviceType.equals(service.getServiceName())) {
- // matching service type - check if has active cluster
- if (log.isDebugEnabled()) {
- log.debug("matching service types, checking clusters for service " + serviceType);
- }
- hasServiceFound = true;
- Collection<Cluster> clusters = service.getClusters();
- boolean hasClusterWithActiveMember = false;
- if (clusters.size() > 0) {
- // at least one cluster has to exist for service to exist
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has at least 1 cluster ");
- }
- for (Cluster cluster : clusters) {
- String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId());
- if (log.isDebugEnabled()) {
- log.debug("checking (active) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" +
- " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")");
- }
-
- if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup) && hasClusterActiveMember (cluster)) {
- hasClusterWithActiveMember = true;
- if (log.isDebugEnabled()) {
- log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup +
- " , adding as active service");
- }
- result.add(serviceType);
- break;
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has no cluster, skipping service ");
- hasClusterWithActiveMember = false;
- }
- }
-
- if (!hasClusterWithActiveMember) {;
- if (log.isDebugEnabled()) {
- log.debug("service has not a clutser with active member, skipping " + serviceType + " as active service");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search ");
- }
- }
-
- }
- // covers the case that service hasn't be deployed yet
- if (!hasServiceFound) {
- if (log.isDebugEnabled()) {
- log.debug("no matching service found for " + serviceType + " skipping as active service");
- }
- }
- }
-
- return result;
- }
-
- /*
- * get a list of clusters based on the subscription alias name
- */
- private List<Cluster> getClusters (String [] clusterAliases) {
- List<Cluster> clusters = new ArrayList<Cluster>();
-
- for (String alias : clusterAliases) {
- Cluster cluster = getClusterFromAlias(alias);
- if (cluster != null) {
- clusters.add(cluster);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("getting a (inactive) cluster retrieved as null for alias " + alias);
- }
- }
- }
- return clusters;
- }
-
- /*
- * get a cluster based on the subscription alias name
- */
- private Cluster getClusterFromAlias(String findClusterId) {
- Cluster result = null;
- Collection<Service> services = TopologyManager.getTopology().getServices();
- for(Service service : services) {
- // extract list of clusters, clusterId -> alias
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:calculateKillBehaviorFlag:service:" + service.getServiceName());
- }
-
- for(Cluster cluster : service.getClusters()) {
- String clusterId = cluster.getClusterId();
- String clusterIdAlias = this.extractAlias(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("looping over cluster " + clusterId +
- " extracted alias " + clusterIdAlias);
- }
-
- if (clusterIdAlias != null && findClusterId.equals(clusterIdAlias)) {
- return cluster;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" ignoring cluster " + clusterId + " in cluster check for " + findClusterId);
- }
- }
-
- }
- }
- return result;
- }
-
- private static void setKillAllEnabled(String groupId ) {
- ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, true);
- }
-
- private static void resetKillAllEnabled(String groupId ) {
- // all cartridges are terminated after kill_all
- ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, false);
- }
-
- private static void resetKillAllTransitionFlag(String alias) {
- ComplexApplicationContext.is_in_kill_all_transition.remove(alias);
- }
-
- private static void setKillAllTransitionFlag(String alias) {
- ComplexApplicationContext.is_in_kill_all_transition.add(alias);
- }
-
- public static synchronized Boolean isKillAllEnabled(String groupId) {
- Boolean flag = false;
- if (ComplexApplicationContext.is_kill_all_enabled_flag == null) {
- if (log.isDebugEnabled()) {
- log.debug(" creating new is_kill_all_enabled_flag");
- }
- ComplexApplicationContext.is_kill_all_enabled_flag = new HashMap<String, Boolean>();
- }
- flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId);
- if (flag == null) {
- if (log.isDebugEnabled()) {
- log.debug(" is_kill_all_enabled_flag not initialized for " + groupId + " initializing with true");
- }
-
- ComplexApplicationContext.setKillAllEnabled(groupId);
- flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId);
- }
- return flag;
- }
-
-
- public static synchronized Boolean isInKillAllTransition(String key) {
- if (ComplexApplicationContext.is_in_kill_all_transition == null) {
- if (log.isDebugEnabled()) {
- log.debug(" creating new is_in_kill_all_transition");
- }
- ComplexApplicationContext.is_in_kill_all_transition = new HashSet<String>();
- }
- if (ComplexApplicationContext.is_in_kill_all_transition.contains(key)) {
- return true;
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/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 0b322f8..6a337ba 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
@@ -44,7 +44,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.MemberStatus;
import org.apache.stratos.messaging.util.Constants;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/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 f4606b8..e715130 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
@@ -30,7 +30,6 @@ 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.topology.*;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
import org.apache.stratos.messaging.event.application.status.*;
import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
@@ -65,6 +64,7 @@ public class TopologyBuilder {
log.warn(String.format("Cartridge list is empty"));
return;
}
+
try {
TopologyManager.acquireWriteLock();
@@ -99,7 +99,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 {
@@ -286,27 +286,6 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceStartedEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceStartedEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId);
- }
- }
-
try {
TopologyManager.acquireWriteLock();
// try update lifecycle state
@@ -348,23 +327,6 @@ public class TopologyBuilder {
return;
}
- // grouping
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for member activated " + appAlias);
- }
- String clusterId = instanceActivatedEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceActivatedEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId);
- }
- }
-
Member member = cluster.getMember(instanceActivatedEvent.getMemberId());
@@ -437,27 +399,7 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceReadyToShutdownEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceReadyToShutdownEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId);
- }
- }
-
+
Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId());
if (member == null) {
log.warn(String.format("Member %s does not exist",
@@ -521,28 +463,6 @@ public class TopologyBuilder {
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceMaintenanceModeEvent.getClusterId();
-
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceMaintenanceModeEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId);
- }
- }
-
MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent(
instanceMaintenanceModeEvent.getServiceName(),
instanceMaintenanceModeEvent.getClusterId(),
@@ -591,27 +511,6 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
-
- String groupAlias = null;
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId);
- }
- }
-
try {
TopologyManager.acquireWriteLock();
properties = member.getProperties();
@@ -620,6 +519,8 @@ public class TopologyBuilder {
} finally {
TopologyManager.releaseWriteLock();
}
+ /* @TODO leftover from grouping_poc*/
+ String groupAlias = null;
TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, properties, groupAlias);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
index bc07404..9862b9a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
@@ -81,8 +81,6 @@ public class TopologyManager {
log.debug("Topology not found in registry, creating new");
}
topology = new Topology();
- } else {
- topology.getConfigCompositeApplication();
}
if (log.isDebugEnabled()) {
log.debug("Topology initialized");
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
index 4dbf251..15d9d44 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
@@ -8,8 +8,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.exception.InvalidCartridgeAliasException;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
import org.apache.stratos.messaging.util.Constants;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index 76d73fe..ddd5ffa 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -38,7 +38,7 @@ public class Topology implements Serializable {
private Map<String, Service> serviceMap;
//Grouping
private Map<String, CompositeApplication> compositeApplicationMap;
- private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
+ // grouping_poc private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
// Key: Application.id
private Map<String, Application> applicationMap;
@@ -48,7 +48,7 @@ public class Topology implements Serializable {
public Topology() {
this.serviceMap = new HashMap<String, Service>();
this.compositeApplicationMap = new HashMap<String, CompositeApplication>();
- this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
+ // grouping_poc this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
this.applicationMap = new HashMap<String, Application>();
}
@@ -124,6 +124,7 @@ public class Topology implements Serializable {
this.compositeApplicationMap.remove(alias);
}
+ /* grouping_poc
public Collection<ConfigCompositeApplication> getConfigCompositeApplication() {
if (this.configCompositeApplicationMap == null) {
@@ -188,6 +189,8 @@ public class Topology implements Serializable {
public void setConfigCompositeApplicationMap(Map<String, ConfigCompositeApplication> configCompositeApplicationMap) {
this.configCompositeApplicationMap = configCompositeApplicationMap;
}
+
+ */
public void setInitialized(boolean initialized) {
this.initialized = initialized;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
deleted file mode 100644
index e29fdbb..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package org.apache.stratos.messaging.domain.topology.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
-
-import java.util.*;
-
-
-
-public class CompositeApplicationBuilder {
-
- private Map<String, GroupTemp> groups = null;
- private Map<String, Cartridge> cartridgesTypes = null;
-
- private List<ConfigGroup> configGroupArray = null;
- private List<ConfigCartridge> configCartridgeArray = null;
-
- private static Log log = LogFactory.getLog(CompositeApplicationBuilder.class);
-
- public CompositeApplication buildCompositeApplication(Topology topology, String appAlias) {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication with topology " + topology);
- }
- Collection<ConfigCompositeApplication> configComplexApplications = topology.getConfigCompositeApplication();
- CompositeApplication complexApplication = new CompositeApplication();
- if (configComplexApplications.size() > 0) {
- ConfigCompositeApplication [] complexConfigAppArray = new ConfigCompositeApplication[configComplexApplications.size()];
- complexConfigAppArray = configComplexApplications.toArray(complexConfigAppArray);
-
- // assuming only 1 complex app is configured
-
- ConfigCompositeApplication configComplexApplication = complexConfigAppArray[0];
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication);
- }
- if (configComplexApplication!= null) {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication);
- }
- setConfigConfiguration(configComplexApplication);
-
- GroupTemp top_level = this.buildApplication();
- if (top_level != null) {
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:configComplexApplication toplevel is " + top_level.getAlias());
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication toplevel is null");
- }
- }
- if (top_level == null) {
- log.debug("buildCompositeApplication top level group is null ...");
- return null;
- } else {
- log.debug("buildCompositeApplication setting top level group " + top_level.getAlias());
- //complexApplication.setTop_level(top_level);
- complexApplication.setAll_groups(this.groups);
- return complexApplication;
- }
- } else {
- log.debug("buildCompositeApplication configComplexApplication is null");
- }
- } else {
- log.debug("buildCompositeApplication configComplexApplications is null");
- return null;
- }
- return null;
- }
-
-
-
- public GroupTemp buildApplication() {
-
- for (ConfigGroup configGroup : configGroupArray) {
- log.debug("deploying group " + configGroup.getAlias());
- GroupTemp realGroupTemp = new GroupTemp(configGroup.getAlias());
- groups.put(realGroupTemp.getAlias(), realGroupTemp);
- }
-
-
- for (ConfigCartridge configCartridge : configCartridgeArray) {
- log.debug("deploying cartridge component " + configCartridge.getAlias());
- Cartridge realCartridge = new Cartridge(configCartridge.getAlias());
- cartridgesTypes.put(realCartridge.getAlias(), realCartridge);
- }
-
- // building groups
- // this should be done when reading the topology event in autoscaler
- log.debug("converting group configuration to groups and assembling application");
- for (ConfigGroup configGroup : configGroupArray) {
- GroupTemp assembleGroupTemp = groups.get(configGroup.getAlias());
- Map<String, Cartridge> groupCartridges = new HashMap<String, Cartridge>();
- log.debug("converting configuration for group " + assembleGroupTemp.getAlias());
- for (String key : configGroup.getSubscribables()) {
- GroupTemp realgroup = groups.get(key);
- if (realgroup != null) {
- // try cartridges
- assembleGroupTemp.add(realgroup);
- realgroup.setParent(assembleGroupTemp);
- realgroup.setHomeGroup(assembleGroupTemp);
- } else {
- Cartridge realcartridge_type = cartridgesTypes.get(key);
- if (realcartridge_type != null) {
- // create a copy of the cartridge type
- Cartridge groupCartridge = new Cartridge(realcartridge_type.getAlias());
- groupCartridge.setCartridgeId(getCartridgeId(assembleGroupTemp.getAlias(), realcartridge_type.getAlias()));
- assembleGroupTemp.add(groupCartridge);
- groupCartridge.setParent(assembleGroupTemp);
- groupCartridge.setHomeGroup(assembleGroupTemp); // TODO need to consolidate parent / home group
- groupCartridges.put(groupCartridge.getAlias(), groupCartridge);
- if (log.isDebugEnabled()) {
- log.debug("added new cartrdige of type " + groupCartridge.getAlias() + " and cartrdigeId " + groupCartridge.getCartridgeId() +
- " to group " + assembleGroupTemp.getAlias());
- }
- } else {
- log.debug("Error: no group, cartridge found for alias: " + key);
- }
- }
- }
- // build dependencies
- log.debug("building dependencies for group " + assembleGroupTemp.getAlias());
- Dependencies real_dependencies = buildDependency(configGroup, groups, groupCartridges);
- assembleGroupTemp.setDependencies(real_dependencies);
- real_dependencies.setGroupTemp(assembleGroupTemp);
- }
-
- GroupTemp application = getTopLevelGroup();
- log.debug("top level group is: " + application.getAlias());
-
- return application;
- }
-
- public GroupTemp getTopLevelGroup () {
- String alias = null;
- for (ConfigGroup configGroup : configGroupArray) {
- alias = configGroup.getAlias();
- boolean isTopLevelGroup = true;
- log.debug("checking if group " + alias + " is a sub component");
- for (ConfigGroup configGroupInner : configGroupArray) {
- for (String key : configGroupInner.getSubscribables()) {
- log.debug("in group " + configGroupInner.getAlias() );
- if (key.equals(alias)) {
- log.debug("found group " + alias + " as sub component in " + configGroupInner.getAlias());
- isTopLevelGroup = false;
- break;
- }
- }
- }
- if (isTopLevelGroup) {
- log.debug("is top level group: " + alias);
- break;
- }
- }
- GroupTemp application = groups.get(alias);
- log.debug("top level group is: " + alias);
- return application;
- }
-
- public Dependencies buildDependency(ConfigGroup configGroup, Map<String, GroupTemp> groups, Map<String, Cartridge> groupCartridges) {
-
- // building dependencies
- ConfigDependencies config_dep = configGroup.getDependencies();
- Dependencies real_dependencies = new Dependencies();
- if (config_dep != null) {
- String kill_behavior = config_dep.getKill_behavior();
- real_dependencies.setKill_behavior(kill_behavior);
- List<ConfigDependencies.Pair> startup_order = config_dep.getStartup_order();
- for (ConfigDependencies.Pair pair: startup_order) {
- String key = pair.getKey();
- String value = pair.getValue();
- //check groups
- GroupTemp gr = groups.get(value);
- log.debug("checking dependency for key " + key + " /val: " + value + " in groups");
- if (gr != null) {
- real_dependencies.addDependency(key, gr);
- } else {
- log.debug("checking dependency for key " + key + " /val: " + value + " in group cartridges");
- Cartridge cr = groupCartridges.get(value);
- if (cr != null) {
- real_dependencies.addDependency(key, cr);
- if (log.isDebugEnabled()) {
- log.debug("adding group cartridge " + cr.getCartridgeId()+ " as dependency");
- }
- } else {
- cr = this.cartridgesTypes.get(value);
- if (cr != null) {
- real_dependencies.addDependency(key, cr);
- if (log.isDebugEnabled()) {
- log.debug("adding a lone cartridge " + cr.getAlias() + " as dependency");
- }
- } else {
- log.debug("error retrieving group with name " + key);
- }
- }
- }
-
- }
- }
- return real_dependencies;
- }
-
- private void setConfigConfiguration(ConfigCompositeApplication configApp) {
- this.groups = new HashMap<String, GroupTemp>();
- this.cartridgesTypes = new HashMap<String, Cartridge>();
-
- if (configApp.getComponents() != null) {
- configGroupArray = configApp.getComponents();
- } else {
- configGroupArray = new ArrayList<ConfigGroup>();
- }
-
- if (configApp.getCartridges() != null) {
- configCartridgeArray = configApp.getCartridges();
- } else {
- configCartridgeArray = new ArrayList<ConfigCartridge>();
- }
-
- }
-
- private String getCartridgeId (String homeGroupId, String cartridgeType) {
- String id = homeGroupId +":"+ cartridgeType;
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
deleted file mode 100644
index 6c3aa7a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class CompositeApplicationCreatedEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
deleted file mode 100644
index 04dce2b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class CompositeApplicationRemovedEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
deleted file mode 100644
index 1b4faa5..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-
-//Grouping
-public class CompositeApplicationCreatedMessageProcessor extends MessageProcessor {
-
- private static final Log log = LogFactory.getLog(CompositeApplicationCreatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
-
- if (log.isDebugEnabled()) {
- log.debug("processing application event of type " + type +
- " / topology:" + topology + " msg: " + message);
- }
-
- if (CompositeApplicationCreatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized()) {
-
- if (log.isDebugEnabled()) {
- log.debug("topology is not initialized .... need to add check ... Grouping");
- }
-
- //return false;
- }
-
- // Parse complete message and build event
- CompositeApplicationCreatedEvent event =
- (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("processing application created event with application id: " + event.getApplicationAlias());
- }
-
- // Validate event against the existing topology
- if (topology.compositeApplicationExists(event.getApplicationAlias())) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias()));
- }
- } else {
-
- ConfigCompositeApplication configApp = event.getCompositeApplication();
- String alias = "compositeApplicationAlias";
- if (log.isInfoEnabled()) {
- log.info("adding ConfigCompositeApplication with alias " + alias + " to topology");
- }
- topology.addConfigCompositeApplication(alias, configApp);
- }
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
deleted file mode 100644
index 2bb688a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-
-//Grouping
-public class CompositeApplicationRemovedMessageProcessor extends MessageProcessor {
-
- private static final Log log = LogFactory.getLog(CompositeApplicationRemovedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
-
- if (log.isDebugEnabled()) {
- log.debug("processing application event of type " + type +
- " / topology:" + topology + " msg: " + message);
- }
-
- if (CompositeApplicationRemovedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
-
- if (!topology.isInitialized()) {
-
- if (log.isDebugEnabled()) {
- log.debug("topology is not initialized .... need to add check ... Grouping");
- }
- //return false;
- }
-
- // Parse complete message and build event
- CompositeApplicationRemovedEvent event =
- (CompositeApplicationRemovedEvent) Util.jsonToObject(message, CompositeApplicationRemovedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("processing application removed event with application id: " + event.getApplicationAlias());
- }
-
- // Validate event against the existing topology
- if (topology.configCompositeApplicationExists(event.getApplicationAlias())) {
- topology.removeAllConfigCompositeApplication();
- if (log.isDebugEnabled()) {
- log.debug("CompositeApplication exists, removing all ConfigCompositeApplication" + event.getApplicationAlias()) ;
- }
- } else {
- topology.removeAllConfigCompositeApplication();
- if (log.isWarnEnabled()) {
- log.warn("ConfigCompositeApplication " + event.getApplicationAlias() + " does not exist, removing all ") ;
- }
- }
-
-
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}