Repository: stratos Updated Branches: refs/heads/master b5111e6d7 -> cf30b5dd6
Renaming CloudControllerDSComponent to CloudControllerServiceComponent Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/cf30b5dd Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/cf30b5dd Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/cf30b5dd Branch: refs/heads/master Commit: cf30b5dd62a7880cbf8b5dd659749e7fe8f3f222 Parents: b5111e6 Author: Imesh Gunaratne <[email protected]> Authored: Thu Nov 27 19:07:54 2014 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Thu Nov 27 19:07:54 2014 +0530 ---------------------------------------------------------------------- .../internal/CloudControllerDSComponent.java | 176 ------------------- .../CloudControllerServiceComponent.java | 172 ++++++++++++++++++ 2 files changed, 172 insertions(+), 176 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/cf30b5dd/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java deleted file mode 100644 index 58eeeb8..0000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.apache.stratos.cloud.controller.internal; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.receiver.application.ApplicationTopicReceiver; -import org.apache.stratos.cloud.controller.receiver.cluster.status.ClusterStatusTopicReceiver; -import org.apache.stratos.cloud.controller.exception.CloudControllerException; -import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; -import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; -import org.apache.stratos.cloud.controller.publisher.TopologySynchronizerTaskScheduler; -import org.apache.stratos.cloud.controller.receiver.instance.status.InstanceStatusTopicReceiver; -import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; -import org.apache.stratos.messaging.broker.publish.EventPublisherPool; -import org.apache.stratos.messaging.util.Constants; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.ntask.core.service.TaskService; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.utils.ConfigurationContextService; - -/** - * Registering Cloud Controller Service. - * - * @scr.component name="org.apache.stratos.cloud.controller" immediate="true" - * @scr.reference name="ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" policy="dynamic" bind="setTaskService" - * unbind="unsetTaskService" - * @scr.reference name="registry.service" interface= - * "org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" policy="dynamic" bind="setRegistryService" - * unbind="unsetRegistryService" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="1..1" policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -public class CloudControllerDSComponent { - - private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class); - private ClusterStatusTopicReceiver clusterStatusTopicReceiver; - private InstanceStatusTopicReceiver instanceStatusTopicReceiver; - private ApplicationTopicReceiver applicationTopicReceiver; - - protected void activate(ComponentContext context) { - try { - - /*// Start instance status event message listener - TopicSubscriber subscriber = new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC); - subscriber.setMessageListener(new InstanceStatusEventMessageListener()); - Thread tsubscriber = new Thread(subscriber); - tsubscriber.start(); - - // Start instance status message delegator - InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator(); - Thread tdelegator = new Thread(delegator); - tdelegator.start();*/ - - - applicationTopicReceiver = new ApplicationTopicReceiver(); - Thread tApplicationTopicReceiver = new Thread(applicationTopicReceiver); - tApplicationTopicReceiver.start(); - - if (log.isInfoEnabled()) { - log.info("Application Receiver thread started"); - } - - clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); - Thread tClusterStatusTopicReceiver = new Thread(clusterStatusTopicReceiver); - tClusterStatusTopicReceiver.start(); - - if (log.isInfoEnabled()) { - log.info("Cluster status Receiver thread started"); - } - - instanceStatusTopicReceiver = new InstanceStatusTopicReceiver(); - Thread tInstanceStatusTopicReceiver = new Thread(instanceStatusTopicReceiver); - tInstanceStatusTopicReceiver.start(); - if(log.isInfoEnabled()) { - log.info("Instance status message receiver thread started"); - } - - // Register cloud controller service - BundleContext bundleContext = context.getBundleContext(); - bundleContext.registerService(CloudControllerService.class.getName(), - new CloudControllerServiceImpl(), null); - - if(log.isInfoEnabled()) { - log.info("Scheduling tasks"); - } - - TopologySynchronizerTaskScheduler - .schedule(ServiceReferenceHolder.getInstance() - .getTaskService()); - - } catch (Throwable e) { - log.error("******* Cloud Controller Service bundle is failed to activate ****", e); - } - } - - protected void setTaskService(TaskService taskService) { - if (log.isDebugEnabled()) { - log.debug("Setting the Task Service"); - } - ServiceReferenceHolder.getInstance().setTaskService(taskService); - } - - protected void unsetTaskService(TaskService taskService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the Task Service"); - } - ServiceReferenceHolder.getInstance().setTaskService(null); - } - - protected void setRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Setting the Registry Service"); - } - - try { - UserRegistry registry = registryService.getGovernanceSystemRegistry(); - ServiceReferenceHolder.getInstance() - .setRegistry(registry); - } catch (RegistryException e) { - String msg = "Failed when retrieving Governance System Registry."; - log.error(msg, e); - throw new CloudControllerException(msg, e); - } - } - - protected void unsetRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting the Registry Service"); - } - ServiceReferenceHolder.getInstance().setRegistry(null); - } - - protected void setConfigurationContextService(ConfigurationContextService cfgCtxService) { - ServiceReferenceHolder.getInstance().setAxisConfiguration( - cfgCtxService.getServerConfigContext().getAxisConfiguration()); - } - - protected void unsetConfigurationContextService(ConfigurationContextService cfgCtxService) { - ServiceReferenceHolder.getInstance().setAxisConfiguration(null); - } - - protected void deactivate(ComponentContext ctx) { - // Close event publisher connections to message broker - EventPublisherPool.close(Constants.TOPOLOGY_TOPIC); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/cf30b5dd/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java new file mode 100644 index 0000000..1f66d25 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerServiceComponent.java @@ -0,0 +1,172 @@ +package org.apache.stratos.cloud.controller.internal; +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.receiver.application.ApplicationTopicReceiver; +import org.apache.stratos.cloud.controller.receiver.cluster.status.ClusterStatusTopicReceiver; +import org.apache.stratos.cloud.controller.exception.CloudControllerException; +import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; +import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; +import org.apache.stratos.cloud.controller.publisher.TopologySynchronizerTaskScheduler; +import org.apache.stratos.cloud.controller.receiver.instance.status.InstanceStatusTopicReceiver; +import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; +import org.apache.stratos.messaging.broker.publish.EventPublisherPool; +import org.apache.stratos.messaging.util.Constants; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.ntask.core.service.TaskService; +import org.wso2.carbon.registry.core.exceptions.RegistryException; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.registry.core.session.UserRegistry; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * Registering Cloud Controller Service. + * + * @scr.component name="org.apache.stratos.cloud.controller" immediate="true" + * @scr.reference name="ntask.component" + * interface="org.wso2.carbon.ntask.core.service.TaskService" + * cardinality="1..1" policy="dynamic" bind="setTaskService" unbind="unsetTaskService" + * @scr.reference name="registry.service" + * interface="org.wso2.carbon.registry.core.service.RegistryService" + * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" + * @scr.reference name="config.context.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" + * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService" + */ +public class CloudControllerServiceComponent { + + private static final Log log = LogFactory.getLog(CloudControllerServiceComponent.class); + private ClusterStatusTopicReceiver clusterStatusTopicReceiver; + private InstanceStatusTopicReceiver instanceStatusTopicReceiver; + private ApplicationTopicReceiver applicationTopicReceiver; + + protected void activate(ComponentContext context) { + try { + + /*// Start instance status event message listener + TopicSubscriber subscriber = new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC); + subscriber.setMessageListener(new InstanceStatusEventMessageListener()); + Thread tsubscriber = new Thread(subscriber); + tsubscriber.start(); + + // Start instance status message delegator + InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator(); + Thread tdelegator = new Thread(delegator); + tdelegator.start();*/ + + + applicationTopicReceiver = new ApplicationTopicReceiver(); + Thread tApplicationTopicReceiver = new Thread(applicationTopicReceiver); + tApplicationTopicReceiver.start(); + + if (log.isInfoEnabled()) { + log.info("Application Receiver thread started"); + } + + clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); + Thread tClusterStatusTopicReceiver = new Thread(clusterStatusTopicReceiver); + tClusterStatusTopicReceiver.start(); + + if (log.isInfoEnabled()) { + log.info("Cluster status Receiver thread started"); + } + + instanceStatusTopicReceiver = new InstanceStatusTopicReceiver(); + Thread tInstanceStatusTopicReceiver = new Thread(instanceStatusTopicReceiver); + tInstanceStatusTopicReceiver.start(); + if(log.isInfoEnabled()) { + log.info("Instance status message receiver thread started"); + } + + // Register cloud controller service + BundleContext bundleContext = context.getBundleContext(); + bundleContext.registerService(CloudControllerService.class.getName(), + new CloudControllerServiceImpl(), null); + + if(log.isInfoEnabled()) { + log.info("Scheduling tasks"); + } + + TopologySynchronizerTaskScheduler + .schedule(ServiceReferenceHolder.getInstance() + .getTaskService()); + + } catch (Throwable e) { + log.error("******* Cloud Controller Service bundle is failed to activate ****", e); + } + } + + protected void setTaskService(TaskService taskService) { + if (log.isDebugEnabled()) { + log.debug("Setting the Task Service"); + } + ServiceReferenceHolder.getInstance().setTaskService(taskService); + } + + protected void unsetTaskService(TaskService taskService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting the Task Service"); + } + ServiceReferenceHolder.getInstance().setTaskService(null); + } + + protected void setRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Setting the Registry Service"); + } + + try { + UserRegistry registry = registryService.getGovernanceSystemRegistry(); + ServiceReferenceHolder.getInstance() + .setRegistry(registry); + } catch (RegistryException e) { + String msg = "Failed when retrieving Governance System Registry."; + log.error(msg, e); + throw new CloudControllerException(msg, e); + } + } + + protected void unsetRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting the Registry Service"); + } + ServiceReferenceHolder.getInstance().setRegistry(null); + } + + protected void setConfigurationContextService(ConfigurationContextService cfgCtxService) { + ServiceReferenceHolder.getInstance().setAxisConfiguration( + cfgCtxService.getServerConfigContext().getAxisConfiguration()); + } + + protected void unsetConfigurationContextService(ConfigurationContextService cfgCtxService) { + ServiceReferenceHolder.getInstance().setAxisConfiguration(null); + } + + protected void deactivate(ComponentContext ctx) { + // Close event publisher connections to message broker + EventPublisherPool.close(Constants.TOPOLOGY_TOPIC); + } + +}
