Package org.apache.stratos.cloud.controller.stub.deployment.partition

Examples of org.apache.stratos.cloud.controller.stub.deployment.partition.Partition


      List<OMNode> partitionXMLNodes = getMatchingNodes(partitionXpath);
      Iterator<OMNode> itr = partitionXMLNodes.iterator();
      List<Partition> partitonList = new ArrayList<Partition>();
        while (itr.hasNext()) {
            OMNode node = itr.next();
            Partition partition = this.getPartition(node);
            if (partition != null) {
                partitonList.add(partition);
            }
        }
    return partitonList;
View Full Code Here


        }
    return partitonList;
  }
 
  private  Partition getPartition(final OMNode item) {
        Partition partition = null;

        if (item.getType() == OMNode.ELEMENT_NODE) {

            OMElement partitionElt = (OMElement) item;
            String partitionId = partitionElt.getAttributeValue(new QName("id"));
           
            if (partitionId == null) {
                String msg ="Essential " + AutoScalerConstants.ID_ELEMENT + "element " +
                                "has not specified.";
                log.warn("Partition is ignored. "+msg);
                return null;
            }        
             
            partition = new Partition();              
            partition.setId(partitionId);
            Properties properties = AutoscalerUtil.getProperties(partitionElt);
            if (properties != null) {
                partition.setProperties(properties);
            }
            String providerValue = readValue(partitionElt, "provider");
            if (providerValue != null) {
                partition.setProvider(providerValue);
            }
            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));
            }
                                   
        }
        return partition;
    }
View Full Code Here

     
      List<Partition> partitionList = reader.getPartitionList();
      Iterator<Partition> it = partitionList.iterator();
     
            while (it.hasNext()) {
                Partition partition = it.next();
                try {
                    PartitionManager.getInstance().addNewPartition(partition);
                } catch (Exception e) {
                    String msg =
                                 "Invalid partition: " + partition.getId() + " in file: " +
                                         partitionFile.getAbsolutePath()+". Cause: "+ e.getMessage();
                    log.error(msg, e);
                    continue;
                }
            }     
View Full Code Here

            }finally{
              TopologyManager.releaseReadLock();
            }
            // start a new member in the same Partition
            String partitionId = monitor.getPartitionOfMember(memberId);
            Partition partition = monitor.getDeploymentPolicy().getPartitionById(partitionId);
            PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId);

            if(!partitionCtxt.activeMemberExist(memberId)){
                if(log.isDebugEnabled()){
                    log.debug(String.format("Could not find the active member in partition context, [member] %s ", memberId));
View Full Code Here

        List<Partition> partitionList = new ArrayList<Partition>();
        RegistryManager registryManager = RegistryManager.getInstance();
        String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.PARTITION_RESOURCE);

        if (partitionsResourceList != null) {
            Partition partition;
            for (String resourcePath : partitionsResourceList) {
                Object serializedObj = registryManager.retrieve(resourcePath);
                if (serializedObj != null) {
                    try {

                        Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
                        if (dataObj instanceof Partition) {
                            partition = (Partition) dataObj;
                            if(log.isDebugEnabled()) {
                                log.debug(String.format("Partition read from registry: [id] %s [provider] %s [min] %d [max] %d",
                                        partition.getId(), partition.getProvider(), partition.getPartitionMin(), partition.getPartitionMax()));
                            }
                            partitionList.add(partition);
                        } else {
                            return null;
                        }
View Full Code Here

            // Adding the registry stored partitions to the information model
            List<Partition> partitions = RegistryManager.getInstance().retrievePartitions();
            Iterator<Partition> partitionIterator = partitions.iterator();
            while (partitionIterator.hasNext()) {
                Partition partition = partitionIterator.next();
                PartitionManager.getInstance().addPartitionToInformationModel(partition);
            }
           
            // Adding the network partitions stored in registry to the information model
            List<NetworkPartitionLbHolder> nwPartitionHolders = RegistryManager.getInstance().retrieveNetworkPartitionLbHolders();
View Full Code Here

              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.");
                                }
View Full Code Here

        Partition[] partitionArr = pm.getAllPartitions();
          for(Partition partition : partitionArr){
            ci.println(partition.toString());
          }
      }else{
        Partition partition = pm.getPartitionById(partitionId);
        if(partition != null){ 
          ci.println(partition);
        }
      }
    }
View Full Code Here


            for (int i = currentPartitionIndex; i < noOfPartitions; i++) {
                if (partitions.get(currentPartitionIndex) instanceof Partition) {
                    currentPartitionIndex = networkPartitionContext.getCurrentPartitionIndex();
                    Partition currentPartition = (Partition) partitions.get(currentPartitionIndex);
                    String currentPartitionId = currentPartition.getId();
                    int nonTerminatedMemberCountOfPartition = networkPartitionContext.getNonTerminatedMemberCountOfPartition(currentPartitionId);
                    if (nonTerminatedMemberCountOfPartition < currentPartition.getPartitionMax()) {
                        // current partition is free
                        if (log.isDebugEnabled())
                            log.debug(String.format("A free space found for scale up in partition %s [current] %s [max] %s",
                                    currentPartitionId, nonTerminatedMemberCountOfPartition, currentPartition.getPartitionMax()))  ;
                        return currentPartition;
                    } else {
                        // last partition is reached which is not free
                        if (currentPartitionIndex == noOfPartitions - 1) {
                            if (log.isDebugEnabled())
View Full Code Here

            List<?> partitions = Arrays.asList(networkPartitionContext.getPartitions());

            for (int i = currentPartitionIndex; i >= 0; i--) {
                if (partitions.get(currentPartitionIndex) instanceof Partition) {
                    currentPartitionIndex = networkPartitionContext.getCurrentPartitionIndex();
                    Partition currentPartition = (Partition) partitions.get(currentPartitionIndex);
                    String currentPartitionId = currentPartition.getId();

                    // has more than minimum instances.
                    int currentlyActiveMemberCount = networkPartitionContext.getActiveMemberCount(currentPartitionId);
                    if ( currentlyActiveMemberCount > currentPartition.getPartitionMin()) {
                        // current partition is free
                        if (log.isDebugEnabled())
                            log.debug(String.format("A free space found for scale down in partition %s [current] %s [min] %s",
                                    currentPartitionId, currentlyActiveMemberCount, currentPartition.getPartitionMin()))  ;
                        return currentPartition;
                    } else {
                        if (currentPartitionIndex == 0) {
                            if (log.isDebugEnabled())
                                log.debug(String.format("Partition %s reached with no space to scale down," +
                                        "[active] %s [min] %s", currentPartitionId, currentlyActiveMemberCount,
                                        currentPartition.getPartitionMin()));
                            return null;
                        }
                        // Set next partition as current partition in Autoscaler Context
                        currentPartitionIndex = currentPartitionIndex - 1;
                        networkPartitionContext.setCurrentPartitionIndex(currentPartitionIndex);
View Full Code Here

TOP

Related Classes of org.apache.stratos.cloud.controller.stub.deployment.partition.Partition

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.