stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [47/50] [abbrv] Merge branch '4.0.0-grouping' into docker-grouping-merge
Date Thu, 30 Oct 2014 04:14:11 GMT
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 80fc464,b7b5695..53b8e52
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@@ -23,25 -23,27 +23,35 @@@ import org.apache.axis2.context.Configu
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 +import org.apache.stratos.autoscaler.stub.*;
 +import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
 +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
+ import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
+ import org.apache.stratos.cloud.controller.stub.*;
  import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig;
  import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
  import org.apache.stratos.cloud.controller.stub.pojo.Property;
+ import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext;
  import org.apache.stratos.manager.client.AutoscalerServiceClient;
  import org.apache.stratos.manager.client.CloudControllerServiceClient;
 +import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager;
+ import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
  import org.apache.stratos.manager.deploy.service.Service;
  import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
  import org.apache.stratos.manager.dto.Cartridge;
  import org.apache.stratos.manager.dto.SubscriptionInfo;
 +import org.apache.stratos.manager.exception.ADCException;
 +import org.apache.stratos.manager.exception.DomainMappingExistsException;
 +import org.apache.stratos.manager.exception.NotSubscribedException;
 +import org.apache.stratos.manager.exception.ServiceDoesNotExistException;
+ import org.apache.stratos.manager.exception.*;
+ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+ import org.apache.stratos.manager.grouping.manager.ServiceGroupingManager;
  import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
  import org.apache.stratos.manager.repository.RepositoryNotification;
+ import org.apache.stratos.manager.subscription.ApplicationSubscription;
  import org.apache.stratos.manager.subscription.CartridgeSubscription;
  import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
  import org.apache.stratos.manager.subscription.SubscriptionData;
@@@ -88,21 -87,103 +99,82 @@@ public class ServiceUtils 
      private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
  
      static void deployCartridge(CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext
ctxt,
 -                                                String userName, String tenantDomain) throws
RestAPIException {
 +                                String userName, String tenantDomain) throws RestAPIException
{
  
 -        log.info("Starting to deploy a Cartridge [type] " + cartridgeDefinitionBean.type);
 -
 -        CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
 -
 -        if (cloudControllerServiceClient != null) {
 -
 -            CartridgeConfig cartridgeConfig = PojoConverter.populateCartridgeConfigPojo(cartridgeDefinitionBean);
 -
 -            if (cartridgeConfig == null) {
 -                throw new RestAPIException("Populated CartridgeConfig instance is null,
cartridge deployment aborted");
 -            }
 -
 -
 -            // call CC
 -            try {
 -                cloudControllerServiceClient
 -                        .deployCartridgeDefinition(cartridgeConfig);
 -            } catch (RemoteException e) {
 -                log.error(e.getMessage(), e);
 -                throw new RestAPIException(e.getMessage(), e);
 -            } catch (CloudControllerServiceInvalidCartridgeDefinitionExceptionException
e) {
 -                String message = e.getFaultMessage().getInvalidCartridgeDefinitionException().getMessage();
 -                log.error(message, e);
 -                throw new RestAPIException(message, e);
 -            } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
 -                String message = e.getFaultMessage().getInvalidIaasProviderException().getMessage();
 -                log.error(message, e);
 -                throw new RestAPIException(message, e);
 -            }
 -
 -            log.info("Successfully deployed Cartridge [type] " + cartridgeDefinitionBean.type);
 -
 -        }
 +		log.info("Starting to deploy a Cartridge [type] "+ cartridgeDefinitionBean.type);
 +		
 +		CartridgeConfig cartridgeConfig = PojoConverter.populateCartridgeConfigPojo(cartridgeDefinitionBean);
 +		if (cartridgeConfig == null) {
 +			throw new RestAPIException("Populated CartridgeConfig instance is null, cartridge deployment
aborted");
 +		}
 +		try {
 +			CartridgeDeploymentManager.getDeploymentManager(cartridgeDefinitionBean.deployerType).deploy(cartridgeConfig);
 +		} catch (ADCException e) {	
 +			throw new RestAPIException(e.getMessage());
 +		}
 +		log.info("Successfully deployed Cartridge [type] "+ cartridgeDefinitionBean.type);
      }
+     
+ 
+     static void deployApplicationDefinition (ApplicationDefinition appDefinition, ConfigurationContext
ctxt,
+                                                                      String userName, String
tenantDomain)
+             throws RestAPIException {
+ 
+     	// check if an application with same id already exists
+         // check if application with same appId / tenant already exists
+         CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
+         int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
+         String appId = appDefinition.getApplicationId();
+ 
+         try {
+             if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) {
+                 String msg = "Duplicate application appId: " + appId + " for tenant " +
tenantId;
+                 throw new RestAPIException(msg);
+             }
+         } catch (ApplicationSubscriptionException e1) {
+             throw new RestAPIException(e1);
+         }
+     	
+         ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition);
+         applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
+         applicationContext.setTenantDomain(tenantDomain);
+         applicationContext.setTeantAdminUsername(userName);
+ 
+         try {
+             CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
+ 
+         } catch (RemoteException e) {
+             throw new RestAPIException(e);
+         } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
+             throw new RestAPIException(e);
+         } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+             throw new RestAPIException(e);
+         }
+     }
+ 
+     static ApplicationSubscription getApplicationSubscriptions(String appId, ConfigurationContext
ctxt) throws RestAPIException {
+         CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
+         try {
+             return subscriptionMgr.getApplicationSubscription(appId, ApplicationManagementUtil.getTenantId(ctxt));
+         } catch (ApplicationSubscriptionException e) {
+             throw new RestAPIException(e);
+         }
+     }
+     
+     static void unDeployApplication(String appId, ConfigurationContext ctxt,
+             String userName, String tenantDomain) throws RestAPIException {
+ 
+         try {
+         	int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
+             CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId,
tenantId, tenantDomain);
+ 
+         } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+             throw new RestAPIException(e);
+         } catch (RemoteException e) {
+             throw new RestAPIException(e);
+         }
+ 
+     }
  
      @SuppressWarnings("unused")
      private static DeploymentPolicy[] intersection(
@@@ -1307,245 -1399,110 +1439,351 @@@
  
      }
  
+     static void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition)
throws RestAPIException {
+ 
+         try {
+             serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition);
+ 
+         } catch (InvalidServiceGroupException e) {
+             throw new RestAPIException(e);
+         } catch (ServiceGroupDefinitioException e) {
+             throw new RestAPIException(e);
+         } catch (ADCException e) {
+             throw new RestAPIException(e);
+         } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+             throw new RestAPIException(e);
+         }
+ 
+         log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName());
+     }
+ 
+     static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName)
throws RestAPIException {
+ 
+         try {
+             return serviceGropingManager.getServiceGroupDefinition(serviceGroupDefinitionName);
+ 
+         } catch (ServiceGroupDefinitioException e) {
+             throw new RestAPIException(e);
+         } catch (ADCException e) {
+ 			throw new RestAPIException(e);
+ 		} 
+     }
+ 
+     static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws
RestAPIException {
+ 
+         try {
+             serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName);
+ 
+         } catch (ServiceGroupDefinitioException e) {
+             throw new RestAPIException(e);
+         } catch (ADCException e) {
+         	throw new RestAPIException(e);
+ 		}
+ 
+         log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName);
+     }
+ 
+     public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext
configContext) {
+         ApplicationBean applicationBean = null;
+         try{
+             TopologyManager.acquireReadLockForApplication(applicationId);
+             Application application = TopologyManager.getTopology().getApplication(applicationId);
+             if(application == null){
+                 return null;
+             }
+             applicationBean = PojoConverter.applicationToBean(application);
+ 
+             Map<String, ClusterDataHolder> topLevelClusterDataMap  = application.getClusterDataMap();
+             for(Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()){
+                 ClusterDataHolder clusterDataHolder = entry.getValue();
+                 String clusterId = clusterDataHolder.getClusterId();
+                 String serviceType = clusterDataHolder.getServiceType();
+                 TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
+                 Cluster topLevelCluster;
+ 
+                 try {
+                     TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
+                     topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
+                 }finally {
+                     TopologyManager.releaseReadLockForCluster(serviceType, clusterId);
+                 }
+                 applicationBean.clusters.add(PojoConverter.populateClusterPojos(topLevelCluster));
+             }
+ 
+             Collection<Group> groups = application.getGroups();
+             for(Group group :  groups){
+                 GroupBean groupBean = PojoConverter.toGroupBean(group);
+                 setSubGroups(group, groupBean);
+                 applicationBean.addGroup(groupBean);
+             }
+         }finally {
+             TopologyManager.releaseReadLockForApplication(applicationId);
+         }
+ 
+ 
+         return applicationBean;
+     }
+ 
+     private static void setSubGroups(Group group, GroupBean groupBean) {
+         Collection<Group> subgroups = group.getGroups();
+         addClustersToGroupBean(group, groupBean);
+         for(Group subGroup : subgroups){
+             GroupBean subGroupBean = PojoConverter.toGroupBean(subGroup);
+ 
+             setSubGroups(subGroup, subGroupBean);
+             groupBean.addGroup(subGroupBean);
+         }
+     }
+ 
+     private static void addClustersToGroupBean(Group group, GroupBean groupBean) {
+         Map<String, ClusterDataHolder> clustersDatamap = group.getClusterDataMap();
+         for(Map.Entry<String, ClusterDataHolder> x : clustersDatamap.entrySet()){
+             String alias = x.getKey();
+             ClusterDataHolder clusterHolder = x.getValue();
+             Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterHolder.getServiceType()).getCluster(clusterHolder.getClusterId());
+             groupBean.addCluster(PojoConverter.populateClusterPojos(topLevelCluster));
+         }
+     }
+ 
 +
 +
 +    public static boolean deployKubernetesGroup(KubernetesGroup kubernetesGroupBean) throws
RestAPIException {
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup
=
 +                    PojoConverter.convertToASKubernetesGroupPojo(kubernetesGroupBean);
 +
 +            try {
 +                return autoscalerServiceClient.deployKubernetesGroup(kubernetesGroup);
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceInvalidKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getInvalidKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static boolean deployKubernetesHost(String kubernetesGroupId, KubernetesHost
kubernetesHostBean)
 +            throws RestAPIException {
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost
=
 +                    PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
 +
 +            try {
 +                return autoscalerServiceClient.deployKubernetesHost(kubernetesGroupId, kubernetesHost);
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceInvalidKubernetesHostExceptionException e) {
 +                String message = e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static boolean updateKubernetesMaster(KubernetesMaster kubernetesMasterBean)
throws RestAPIException {
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster kubernetesMaster
=
 +                    PojoConverter.convertToASKubernetesMasterPojo(kubernetesMasterBean);
 +
 +            try {
 +                return autoscalerServiceClient.updateKubernetesMaster(kubernetesMaster);
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceInvalidKubernetesMasterExceptionException e) {
 +                String message = e.getFaultMessage().getInvalidKubernetesMasterException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            } catch (AutoScalerServiceNonExistingKubernetesMasterExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesMasterException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static KubernetesGroup[] getAvailableKubernetesGroups() throws RestAPIException
{
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup[]
 +                        kubernetesGroups = autoscalerServiceClient.getAvailableKubernetesGroups();
 +                return PojoConverter.populateKubernetesGroupsPojo(kubernetesGroups);
 +
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            }
 +        }
 +        return null;
 +    }
 +
 +    public static KubernetesGroup getKubernetesGroup(String kubernetesGroupId) throws RestAPIException
{
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup
 +                        kubernetesGroup = autoscalerServiceClient.getKubernetesGroup(kubernetesGroupId);
 +                return PojoConverter.populateKubernetesGroupPojo(kubernetesGroup);
 +
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return null;
 +    }
 +
 +    public static boolean undeployKubernetesGroup(String kubernetesGroupId) throws RestAPIException
{
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                return autoscalerServiceClient.undeployKubernetesGroup(kubernetesGroupId);
 +
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static boolean undeployKubernetesHost(String kubernetesHostId) throws RestAPIException
{
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                return autoscalerServiceClient.undeployKubernetesHost(kubernetesHostId);
 +
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static KubernetesHost[] getKubernetesHosts(String kubernetesGroupId) throws RestAPIException
{
 +
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[]
 +                        kubernetesHosts = autoscalerServiceClient.getKubernetesHosts(kubernetesGroupId);
 +
 +                List<KubernetesHost> arrayList = PojoConverter.populateKubernetesHostsPojo(kubernetesHosts);
 +                KubernetesHost[] array = new KubernetesHost[arrayList.size()];
 +                array = arrayList.toArray(array);
 +                return array;
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return null;
 +    }
 +
 +    public static KubernetesMaster getKubernetesMaster(String kubernetesGroupId) throws
RestAPIException {
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster
 +                        kubernetesMaster = autoscalerServiceClient.getKubernetesMaster(kubernetesGroupId);
 +                return PojoConverter.populateKubernetesMasterPojo(kubernetesMaster);
 +
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return null;
 +    }
 +
 +    public static boolean updateKubernetesHost(KubernetesHost kubernetesHostBean) throws
RestAPIException {
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost
=
 +                    PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
 +            try {
 +                return autoscalerServiceClient.updateKubernetesHost(kubernetesHost);
 +            } catch (RemoteException e) {
 +                log.error(e.getMessage(), e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            } catch (AutoScalerServiceInvalidKubernetesHostExceptionException e) {
 +                String message = e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            } catch (AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
 +                String message = e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            }
 +        }
 +        return false;
 +    }
 +
 +    public static void updateSubscriptionProperties(ConfigurationContext context, String
alias, List<PropertyBean> property) throws RestAPIException {
 +        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
 +        if (autoscalerServiceClient != null) {
 +            try {
 +                Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(context)
 +                        , alias);
 +                if (cluster == null) {
 +                    throw new RestAPIException("No matching cluster found for [alias] "
+ alias);
 +                } 
 +                if (property != null) {
 +                    autoscalerServiceClient.updateClusterMonitor(cluster.getClusterId(),
PojoConverter.getProperties(property));
 +                }
 +            } catch(AutoScalerServiceInvalidArgumentExceptionException e) {
 +                String message = e.getFaultMessage().getInvalidArgumentException().getMessage();
 +                log.error(message, e);
 +                throw new RestAPIException(message, e);
 +            } catch (RemoteException e) {
 +                String msg = "Error while connecting to Autoscaler Service. "+e.getMessage();
 +                log.error(msg, e);
 +                throw new RestAPIException(e.getMessage(), e);
 +            }
 +        }
 +        
 +    }
  }

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 226a4ab,44d42a5..f889e02
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@@ -29,10 -30,9 +30,12 @@@ import org.apache.stratos.manager.dto.C
  import org.apache.stratos.manager.dto.SubscriptionInfo;
  import org.apache.stratos.manager.exception.DomainMappingExistsException;
  import org.apache.stratos.manager.exception.ServiceDoesNotExistException;
+ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+ import org.apache.stratos.manager.subscription.ApplicationSubscription;
  import org.apache.stratos.manager.subscription.CartridgeSubscription;
 +import org.apache.stratos.manager.user.mgt.StratosUserManager;
 +import org.apache.stratos.manager.user.mgt.beans.UserInfoBean;
 +import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
  import org.apache.stratos.rest.endpoint.ServiceHolder;
  import org.apache.stratos.rest.endpoint.Utils;
  import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
@@@ -45,10 -46,7 +49,11 @@@ import org.apache.stratos.rest.endpoint
  import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy;
  import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
  import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean;
 +import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesGroup;
 +import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesHost;
 +import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesMaster;
  import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload;
++import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository;
  import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean;
  import org.apache.stratos.rest.endpoint.bean.topology.Cluster;
  import org.apache.stratos.rest.endpoint.exception.RestAPIException;
@@@ -400,10 -515,10 +543,12 @@@ public class StratosAdmin extends Abstr
      @Path("/cartridge/lb")
      @Produces("application/json")
      @Consumes("application/json")
 -    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
 +    @AuthorizationAction("/permission/admin/manage/view/cartridge")
      public Response getAvailableLbCartridges() throws RestAPIException {
 +        List<Cartridge> lbCartridges = ServiceUtils.getAvailableLbCartridges(false,
getConfigContext());
 +        return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new
Cartridge[lbCartridges.size()])).build();
+     	List<Cartridge> lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext());
+         return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new
Cartridge[lbCartridges.size()])).build();
      }
  
      @GET

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/features/manager/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/distribution/src/assembly/bin.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/distribution/src/main/conf/mincheck.drl
----------------------------------------------------------------------
diff --cc products/stratos/modules/distribution/src/main/conf/mincheck.drl
index 0000000,105523d..ceeab48
mode 000000,100755..100755
--- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl
+++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl
@@@ -1,0 -1,88 +1,84 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  * 
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied.  See the License for the 
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package org.apache.stratos.autoscaler.rule;
+ 
+ import org.apache.stratos.messaging.domain.topology.Service;
+ import org.apache.stratos.messaging.domain.topology.Cluster;
+ import org.apache.stratos.autoscaler.AutoscalerContext;
+ import org.apache.stratos.autoscaler.Constants;
+ import org.apache.stratos.autoscaler.policy.PolicyManager;
+ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.policy.model.RequestsInFlight;
+ import org.apache.stratos.autoscaler.policy.model.LoadThresholds;
+ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+ import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
+ import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
+ import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+ import org.apache.stratos.autoscaler.PartitionContext;
+ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
+ import org.apache.commons.logging.Log;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.partition.PartitionGroup;
+ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
+ 
+ global org.apache.stratos.autoscaler.rule.RuleLog log;
+ global org.apache.stratos.autoscaler.policy.PolicyManager $manager;
+ global org.apache.stratos.autoscaler.AutoscalerContext $context;
+ global org.apache.stratos.autoscaler.rule.RuleTasksDelegator $delegator;
+ global org.apache.stratos.messaging.domain.topology.Topology $topology;
+ global java.util.Map partitionCtxts;
+ global java.lang.String clusterId;
+ global java.lang.String lbRef;
+ global java.lang.Boolean isPrimary;
+ global Integer primaryMemberCount;
 -global java.lang.String serviceId;
 -
 -global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy;
 -
+ 
+ rule "Minimum Rule"
+ dialect "mvel"
+        when
+            $ctxt : PartitionContext ()
+            eval(log.debug("Running minimum rule: [network-partition] " + $ctxt.getNetworkPartitionId()
+ " [partition] " + $ctxt.getPartitionId()))
+ 	       eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId()
+ " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount()))
+ 	       eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId()
+ " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount()))
+ 	       eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount()
)) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount()
)) )
+        then
+            if (isPrimary){
+               log.debug("[min-check] true  [primary] true   [primary member count] " + primaryMemberCount);
+            } else{
+               log.debug("[min-check] true  [primary] false");
+            }
+ 	       $delegator.delegateSpawn($ctxt, clusterId, lbRef, isPrimary);
+ end
+ 
+ rule "Terminate Obsoleted Instances"
+ dialect "mvel"
+         when
+             $ctxt : PartitionContext ()
+             eval(log.debug("Running obsolete instances rule: [partition] " + $ctxt.getPartitionId()
+ " [network-partition] " + $ctxt.getNetworkPartitionId()))
+             eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId()
+ " [partition] " + $ctxt.getPartitionId() +" Obsolete member count: " + $ctxt.getObsoletedMembers().size()))
+             eval($ctxt.getObsoletedMembers().size() > 0)
+             memberId : String() from $ctxt.getObsoletedMembers()
+             eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId()
+ " [partition] " + $ctxt.getPartitionId() + " Member id: " + memberId))
+             eval($ctxt.removeObsoleteMember(memberId))
+         then
+            $delegator.terminateObsoleteInstance(memberId);
+ end
+ 

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/p2-profile-gen/pom.xml
----------------------------------------------------------------------
diff --cc products/stratos/modules/p2-profile-gen/pom.xml
index 54c20e6,91e9ed2..14c6eca
--- a/products/stratos/modules/p2-profile-gen/pom.xml
+++ b/products/stratos/modules/p2-profile-gen/pom.xml
@@@ -280,7 -205,9 +280,8 @@@
                                  <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.caching.feature:${carbon.version}</featureArtifactDef>
                                  <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.rm.server.feature:${carbon.version}</featureArtifactDef>
                                  <featureArtifactDef>org.apache.stratos:org.apache.stratos.manager.feature:${project.version}</featureArtifactDef>
 -                                <featureArtifactDef>org.apache.stratos:org.apache.stratos.cartridge.mgt.ui.feature:${project.version}</featureArtifactDef>
                                  <featureArtifactDef>org.apache.stratos:org.apache.stratos.rest.endpoint.feature:${project.version}</featureArtifactDef>
+                                 <featureArtifactDef>org.apache.stratos:org.apache.stratos.metadataservice.feature:${project.version}</featureArtifactDef>
                                  <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.patch.version.4.2.1}</featureArtifactDef>
                                  <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.patch.version.4.2.2}</featureArtifactDef>
                                  <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.patch.version.4.2.1}</featureArtifactDef>

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/tools/stratos-installer/conf/setup.conf
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/tools/stratos-installer/setup.sh
----------------------------------------------------------------------
diff --cc tools/stratos-installer/setup.sh
index 5a02de2,5035af9..ae88b32
--- a/tools/stratos-installer/setup.sh
+++ b/tools/stratos-installer/setup.sh
@@@ -557,10 -551,24 +572,24 @@@ if [[ ($profile = "default" && $config_
      echo "Extracting ActiveMQ"
      tar -xzf $activemq_pack -C $stratos_path
      # disable amqp connector to prevent conflicts with openstack
 -    sed -r -i -e 's@^(\s*)(<transportConnector name="amqp".*\s*)$@\1<!--\2-->@g'
$stratos_path/apache-activemq-5.9.1/conf/activemq.xml
 +    ${SED} -r -i -e 's@^(\s*)(<transportConnector name="amqp".*\s*)$@\1<!--\2-->@g'
$activemq_path/conf/activemq.xml
  fi
  
+ if [[ ($profile = "default" && $config_greg = "true") ]]; then
+     echo "Extracting wso2 greg"
+     unzip -q $greg_pack_zip -d $stratos_path
+   
+ fi
+ 
  general_setup
+ 
+ if [[ ($profile = "default" && $config_greg = "true") ]]; then
+     echo "Running the GREG"
+     greg_setup
+   
+ fi
+ 
+ 
  if [[ $profile = "cc" ]]; then
      cc_setup
  elif [[ $profile = "as" ]]; then


Mime
View raw message