You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/01/08 06:51:49 UTC

[38/46] renaming package adc.mgt to manager

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
deleted file mode 100644
index 8084468..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.manager.subscription.tenancy;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.cloud.controller.pojo.Properties;
-
-
-public class SubscriptionMultiTenantBehaviour extends SubscriptionTenancyBehaviour {
-
-    private static Log log = LogFactory.getLog(SubscriptionMultiTenantBehaviour.class);
-
-
-    public void createSubscription(CartridgeSubscription cartridgeSubscription) throws ADCException, AlreadySubscribedException {
-
-        boolean allowMultipleSubscription = Boolean.
-                valueOf(System.getProperty(CartridgeConstants.FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED));
-
-        if (!allowMultipleSubscription) {
-            // If the cartridge is multi-tenant. We should not let users createSubscription twice.
-            boolean subscribed;
-            try {
-                /////////////////////////////////////////////////////////////////////////////////////////////////////////
-                //subscribed = PersistenceManager.isAlreadySubscribed(cartridgeSubscription.getType(),
-                //        cartridgeSubscription.getSubscriber().getTenantId());
-                /////////////////////////////////////////////////////////////////////////////////////////////////////////
-                subscribed = hasAlreadySubscribed(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getType());
-
-            } catch (Exception e) {
-                String msg = "Error checking whether the cartridge type " + cartridgeSubscription.getType() +
-                        " is already subscribed";
-                log.error(msg, e);
-                throw new ADCException(msg, e);
-            }
-
-            if (subscribed) {
-                String msg = "Already subscribed to " + cartridgeSubscription.getType()
-                        + ". This multi-tenant cartridge will not be available to createSubscription";
-                if (log.isDebugEnabled()) {
-                    log.debug(msg);
-                }
-                throw new AlreadySubscribedException(msg, cartridgeSubscription.getType());
-            }
-        }
-
-        //TODO: implement getting cluster Id from DB
-        /*TopologyManager.acquireReadLock();
-
-        try {
-            Service service = TopologyManager.getTopology().getService(cartridgeSubscription.getType());
-            if(service == null) {
-                TopologyManager.releaseReadLock();
-                String errorMsg = "Error in subscribing, no service found with the name " + cartridgeSubscription.getType();
-                log.error(errorMsg);
-                throw new ADCException(errorMsg);
-            }
-
-            //cartridgeSubscription.getCluster().setClusterDomain(service.getCluster().);
-            //cartridgeSubscription.getCluster().setClusterSubDomain(domainContext.getSubDomain());
-
-        } finally {
-            TopologyManager.releaseReadLock();
-        }*/
-    }
-
-    public void registerSubscription(CartridgeSubscription cartridgeSubscription, Properties properties)
-            throws ADCException, UnregisteredCartridgeException {
-
-        //nothing to do
-    }
-
-    public void removeSubscription(CartridgeSubscription cartridgeSubscription) throws ADCException, NotSubscribedException {
-
-        log.info("Cartridge with alias " + cartridgeSubscription.getAlias() + ", and type " + cartridgeSubscription.getType() +
-                " is a multi-tenant cartridge and therefore will not terminate all instances and " +
-                "unregister services");
-    }
-
-    private static boolean hasAlreadySubscribed(int tenantId, String cartridgeType) {
-
-        DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-        return ( dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType) == null ||
-                 dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType).isEmpty() ) ? false : true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
deleted file mode 100644
index cab0bac..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
+++ /dev/null
@@ -1,97 +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.manager.subscription.tenancy;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-import org.apache.stratos.cloud.controller.pojo.Properties;
-
-
-public class SubscriptionSingleTenantBehaviour extends SubscriptionTenancyBehaviour {
-
-    private static Log log = LogFactory.getLog(SubscriptionSingleTenantBehaviour.class);
-
-
-
-    public void createSubscription(CartridgeSubscription cartridgeSubscription) throws ADCException, AlreadySubscribedException {
-
-        //set the cluster and hostname
-        cartridgeSubscription.getCluster().setClusterDomain(cartridgeSubscription.getAlias() + "." +
-                cartridgeSubscription.getCluster().getHostName() + "." + cartridgeSubscription.getType() + ".domain");
-        cartridgeSubscription.getCluster().setHostName(cartridgeSubscription.getAlias() + "." +
-                cartridgeSubscription.getCluster().getHostName());
-    }
-
-    public void registerSubscription(CartridgeSubscription cartridgeSubscription, Properties properties) throws ADCException, UnregisteredCartridgeException {
-
-        log.info("Payload: " + cartridgeSubscription.getPayloadData().getCompletePayloadData().toString());
-
-        ApplicationManagementUtil.registerService(cartridgeSubscription.getType(),
-                cartridgeSubscription.getCluster().getClusterDomain(),
-                cartridgeSubscription.getCluster().getClusterSubDomain(),
-                cartridgeSubscription.getPayloadData().getCompletePayloadData(),
-                cartridgeSubscription.getPayloadData().getBasicPayloadData().getTenantRange(),
-                cartridgeSubscription.getCluster().getHostName(),
-                cartridgeSubscription.getAutoscalingPolicyName(),
-                cartridgeSubscription.getDeploymentPolicyName(),
-                properties);
-    }
-
-    public void removeSubscription(CartridgeSubscription cartridgeSubscription) throws ADCException, NotSubscribedException {
-
-        try {
-            CloudControllerServiceClient.getServiceClient().terminateAllInstances(cartridgeSubscription.getCluster().getClusterDomain());
-
-        } catch (AxisFault e) {
-            String errorMsg = "Error in terminating cartridge subscription, alias " + cartridgeSubscription.getAlias();
-            log.error(errorMsg);
-            throw new ADCException(errorMsg, e);
-
-        } catch (Exception e) {
-            String errorMsg = "Error in terminating cartridge subscription, alias " + cartridgeSubscription.getAlias();
-            log.error(errorMsg);
-            throw new ADCException(errorMsg, e);
-        }
-
-        log.info("Terminated all instances of " + cartridgeSubscription.getCluster().getClusterDomain() + " " +
-                cartridgeSubscription.getCluster().getClusterSubDomain());
-
-        try {
-            CloudControllerServiceClient.getServiceClient().unregisterService(cartridgeSubscription.getCluster().getClusterDomain());
-
-        } catch (Exception e) {
-            String errorMsg = "Error in unregistering service cluster with domain " + cartridgeSubscription.getCluster().getClusterDomain() +
-                    ", sub domain " + cartridgeSubscription.getCluster().getClusterSubDomain();
-            log.error(errorMsg);
-            throw new ADCException(errorMsg, e);
-        }
-
-        log.info("Unregistered service cluster, domain " + cartridgeSubscription.getCluster().getClusterDomain() + ", sub domain " +
-                cartridgeSubscription.getCluster().getClusterSubDomain());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
deleted file mode 100644
index 774dd22..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
+++ /dev/null
@@ -1,43 +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.manager.subscription.tenancy;
-
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.cloud.controller.pojo.Properties;
-
-import java.io.Serializable;
-
-public abstract class SubscriptionTenancyBehaviour implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    public abstract void createSubscription(CartridgeSubscription cartridgeSubscription)
-            throws ADCException, AlreadySubscribedException;
-
-    public abstract void registerSubscription(CartridgeSubscription cartridgeSubscription, Properties properties)
-            throws ADCException, UnregisteredCartridgeException;
-
-    public abstract void removeSubscription(CartridgeSubscription cartridgeSubscription)
-            throws ADCException, NotSubscribedException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
deleted file mode 100644
index 4a50237..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
+++ /dev/null
@@ -1,172 +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.manager.subscription.utils;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.service.Service;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.DuplicateCartridgeAliasException;
-import org.apache.stratos.manager.exception.InvalidCartridgeAliasException;
-import org.apache.stratos.manager.payload.BasicPayloadData;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent;
-import org.apache.stratos.messaging.event.tenant.TenantUnSubscribedEvent;
-import org.apache.stratos.messaging.util.Constants;
-
-import java.util.regex.Pattern;
-
-public class CartridgeSubscriptionUtils {
-
-    private static Log log = LogFactory.getLog(CartridgeSubscriptionUtils.class);
-
-    public static BasicPayloadData createBasicPayload (CartridgeSubscription cartridgeSubscription) {
-
-        BasicPayloadData basicPayloadData = new BasicPayloadData();
-        basicPayloadData.setApplicationPath(cartridgeSubscription.getCartridgeInfo().getBaseDir());
-        basicPayloadData.setSubscriptionKey(cartridgeSubscription.getSubscriptionKey());
-        basicPayloadData.setClusterId(cartridgeSubscription.getClusterDomain());
-        basicPayloadData.setDeployment("default");//currently hard coded to default
-        if(cartridgeSubscription.getRepository() != null) {
-            basicPayloadData.setGitRepositoryUrl(cartridgeSubscription.getRepository().getUrl());
-        }
-        basicPayloadData.setHostName(cartridgeSubscription.getHostName());
-        basicPayloadData.setMultitenant(String.valueOf(cartridgeSubscription.getCartridgeInfo().getMultiTenant()));
-        basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridgeSubscription.getCartridgeInfo()));
-        basicPayloadData.setServiceName(cartridgeSubscription.getCartridgeInfo().getType());
-        basicPayloadData.setSubscriptionAlias(cartridgeSubscription.getAlias());
-        basicPayloadData.setTenantId(cartridgeSubscription.getSubscriber().getTenantId());
-        //TODO:remove. we do not want to know about the tenant rance in subscription!
-        if(cartridgeSubscription.getCartridgeInfo().getMultiTenant() ||
-                cartridgeSubscription.getSubscriber().getTenantId() == -1234) {  //TODO: fix properly
-            basicPayloadData.setTenantRange("*");
-        } else {
-            basicPayloadData.setTenantRange(String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()));
-        }
-
-        return basicPayloadData;
-    }
-
-    public static BasicPayloadData createBasicPayload (Service service) {
-
-        BasicPayloadData basicPayloadData = new BasicPayloadData();
-        basicPayloadData.setApplicationPath(service.getCartridgeInfo().getBaseDir());
-        basicPayloadData.setSubscriptionKey(service.getSubscriptionKey());
-        basicPayloadData.setClusterId(service.getClusterId());
-        basicPayloadData.setDeployment("default");//currently hard coded to default
-        basicPayloadData.setHostName(service.getHostName());
-        basicPayloadData.setMultitenant(String.valueOf(service.getCartridgeInfo().getMultiTenant()));
-        basicPayloadData.setPortMappings(createPortMappingPayloadString(service.getCartridgeInfo()));
-        basicPayloadData.setServiceName(service.getType());
-        basicPayloadData.setTenantId(service.getTenantId());
-        basicPayloadData.setTenantRange(service.getTenantRange());
-
-        return basicPayloadData;
-    }
-
-    private static String createPortMappingPayloadString (CartridgeInfo cartridgeInfo) {
-
-        // port mappings
-        StringBuilder portMapBuilder = new StringBuilder();
-        org.apache.stratos.cloud.controller.pojo.PortMapping[] portMappings = cartridgeInfo.getPortMappings();
-        for (org.apache.stratos.cloud.controller.pojo.PortMapping portMapping : portMappings) {
-            String port = portMapping.getPort();
-            portMapBuilder.append(port).append("|");
-        }
-
-        // remove last "|" character
-        String portMappingString = portMapBuilder.toString().replaceAll("\\|$", "");
-
-        return portMappingString;
-    }
-
-    public static String generateSubscriptionKey() {
-        String key = RandomStringUtils.randomAlphanumeric(16);
-        log.info("Generated key  : " + key); // TODO -- remove the log
-        return key;
-    }
-
-    public static void publishTenantSubscribedEvent(int tenantId, String serviceName) {
-        try {
-            if(log.isInfoEnabled()) {
-                log.info(String.format("Publishing tenant subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName));
-            }
-            TenantSubscribedEvent subscribedEvent = new TenantSubscribedEvent(tenantId, serviceName);
-            EventPublisher eventPublisher = new EventPublisher(Constants.TENANT_TOPIC);
-            eventPublisher.publish(subscribedEvent);
-        } catch (Exception e) {
-            if (log.isErrorEnabled()) {
-                log.error(String.format("Could not publish tenant subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName), e);
-            }
-        }
-    }
-
-    public static void publishTenantUnSubscribedEvent(int tenantId, String serviceName) {
-        try {
-            if(log.isInfoEnabled()) {
-                log.info(String.format("Publishing tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName));
-            }
-            TenantUnSubscribedEvent event = new TenantUnSubscribedEvent(tenantId, serviceName);
-            EventPublisher eventPublisher = new EventPublisher(Constants.TENANT_TOPIC);
-            eventPublisher.publish(event);
-        } catch (Exception e) {
-            if (log.isErrorEnabled()) {
-                log.error(String.format("Could not publish tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName), e);
-            }
-        }
-    }
-
-    public static void validateCartridgeAlias (int tenantId, String cartridgeType, String alias) throws InvalidCartridgeAliasException, DuplicateCartridgeAliasException, ADCException {
-
-        String patternString = "([a-z0-9]+([-][a-z0-9])*)+";
-        Pattern pattern = Pattern.compile(patternString);
-
-        if (!pattern.matcher(alias).matches()) {
-            String msg = "The alias " + alias + " can contain only alpha-numeric lowercase characters. Please enter a valid alias.";
-            log.error(msg);
-            throw new InvalidCartridgeAliasException(msg, tenantId, cartridgeType, alias);
-        }
-
-        boolean isAliasTaken = false;
-        try {
-            isAliasTaken = isAliasTaken(tenantId, alias);
-        } catch (Exception e) {
-            String msg = "Exception : " + e.getMessage();
-            log.error(msg, e);
-            throw new ADCException("Error when checking alias is already taken", e);
-        }
-
-        if (isAliasTaken) {
-            String msg = "The alias " + alias + " is already taken. Please try again with a different alias.";
-            log.error(msg);
-            throw new DuplicateCartridgeAliasException(msg, cartridgeType, alias);
-        }
-    }
-
-    public static boolean isAliasTaken (int tenantId, String alias) {
-
-        DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-        return (dataInsertionAndRetrievalManager.getCartridgeSubscription(tenantId, alias) == null) ? false : true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
deleted file mode 100644
index 284e36b..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
+++ /dev/null
@@ -1,502 +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.manager.topology.model;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-
-import java.util.*;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-public class TopologyClusterInformationModel {
-
-    private static final Log log = LogFactory.getLog(TopologyClusterInformationModel.class);
-
-    private Map<Integer, Set<CartridgeTypeContext>> tenantIdToCartridgeTypeContextMap;
-    //private Map<TenantIdAndAliasTopologyKey, Cluster> tenantIdAndAliasTopologyKeyToClusterMap;
-    //private Map<Integer, List<Cluster>> tenantIdToClusterMap;
-    //private Map<TenantIdAndTypeTopologyKey , List<Cluster>> tenantIdAndTypeTopologyKeyToClusterMap;
-    private static TopologyClusterInformationModel topologyClusterInformationModel;
-
-    //locks
-    private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
-    private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
-    private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
-
-    private TopologyClusterInformationModel() {
-        //tenantIdAndAliasTopologyKeyToClusterMap = new HashMap<TenantIdAndAliasTopologyKey, Cluster>();
-        //tenantIdAndTypeTopologyKeyToClusterMap = new HashMap<TenantIdAndTypeTopologyKey, List<Cluster>>();
-        //tenantIdToClusterMap = new HashMap<Integer, List<Cluster>>();
-        tenantIdToCartridgeTypeContextMap = new HashMap<Integer, Set<CartridgeTypeContext>>();
-    }
-
-    public static TopologyClusterInformationModel getInstance () {
-        if(topologyClusterInformationModel == null) {
-            synchronized (TopologyClusterInformationModel.class) {
-                if (topologyClusterInformationModel == null) {
-                    topologyClusterInformationModel = new TopologyClusterInformationModel();
-                }
-            }
-        }
-
-        return topologyClusterInformationModel;
-    }
-
-    /*public void addCluster (int tenantId, String cartridgeType, String subscriptionAlias, Cluster cluster) {
-
-        List<Cluster> clusters;
-        writeLock.lock();
-
-        try {
-            //[Tenant Id + Subscription Alias] -> Cluster map
-            tenantIdAndAliasTopologyKeyToClusterMap.putSubscription(new TenantIdAndAliasTopologyKey(tenantId, subscriptionAlias), cluster);
-
-            //Tenant Id -> Cluster map
-            clusters = tenantIdToClusterMap.get(tenantId);
-            if(clusters == null) {
-                clusters = new ArrayList<Cluster>();
-                clusters.add(cluster);
-                tenantIdToClusterMap.putSubscription(tenantId, clusters);
-            } else {
-                clusters.add(cluster);
-            }
-
-            //[Tenant Id + Cartridge Type] -> Cluster map
-            clusters = tenantIdAndTypeTopologyKeyToClusterMap.get(new TenantIdAndTypeTopologyKey(tenantId, cartridgeType));
-            if(clusters == null) {
-                clusters = new ArrayList<Cluster>();
-                clusters.add(cluster);
-                tenantIdAndTypeTopologyKeyToClusterMap.putSubscription(new TenantIdAndTypeTopologyKey(tenantId, cartridgeType), clusters);
-            } else {
-                clusters.add(cluster);
-            }
-
-        } finally {
-            writeLock.unlock();
-        }
-    } */
-
-    public void addCluster (int tenantId, String cartridgeType, String subscriptionAlias, Cluster cluster) {
-
-        Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-        Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-
-        writeLock.lock();
-        try {
-            //check if a set of CartridgeTypeContext instances already exist for given tenant Id
-            cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-            if(cartridgeTypeContextSet != null) {
-                CartridgeTypeContext cartridgeTypeContext = null;
-                //iterate through the set
-                Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-                while (typeCtxIterator.hasNext()) {
-                    //see if the set contains a CartridgeTypeContext instance with the given cartridge type
-                    cartridgeTypeContext = typeCtxIterator.next();
-                    if (cartridgeTypeContext.getType().equals(cartridgeType)){
-                        //if so, get the SubscriptionAliasContext set
-                        subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-                        break;
-                    }
-                }
-                //check if a SubscriptionAliasContext set is not found
-                if(subscriptionAliasContextSet == null) {
-                    //no SubscriptionAliasContext instance
-                    //create a new SubscriptionAliasContext instance
-                    SubscriptionAliasContext subscriptionAliasContext = new SubscriptionAliasContext(subscriptionAlias,
-                            cluster);
-                    //create a SubscriptionAliasContext set
-                    subscriptionAliasContextSet = new HashSet<SubscriptionAliasContext>();
-                    //add the created SubscriptionAliasContext instance to SubscriptionAliasContext set
-                    subscriptionAliasContextSet.add(subscriptionAliasContext);
-                    //set it to the CartridgeTypeContext instance
-                    cartridgeTypeContext = new CartridgeTypeContext(cartridgeType);
-                    cartridgeTypeContext.setSubscriptionAliasContextSet(subscriptionAliasContextSet);
-                    //add to the cartridgeTypeContextSet
-                    cartridgeTypeContextSet.add(cartridgeTypeContext);
-
-                } else {
-                    //iterate through the set
-                    /*Iterator<SubscriptionAliasContext> aliasIterator = subscriptionAliasContextSet.iterator();
-                    while (aliasIterator.hasNext()) {
-                        //see if the set contains a SubscriptionAliasContext instance with the given alias
-                        SubscriptionAliasContext subscriptionAliasContext = aliasIterator.next();
-                        if (subscriptionAliasContext.getSubscriptionAlias().equals(subscriptionAlias)) {
-                            //remove the existing one
-                            aliasIterator.remove();
-                            break;
-                        }
-                    }*/
-                    // remove the existing one
-                    subscriptionAliasContextSet.remove(new SubscriptionAliasContext(subscriptionAlias, null));
-
-                    //now, add the new cluster object
-                    subscriptionAliasContextSet.add(new SubscriptionAliasContext(subscriptionAlias, cluster));
-                }
-
-            } else {
-                //no entries for this tenant, go from down to top creating relevant objects and populating them
-                //create a new SubscriptionAliasContext instance
-                SubscriptionAliasContext subscriptionAliasContext = new SubscriptionAliasContext(subscriptionAlias,
-                        cluster);
-                //create a SubscriptionAliasContext set
-                subscriptionAliasContextSet = new HashSet<SubscriptionAliasContext>();
-                //add the created SubscriptionAliasContext instance to SubscriptionAliasContext set
-                subscriptionAliasContextSet.add(subscriptionAliasContext);
-
-                //create a new CartridgeTypeContext instance
-                CartridgeTypeContext cartridgeTypeContext = new CartridgeTypeContext(cartridgeType);
-                //link the SubscriptionAliasContextSet to it
-                cartridgeTypeContext.setSubscriptionAliasContextSet(subscriptionAliasContextSet);
-
-                //Create CartridgeTypeContext instance
-                cartridgeTypeContextSet = new HashSet<CartridgeTypeContext>();
-                //link the SubscriptionAliasContext set to CartridgeTypeContext instance
-                cartridgeTypeContext.setSubscriptionAliasContextSet(subscriptionAliasContextSet);
-
-                //link the CartridgeTypeContext set to the [tenant Id -> CartridgeTypeContext] map
-                tenantIdToCartridgeTypeContextMap.put(tenantId, cartridgeTypeContextSet);
-            }
-
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    public Cluster getCluster (int tenantId, String cartridgeType, String subscriptionAlias) {
-
-        Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-        Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-
-        readLock.lock();
-        try {
-            //check if a set of CartridgeTypeContext instances already exist for given tenant Id
-            cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-            if(cartridgeTypeContextSet != null) {
-                CartridgeTypeContext cartridgeTypeContext = null;
-                //iterate through the set
-                Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-                while (typeCtxIterator.hasNext()) {
-                    //see if the set contains a CartridgeTypeContext instance with the given cartridge type
-                    cartridgeTypeContext = typeCtxIterator.next();
-                    if (cartridgeTypeContext.getType().equals(cartridgeType)){
-                        //if so, get the SubscriptionAliasContext set
-                        subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-                        break;
-                    }
-                }
-                if(subscriptionAliasContextSet != null) {
-                    //iterate through the set
-                    Iterator<SubscriptionAliasContext> aliasIterator = subscriptionAliasContextSet.iterator();
-                    while (aliasIterator.hasNext()) {
-                        //see if the set contains a SubscriptionAliasContext instance with the given alias
-                        SubscriptionAliasContext subscriptionAliasContext = aliasIterator.next();
-                        if (subscriptionAliasContext.equals(new SubscriptionAliasContext(subscriptionAlias, null))) {
-                            return subscriptionAliasContext.getCluster();
-                        }
-                    }
-                }
-            }
-
-        } finally {
-            readLock.unlock();
-        }
-
-        return null;
-    }
-
-    public Set<Cluster> getClusters (int tenantId, String cartridgeType) {
-
-        Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-        Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-        Set<Cluster> clusterSet = null;
-
-        readLock.lock();
-        try {
-            cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-            if(cartridgeTypeContextSet != null) {
-                //iterate through the set
-                Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-                while (typeCtxIterator.hasNext()) {
-                    //iterate and get each of SubscriptionAliasContext sets
-                    CartridgeTypeContext cartridgeTypeContext = typeCtxIterator.next();
-
-                    if (cartridgeType != null) {
-                        // check if CartridgeTypeContext instance matches the cartridgeType
-                        if (cartridgeTypeContext.equals(new CartridgeTypeContext(cartridgeType))) {
-
-                            subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-
-                            if (subscriptionAliasContextSet != null) {
-                                //iterate and convert to Cluster set
-                                Iterator<SubscriptionAliasContext> aliasCtxIterator = subscriptionAliasContextSet.iterator();
-
-                                clusterSet = new HashSet<Cluster>();
-                                while (aliasCtxIterator.hasNext()) {
-                                    clusterSet.add(aliasCtxIterator.next().getCluster());
-                                }
-                            }
-                        }
-
-                    } else {
-                        // no cartridgeType specified
-                        subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-
-                        if (subscriptionAliasContextSet != null) {
-                            //iterate and convert to Cluster set
-                            Iterator<SubscriptionAliasContext> aliasCtxIterator = subscriptionAliasContextSet.iterator();
-
-                            clusterSet = new HashSet<Cluster>();
-                            while (aliasCtxIterator.hasNext()) {
-                                clusterSet.add(aliasCtxIterator.next().getCluster());
-                            }
-                        }
-                    }
-                }
-            }
-
-        } finally {
-            readLock.unlock();
-        }
-
-        return clusterSet;
-    }
-
-    /*public Set<Cluster> getClusters (int tenantId) {
-
-        Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-        Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-        Set<Cluster> clusterSet = null;
-
-        readLock.lock();
-        try {
-            cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-            if(cartridgeTypeContextSet != null) {
-                CartridgeTypeContext cartridgeTypeContext = null;
-                //iterate through the set
-                Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-                while (typeCtxIterator.hasNext()) {
-                    //see if the set contains a CartridgeTypeContext instance with the given cartridge type
-                }
-
-                if (subscriptionAliasContextSet != null) {
-                    //iterate and convert to Cluster set
-                    Iterator<SubscriptionAliasContext> aliasCtxIterator = subscriptionAliasContextSet.iterator();
-                    clusterSet = new HashSet<Cluster>();
-                    while (aliasCtxIterator.hasNext()) {
-                        clusterSet.add(aliasCtxIterator.next().getCluster());
-                    }
-                }
-            }
-
-        } finally {
-            readLock.unlock();
-        }
-
-        return clusterSet;
-    }*/
-
-    public void removeCluster (int tenantId, String cartridgeType, String subscriptionAlias) {
-
-        Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-        Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-
-        writeLock.lock();
-        try {
-            //check if a set of CartridgeTypeContext instances already exist for given tenant Id
-            cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-            if(cartridgeTypeContextSet != null) {
-                CartridgeTypeContext cartridgeTypeContext = null;
-                //iterate through the set
-                Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-                while (typeCtxIterator.hasNext()) {
-                    //see if the set contains a CartridgeTypeContext instance with the given cartridge type
-                    cartridgeTypeContext = typeCtxIterator.next();
-                    if (cartridgeTypeContext.getType().equals(cartridgeType)){
-                        //if so, get the SubscriptionAliasContext set
-                        subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-                        break;
-                    }
-                }
-                if(subscriptionAliasContextSet != null) {
-                    //iterate through the set
-                    Iterator<SubscriptionAliasContext> aliasIterator = subscriptionAliasContextSet.iterator();
-                    while (aliasIterator.hasNext()) {
-                        //see if the set contains a SubscriptionAliasContext instance with the given alias
-                        SubscriptionAliasContext subscriptionAliasContext = aliasIterator.next();
-                        if (subscriptionAliasContext.getSubscriptionAlias().equals(subscriptionAlias)) {
-                            //remove the existing one
-                            aliasIterator.remove();
-                            break;
-                        }
-                    }
-                }
-            }
-
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    private class CartridgeTypeContext {
-
-        private String type;
-        private Set<SubscriptionAliasContext> subscriptionAliasContextSet;
-
-        public CartridgeTypeContext (String type) {
-            this.type = type;
-        }
-
-        public void setSubscriptionAliasContextSet (Set<SubscriptionAliasContext> subscriptionAliasContextSet) {
-            this.subscriptionAliasContextSet = subscriptionAliasContextSet;
-        }
-
-        public String getType () {
-            return type;
-        }
-
-        public Set<SubscriptionAliasContext> getSubscriptionAliasContextSet () {
-            return subscriptionAliasContextSet;
-        }
-
-        public boolean equals(Object other) {
-
-            if(this == other) {
-                return true;
-            }
-            if(!(other instanceof CartridgeTypeContext)) {
-                return false;
-            }
-
-            CartridgeTypeContext that = (CartridgeTypeContext)other;
-            return this.type.equals(that.type);
-        }
-
-        public int hashCode () {
-            return type.hashCode();
-        }
-    }
-
-    private class SubscriptionAliasContext {
-
-        private String subscriptionAlias;
-        private Cluster cluster;
-
-        public SubscriptionAliasContext(String subscriptionAlias, Cluster cluster) {
-            this.subscriptionAlias = subscriptionAlias;
-            this.cluster = cluster;
-        }
-
-        public String getSubscriptionAlias () {
-            return subscriptionAlias;
-        }
-
-        public Cluster getCluster () {
-            return cluster;
-        }
-
-        public boolean equals(Object other) {
-
-            if(this == other) {
-                return true;
-            }
-            if(!(other instanceof SubscriptionAliasContext)) {
-                return false;
-            }
-
-            SubscriptionAliasContext that = (SubscriptionAliasContext)other;
-            return this.subscriptionAlias.equals(that.subscriptionAlias);
-        }
-
-        public int hashCode () {
-            return subscriptionAlias.hashCode();
-        }
-    }
-
-    private class TenantIdAndAliasTopologyKey {
-
-        private int tenantId;
-        private String subscriptionAlias;
-
-        public TenantIdAndAliasTopologyKey (int tenantId, String subscriptionAlias) {
-
-            this.tenantId = tenantId;
-            this.subscriptionAlias = subscriptionAlias;
-        }
-
-        public boolean equals(Object other) {
-
-            if(this == other) {
-                return true;
-            }
-            if(!(other instanceof TenantIdAndAliasTopologyKey)) {
-                return false;
-            }
-
-            TenantIdAndAliasTopologyKey that = (TenantIdAndAliasTopologyKey)other;
-            return ((this.tenantId == that.tenantId) && (this.subscriptionAlias == that.subscriptionAlias));
-        }
-
-        public int hashCode () {
-
-            int subscriptionAliasHashCode = 0;
-            if(subscriptionAlias != null) {
-                subscriptionAliasHashCode = subscriptionAlias.hashCode();
-            }
-
-            return (tenantId * 3 + subscriptionAliasHashCode * 5);
-        }
-    }
-
-    public class TenantIdAndTypeTopologyKey {
-
-        private int tenantId;
-        private String subscriptionAlias;
-
-        public TenantIdAndTypeTopologyKey (int tenantId, String subscriptionAlias) {
-
-            this.tenantId = tenantId;
-            this.subscriptionAlias = subscriptionAlias;
-        }
-
-        public boolean equals(Object other) {
-
-            if(this == other) {
-                return true;
-            }
-            if(!(other instanceof TenantIdAndTypeTopologyKey)) {
-                return false;
-            }
-
-            TenantIdAndTypeTopologyKey that = (TenantIdAndTypeTopologyKey)other;
-            return ((this.tenantId == that.tenantId) && (this.subscriptionAlias == that.subscriptionAlias));
-        }
-
-        public int hashCode () {
-
-            int subscriptionAliasHashCode = 0;
-            if(subscriptionAlias != null) {
-                subscriptionAliasHashCode = subscriptionAlias.hashCode();
-            }
-
-            return (tenantId * 3 + subscriptionAliasHashCode * 5);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9d280533/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyReceiver.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyReceiver.java
deleted file mode 100644
index 6dc827d..0000000
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyReceiver.java
+++ /dev/null
@@ -1,310 +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.manager.topology.receiver;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.listener.topology.*;
-import org.apache.stratos.messaging.message.processor.topology.TopologyMessageProcessorChain;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventMessageDelegator;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyReceiver;
-
-public class StratosManagerTopologyReceiver implements Runnable {
-
-    private static final Log log = LogFactory.getLog(StratosManagerTopologyReceiver.class);
-
-    private TopologyReceiver stratosManagerTopologyReceiver;
-    private boolean terminate;
-
-    public StratosManagerTopologyReceiver() {
-        this.terminate = false;
-        this.stratosManagerTopologyReceiver = new TopologyReceiver(createMessageDelegator());
-    }
-
-    private TopologyEventMessageDelegator createMessageDelegator() {
-        TopologyMessageProcessorChain processorChain = createEventProcessorChain();
-        return new TopologyEventMessageDelegator(processorChain);
-    }
-
-    private TopologyMessageProcessorChain createEventProcessorChain() {
-
-        TopologyMessageProcessorChain processorChain = new TopologyMessageProcessorChain();
-
-        //add listner to Complete Topology Event
-        processorChain.addEventListener(new CompleteTopologyEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [CompleteTopologyEventListener] Received: " + event.getClass() + " **********");
-
-                try {
-                    TopologyManager.acquireReadLock();
-
-                    for (Service service : TopologyManager.getTopology().getServices()) {
-                        //iterate through all clusters
-                        for (Cluster cluster : service.getClusters()) {
-                            //get subscription details
-                            CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(cluster.getClusterId());
-
-                            if(cartridgeSubscription != null) {
-                                //add the information to Topology Cluster Info. model
-                                TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                        cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), cluster);
-                            }
-                        }
-                    }
-                } finally {
-                    TopologyManager.releaseReadLock();
-                }
-            }
-        });
-
-        //Cluster Created event listner
-        processorChain.addEventListener(new ClusterCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [ClusterCreatedEventListener] Received: " + event.getClass() + " **********");
-
-                ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event;
-                //get subscription details
-                CartridgeSubscription cartridgeSubscription =
-                        getCartridgeSubscription(clustercreatedEvent.getClusterId());
-
-                if(cartridgeSubscription != null) {
-
-                    Cluster cluster;
-                    //acquire read lock
-                    TopologyManager.acquireReadLock();
-                    try {
-                        cluster = TopologyManager.getTopology().
-                                getService(cartridgeSubscription.getType()).getCluster(cartridgeSubscription.getClusterDomain());
-
-                        //add the information to Topology Cluster Info. model
-                        TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), cluster);
-
-                    } finally {
-                        //release read lock
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-            }
-        });
-
-        //Cluster Removed event listner
-        processorChain.addEventListener(new ClusterRemovedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [ClusterRemovedEventListener] Received: " + event.getClass() + " **********");
-
-                ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
-
-                CartridgeSubscription cartridgeSubscription =
-                        getCartridgeSubscription(clusterRemovedEvent.getClusterId());
-
-                if(cartridgeSubscription != null) {
-                    //add the information to Topology Cluster Info. model
-                    TopologyClusterInformationModel.getInstance().removeCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                            cartridgeSubscription.getType(), cartridgeSubscription.getAlias());
-                }
-            }
-        });
-
-        //Member Started event listner
-        processorChain.addEventListener(new MemberStartedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [MemberStartedEventListener] Received: " + event.getClass() + " **********");
-
-                MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event;
-
-                String clusterDomain = memberStartedEvent.getClusterId();
-                CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(clusterDomain);
-
-                if(cartridgeSubscription != null) {
-
-                    Cluster cluster;
-                    //acquire read lock
-                    TopologyManager.acquireReadLock();
-
-                    try {
-                        cluster = TopologyManager.getTopology().
-                                getService(cartridgeSubscription.getType()).getCluster(cartridgeSubscription.getClusterDomain());
-
-                        TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), cluster);
-
-                    } finally {
-                        //release read lock
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-
-            }
-        });
-
-        //Member Activated event listner
-        processorChain.addEventListener(new MemberActivatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [MemberActivatedEventListener] Received: " + event.getClass() + " **********");
-
-                MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
-
-                String clusterDomain = memberActivatedEvent.getClusterId();
-                CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(clusterDomain);
-
-                if(cartridgeSubscription != null) {
-
-                    Cluster cluster;
-                    //acquire read lock
-                    TopologyManager.acquireReadLock();
-
-                    try {
-                        cluster = TopologyManager.getTopology().
-                                getService(cartridgeSubscription.getType()).getCluster(cartridgeSubscription.getClusterDomain());
-
-                        TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                cartridgeSubscription.getType(),
-                                cartridgeSubscription.getAlias(), cluster);
-
-                    } finally {
-                        //release read lock
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-
-            }
-        });
-
-        //Member Suspended event listner
-        processorChain.addEventListener(new MemberSuspendedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [MemberSuspendedEventListener] Received: " + event.getClass() + " **********");
-
-                MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event;
-
-                String clusterDomain = memberSuspendedEvent.getClusterId();
-                CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(clusterDomain);
-
-                if(cartridgeSubscription != null) {
-
-                    Cluster cluster;
-                    //acquire read lock
-                    TopologyManager.acquireReadLock();
-
-                    try {
-                        cluster = TopologyManager.getTopology().
-                                getService(cartridgeSubscription.getType()).getCluster(cartridgeSubscription.getClusterDomain());
-
-                        TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), cluster);
-
-                    } finally {
-                        //release read lock
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-
-            }
-        });
-
-        //Member Terminated event listner
-        processorChain.addEventListener(new MemberTerminatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                log.info("********** [MemberTerminatedEventListener] Received: " + event.getClass() + " **********");
-
-                MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
-
-                String clusterDomain = memberTerminatedEvent.getClusterId();
-                CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(clusterDomain);
-
-                if(cartridgeSubscription != null) {
-
-                    Cluster cluster;
-                    //acquire read lock
-                    TopologyManager.acquireReadLock();
-
-                    try {
-                        cluster = TopologyManager.getTopology().
-                                getService(cartridgeSubscription.getType()).getCluster(cartridgeSubscription.getClusterDomain());
-
-                        TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscription.getSubscriber().getTenantId(),
-                                cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), cluster);
-
-                    } finally {
-                        //release read lock
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-
-            }
-        });
-
-        return processorChain;
-    }
-
-    private CartridgeSubscription getCartridgeSubscription(String clusterDomain) {
-
-        try {
-            return new DataInsertionAndRetrievalManager().getCartridgeSubscription(clusterDomain);
-
-        } catch (Exception e) {
-            log.error("Error getting subscription information for cluster " + clusterDomain, e);
-            return null;
-        }
-    }
-
-    @Override
-    public void run() {
-
-        Thread thread = new Thread(stratosManagerTopologyReceiver);
-        thread.start();
-        log.info("Stratos Manager topology receiver thread started");
-
-        //Keep running till terminate is set from deactivate method of the component
-        while (!terminate) {
-            //loop while terminate = false
-        }
-        log.info("Stratos Manager topology receiver thread terminated");
-    }
-
-    //terminate Topology Receiver
-    public void terminate () {
-        stratosManagerTopologyReceiver.terminate();
-        terminate = true;
-    }
-}