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 2015/03/21 12:21:09 UTC
[1/3] stratos git commit: Implementing stratos component startup
synchronizer
Repository: stratos
Updated Branches:
refs/heads/master 42f439079 -> c6e8359d5
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
index d73680f..5ed320f 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax27="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax25="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax21="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax22="http://common.stratos.apache.org/xsd" xmlns:ax216="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://rmi.java/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax220="http://io.java/xsd" xmlns:ax213="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:mime="http://schemas.x
mlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax28="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax25="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax21="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax22="http://common.stratos.apache.org/xsd" xmlns:ax218="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://rmi.java/xsd" xmlns:ax220="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax215="http://io.java/xsd" xmlns:ax212="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax210="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.
xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
<wsdl:types>
- <xs:schema xmlns:ax221="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
+ <xs:schema xmlns:ax216="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
<xs:import namespace="http://io.java/xsd"/>
<xs:complexType name="RemoteException">
<xs:complexContent>
- <xs:extension base="ax220:IOException">
+ <xs:extension base="ax216:IOException">
<xs:sequence>
<xs:element minOccurs="0" name="cause" nillable="true" type="xs:anyType"/>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
@@ -21,7 +21,7 @@
<xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"/>
<xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
- <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax29:LoadThresholds"/>
+ <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax212:LoadThresholds"/>
<xs:element minOccurs="0" name="tenantId" type="xs:int"/>
</xs:sequence>
</xs:complexType>
@@ -33,17 +33,17 @@
</xs:sequence>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax217="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
+ <xs:schema xmlns:ax26="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
<xs:import namespace="http://common.stratos.apache.org/xsd"/>
<xs:complexType name="ApplicationContext">
<xs:sequence>
<xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="components" nillable="true" type="ax216:ComponentContext"/>
+ <xs:element minOccurs="0" name="components" nillable="true" type="ax25:ComponentContext"/>
<xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="multiTenant" type="xs:boolean"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="properties" nillable="true" type="ax217:Properties"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax26:Properties"/>
<xs:element minOccurs="0" name="status" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="tenantAdminUsername" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"/>
@@ -52,10 +52,10 @@
</xs:complexType>
<xs:complexType name="ComponentContext">
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax216:ApplicationClusterContext"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax216:CartridgeContext"/>
- <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax216:DependencyContext"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax216:GroupContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax25:ApplicationClusterContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax25:CartridgeContext"/>
+ <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax25:DependencyContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax25:GroupContext"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ApplicationClusterContext">
@@ -66,8 +66,8 @@
<xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyClusterIds" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="persistenceContext" nillable="true" type="ax216:PersistenceContext"/>
- <xs:element minOccurs="0" name="properties" nillable="true" type="ax217:Properties"/>
+ <xs:element minOccurs="0" name="persistenceContext" nillable="true" type="ax25:PersistenceContext"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax26:Properties"/>
<xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="textPayload" nillable="true" type="xs:string"/>
</xs:sequence>
@@ -75,7 +75,7 @@
<xs:complexType name="PersistenceContext">
<xs:sequence>
<xs:element minOccurs="0" name="persistenceRequired" type="xs:boolean"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax216:VolumeContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax25:VolumeContext"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="VolumeContext">
@@ -94,21 +94,21 @@
<xs:sequence>
<xs:element minOccurs="0" name="cartridgeMax" type="xs:int"/>
<xs:element minOccurs="0" name="cartridgeMin" type="xs:int"/>
- <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax216:SubscribableInfoContext"/>
+ <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax25:SubscribableInfoContext"/>
<xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SubscribableInfoContext">
<xs:sequence>
<xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax216:ArtifactRepositoryContext"/>
+ <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax25:ArtifactRepositoryContext"/>
<xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="maxMembers" type="xs:int"/>
<xs:element minOccurs="0" name="minMembers" type="xs:int"/>
- <xs:element minOccurs="0" name="persistenceContext" nillable="true" type="ax216:PersistenceContext"/>
- <xs:element minOccurs="0" name="properties" nillable="true" type="ax217:Properties"/>
+ <xs:element minOccurs="0" name="persistenceContext" nillable="true" type="ax25:PersistenceContext"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax26:Properties"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ArtifactRepositoryContext">
@@ -130,9 +130,9 @@
<xs:complexType name="GroupContext">
<xs:sequence>
<xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax216:CartridgeContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax25:CartridgeContext"/>
<xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax216:GroupContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax25:GroupContext"/>
<xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"/>
<xs:element minOccurs="0" name="groupMinInstances" type="xs:int"/>
<xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"/>
@@ -144,8 +144,8 @@
<xs:complexType name="ServiceGroup">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax27:Dependencies"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax27:ServiceGroup"/>
+ <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax210:Dependencies"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax210:ServiceGroup"/>
<xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
@@ -158,16 +158,16 @@
</xs:sequence>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax28="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax218="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://common.stratos.apache.org/xsd" xmlns:ax212="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax222="http://rmi.java/xsd" xmlns:ax210="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+ <xs:schema xmlns:ax29="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax27="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://rmi.java/xsd" xmlns:ax219="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax221="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax222="http://common.stratos.apache.org/xsd" xmlns:ax213="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax211="http://pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
<xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
- <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
+ <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"/>
+ <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"/>
<xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
<xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
- <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"/>
+ <xs:import namespace="http://rmi.java/xsd"/>
<xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"/>
+ <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
<xs:import namespace="http://common.stratos.apache.org/xsd"/>
- <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"/>
- <xs:import namespace="http://rmi.java/xsd"/>
<xs:element name="getApplicationPolicy">
<xs:complexType>
<xs:sequence>
@@ -182,320 +182,320 @@
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="serviceGroupExist">
+ <xs:element name="getApplications">
+ <xs:complexType>
+ <xs:sequence/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getApplicationsResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax27:ApplicationContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="serviceGroupExistResponse">
+ <xs:element name="AutoscalerServiceApplicationDefinitionException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax29:ApplicationDefinitionException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceAutoScalerException">
+ <xs:element name="addApplication">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax25:AutoScalerException"/>
+ <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax27:ApplicationContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getServiceGroups">
+ <xs:element name="getServiceGroup">
<xs:complexType>
- <xs:sequence/>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+ </xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getServiceGroupsResponse">
+ <xs:element name="getServiceGroupResponse">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax27:ServiceGroup"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax210:ServiceGroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="removeServiceGroup">
+ <xs:element name="getAutoscalingPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="groupName" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getAutoScalingPolicies">
+ <xs:element name="getAutoscalingPolicyResponse">
<xs:complexType>
- <xs:sequence/>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax212:AutoscalePolicy"/>
+ </xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getAutoScalingPoliciesResponse">
+ <xs:element name="getApplication">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
+ <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceApplicationDefinitionException">
+ <xs:element name="getApplicationResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax212:ApplicationDefinitionException"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax27:ApplicationContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="deployApplication">
+ <xs:element name="deleteApplication">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="deployApplicationResponse">
+ <xs:element name="AutoscalerServiceRemoteException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax217:RemoteException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceInvalidPolicyException">
+ <xs:element name="AutoscalerServiceInvalidApplicationPolicyException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax214:InvalidPolicyException"/>
+ <xs:element minOccurs="0" name="InvalidApplicationPolicyException" nillable="true" type="ax29:InvalidApplicationPolicyException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="addAutoScalingPolicy">
+ <xs:element name="AutoscalerServiceInvalidPolicyException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
+ <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax219:InvalidPolicyException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="addAutoScalingPolicyResponse">
+ <xs:element name="addApplicationPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax24:ApplicationPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="updateAutoScalingPolicy">
+ <xs:element name="removeApplicationPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
+ <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="updateAutoScalingPolicyResponse">
+ <xs:element name="AutoscalerServiceApplicatioinPolicyNotExistsException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax219:ApplicatioinPolicyNotExistsException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="removeAutoScalingPolicy">
+ <xs:element name="updateApplicationPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="autoscalePolicyId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax24:ApplicationPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="removeAutoScalingPolicyResponse">
+ <xs:element name="getApplicationPolicies">
<xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
- </xs:sequence>
+ <xs:sequence/>
</xs:complexType>
</xs:element>
- <xs:element name="undeployApplication">
+ <xs:element name="getApplicationPoliciesResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:ApplicationPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceInvalidArgumentException">
+ <xs:element name="serviceGroupExist">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax25:InvalidArgumentException"/>
+ <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="updateClusterMonitor">
+ <xs:element name="serviceGroupExistResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="properties" nillable="true" type="ax22:Properties"/>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceInvalidServiceGroupException">
+ <xs:element name="AutoscalerServiceAutoScalerException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax212:InvalidServiceGroupException"/>
+ <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax220:AutoScalerException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="addServiceGroup">
+ <xs:element name="getServiceGroups">
<xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax27:ServiceGroup"/>
- </xs:sequence>
+ <xs:sequence/>
</xs:complexType>
</xs:element>
- <xs:element name="findClusterId">
+ <xs:element name="getServiceGroupsResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax210:ServiceGroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="findClusterIdResponse">
+ <xs:element name="removeServiceGroup">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="groupName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplicationNetworkPartitions">
+ <xs:element name="addAutoScalingPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax212:AutoscalePolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplicationNetworkPartitionsResponse">
+ <xs:element name="addAutoScalingPolicyResponse">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="undeployServiceGroup">
+ <xs:element name="getAutoScalingPolicies">
<xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
- </xs:sequence>
+ <xs:sequence/>
</xs:complexType>
</xs:element>
- <xs:element name="getServiceGroup">
+ <xs:element name="getAutoScalingPoliciesResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax212:AutoscalePolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getServiceGroupResponse">
+ <xs:element name="updateAutoScalingPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax27:ServiceGroup"/>
+ <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax212:AutoscalePolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getAutoscalingPolicy">
+ <xs:element name="updateAutoScalingPolicyResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getAutoscalingPolicyResponse">
+ <xs:element name="removeAutoScalingPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
+ <xs:element minOccurs="0" name="autoscalePolicyId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplications">
+ <xs:element name="removeAutoScalingPolicyResponse">
<xs:complexType>
- <xs:sequence/>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ </xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplicationsResponse">
+ <xs:element name="deployApplication">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax216:ApplicationContext"/>
+ <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="addApplication">
+ <xs:element name="deployApplicationResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax216:ApplicationContext"/>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplication">
+ <xs:element name="undeployApplication">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplicationResponse">
+ <xs:element name="AutoscalerServiceInvalidArgumentException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax216:ApplicationContext"/>
+ <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax220:InvalidArgumentException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="deleteApplication">
+ <xs:element name="updateClusterMonitor">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax22:Properties"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceRemoteException">
+ <xs:element name="AutoscalerServiceInvalidServiceGroupException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax219:RemoteException"/>
+ <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax29:InvalidServiceGroupException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceInvalidApplicationPolicyException">
+ <xs:element name="addServiceGroup">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidApplicationPolicyException" nillable="true" type="ax212:InvalidApplicationPolicyException"/>
+ <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax210:ServiceGroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="addApplicationPolicy">
+ <xs:element name="findClusterId">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax24:ApplicationPolicy"/>
+ <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="removeApplicationPolicy">
+ <xs:element name="findClusterIdResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="AutoscalerServiceApplicatioinPolicyNotExistsException">
+ <xs:element name="getApplicationNetworkPartitions">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax214:ApplicatioinPolicyNotExistsException"/>
+ <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="updateApplicationPolicy">
+ <xs:element name="getApplicationNetworkPartitionsResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax24:ApplicationPolicy"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getApplicationPolicies">
- <xs:complexType>
- <xs:sequence/>
- </xs:complexType>
- </xs:element>
- <xs:element name="getApplicationPoliciesResponse">
+ <xs:element name="undeployServiceGroup">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:ApplicationPolicy"/>
+ <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -518,12 +518,12 @@
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="InvalidServiceGroupException">
+ <xs:complexType name="InvalidApplicationPolicyException">
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="InvalidApplicationPolicyException">
+ <xs:complexType name="InvalidServiceGroupException">
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
index a6a9f9d..7c1faf5 100644
--- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
+++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
@@ -1,10 +1,31 @@
-<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://topology.domain.messaging.stratos.apache.org/xsd" xmlns:ns="http://impl.services.controller.cloud.stratos.apache.org" xmlns:ax27="http://domain.common.stratos.apache.org/xsd" xmlns:ax25="http://common.stratos.apache.org/xsd" xmlns:ax23="http://domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax21="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://kubernetes.domain.controller.cloud.stratos.apache.org/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.controller.cloud.stratos.apache.org">
+<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://topology.domain.messaging.stratos.apache.org/xsd" xmlns:ns="http://impl.services.controller.cloud.stratos.apache.org" xmlns:ax27="http://domain.common.stratos.apache.org/xsd" xmlns:ax23="http://domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax24="http://common.stratos.apache.org/xsd" xmlns:ax21="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://kubernetes.domain.controller.cloud.stratos.apache.org/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.controller.cloud.stratos.apache.org">
<wsdl:types>
- <xs:schema xmlns:ax213="http://kubernetes.domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax210="http://topology.domain.messaging.stratos.apache.org/xsd" xmlns:ax24="http://domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax22="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.controller.cloud.stratos.apache.org">
+ <xs:schema xmlns:ax213="http://kubernetes.domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax210="http://topology.domain.messaging.stratos.apache.org/xsd" xmlns:ax26="http://domain.controller.cloud.stratos.apache.org/xsd" xmlns:ax22="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.controller.cloud.stratos.apache.org">
<xs:import namespace="http://exception.controller.cloud.stratos.apache.org/xsd"/>
<xs:import namespace="http://domain.controller.cloud.stratos.apache.org/xsd"/>
<xs:import namespace="http://topology.domain.messaging.stratos.apache.org/xsd"/>
<xs:import namespace="http://kubernetes.domain.controller.cloud.stratos.apache.org/xsd"/>
+ <xs:element name="CloudControllerServiceInvalidPartitionException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax21:InvalidPartitionException"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="validatePartition">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="partition" nillable="true" type="ax26:Partition"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="validatePartitionResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="CloudControllerServiceInvalidServiceGroupException">
<xs:complexType>
<xs:sequence>
@@ -50,60 +71,53 @@
<xs:element name="getServiceGroupDependenciesResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:Dependencies"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:Dependencies"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="CloudControllerServiceInvalidPartitionException">
+ <xs:element name="CloudControllerServiceInvalidCartridgeTypeException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidPartitionException" nillable="true" type="ax21:InvalidPartitionException"/>
+ <xs:element minOccurs="0" name="InvalidCartridgeTypeException" nillable="true" type="ax21:InvalidCartridgeTypeException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="validatePartition">
+ <xs:element name="validateDeploymentPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="partition" nillable="true" type="ax23:Partition"/>
+ <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax26:Partition"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="validatePartitionResponse">
+ <xs:element name="validateDeploymentPolicyResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="CloudControllerServiceInvalidCartridgeTypeException">
+ <xs:element name="CloudControllerServiceCartridgeNotFoundException">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="InvalidCartridgeTypeException" nillable="true" type="ax21:InvalidCartridgeTypeException"/>
+ <xs:element minOccurs="0" name="CartridgeNotFoundException" nillable="true" type="ax21:CartridgeNotFoundException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="validateDeploymentPolicy">
+ <xs:element name="registerService">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax23:Partition"/>
+ <xs:element minOccurs="0" name="registrant" nillable="true" type="ax26:Registrant"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="validateDeploymentPolicyResponse">
+ <xs:element name="registerServiceResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="CloudControllerServiceCartridgeNotFoundException">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="CartridgeNotFoundException" nillable="true" type="ax21:CartridgeNotFoundException"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
<xs:element name="CloudControllerServiceInvalidIaasProviderException">
<xs:complexType>
<xs:sequence>
@@ -121,14 +135,14 @@
<xs:element name="startInstances">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceContexts" nillable="true" type="ax23:InstanceContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceContexts" nillable="true" type="ax26:InstanceContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="startInstancesResponse">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:MemberContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:MemberContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -180,7 +194,7 @@
<xs:element name="getCartridgeInfoResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:CartridgeInfo"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:CartridgeInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -195,7 +209,7 @@
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="appId" nillable="true" type="xs:string"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="appClustersContexts" nillable="true" type="ax23:ApplicationClusterContext"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="appClustersContexts" nillable="true" type="ax26:ApplicationClusterContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -341,7 +355,7 @@
<xs:element name="addDeployementPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax23:DeploymentPolicy"/>
+ <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax26:DeploymentPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -355,7 +369,7 @@
<xs:element name="updateDeployementPolicy">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax23:DeploymentPolicy"/>
+ <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax26:DeploymentPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -376,21 +390,7 @@
<xs:element name="updateNetworkPartition">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="networkPartition" nillable="true" type="ax23:NetworkPartition"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="registerService">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="registrant" nillable="true" type="ax23:Registrant"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="registerServiceResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="networkPartition" nillable="true" type="ax26:NetworkPartition"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -423,7 +423,7 @@
<xs:element name="addCartridge">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax23:CartridgeConfig"/>
+ <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax26:CartridgeConfig"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -437,7 +437,7 @@
<xs:element name="getDeploymentPolicyResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:DeploymentPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -449,7 +449,7 @@
<xs:element name="getDeploymentPoliciesResponse">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:DeploymentPolicy"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:DeploymentPolicy"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -463,7 +463,7 @@
<xs:element name="addNetworkPartition">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="networkPartition" nillable="true" type="ax23:NetworkPartition"/>
+ <xs:element minOccurs="0" name="networkPartition" nillable="true" type="ax26:NetworkPartition"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -477,7 +477,7 @@
<xs:element name="getNetworkPartitionResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:NetworkPartition"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:NetworkPartition"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -489,7 +489,7 @@
<xs:element name="getNetworkPartitionsResponse">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:NetworkPartition"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax26:NetworkPartition"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -517,7 +517,7 @@
<xs:element name="updateCartridge">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax23:CartridgeConfig"/>
+ <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax26:CartridgeConfig"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -531,14 +531,14 @@
<xs:element name="getServiceGroupResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:ServiceGroup"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:ServiceGroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="addServiceGroup">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax23:ServiceGroup"/>
+ <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax26:ServiceGroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -559,7 +559,7 @@
<xs:element name="getClusterContextResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:ClusterContext"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:ClusterContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -641,14 +641,14 @@
<xs:element name="startInstance">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="instanceContext" nillable="true" type="ax23:InstanceContext"/>
+ <xs:element minOccurs="0" name="instanceContext" nillable="true" type="ax26:InstanceContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="startInstanceResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax23:MemberContext"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax26:MemberContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -681,7 +681,7 @@
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.stratos.apache.org/xsd">
<xs:complexType name="Properties">
<xs:sequence>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax25:Property"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax24:Property"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Property">
@@ -692,12 +692,12 @@
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.controller.cloud.stratos.apache.org/xsd">
- <xs:complexType name="InvalidServiceGroupException">
+ <xs:complexType name="InvalidPartitionException">
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="InvalidPartitionException">
+ <xs:complexType name="InvalidServiceGroupException">
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
@@ -860,15 +860,9 @@
</xs:complexContent>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax28="http://domain.common.stratos.apache.org/xsd" xmlns:ax26="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://domain.controller.cloud.stratos.apache.org/xsd">
+ <xs:schema xmlns:ax28="http://domain.common.stratos.apache.org/xsd" xmlns:ax25="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://domain.controller.cloud.stratos.apache.org/xsd">
<xs:import namespace="http://common.stratos.apache.org/xsd"/>
<xs:import namespace="http://domain.common.stratos.apache.org/xsd"/>
- <xs:complexType name="Dependencies">
- <xs:sequence>
- <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
<xs:complexType name="Partition">
<xs:sequence>
<xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
@@ -879,17 +873,28 @@
<xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="InstanceContext">
+ <xs:complexType name="Dependencies">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="killBehaviour" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Registrant">
<xs:sequence>
+ <xs:element minOccurs="0" name="autoScalerPolicyName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="clusterInstanceId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="initTime" type="xs:long"/>
- <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="obsoleteExpiryTime" type="xs:long"/>
- <xs:element minOccurs="0" name="partition" nillable="true" type="ax23:Partition"/>
+ <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="payload" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="persistence" nillable="true" type="ax23:Persistence"/>
<xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"/>
- <xs:element minOccurs="0" name="volumeRequired" type="xs:boolean"/>
+ <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Persistence">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="persistenceRequired" type="xs:boolean"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax23:Volume"/>
</xs:sequence>
</xs:complexType>
@@ -905,6 +910,20 @@
<xs:element minOccurs="0" name="volumeId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
+ <xs:complexType name="InstanceContext">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="clusterInstanceId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="initTime" type="xs:long"/>
+ <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="obsoleteExpiryTime" type="xs:long"/>
+ <xs:element minOccurs="0" name="partition" nillable="true" type="ax23:Partition"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"/>
+ <xs:element minOccurs="0" name="volumeRequired" type="xs:boolean"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax23:Volume"/>
+ </xs:sequence>
+ </xs:complexType>
<xs:complexType name="MemberContext">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="allocatedIPs" nillable="true" type="xs:string"/>
@@ -973,12 +992,6 @@
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="Persistence">
- <xs:sequence>
- <xs:element minOccurs="0" name="persistenceRequired" type="xs:boolean"/>
- <xs:element maxOccurs="unbounded" minOccurs="0" name="volumes" nillable="true" type="ax23:Volume"/>
- </xs:sequence>
- </xs:complexType>
<xs:complexType name="PortMapping">
<xs:sequence>
<xs:element minOccurs="0" name="kubernetesServicePort" type="xs:int"/>
@@ -1031,19 +1044,6 @@
<xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="Registrant">
- <xs:sequence>
- <xs:element minOccurs="0" name="autoScalerPolicyName" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="payload" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="persistence" nillable="true" type="ax23:Persistence"/>
- <xs:element minOccurs="0" name="properties" nillable="true" type="ax25:Properties"/>
- <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
<xs:complexType name="CartridgeConfig">
<xs:sequence>
<xs:element minOccurs="0" name="baseDir" nillable="true" type="xs:string"/>
[2/3] stratos git commit: Implementing stratos component startup
synchronizer
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/CommonServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/CommonServiceComponent.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/CommonServiceComponent.java
new file mode 100644
index 0000000..ffef662
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/CommonServiceComponent.java
@@ -0,0 +1,179 @@
+/*
+ * 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.common.internal;
+
+import com.hazelcast.core.HazelcastInstance;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.clustering.impl.HazelcastDistributedObjectProvider;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
+import org.apache.stratos.common.util.CommonUtil;
+import org.apache.stratos.common.util.StratosConfiguration;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.caching.impl.DistributedMapProvider;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+/**
+ * @scr.component name="apache.stratos.common" immediate="true"
+ * @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
+ * cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
+ * @scr.reference name="distributedMapProvider" interface="org.wso2.carbon.caching.impl.DistributedMapProvider"
+ * cardinality="0..1" policy="dynamic" bind="setDistributedMapProvider" unbind="unsetDistributedMapProvider"
+ * @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="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService"
+ * unbind="unsetRealmService"
+ * @scr.reference name="configuration.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
+ * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
+ *
+ */
+public class CommonServiceComponent {
+
+ private static Log log = LogFactory.getLog(CommonServiceComponent.class);
+
+ protected void activate(ComponentContext context) {
+ try {
+ final BundleContext bundleContext = context.getBundleContext();
+ if (CommonUtil.getStratosConfig() == null) {
+ StratosConfiguration stratosConfig = CommonUtil.loadStratosConfiguration();
+ CommonUtil.setStratosConfig(stratosConfig);
+ }
+
+ // Loading the EULA
+ if (CommonUtil.getEula() == null) {
+ String eula = CommonUtil.loadTermsOfUsage();
+ CommonUtil.setEula(eula);
+ }
+
+ AxisConfiguration axisConfig = ServiceReferenceHolder.getInstance().getAxisConfiguration();
+ if((axisConfig != null) && (axisConfig.getClusteringAgent() != null)) {
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ // Wait for the hazelcast instance to be available
+ long startTime = System.currentTimeMillis();
+ log.info("Waiting for the hazelcast instance to be initialized...");
+ while (ServiceReferenceHolder.getInstance().getHazelcastInstance() == null) {
+ Thread.sleep(1000);
+ if ((System.currentTimeMillis() - startTime) >= StratosConstants.HAZELCAST_INSTANCE_INIT_TIMEOUT) {
+ throw new RuntimeException("Hazelcast instance was not initialized within "
+ + StratosConstants.HAZELCAST_INSTANCE_INIT_TIMEOUT / 1000 + " seconds");
+ }
+ }
+ registerDistributedObjectProviderService(bundleContext);
+ registerComponentStartUpSynchronizer(bundleContext);
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ };
+ thread.setName("Distributed object provider registration thread");
+ thread.start();
+ } else {
+ // Register distributed object provider service
+ registerDistributedObjectProviderService(bundleContext);
+ registerComponentStartUpSynchronizer(bundleContext);
+ }
+
+ // Register manager configuration service
+ try {
+ StratosConfiguration stratosConfiguration = CommonUtil.loadStratosConfiguration();
+ bundleContext.registerService(StratosConfiguration.class.getName(), stratosConfiguration, null);
+ } catch (Exception ex) {
+ String msg = "An error occurred while registering stratos configuration service";
+ log.error(msg, ex);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Stratos common service component is activated");
+ }
+ } catch (Exception e) {
+ log.error("Error in activating stratos common service component", e);
+ }
+ }
+
+ private void registerDistributedObjectProviderService(BundleContext bundleContext) {
+ DistributedObjectProvider distributedObjectProvider = new HazelcastDistributedObjectProvider();
+ ServiceReferenceHolder.getInstance().setDistributedObjectProvider(distributedObjectProvider);
+ bundleContext.registerService(DistributedObjectProvider.class, distributedObjectProvider, null);
+ }
+
+ private void registerComponentStartUpSynchronizer(BundleContext bundleContext) {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ new ComponentStartUpSynchronizerImpl(
+ ServiceReferenceHolder.getInstance().getDistributedObjectProvider());
+ bundleContext.registerService(ComponentStartUpSynchronizer.class, componentStartUpSynchronizer, null);
+ }
+
+ protected void deactivate(ComponentContext context) {
+ log.debug("Stratos common service is deactivated");
+ }
+
+ protected void setRegistryService(RegistryService registryService) {
+ ServiceReferenceHolder.getInstance().setRegistryService(registryService);
+ }
+
+ protected void unsetRegistryService(RegistryService registryService) {
+ setRegistryService(null);
+ }
+
+ protected void setRealmService(RealmService realmService) {
+ ServiceReferenceHolder.getInstance().setRealmService(realmService);
+ }
+
+ protected void unsetRealmService(RealmService realmService) {
+ ServiceReferenceHolder.getInstance().setRealmService(null);
+ }
+
+ public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
+ ServiceReferenceHolder.getInstance().setHazelcastInstance(hazelcastInstance);
+ }
+
+ public void unsetHazelcastInstance(HazelcastInstance hazelcastInstance) {
+ ServiceReferenceHolder.getInstance().setHazelcastInstance(null);
+ }
+
+ protected void setDistributedMapProvider(DistributedMapProvider mapProvider) {
+ ServiceReferenceHolder.getInstance().setDistributedMapProvider(mapProvider);
+ }
+
+ protected void unsetDistributedMapProvider(DistributedMapProvider mapProvider) {
+ ServiceReferenceHolder.getInstance().setDistributedMapProvider(null);
+ }
+
+ protected void setConfigurationContextService(ConfigurationContextService cfgCtxService) {
+ ServiceReferenceHolder.getInstance().setAxisConfiguration(cfgCtxService.getServerConfigContext().getAxisConfiguration());
+ }
+
+ protected void unsetConfigurationContextService(ConfigurationContextService cfgCtxService) {
+ ServiceReferenceHolder.getInstance().setAxisConfiguration(null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ComponentStartUpSynchronizerImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ComponentStartUpSynchronizerImpl.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ComponentStartUpSynchronizerImpl.java
new file mode 100644
index 0000000..e0fff77
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ComponentStartUpSynchronizerImpl.java
@@ -0,0 +1,124 @@
+/*
+ * 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.common.internal;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
+import org.wso2.carbon.core.CarbonConfigurationContextFactory;
+
+import java.util.Map;
+
+/**
+ * Stratos component startup synchronizer.
+ */
+public class ComponentStartUpSynchronizerImpl implements ComponentStartUpSynchronizer {
+
+ private static final Log log = LogFactory.getLog(ComponentStartUpSynchronizerImpl.class);
+
+ private static final String COMPONENT_STATUS_MAP = "stratos.component.status.map";
+ private static final String COMPONENT_ACTIVATION_CHECK_INTERVAL = "stratos.component.activation.check.interval";
+ private static final String COMPONENT_ACTIVATION_TIMEOUT = "stratos.component.activation.timeout";
+ private static final long DEFAULT_COMPONENT_ACTIVATION_CHECK_INTERVAL = 5000;
+ private static final long DEFAULT_COMPONENT_ACTIVATION_TIMEOUT = 600000;
+
+ private Map<Component, Boolean> componentStatusMap;
+ private long componentActivationCheckInterval;
+ private long componentActivationTimeout;
+
+ ComponentStartUpSynchronizerImpl(DistributedObjectProvider distributedObjectProvider) {
+ componentStatusMap = distributedObjectProvider.getMap(COMPONENT_STATUS_MAP);
+
+ componentActivationCheckInterval = Long.getLong(COMPONENT_ACTIVATION_CHECK_INTERVAL,
+ DEFAULT_COMPONENT_ACTIVATION_CHECK_INTERVAL);
+ log.info(String.format("Component activation check interval: %s seconds",
+ (componentActivationCheckInterval/1000)));
+
+ componentActivationTimeout = Long.getLong(COMPONENT_ACTIVATION_TIMEOUT,
+ DEFAULT_COMPONENT_ACTIVATION_TIMEOUT);
+ log.info(String.format("Component activation timeout: %s seconds", (componentActivationTimeout/1000)));
+ }
+
+ @Override
+ public void setComponentStatus(Component component, boolean active) {
+ componentStatusMap.put(component, active);
+
+ if(active) {
+ log.info(String.format("%s component became active", component));
+ } else {
+ log.info(String.format("%s component became inactive", component));
+ }
+ }
+
+ @Override
+ public boolean isComponentActive(Component component) {
+ if(componentStatusMap.containsKey(component)) {
+ return componentStatusMap.get(component);
+ }
+ return false;
+ }
+
+ @Override
+ public void waitForComponentActivation(Component owner, Component component) {
+ long startTime = System.currentTimeMillis();
+ while(!isComponentActive(component)) {
+ log.info(String.format("%s component is waiting for %s component to become active...",
+ owner, component));
+
+ try {
+ Thread.sleep(componentActivationCheckInterval);
+ } catch (InterruptedException ignore) {
+ throw new RuntimeException(String.format("Thread interrupted, %s component could not wait for " +
+ "component %s to become active", owner, component));
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if((currentTime - startTime) > componentActivationTimeout) {
+ throw new RuntimeException(String.format("%s component did not become active within %d seconds ",
+ component, (componentActivationTimeout/1000)));
+ }
+ }
+ }
+
+ @Override
+ public void waitForWebServiceActivation(String serviceName) throws AxisFault {
+ AxisConfiguration axisConfiguration = CarbonConfigurationContextFactory.getConfigurationContext()
+ .getAxisConfiguration();
+ AxisService cloudControllerService = axisConfiguration.getService(serviceName);
+ if(!cloudControllerService.isActive()) {
+ while (!cloudControllerService.isActive()) {
+ log.info(String.format("Waiting for %s web service to become active...", serviceName));
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignore) {
+ return;
+ }
+ }
+ log.info(String.format("%s web service became active", serviceName));
+ } else {
+ log.debug(String.format("%s web service is active", serviceName));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ServiceReferenceHolder.java
index ed51902..1e21975 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/ServiceReferenceHolder.java
@@ -4,6 +4,7 @@ import com.hazelcast.core.HazelcastInstance;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.caching.impl.DistributedMapProvider;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
@@ -14,12 +15,14 @@ import org.wso2.carbon.user.core.service.RealmService;
public class ServiceReferenceHolder {
private static final Log log = LogFactory.getLog(ServiceReferenceHolder.class);
+
private static volatile ServiceReferenceHolder instance;
private HazelcastInstance hazelcastInstance;
private DistributedMapProvider distributedMapProvider;
private RealmService realmService;
private RegistryService registryService;
private AxisConfiguration axisConfiguration;
+ private DistributedObjectProvider distributedObjectProvider;
private ServiceReferenceHolder() {
}
@@ -75,4 +78,12 @@ public class ServiceReferenceHolder {
public AxisConfiguration getAxisConfiguration() {
return axisConfiguration;
}
+
+ public void setDistributedObjectProvider(DistributedObjectProvider distributedObjectProvider) {
+ this.distributedObjectProvider = distributedObjectProvider;
+ }
+
+ public DistributedObjectProvider getDistributedObjectProvider() {
+ return distributedObjectProvider;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/StratosCommonServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/StratosCommonServiceComponent.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/StratosCommonServiceComponent.java
deleted file mode 100644
index 275128b..0000000
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/internal/StratosCommonServiceComponent.java
+++ /dev/null
@@ -1,167 +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.common.internal;
-
-import com.hazelcast.core.HazelcastInstance;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
-import org.apache.stratos.common.clustering.impl.HazelcastDistributedObjectProvider;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.common.util.CommonUtil;
-import org.apache.stratos.common.util.StratosConfiguration;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.caching.impl.DistributedMapProvider;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-/**
- * @scr.component name="apache.stratos.common" immediate="true"
- * @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
- * cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
- * @scr.reference name="distributedMapProvider" interface="org.wso2.carbon.caching.impl.DistributedMapProvider"
- * cardinality="0..1" policy="dynamic" bind="setDistributedMapProvider" unbind="unsetDistributedMapProvider"
- * @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="user.realmservice.default"
- * interface="org.wso2.carbon.user.core.service.RealmService"
- * cardinality="1..1" policy="dynamic" bind="setRealmService"
- * unbind="unsetRealmService"
- * @scr.reference name="configuration.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
- * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- *
- */
-public class StratosCommonServiceComponent {
-
- private static Log log = LogFactory.getLog(StratosCommonServiceComponent.class);
-
- protected void activate(ComponentContext context) {
- try {
- final BundleContext bundleContext = context.getBundleContext();
- if (CommonUtil.getStratosConfig() == null) {
- StratosConfiguration stratosConfig = CommonUtil.loadStratosConfiguration();
- CommonUtil.setStratosConfig(stratosConfig);
- }
-
- // Loading the EULA
- if (CommonUtil.getEula() == null) {
- String eula = CommonUtil.loadTermsOfUsage();
- CommonUtil.setEula(eula);
- }
-
- AxisConfiguration axisConfig = ServiceReferenceHolder.getInstance().getAxisConfiguration();
- if((axisConfig != null) && (axisConfig.getClusteringAgent() != null)) {
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- // Wait for the hazelcast instance to be available
- long startTime = System.currentTimeMillis();
- log.info("Waiting for the hazelcast instance to be initialized...");
- while (ServiceReferenceHolder.getInstance().getHazelcastInstance() == null) {
- Thread.sleep(1000);
- if ((System.currentTimeMillis() - startTime) >= StratosConstants.HAZELCAST_INSTANCE_INIT_TIMEOUT) {
- throw new RuntimeException("Hazelcast instance was not initialized within "
- + StratosConstants.HAZELCAST_INSTANCE_INIT_TIMEOUT / 1000 + " seconds");
- }
- }
- registerDistributedObjectProviderService(bundleContext);
- } catch (Exception e) {
- log.error(e);
- }
- }
- };
- thread.setName("Distributed object provider registration thread");
- thread.start();
- } else {
- // Register distributed object provider service
- registerDistributedObjectProviderService(bundleContext);
- }
-
- // Register manager configuration service
- try {
- StratosConfiguration stratosConfiguration = CommonUtil.loadStratosConfiguration();
- bundleContext.registerService(StratosConfiguration.class.getName(), stratosConfiguration, null);
- } catch (Exception ex) {
- String msg = "An error occurred while registering stratos configuration service";
- log.error(msg, ex);
- }
-
- if (log.isInfoEnabled()) {
- log.info("Stratos common service component is activated");
- }
- } catch (Exception e) {
- log.error("Error in activating stratos common service component", e);
- }
- }
-
- private void registerDistributedObjectProviderService(BundleContext bundleContext) {
- DistributedObjectProvider distributedObjectProvider = new HazelcastDistributedObjectProvider();
- bundleContext.registerService(DistributedObjectProvider.class, distributedObjectProvider, null);
- }
-
- protected void deactivate(ComponentContext context) {
- log.debug("Stratos common service is deactivated");
- }
-
- protected void setRegistryService(RegistryService registryService) {
- ServiceReferenceHolder.getInstance().setRegistryService(registryService);
- }
-
- protected void unsetRegistryService(RegistryService registryService) {
- setRegistryService(null);
- }
-
- protected void setRealmService(RealmService realmService) {
- ServiceReferenceHolder.getInstance().setRealmService(realmService);
- }
-
- protected void unsetRealmService(RealmService realmService) {
- ServiceReferenceHolder.getInstance().setRealmService(null);
- }
-
- public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
- ServiceReferenceHolder.getInstance().setHazelcastInstance(hazelcastInstance);
- }
-
- public void unsetHazelcastInstance(HazelcastInstance hazelcastInstance) {
- ServiceReferenceHolder.getInstance().setHazelcastInstance(null);
- }
-
- protected void setDistributedMapProvider(DistributedMapProvider mapProvider) {
- ServiceReferenceHolder.getInstance().setDistributedMapProvider(mapProvider);
- }
-
- protected void unsetDistributedMapProvider(DistributedMapProvider mapProvider) {
- ServiceReferenceHolder.getInstance().setDistributedMapProvider(null);
- }
-
- protected void setConfigurationContextService(ConfigurationContextService cfgCtxService) {
- ServiceReferenceHolder.getInstance().setAxisConfiguration(cfgCtxService.getServerConfigContext().getAxisConfiguration());
- }
-
- protected void unsetConfigurationContextService(ConfigurationContextService cfgCtxService) {
- ServiceReferenceHolder.getInstance().setAxisConfiguration(null);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/ComponentStartUpSynchronizer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/ComponentStartUpSynchronizer.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/ComponentStartUpSynchronizer.java
new file mode 100644
index 0000000..e584237
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/ComponentStartUpSynchronizer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.common.services;
+
+import org.apache.axis2.AxisFault;
+import org.apache.stratos.common.Component;
+
+/**
+ * Component startup synchronizer service interface.
+ */
+public interface ComponentStartUpSynchronizer {
+
+ void setComponentStatus(Component component, boolean active);
+
+ boolean isComponentActive(Component component);
+
+ void waitForComponentActivation(Component owner, Component component);
+
+ void waitForWebServiceActivation(String serviceName) throws AxisFault;
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/DistributedObjectProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/DistributedObjectProvider.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/DistributedObjectProvider.java
new file mode 100644
index 0000000..2c013bd
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/DistributedObjectProvider.java
@@ -0,0 +1,73 @@
+/*
+ * 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.common.services;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Distributed object provider service interface.
+ * Caution! When using distributed maps and lists, please note that changes done to an item in a map/list
+ * after adding them to the map/list will not be replicated in the cluster. If a modification of an item
+ * needs to be replicated, that item needs to be put() to the map or set() back in the list.
+ */
+public interface DistributedObjectProvider extends Serializable {
+ /**
+ * Returns a distributed map if clustering is enabled, else returns a local hash map.
+ * @param name
+ * @return
+ */
+ Map getMap(String name);
+
+ /**
+ * Removes a map from the object provider.
+ * @param name
+ */
+ void removeMap(String name);
+
+ /**
+ * Returns a distributed list if clustering is enabled, else returns a local array list.
+ * @param name
+ * @return
+ */
+ List getList(String name);
+
+ /**
+ * Remove a list from the object provider.
+ * @param name
+ */
+ void removeList(String name);
+
+ /**
+ * Acquires a distributed lock if clustering is enabled, else acquires a local reentrant lock and
+ * returns the lock object.
+ * @param object
+ * @return
+ */
+ Lock acquireLock(Object object);
+
+ /**
+ * Releases a given distributed/local lock.
+ * @param lock
+ */
+ void releaseLock(Lock lock);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/PackageInfoService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/PackageInfoService.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/PackageInfoService.java
deleted file mode 100644
index 82c0e86..0000000
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/services/PackageInfoService.java
+++ /dev/null
@@ -1,35 +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.common.services;
-
-import org.apache.stratos.common.internal.StratosCommonServiceComponent;
-import org.apache.stratos.common.packages.PackageInfo;
-
-import java.util.List;
-
-
-public class PackageInfoService {
-
-// public PackageInfo[] getPackageInfos() throws Exception {
-// List<PackageInfo> list = StratosCommonServiceComponent.getPackageInfos().
-// getMultitenancyPackages();
-// PackageInfo[] packageInfos = list.toArray(new PackageInfo[list.size()]);
-// return packageInfos;
-// }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommonUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommonUtil.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommonUtil.java
index 436eb2a..b49c42d 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommonUtil.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommonUtil.java
@@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.common.constants.StratosConstants;
import org.apache.stratos.common.internal.ServiceReferenceHolder;
-import org.apache.stratos.common.internal.StratosCommonServiceComponent;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.registry.core.ActionConstants;
import org.wso2.carbon.registry.core.RegistryConstants;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
index 365cfc4..d261791 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
@@ -19,7 +19,7 @@
package org.apache.stratos.load.balancer.context;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.load.balancer.internal.ServiceReferenceHolder;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
index 2532d96..ca055de 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
@@ -24,7 +24,7 @@ import org.apache.axis2.deployment.DeploymentEngine;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerCommonApplicationSignUpEventReceiver;
import org.apache.stratos.load.balancer.common.statistics.notifier.LoadBalancerStatisticsNotifier;
@@ -67,7 +67,7 @@ import java.util.concurrent.ExecutorService;
/**
* @scr.component name="org.apache.stratos.load.balancer.internal.LoadBalancerServiceComponent" immediate="true"
- * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
* @scr.reference name="configuration.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/ServiceReferenceHolder.java
index e026ac5..cae9bec 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/ServiceReferenceHolder.java
@@ -23,7 +23,7 @@ import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.load.balancer.exception.TenantAwareLoadBalanceEndpointException;
import org.apache.synapse.config.SynapseConfiguration;
import org.wso2.carbon.mediation.dependency.mgt.services.DependencyManagementService;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/context/StratosManagerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/context/StratosManagerContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/context/StratosManagerContext.java
index 8841b46..44d44d9 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/context/StratosManagerContext.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/context/StratosManagerContext.java
@@ -20,9 +20,7 @@
package org.apache.stratos.manager.context;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
@@ -31,7 +29,7 @@ import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.registry.RegistryManager;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.manager.internal.ServiceReferenceHolder;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
index 4c3d9a5..221891d 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
@@ -22,7 +22,8 @@ package org.apache.stratos.manager.internal;
import com.hazelcast.core.HazelcastInstance;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
@@ -42,6 +43,7 @@ public class ServiceReferenceHolder {
private HazelcastInstance hazelcastInstance;
private AxisConfiguration axisConfiguration;
private DistributedObjectProvider distributedObjectProvider;
+ private ComponentStartUpSynchronizer componentStartUpSynchronizer;
private ServiceReferenceHolder() { }
@@ -121,5 +123,12 @@ public class ServiceReferenceHolder {
public DistributedObjectProvider getDistributedObjectProvider() {
return distributedObjectProvider;
}
-
+
+ public void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ this.componentStartUpSynchronizer = componentStartUpSynchronizer;
+ }
+
+ public ComponentStartUpSynchronizer getComponentStartUpSynchronizer() {
+ return componentStartUpSynchronizer;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
index 2830bf1..cd3215c 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
@@ -18,11 +18,12 @@
*/
package org.apache.stratos.manager.internal;
-import java.util.concurrent.ExecutorService;
-
+import com.hazelcast.core.HazelcastInstance;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.apache.stratos.manager.context.StratosManagerContext;
import org.apache.stratos.manager.messaging.publisher.TenantEventPublisher;
@@ -48,7 +49,7 @@ import org.wso2.carbon.user.core.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.ConfigurationContextService;
-import com.hazelcast.core.HazelcastInstance;
+import java.util.concurrent.ExecutorService;
/**
* @scr.component name="org.wso2.carbon.hosting.mgt.internal.StratosManagerServiceComponent"
@@ -71,8 +72,10 @@ import com.hazelcast.core.HazelcastInstance;
* @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="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * @scr.reference name="componentStartUpSynchronizer" interface="org.apache.stratos.common.services.ComponentStartUpSynchronizer"
+ * cardinality="1..1" policy="dynamic" bind="setComponentStartUpSynchronizer" unbind="unsetComponentStartUpSynchronizer"
*/
public class StratosManagerServiceComponent {
@@ -88,46 +91,67 @@ public class StratosManagerServiceComponent {
protected void activate(final ComponentContext componentContext) throws Exception {
try {
- CartridgeConfigFileReader.readProperties();
- executorService = StratosThreadPool.getExecutorService(THREAD_EXECUTOR_ID, THREAD_POOL_SIZE);
-
- if(StratosManagerContext.getInstance().isClustered()) {
- Thread coordinatorElectorThread = new Thread() {
- @Override
- public void run() {
- try {
- ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getLock(STRATOS_MANAGER_COORDINATOR_LOCK).lock();
-
- String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getCluster().getLocalMember().getUuid();
- log.info("Elected this member [" + localMemberId + "] " +
- "as the stratos manager coordinator for the cluster");
-
- StratosManagerContext.getInstance().setCoordinator(true);
+ executorService = StratosThreadPool.getExecutorService(THREAD_EXECUTOR_ID, THREAD_POOL_SIZE);
+ Runnable stratosManagerActivator = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+
+ // Wait for cloud controller and autoscaler components to start
+ componentStartUpSynchronizer.waitForComponentActivation(Component.StratosManager,
+ Component.CloudController);
+ componentStartUpSynchronizer.waitForComponentActivation(Component.StratosManager,
+ Component.Autoscaler);
+
+ CartridgeConfigFileReader.readProperties();
+ if (StratosManagerContext.getInstance().isClustered()) {
+ Thread coordinatorElectorThread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getLock(STRATOS_MANAGER_COORDINATOR_LOCK).lock();
+
+ String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getCluster().getLocalMember().getUuid();
+ log.info("Elected this member [" + localMemberId + "] " +
+ "as the stratos manager coordinator for the cluster");
+
+ StratosManagerContext.getInstance().setCoordinator(true);
+ executeCoordinatorTasks(componentContext);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not execute coordinator tasks", e);
+ }
+ }
+ }
+ };
+ coordinatorElectorThread.setName("Stratos manager coordinator elector thread");
+ executorService.submit(coordinatorElectorThread);
+ } else {
executeCoordinatorTasks(componentContext);
- } catch (Exception e) {
- if(log.isErrorEnabled()) {
- log.error("Could not execute coordinator tasks", e);
- }
}
+
+ // Initialize topology event receiver
+ initializeTopologyEventReceiver();
+
+ // Initialize application event receiver
+ initializeApplicationEventReceiver();
+
+ componentStartUpSynchronizer.waitForWebServiceActivation("StratosManagerService");
+ componentStartUpSynchronizer.setComponentStatus(Component.StratosManager, true);
+ if (log.isInfoEnabled()) {
+ log.info("Stratos manager component is activated");
+ }
+ } catch (Exception e) {
+ log.error("Could not activate stratos manager service component", e);
}
- };
- coordinatorElectorThread.setName("Stratos manager coordinator elector thread");
- executorService.submit(coordinatorElectorThread);
- } else {
- executeCoordinatorTasks(componentContext);
- }
-
- // Initialize topology event receiver
- initializeTopologyEventReceiver();
-
- // Initialize application event receiver
- initializeApplicationEventReceiver();
-
- if(log.isInfoEnabled()) {
- log.info("Stratos manager component is activated");
- }
+ }
+ };
+ Thread stratosManagerActivatorThread = new Thread(stratosManagerActivator);
+ stratosManagerActivatorThread.start();
} catch (Exception e) {
log.error("Could not activate stratos manager service component", e);
}
@@ -290,6 +314,14 @@ public class StratosManagerServiceComponent {
ServiceReferenceHolder.getInstance().setDistributedObjectProvider(null);
}
+ protected void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(componentStartUpSynchronizer);
+ }
+
+ protected void unsetComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(null);
+ }
+
protected void deactivate(ComponentContext context) {
// Close event publisher connections to message broker
EventPublisherPool.close(MessagingUtil.Topics.INSTANCE_NOTIFIER_TOPIC.getTopicName());
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ComponentSynchronizerHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ComponentSynchronizerHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ComponentSynchronizerHandler.java
new file mode 100644
index 0000000..b7456e4
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ComponentSynchronizerHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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.rest.endpoint.handlers;
+
+import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.message.Message;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.beans.ApiResponseBean;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
+
+import javax.ws.rs.core.Response;
+
+/**
+ * Component synchronizer handler for enabling rest api once stratos manager component becomes active.
+ */
+public class ComponentSynchronizerHandler implements RequestHandler {
+
+ public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+ if(!componentStartUpSynchronizer.isComponentActive(Component.StratosManager)) {
+ ApiResponseBean responseBean = new ApiResponseBean();
+ responseBean.setMessage("Stratos manager component is not active");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).entity(responseBean).build();
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.rest.endpoint/src/main/webapp/api-test/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/api-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/api-test/WEB-INF/cxf-servlet.xml
index 8952d7e..fdecda7 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/api-test/WEB-INF/cxf-servlet.xml
+++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/api-test/WEB-INF/cxf-servlet.xml
@@ -53,6 +53,7 @@
<bean id="badRequestExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.BadRequestExceptionMapper"/>
<bean id="genericExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.GenericExceptionMapper"/>
<bean id="throwableExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomThrowableExceptionMapper"/>
+ <bean id="componentSynrhronizerHandler" class="org.apache.stratos.rest.endpoint.handlers.ComponentSynchronizerHandler"/>
<!--The below config enables OAuth based authentication/authorization for REST API-->
<bean id="OAuthFilter" class="org.apache.stratos.rest.endpoint.handlers.OAuthHandler">
<property name="password" value="admin"/>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.rest.endpoint/src/main/webapp/api/WEB-INF/cxf-servlet.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/api/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/api/WEB-INF/cxf-servlet.xml
index e326d79..3e6aa55 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/api/WEB-INF/cxf-servlet.xml
+++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/api/WEB-INF/cxf-servlet.xml
@@ -38,6 +38,7 @@
<ref bean="badRequestExceptionHandler"/>
<ref bean="jsonProvider"/>
<ref bean="exceptionHandler"/>
+ <ref bean="componentSynchronizerHandler"/>
<ref bean="basicAuthenticationFilter"/>
<ref bean="sessionAuthenticationFilter"/>
<ref bean="authorizationFilterV41"/>
@@ -55,6 +56,7 @@
<ref bean="badRequestExceptionHandler"/>
<ref bean="jsonProvider"/>
<ref bean="exceptionHandler"/>
+ <ref bean="componentSynchronizerHandler"/>
<ref bean="basicAuthenticationFilter"/>
<ref bean="sessionAuthenticationFilter"/>
<ref bean="authorizationFilterV40"/>
@@ -72,6 +74,7 @@
<ref bean="badRequestExceptionHandler"/>
<ref bean="jsonProvider"/>
<ref bean="exceptionHandler"/>
+ <ref bean="componentSynchronizerHandler"/>
<ref bean="basicAuthenticationFilter"/>
<ref bean="sessionAuthenticationFilter"/>
<ref bean="authorizationFilterV41"/>
@@ -92,6 +95,7 @@
<bean id="badRequestExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.BadRequestExceptionMapper"/>
<bean id="genericExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.GenericExceptionMapper"/>
<bean id="throwableExceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomThrowableExceptionMapper"/>
+ <bean id="componentSynchronizerHandler" class="org.apache.stratos.rest.endpoint.handlers.ComponentSynchronizerHandler"/>
<!--The below config enables OAuth based authentication/authorization for REST API-->
<bean id="OAuthFilter" class="org.apache.stratos.rest.endpoint.handlers.OAuthHandler">
<property name="password" value="admin"/>
[3/3] stratos git commit: Implementing stratos component startup
synchronizer
Posted by im...@apache.org.
Implementing stratos component startup synchronizer
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c6e8359d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c6e8359d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c6e8359d
Branch: refs/heads/master
Commit: c6e8359d5dd561ac3c5b268d19e6aa8d725a9681
Parents: 42f4390
Author: Imesh Gunaratne <im...@apache.org>
Authored: Sat Mar 21 16:50:51 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Mar 21 16:50:51 2015 +0530
----------------------------------------------------------------------
.../org.apache.stratos.autoscaler/pom.xml | 1 +
.../autoscaler/context/AutoscalerContext.java | 15 +-
.../internal/AutoscalerServiceComponent.java | 121 ++--
.../autoscaler/pojo/policy/PolicyManager.java | 2 +-
.../autoscaler/registry/RegistryManager.java | 599 ++++++++++---------
.../autoscaler/util/ServiceReferenceHolder.java | 24 +-
.../context/CloudControllerContext.java | 2 +-
.../CloudControllerServiceComponent.java | 94 ++-
.../internal/ServiceReferenceHolder.java | 12 +-
.../axiom/CloudControllerContextTest.java | 2 +-
components/org.apache.stratos.common/pom.xml | 2 +-
.../org/apache/stratos/common/Component.java | 27 +
.../clustering/DistributedObjectProvider.java | 73 ---
.../HazelcastDistributedObjectProvider.java | 6 +-
.../common/internal/CommonServiceComponent.java | 179 ++++++
.../ComponentStartUpSynchronizerImpl.java | 124 ++++
.../common/internal/ServiceReferenceHolder.java | 11 +
.../internal/StratosCommonServiceComponent.java | 167 ------
.../services/ComponentStartUpSynchronizer.java | 37 ++
.../services/DistributedObjectProvider.java | 73 +++
.../common/services/PackageInfoService.java | 35 --
.../apache/stratos/common/util/CommonUtil.java | 1 -
.../load/balancer/context/AlgorithmContext.java | 2 +-
.../internal/LoadBalancerServiceComponent.java | 4 +-
.../internal/ServiceReferenceHolder.java | 2 +-
.../manager/context/StratosManagerContext.java | 4 +-
.../internal/ServiceReferenceHolder.java | 13 +-
.../StratosManagerServiceComponent.java | 116 ++--
.../handlers/ComponentSynchronizerHandler.java | 47 ++
.../webapp/api-test/WEB-INF/cxf-servlet.xml | 1 +
.../src/main/webapp/api/WEB-INF/cxf-servlet.xml | 4 +
.../src/main/resources/AutoscalerService.wsdl | 262 ++++----
.../main/resources/CloudControllerService.wsdl | 180 +++---
33 files changed, 1310 insertions(+), 932 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml
index 355aec6..3f0527c 100644
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@ -224,6 +224,7 @@
</Export-Package>
<Import-Package>
org.osgi.framework.*;resolution:=optional,
+ org.apache.stratos.common.services.*; version="${project.version}",
*;resolution:=optional
</Import-Package>
<Bundle-Activator>org.apache.stratos.autoscaler.internal.ASBundleActivater</Bundle-Activator>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
index af75545..0760e5f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
@@ -27,13 +27,11 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
import org.apache.stratos.autoscaler.exception.AutoScalerException;
-import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
import org.apache.stratos.autoscaler.registry.RegistryManager;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import java.util.Collection;
import java.util.List;
@@ -54,7 +52,7 @@ public class AutoscalerContext {
private boolean clustered;
private boolean coordinator;
- private static final AutoscalerContext INSTANCE = new AutoscalerContext();
+ private static volatile AutoscalerContext instance;
private final transient DistributedObjectProvider distributedObjectProvider;
// Map<ApplicationId, ApplicationContext>
@@ -103,7 +101,14 @@ public class AutoscalerContext {
}
public static AutoscalerContext getInstance() {
- return INSTANCE;
+ if(instance == null) {
+ synchronized (AutoscalerContext.class) {
+ if(instance == null) {
+ instance = new AutoscalerContext();
+ }
+ }
+ }
+ return instance;
}
public void addClusterMonitor(ClusterMonitor clusterMonitor) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
index 3929853..9fd9b68 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
@@ -18,6 +18,7 @@
*/
package org.apache.stratos.autoscaler.internal;
+import com.hazelcast.core.HazelcastInstance;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,7 +38,9 @@ import org.apache.stratos.autoscaler.status.processor.group.GroupStatusProcessor
import org.apache.stratos.autoscaler.util.AutoscalerConstants;
import org.apache.stratos.autoscaler.util.ConfUtil;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.ntask.core.service.TaskService;
@@ -45,8 +48,6 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.utils.ConfigurationContextService;
-import com.hazelcast.core.HazelcastInstance;
-
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -59,8 +60,10 @@ import java.util.concurrent.ExecutorService;
* cardinality="1..1" policy="dynamic" bind="setTaskService" unbind="unsetTaskService"
* @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
* cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
- * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * @scr.reference name="componentStartUpSynchronizer" interface="org.apache.stratos.common.services.ComponentStartUpSynchronizer"
+ * cardinality="1..1" policy="dynamic" bind="setComponentStartUpSynchronizer" unbind="unsetComponentStartUpSynchronizer"
* @scr.reference name="config.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
*/
@@ -77,45 +80,63 @@ public class AutoscalerServiceComponent {
protected void activate(ComponentContext componentContext) throws Exception {
try {
-
- XMLConfiguration conf = ConfUtil.getInstance(AutoscalerConstants.COMPONENTS_CONFIG).getConfiguration();
+ XMLConfiguration conf = ConfUtil.getInstance(AutoscalerConstants.COMPONENTS_CONFIG).getConfiguration();
int threadPoolSize = conf.getInt(AutoscalerConstants.THREAD_POOL_SIZE_KEY,
AutoscalerConstants.AUTOSCALER_THREAD_POOL_SIZE);
- executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID,
+ executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID,
threadPoolSize);
- ServiceReferenceHolder.getInstance().setExecutorService(executorService);
-
- if(AutoscalerContext.getInstance().isClustered()) {
- Thread coordinatorElectorThread = new Thread() {
- @Override
- public void run() {
- ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getLock(AUTOSCALER_COORDINATOR_LOCK).lock();
-
- log.info("Elected this member [" + ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getCluster().getLocalMember().getUuid() + "] " +
- "as the autoscaler coordinator for the cluster");
-
- AutoscalerContext.getInstance().setCoordinator(true);
- try {
- executeCoordinatorTasks();
- } catch (Exception e) {
- log.error("Error in activating the autoscaler component ", e);
+ Runnable autoscalerActivator = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+ // Wait for cloud controller component to start
+ componentStartUpSynchronizer.waitForComponentActivation(Component.Autoscaler,
+ Component.CloudController);
+
+ ServiceReferenceHolder.getInstance().setExecutorService(executorService);
+
+ if (AutoscalerContext.getInstance().isClustered()) {
+ Thread coordinatorElectorThread = new Thread() {
+ @Override
+ public void run() {
+ ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getLock(AUTOSCALER_COORDINATOR_LOCK).lock();
+
+ log.info("Elected this member [" + ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getCluster().getLocalMember().getUuid() + "] " +
+ "as the autoscaler coordinator for the cluster");
+
+ AutoscalerContext.getInstance().setCoordinator(true);
+ try {
+ executeCoordinatorTasks();
+ } catch (Exception e) {
+ log.error("Error in activating the autoscaler component ", e);
+ }
+ }
+ };
+ coordinatorElectorThread.setName("Autoscaler coordinator elector thread");
+ executorService.submit(coordinatorElectorThread);
+ } else {
+ executeCoordinatorTasks();
}
- }
- };
- coordinatorElectorThread.setName("Autoscaler coordinator elector thread");
- executorService.submit(coordinatorElectorThread);
- } else {
- executeCoordinatorTasks();
- }
- if (log.isInfoEnabled()) {
- log.info("Autoscaler service component activated");
- }
+ componentStartUpSynchronizer.waitForWebServiceActivation("AutoscalerService");
+ componentStartUpSynchronizer.setComponentStatus(Component.Autoscaler, true);
+ if (log.isInfoEnabled()) {
+ log.info("Autoscaler service component activated");
+ }
+ } catch (Exception e) {
+ log.error("Error in activating autoscaler service component ", e);
+ }
+ }
+ };
+ Thread autoscalerActivatorThread = new Thread(autoscalerActivator);
+ autoscalerActivatorThread.start();
} catch (Exception e) {
- log.error("Error in activating the autoscaler service component ", e);
+ log.error("Error in activating autoscaler service component ", e);
}
}
@@ -179,16 +200,20 @@ public class AutoscalerServiceComponent {
}
protected void deactivate(ComponentContext context) {
- try {
- asTopologyReceiver.terminate();
- } catch (Exception e) {
- log.warn("An error occurred while terminating autoscaler topology event receiver", e);
+ if(asTopologyReceiver != null) {
+ try {
+ asTopologyReceiver.terminate();
+ } catch (Exception e) {
+ log.warn("An error occurred while terminating autoscaler topology event receiver", e);
+ }
}
- try {
- autoscalerHealthStatEventReceiver.terminate();
- } catch (Exception e) {
- log.warn("An error occurred while terminating autoscaler health statistics event receiver", e);
+ if(autoscalerHealthStatEventReceiver != null) {
+ try {
+ autoscalerHealthStatEventReceiver.terminate();
+ } catch (Exception e) {
+ log.warn("An error occurred while terminating autoscaler health statistics event receiver", e);
+ }
}
// Shutdown executor service
@@ -289,5 +314,13 @@ public class AutoscalerServiceComponent {
protected void unsetDistributedObjectProvider(DistributedObjectProvider distributedObjectProvider) {
ServiceReferenceHolder.getInstance().setDistributedObjectProvider(null);
}
+
+ protected void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(componentStartUpSynchronizer);
+ }
+
+ protected void unsetComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(null);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
index a5ca3b4..8406549 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
@@ -28,7 +28,7 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
import org.apache.stratos.autoscaler.registry.RegistryManager;
import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index b60fe2c..b1ae493 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -1,6 +1,4 @@
-package org.apache.stratos.autoscaler.registry;
/*
- *
* 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
@@ -17,9 +15,9 @@ package org.apache.stratos.autoscaler.registry;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
-*/
+ */
+package org.apache.stratos.autoscaler.registry;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -46,43 +44,92 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Autoscaler registry manager.
+ */
public class RegistryManager {
private final static Log log = LogFactory.getLog(RegistryManager.class);
+
private static Registry registryService;
- private static RegistryManager registryManager;
+ private static volatile RegistryManager instance;
private RegistryManager() {
try {
- if (!registryService.resourceExists(AutoscalerConstants.AUTOSCALER_RESOURCE)) {
- registryService.put(AutoscalerConstants.AUTOSCALER_RESOURCE,
- registryService.newCollection());
+ registryService = ServiceReferenceHolder.getInstance().getRegistry();
+ try {
+ startTenantFlow();
+ if (!registryService.resourceExists(AutoscalerConstants.AUTOSCALER_RESOURCE)) {
+ registryService.put(AutoscalerConstants.AUTOSCALER_RESOURCE, registryService.newCollection());
+ }
+ } finally {
+ endTenantFlow();
}
} catch (RegistryException e) {
- String msg =
- "Failed to create the registry resource " +
- AutoscalerConstants.AUTOSCALER_RESOURCE;
+ String msg = "Failed to create the registry resource " + AutoscalerConstants.AUTOSCALER_RESOURCE;
log.error(msg, e);
throw new AutoScalerException(msg, e);
}
}
public static RegistryManager getInstance() {
+ if (instance == null) {
+ synchronized (RegistryManager.class) {
+ if (instance == null) {
+ instance = new RegistryManager();
+ }
+ }
+ }
+ return instance;
+ }
- registryService = ServiceReferenceHolder.getInstance().getRegistry();
+ private Object retrieve(String resourcePath) {
+ try {
+ Resource resource = registryService.get(resourcePath);
+ return resource.getContent();
+ } catch (ResourceNotFoundException ignore) {
+ // this means, we've never persisted info in registry
+ return null;
+ } catch (RegistryException e) {
+ String msg = "Failed to retrieve data from registry.";
+ log.error(msg, e);
+ throw new AutoScalerException(msg, e);
+ }
+ }
- synchronized (RegistryManager.class) {
- if (registryManager == null) {
- if (registryService == null) {
- // log.warn("Registry Service is null. Hence unable to fetch data from registry.");
- return registryManager;
+ private void delete(String resourcePath) {
+ try {
+ registryService.beginTransaction();
+ registryService.delete(resourcePath);
+ registryService.commitTransaction();
+ } catch (RegistryException e) {
+ try {
+ registryService.rollbackTransaction();
+ } catch (RegistryException e1) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not rollback transaction", e);
}
- registryManager = new RegistryManager();
}
+ String message = "Could not delete resource at " + resourcePath;
+ log.error(message);
+ throw new AutoScalerException(message, e);
}
- return registryManager;
}
+ private void startTenantFlow() {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+ carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+ }
+
+ private void endTenantFlow() {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+
+ private boolean resourceExist(String resourcePath) {
+ return retrieve(resourcePath) != null;
+ }
/**
* Persist an object in the local registry.
@@ -91,10 +138,6 @@ public class RegistryManager {
* @param resourcePath resource path to be persisted.
*/
private void persist(Object dataObj, String resourcePath) throws AutoScalerException {
- PrivilegedCarbonContext ctx = PrivilegedCarbonContext
- .getThreadLocalCarbonContext();
- ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
- ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
try {
registryService.beginTransaction();
@@ -118,6 +161,7 @@ public class RegistryManager {
public void persistAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
try {
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
persist(autoscalePolicy, resourcePath);
@@ -128,17 +172,14 @@ public class RegistryManager {
} catch (Exception e) {
throw new AutoScalerException((String.format("Unable to persist autoscaler policy [autoscaler-policy-id] %s"
, autoscalePolicy.getId())), e);
+ } finally {
+ endTenantFlow();
}
}
public void persistApplication(Application application) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATIONS_RESOURCE +
"/" + application.getUniqueIdentifier();
persist(application, resourcePath);
@@ -147,17 +188,13 @@ public class RegistryManager {
" ] persisted successfully in the Autoscaler Registry");
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public String[] getApplicationResourcePaths() {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATIONS_RESOURCE);
@@ -165,14 +202,13 @@ public class RegistryManager {
if (obj instanceof String[]) {
return (String[]) obj;
} else {
- log.warn("Expected object type not found for Applications in Registry");
- return null;
+ log.warn("Expected object type not found for applications in registry");
}
}
+ return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
- return null;
}
public Application getApplication(String applicationId) {
@@ -182,75 +218,55 @@ public class RegistryManager {
}
public Application getApplicationByResourcePath(String applicationResourcePath) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(applicationResourcePath);
if (obj != null) {
try {
Object dataObj = Deserializer.deserializeFromByteArray((byte[]) obj);
if (dataObj instanceof Application) {
return (Application) dataObj;
- } else {
- return null;
}
} catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical data will not get reflected.";
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + applicationResourcePath;
log.warn(msg, e);
}
}
+ return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
- return null;
}
public void removeApplication(String applicationId) {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
delete(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATIONS_RESOURCE +
"/" + applicationId);
-
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void persistApplicationContext(ApplicationContext applicationContext) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationContext.getApplicationId();
persist(applicationContext, resourcePath);
if (log.isDebugEnabled()) {
log.debug("Application context [" + applicationContext.getApplicationId() + "] " +
- "persisted successfully in the Autoscaler Registry");
+ "persisted successfully in the autoscaler registry");
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public String[] getApplicationContextResourcePaths() {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE);
@@ -258,40 +274,30 @@ public class RegistryManager {
if (obj instanceof String[]) {
return (String[]) obj;
} else {
- log.warn("Expected object type not found for Applications in Registry");
+ log.warn("Expected object type not found for applications in registry");
return null;
}
}
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
return null;
}
public ApplicationContext getApplicationContext(String applicationId) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
String applicationResourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE + "/" + applicationId;
return getApplicationContextByResourcePath(applicationResourcePath);
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public ApplicationContext getApplicationContextByResourcePath(String resourcePath) {
-
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
Object obj = retrieve(resourcePath);
if (obj != null) {
try {
@@ -302,297 +308,310 @@ public class RegistryManager {
}
return null;
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void removeApplicationContext(String applicationId) {
try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
+ startTenantFlow();
delete(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_CONTEXTS_RESOURCE +
"/" + applicationId);
} finally {
- PrivilegedCarbonContext.endTenantFlow();
+ endTenantFlow();
}
}
public void persistServiceGroup(ServiceGroup servicegroup) {
- if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
- throw new IllegalArgumentException("Cartridge group or group name can not be null");
- }
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
- persist(servicegroup, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Persisted cartridge group %s at path %s", servicegroup.getName(), resourcePath));
+ try {
+ startTenantFlow();
+ if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) {
+ throw new IllegalArgumentException("Cartridge group or group name can not be null");
+ }
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
+ persist(servicegroup, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Persisted cartridge group %s at path %s", servicegroup.getName(), resourcePath));
+ }
+ } finally {
+ endTenantFlow();
}
}
public boolean serviceGroupExist(String serviceGroupName) {
String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + serviceGroupName;
- return this.resourceExist(resourcePath);
- }
-
- private Object retrieve(String resourcePath) {
- try {
- Resource resource = registryService.get(resourcePath);
- return resource.getContent();
- } catch (ResourceNotFoundException ignore) {
- // this means, we've never persisted info in registry
- return null;
- } catch (RegistryException e) {
- String msg = "Failed to retrieve data from registry.";
- log.error(msg, e);
- throw new AutoScalerException(msg, e);
- }
- }
-
- private boolean resourceExist(String resourcePath) {
- return this.retrieve(resourcePath) != null;
+ return resourceExist(resourcePath);
}
public List<AutoscalePolicy> retrieveASPolicies() {
- List<AutoscalePolicy> asPolicyList = new ArrayList<AutoscalePolicy>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
-
- if (partitionsResourceList != null) {
- AutoscalePolicy asPolicy;
- for (String resourcePath : partitionsResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof AutoscalePolicy) {
- asPolicy = (AutoscalePolicy) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Autoscaler policy read from registry: [id] %s [name] %s [description] %s",
- asPolicy.getId(), asPolicy.getDisplayName(), asPolicy.getDescription()));
+ try {
+ startTenantFlow();
+ List<AutoscalePolicy> asPolicyList = new ArrayList<AutoscalePolicy>();
+ String[] partitionsResourceList = (String[]) retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
+
+ if (partitionsResourceList != null) {
+ AutoscalePolicy asPolicy;
+ for (String resourcePath : partitionsResourceList) {
+ Object serializedObj = retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof AutoscalePolicy) {
+ asPolicy = (AutoscalePolicy) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Autoscaler policy read from registry: [id] %s [name] %s [description] %s",
+ asPolicy.getId(), asPolicy.getDisplayName(), asPolicy.getDescription()));
+ }
+ asPolicyList.add(asPolicy);
+ } else {
+ return null;
}
- asPolicyList.add(asPolicy);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical autoscaler policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return asPolicyList;
+ } finally {
+ endTenantFlow();
}
- return asPolicyList;
}
public List<ApplicationPolicy> retrieveApplicationPolicies() {
- List<ApplicationPolicy> applicationPolicyList = new ArrayList<ApplicationPolicy>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] applicationPoliciesResourceList = (String[]) registryManager.retrieve(
- AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE);
-
- if (applicationPoliciesResourceList != null) {
- ApplicationPolicy applicationPolicy;
- for (String resourcePath : applicationPoliciesResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ApplicationPolicy) {
- applicationPolicy = (ApplicationPolicy) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy read from registry %s", applicationPolicy.toString()));
+ try {
+ startTenantFlow();
+ List<ApplicationPolicy> applicationPolicyList = new ArrayList<ApplicationPolicy>();
+ String[] applicationPoliciesResourceList = (String[]) retrieve(
+ AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE);
+
+ if (applicationPoliciesResourceList != null) {
+ ApplicationPolicy applicationPolicy;
+ for (String resourcePath : applicationPoliciesResourceList) {
+ Object serializedObj = instance.retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ApplicationPolicy) {
+ applicationPolicy = (ApplicationPolicy) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy read from registry %s",
+ applicationPolicy.toString()));
+ }
+ applicationPolicyList.add(applicationPolicy);
+ } else {
+ return null;
}
- applicationPolicyList.add(applicationPolicy);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical application policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return applicationPolicyList;
+ } finally {
+ endTenantFlow();
}
- return applicationPolicyList;
}
public List<NetworkPartitionAlgorithmContext> retrieveNetworkPartitionAlgorithmContexts() {
- List<NetworkPartitionAlgorithmContext> algorithmContexts = new ArrayList<NetworkPartitionAlgorithmContext>();
- RegistryManager registryManager = RegistryManager.getInstance();
- String[] networkPartitionAlgoCtxtResourceList = (String[]) registryManager.retrieve(
- AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE);
-
- if (networkPartitionAlgoCtxtResourceList != null) {
- NetworkPartitionAlgorithmContext algorithmContext;
- for (String resourcePath : networkPartitionAlgoCtxtResourceList) {
- Object serializedObj = registryManager.retrieve(resourcePath);
- if (serializedObj != null) {
- try {
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof NetworkPartitionAlgorithmContext) {
- algorithmContext = (NetworkPartitionAlgorithmContext) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context read from registry %s", algorithmContext.toString()));
+ try {
+ startTenantFlow();
+ List<NetworkPartitionAlgorithmContext> algorithmContexts = new ArrayList<NetworkPartitionAlgorithmContext>();
+ String[] networkPartitionAlgoCtxtResourceList = (String[]) retrieve(
+ AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE);
+
+ if (networkPartitionAlgoCtxtResourceList != null) {
+ NetworkPartitionAlgorithmContext algorithmContext;
+ for (String resourcePath : networkPartitionAlgoCtxtResourceList) {
+ Object serializedObj = retrieve(resourcePath);
+ if (serializedObj != null) {
+ try {
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof NetworkPartitionAlgorithmContext) {
+ algorithmContext = (NetworkPartitionAlgorithmContext) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context read from registry %s", algorithmContext.toString()));
+ }
+ algorithmContexts.add(algorithmContext);
+ } else {
+ return null;
}
- algorithmContexts.add(algorithmContext);
- } else {
- return null;
+ } catch (Exception e) {
+ String msg = "Unable to retrieve resource from registry: [resource-path] "
+ + resourcePath;
+ log.warn(msg, e);
}
- } catch (Exception e) {
- String msg = "Unable to retrieve data from Registry. Hence, any historical application policies will not get reflected.";
- log.warn(msg, e);
}
}
}
+ return algorithmContexts;
+ } finally {
+ endTenantFlow();
}
- return algorithmContexts;
}
public ServiceGroup getServiceGroup(String name) throws Exception {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + name;
- Object serializedObj = registryManager.retrieve(resourcePath);
- ServiceGroup group = null;
- if (serializedObj != null) {
-
- Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ServiceGroup) {
- group = (ServiceGroup) dataObj;
- if (log.isDebugEnabled()) {
- log.debug(group.toString());
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + name;
+ Object serializedObj = instance.retrieve(resourcePath);
+ ServiceGroup group = null;
+ if (serializedObj != null) {
+
+ Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ServiceGroup) {
+ group = (ServiceGroup) dataObj;
+ if (log.isDebugEnabled()) {
+ log.debug(group.toString());
+ }
+ } else {
+ return null;
}
- } else {
- return null;
}
+ return group;
+ } finally {
+ endTenantFlow();
}
-
- return group;
}
public ServiceGroup[] getServiceGroups() {
- Object serializedObj;
- List<ServiceGroup> serviceGroupList = new ArrayList<ServiceGroup>();
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP;
- if (registryManager.resourceExist(resourcePath)) {
- serializedObj = registryManager.retrieve(resourcePath);
- } else {
- return null;
- }
+ try {
+ startTenantFlow();
+ Object serializedObj;
+ List<ServiceGroup> serviceGroupList = new ArrayList<ServiceGroup>();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP;
+ if (instance.resourceExist(resourcePath)) {
+ serializedObj = instance.retrieve(resourcePath);
+ } else {
+ return null;
+ }
- String[] groupPathList = (String[]) serializedObj;
-
- if (groupPathList != null) {
- ServiceGroup serviceGroup;
- for (String groupPath : groupPathList) {
- serializedObj = registryManager.retrieve(groupPath);
- if (serializedObj != null) {
- Object dataObj = null;
- try {
- dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
- if (dataObj instanceof ServiceGroup) {
- serviceGroup = (ServiceGroup) dataObj;
- serviceGroupList.add(serviceGroup);
+ String[] groupPathList = (String[]) serializedObj;
+
+ if (groupPathList != null) {
+ ServiceGroup serviceGroup;
+ for (String groupPath : groupPathList) {
+ serializedObj = instance.retrieve(groupPath);
+ if (serializedObj != null) {
+ Object dataObj = null;
+ try {
+ dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+ if (dataObj instanceof ServiceGroup) {
+ serviceGroup = (ServiceGroup) dataObj;
+ serviceGroupList.add(serviceGroup);
+ }
+ } catch (IOException e) {
+ throw new AutoScalerException("Error occurred while retrieving cartridge group from registry");
+ } catch (ClassNotFoundException e) {
+ throw new AutoScalerException("Error occurred while retrieving cartridge group from registry");
}
- } catch (IOException e) {
- throw new AutoScalerException("Error occurred while retrieving cartridge group from Registry");
- } catch (ClassNotFoundException e) {
- throw new AutoScalerException("Error occurred while retrieving cartridge group from Registry");
}
-
}
}
- }
- ServiceGroup[] groupArr = new ServiceGroup[serviceGroupList.size()];
- groupArr = serviceGroupList.toArray(groupArr);
- return groupArr;
+ ServiceGroup[] serviceGroups = new ServiceGroup[serviceGroupList.size()];
+ serviceGroups = serviceGroupList.toArray(serviceGroups);
+ return serviceGroups;
+ } finally {
+ endTenantFlow();
+ }
}
public void removeServiceGroup(String name) throws RegistryException {
- if (StringUtils.isEmpty(name)) {
- throw new IllegalArgumentException("Name of the cartridge group can not be empty");
- }
+ try {
+ startTenantFlow();
+ if (StringUtils.isEmpty(name)) {
+ throw new IllegalArgumentException("Name of the cartridge group can not be empty");
+ }
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.SERVICE_GROUP + "/" + name;
- if (registryService.resourceExists(resourcePath)) {
- registryService.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cartridge group %s is removed from registry", name));
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.SERVICE_GROUP + "/" + name;
+ if (registryService.resourceExists(resourcePath)) {
+ registryService.delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Cartridge group %s is removed from registry", name));
+ }
+ } else {
+ throw new AutoScalerException("No cartridge group is found with name" + name);
}
- } else {
- throw new AutoScalerException("No cartridge group is found with name" + name);
+ } finally {
+ endTenantFlow();
}
}
public void removeAutoscalerPolicy(String policyID) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE + "/" +
- policyID;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Autoscaler policy deleted from registry: [id]",policyID));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE + "/" +
+ policyID;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Autoscaler policy deleted from registry: [id]", policyID));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void removeApplicationPolicy(String applicationPolicyId) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" +
- applicationPolicyId;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy deleted from registry [application-policy-id] %s", applicationPolicyId));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" +
+ applicationPolicyId;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy deleted from registry [application-policy-id] %s", applicationPolicyId));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void removeNetworkPartitionAlgorithmContext(String applicationPolicyId) {
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" +
- applicationPolicyId;
- this.delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context deleted from registry [application-policy-id] %s", applicationPolicyId));
- }
-
- }
-
- private void delete(String resourcePath) {
try {
- registryService.beginTransaction();
- registryService.delete(resourcePath);
- registryService.commitTransaction();
- } catch (RegistryException e) {
- try {
- registryService.rollbackTransaction();
- } catch (RegistryException e1) {
- if (log.isErrorEnabled()) {
- log.error("Could not rollback transaction", e);
- }
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" +
+ applicationPolicyId;
+ delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context deleted from registry [application-policy-id] %s", applicationPolicyId));
}
- log.error("Could not delete resource at " + resourcePath);
- throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
+ } finally {
+ endTenantFlow();
}
-
}
public void persistApplicationPolicy(ApplicationPolicy applicationPolicy) {
-
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getId();
- persist(applicationPolicy, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Application policy written to registry : %s", applicationPolicy.getId()));
+ try {
+ startTenantFlow();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getId();
+ persist(applicationPolicy, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Application policy written to registry : %s", applicationPolicy.getId()));
+ }
+ } finally {
+ endTenantFlow();
}
-
}
public void persistNetworkPartitionAlgorithmContext(NetworkPartitionAlgorithmContext algorithmContext) {
- String applicationId = algorithmContext.getApplicationId();
- String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
- AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" + applicationId;
- persist(algorithmContext, resourcePath);
- if (log.isDebugEnabled()) {
- log.debug(String.format("Network partition algorithm context written to registry : %s", applicationId));
+ try {
+ startTenantFlow();
+ String applicationId = algorithmContext.getApplicationId();
+ String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE +
+ AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" + applicationId;
+ persist(algorithmContext, resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Network partition algorithm context written to registry : %s", applicationId));
+ }
+ } finally {
+ endTenantFlow();
}
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
index 9d1fa9c..d351fef 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
@@ -24,7 +24,8 @@ package org.apache.stratos.autoscaler.util;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusProcessorChain;
import org.apache.stratos.autoscaler.status.processor.group.GroupStatusProcessorChain;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.session.UserRegistry;
@@ -44,15 +45,20 @@ public class ServiceReferenceHolder {
private DistributedObjectProvider distributedObjectProvider;
private HazelcastInstance hazelcastInstance;
private ExecutorService executorService;
+ private ComponentStartUpSynchronizer componentStartUpSynchronizer;
private ServiceReferenceHolder() {
}
public static ServiceReferenceHolder getInstance() {
- if (instance == null) {
- instance = new ServiceReferenceHolder();
- }
- return instance;
+ if(instance == null) {
+ synchronized (ServiceReferenceHolder.class) {
+ if (instance == null) {
+ instance = new ServiceReferenceHolder();
+ }
+ }
+ }
+ return instance;
}
public void setAxisConfiguration(AxisConfiguration axisConfiguration) {
@@ -118,4 +124,12 @@ public class ServiceReferenceHolder {
public ExecutorService getExecutorService() {
return executorService;
}
+
+ public void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ this.componentStartUpSynchronizer = componentStartUpSynchronizer;
+ }
+
+ public ComponentStartUpSynchronizer getComponentStartUpSynchronizer() {
+ return componentStartUpSynchronizer;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index 8543810..c503c02 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -37,7 +37,7 @@ import org.apache.stratos.cloud.controller.exception.NonExistingKubernetesHostEx
import org.apache.stratos.cloud.controller.internal.ServiceReferenceHolder;
import org.apache.stratos.cloud.controller.registry.RegistryManager;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/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
index 75a88ff..87928cd 100644
--- 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
@@ -1,4 +1,3 @@
-package org.apache.stratos.cloud.controller.internal;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,6 +19,8 @@ package org.apache.stratos.cloud.controller.internal;
*
*/
+package org.apache.stratos.cloud.controller.internal;
+
import com.hazelcast.core.HazelcastInstance;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -32,7 +33,9 @@ import org.apache.stratos.cloud.controller.messaging.receiver.cluster.status.Clu
import org.apache.stratos.cloud.controller.messaging.receiver.instance.status.InstanceStatusTopicReceiver;
import org.apache.stratos.cloud.controller.services.CloudControllerService;
import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceImpl;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.Component;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.util.MessagingUtil;
@@ -52,8 +55,10 @@ import java.util.concurrent.ExecutorService;
* @scr.component name="org.apache.stratos.cloud.controller" immediate="true"
* @scr.reference name="hazelcast.instance.service" interface="com.hazelcast.core.HazelcastInstance"
* cardinality="0..1"policy="dynamic" bind="setHazelcastInstance" unbind="unsetHazelcastInstance"
- * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.clustering.DistributedObjectProvider"
+ * @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
* cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * @scr.reference name="componentStartUpSynchronizer" interface="org.apache.stratos.common.services.ComponentStartUpSynchronizer"
+ * cardinality="1..1" policy="dynamic" bind="setComponentStartUpSynchronizer" unbind="unsetComponentStartUpSynchronizer"
* @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"
@@ -74,38 +79,53 @@ public class CloudControllerServiceComponent {
private static final int THREAD_POOL_SIZE = 10;
private static final String CLOUD_CONTROLLER_COORDINATOR_LOCK = "CLOUD_CONTROLLER_COORDINATOR_LOCK";
- protected void activate(ComponentContext context) {
+ protected void activate(final ComponentContext context) {
try {
- executorService = StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER, THREAD_POOL_SIZE);
-
- // Register cloud controller service
- BundleContext bundleContext = context.getBundleContext();
- bundleContext.registerService(CloudControllerService.class.getName(),
- new CloudControllerServiceImpl(), null);
-
- if(CloudControllerContext.getInstance().isClustered()) {
- Thread coordinatorElectorThread = new Thread() {
- @Override
- public void run() {
- ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
-
- String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
- .getCluster().getLocalMember().getUuid();
- log.info("Elected this member [" + localMemberId + "] " +
- "as the cloud controller coordinator for the cluster");
-
- CloudControllerContext.getInstance().setCoordinator(true);
- executeCoordinatorTasks();
+ executorService = StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER, THREAD_POOL_SIZE);
+ Runnable cloudControllerActivator = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ComponentStartUpSynchronizer componentStartUpSynchronizer =
+ ServiceReferenceHolder.getInstance().getComponentStartUpSynchronizer();
+
+ // Register cloud controller service
+ BundleContext bundleContext = context.getBundleContext();
+ bundleContext.registerService(CloudControllerService.class.getName(),
+ new CloudControllerServiceImpl(), null);
+
+ if(CloudControllerContext.getInstance().isClustered()) {
+ Thread coordinatorElectorThread = new Thread() {
+ @Override
+ public void run() {
+ ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
+
+ String localMemberId = ServiceReferenceHolder.getInstance().getHazelcastInstance()
+ .getCluster().getLocalMember().getUuid();
+ log.info("Elected member [" + localMemberId + "] " +
+ "as the cloud controller coordinator of the cluster");
+
+ CloudControllerContext.getInstance().setCoordinator(true);
+ executeCoordinatorTasks();
+ }
+ };
+ coordinatorElectorThread.setName("Cloud controller coordinator elector thread");
+ executorService.submit(coordinatorElectorThread);
+ } else {
+ executeCoordinatorTasks();
+ }
+
+ componentStartUpSynchronizer.waitForWebServiceActivation("CloudControllerService");
+ componentStartUpSynchronizer.setComponentStatus(Component.CloudController, true);
+ log.info("Cloud controller service component activated");
+ } catch (Exception e) {
+ log.error("Could not activate cloud controller service component", e);
}
- };
- coordinatorElectorThread.setName("Cloud controller coordinator elector thread");
- executorService.submit(coordinatorElectorThread);
- } else {
- executeCoordinatorTasks();
- }
-
- log.info("Cloud controller service component activated");
+ }
+ };
+ Thread cloudControllerActivatorThread = new Thread(cloudControllerActivator);
+ cloudControllerActivatorThread.start();
} catch (Exception e) {
log.error("Could not activate cloud controller service component", e);
}
@@ -206,6 +226,14 @@ public class CloudControllerServiceComponent {
ServiceReferenceHolder.getInstance().setDistributedObjectProvider(null);
}
+ protected void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(componentStartUpSynchronizer);
+ }
+
+ protected void unsetComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ ServiceReferenceHolder.getInstance().setComponentStartUpSynchronizer(null);
+ }
+
protected void deactivate(ComponentContext ctx) {
// Close event publisher connections to message broker
try {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
index ef4015a..f26bd79 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/ServiceReferenceHolder.java
@@ -20,7 +20,8 @@ package org.apache.stratos.cloud.controller.internal;
import com.hazelcast.core.HazelcastInstance;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.ComponentStartUpSynchronizer;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.session.UserRegistry;
@@ -37,6 +38,7 @@ public class ServiceReferenceHolder {
private AxisConfiguration axisConfiguration;
private DistributedObjectProvider distributedObjectProvider;
private HazelcastInstance hazelcastInstance;
+ private ComponentStartUpSynchronizer componentStartUpSynchronizer;
private ServiceReferenceHolder() {
}
@@ -91,4 +93,12 @@ public class ServiceReferenceHolder {
public HazelcastInstance getHazelcastInstance() {
return hazelcastInstance;
}
+
+ public void setComponentStartUpSynchronizer(ComponentStartUpSynchronizer componentStartUpSynchronizer) {
+ this.componentStartUpSynchronizer = componentStartUpSynchronizer;
+ }
+
+ public ComponentStartUpSynchronizer getComponentStartUpSynchronizer() {
+ return componentStartUpSynchronizer;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
index b48055f..91be61b 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
@@ -18,10 +18,10 @@
*/
package org.apache.cartridge.autoscaler.service.axiom;
+import junit.framework.TestCase;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.stratos.cloud.controller.context.CloudControllerContext;
import org.apache.stratos.cloud.controller.domain.MemberContext;
-import junit.framework.TestCase;
import org.apache.stratos.cloud.controller.internal.ServiceReferenceHolder;
import org.apache.stratos.common.clustering.impl.HazelcastDistributedObjectProvider;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/pom.xml b/components/org.apache.stratos.common/pom.xml
index 5a01de6..74fc755 100644
--- a/components/org.apache.stratos.common/pom.xml
+++ b/components/org.apache.stratos.common/pom.xml
@@ -47,7 +47,7 @@
<Export-Package>
org.apache.stratos.common.*,
org.apache.stratos.common.client.*,
- org.apache.stratos.common.clustering.*,
+ org.apache.stratos.common.services.*,
org.apache.stratos.common.statistics.publisher.*,
org.apache.stratos.common.concurrent.locks.*,
</Export-Package>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
new file mode 100644
index 0000000..28f5341
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Component.java
@@ -0,0 +1,27 @@
+/*
+ * 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.common;
+
+/**
+ * Stratos components enumeration.
+ */
+public enum Component {
+ MessageBroker, StratosManager, CloudController, Autoscaler, ComplexEventProcessor
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
deleted file mode 100644
index 6caa3a1..0000000
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/DistributedObjectProvider.java
+++ /dev/null
@@ -1,73 +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.common.clustering;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-
-/**
- * Distributed object provider service interface.
- * Caution! When using distributed maps and lists, please note that changes done to an item in a map/list
- * after adding them to the map/list will not be replicated in the cluster. If a modification of an item
- * needs to be replicated, that item needs to be put() to the map or set() back in the list.
- */
-public interface DistributedObjectProvider extends Serializable {
- /**
- * Returns a distributed map if clustering is enabled, else returns a local hash map.
- * @param name
- * @return
- */
- Map getMap(String name);
-
- /**
- * Removes a map from the object provider.
- * @param name
- */
- void removeMap(String name);
-
- /**
- * Returns a distributed list if clustering is enabled, else returns a local array list.
- * @param name
- * @return
- */
- List getList(String name);
-
- /**
- * Remove a list from the object provider.
- * @param name
- */
- void removeList(String name);
-
- /**
- * Acquires a distributed lock if clustering is enabled, else acquires a local reentrant lock and
- * returns the lock object.
- * @param object
- * @return
- */
- Lock acquireLock(Object object);
-
- /**
- * Releases a given distributed/local lock.
- * @param lock
- */
- void releaseLock(Lock lock);
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6e8359d/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
index f7ff50e..14c1d08 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/clustering/impl/HazelcastDistributedObjectProvider.java
@@ -26,7 +26,7 @@ import com.hazelcast.core.IMap;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.common.services.DistributedObjectProvider;
import org.apache.stratos.common.internal.ServiceReferenceHolder;
import org.wso2.carbon.caching.impl.MapEntryListener;
import org.wso2.carbon.core.clustering.hazelcast.HazelcastDistributedMapProvider;
@@ -39,9 +39,11 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
- * Provides objects to be managed in distributed and non-distributed environments.
+ * Implements DistributedObjectProvider osgi service interface for providing objects to be managed
+ * in distributed and non-distributed environments.
*/
public class HazelcastDistributedObjectProvider implements DistributedObjectProvider {
+
private static final Log log = LogFactory.getLog(HazelcastDistributedObjectProvider.class);
private HazelcastDistributedMapProvider mapProvider;