Package org.apache.stratos.autoscaler.deployment.policy

Examples of org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy


    }

    public static org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy
    getDeploymentPolicy(String deploymentPolicyId) throws RestAPIException {

        DeploymentPolicy deploymentPolicy = null;
        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
        if (autoscalerServiceClient != null) {
            try {
                deploymentPolicy = autoscalerServiceClient.getDeploymentPolicy(deploymentPolicyId);
View Full Code Here


  public PartitionGroup[] getPartitionGroups(String deploymentPolicyId) { 
    return PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups();
  }

  public Partition[] getPartitionsOfDeploymentPolicy(String deploymentPolicyId) {
    DeploymentPolicy depPol = this.getDeploymentPolicy(deploymentPolicyId);
    if(null == depPol) {
      return null;
    }
   
    return depPol.getAllPartitions();
  }
View Full Code Here

    return depPol.getAllPartitions();
  }
 
  @Override
    public Partition[] getPartitionsOfGroup(String deploymentPolicyId, String groupId) {
        DeploymentPolicy depPol = this.getDeploymentPolicy(deploymentPolicyId);
        if(null == depPol) {
            return null;
        }
       
        PartitionGroup group = depPol.getPartitionGroup(groupId);
       
        if(group == null) {
            return null;
        }
       
View Full Code Here

                    String deploymentPolicy = e.getDeploymentPolicy();

                    AbstractMonitor monitor;

                    if (e.isLbCluster()) {
                        DeploymentPolicy depPolicy = PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicy);
                        if (depPolicy != null) {
                            List<NetworkPartitionLbHolder> lbHolders = PartitionManager.getInstance()
                                    .getNetworkPartitionLbHolders(depPolicy);

                            for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) {
View Full Code Here

        List<DeploymentPolicy> depPolicyList = new ArrayList<DeploymentPolicy>();
        RegistryManager registryManager = RegistryManager.getInstance();
        String[] depPolicyResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE);

        if (depPolicyResourceList != null) {
            DeploymentPolicy depPolicy;
            for (String resourcePath : depPolicyResourceList) {
                Object serializedObj = registryManager.retrieve(resourcePath);
                if (serializedObj != null) {
                    try {
                        Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
                        if (dataObj instanceof DeploymentPolicy) {
                            depPolicy = (DeploymentPolicy) dataObj;
                            if(log.isDebugEnabled()) {
                                log.debug(depPolicy.toString());
                            }
                            depPolicyList.add(depPolicy);
                        } else {
                            return null;
                        }
View Full Code Here

            }

            List<DeploymentPolicy> depPolicies = RegistryManager.getInstance().retrieveDeploymentPolicies();
            Iterator<DeploymentPolicy> depPolicyIterator = depPolicies.iterator();
            while (depPolicyIterator.hasNext()) {
                DeploymentPolicy depPolicy = depPolicyIterator.next();
                PolicyManager.getInstance().addDeploymentPolicyToInformationModel(depPolicy);
            }

            if (log.isInfoEnabled()) {
                log.info("Autoscaler Server Component activated");
View Full Code Here

    public void undeployDeploymentPolicy(String policy) throws InvalidPolicyException {
        if (deploymentPolicyListMap.containsKey(policy)) {
            if (log.isDebugEnabled()) {
                log.debug("Removing deployment policy :" + policy);
            }
            DeploymentPolicy depPolicy = this.getDeploymentPolicy(policy);
            // undeploy network partitions this deployment policy.
            PartitionManager.getInstance().undeployNetworkPartitions(depPolicy);
            // undeploy the deployment policy.
            RegistryManager.getInstance().removeDeploymentPolicy(depPolicy);
            // remove from the infromation model.
View Full Code Here

  public DeploymentPolicyReader(File file) {
    super(file);
  }
 
  public DeploymentPolicy read() throws InvalidPolicyException{
    DeploymentPolicy policy = new DeploymentPolicy();
    try {
      OMElement docEle = getDocument();
      if("deploymentPolicy".equalsIgnoreCase(docEle.getLocalName())){
        policy.setId(docEle.getAttributeValue(new QName("id")));
       
        //Partition-Groups
        Iterator<?> partitionGroupItr = docEle.getChildrenWithLocalName("partitionGroup");
        while(partitionGroupItr.hasNext()){
            List<PartitionGroup> partitionGroups = new ArrayList<PartitionGroup>();
          Object nextGroup = partitionGroupItr.next();
          if(nextGroup instanceof OMElement){
            OMElement groupEle = (OMElement) nextGroup;
            PartitionGroup group = new PartitionGroup();
            group.setId(groupEle.getAttributeValue(new QName("id")));
            group.setPartitionAlgo(readValue(groupEle, "partitionAlgo"));
           
            List<Partition> partitions = new ArrayList<Partition>() ;
            //Partitions
            Iterator<?> partitionItr = groupEle.getChildrenWithLocalName("partition");
            while(partitionItr.hasNext()){
              Object next = partitionItr.next();
              if(next instanceof OMElement){
                OMElement partitionElt = (OMElement) next;
               
                String partitionId = partitionElt.getAttributeValue(new QName("id"));
                                if (partitionId != null) {
                                    Partition partition = new Partition();
                                    partition.setId(partitionId);
                                    String maxValue = readValue(partitionElt, "max");
                                    if (maxValue != null) {
                                        partition.setPartitionMax(Integer.valueOf(maxValue));
                                    }
                                    String minValue = readValue(partitionElt, "min");
                                    if (minValue != null) {
                                        partition.setPartitionMin(Integer.valueOf(minValue));
                                    }
                                    String providerValue = readValue(partitionElt, "provider");
                                    if (providerValue != null) {
                                        partition.setProvider(providerValue);
                                    }
                                   
                                    Properties properties = AutoscalerUtil.getProperties(partitionElt);
                                    if (properties != null) {
                                        partition.setProperties(properties);
                                    }
                                    partitions.add(partition);
                                } else {
                                    log.warn("Invalid Partition id: null. Partition will be ignored.");
                                }
              }
            }
            if(group.getPartitions() == null) {
                group.setPartitions(new Partition[0]);
            }
            group.setPartitions(partitions.toArray(group.getPartitions()));
            partitionGroups.add(group);
          }
          if(policy.getPartitionGroups() == null) {
                        policy.setPartitionGroups(new PartitionGroup[0]);
                    }
          policy.setPartitionGroups(partitionGroups.toArray(policy.getPartitionGroups()));
        }
      } else{
        throw new DeploymentException("File is not a valid deployment policy");
      }
View Full Code Here

        DeploymentPolicy[] depPolicyArr = pm.getDeploymentPolicyList();
          for(DeploymentPolicy depPoolicy : depPolicyArr){
            ci.println(depPoolicy.toString());
          }
      }else{
        DeploymentPolicy asPolicy = pm.getDeploymentPolicy(policyId);
        if(asPolicy != null){
          ci.println(asPolicy);
        }
      }
    }
View Full Code Here

        }

        AutoscalePolicy policy =
                                 PolicyManager.getInstance()
                                              .getAutoscalePolicy(autoscalePolicyName);
        DeploymentPolicy deploymentPolicy =
                                            PolicyManager.getInstance()
                                                         .getDeploymentPolicy(deploymentPolicyName);

        if (deploymentPolicy == null) {
            String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName;
            log.error(msg);
            throw new PolicyValidationException(msg);
        }

        Partition[] allPartitions = deploymentPolicy.getAllPartitions();
        if (allPartitions == null) {
            String msg =
                         "Deployment Policy's Partitions are null. Policy name: " +
                                 deploymentPolicyName;
            log.error(msg);
            throw new PolicyValidationException(msg);
        }

        CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy);

        ClusterMonitor clusterMonitor =
                                        new ClusterMonitor(cluster.getClusterId(),
                                                           cluster.getServiceName(),
                                                           deploymentPolicy, policy);
       
        for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){

            NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(),
                    partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions());

            for(Partition partition: partitionGroup.getPartitions()){
View Full Code Here

TOP

Related Classes of org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.