Examples of AutoscalePolicy


Examples of org.apache.stratos.autoscaler.policy.model.AutoscalePolicy

  public AutoscalerPolicyReader(File file) {
    super(file);
  }
 
  public AutoscalePolicy read() throws InvalidPolicyException{
    AutoscalePolicy policy = new AutoscalePolicy();
    try {
      OMElement docEle = getDocument();
      if("autoscalePolicy".equalsIgnoreCase(docEle.getLocalName())){
        policy.setId(docEle.getAttributeValue(new QName("id")));
        OMElement displayNameEle = docEle.getFirstChildWithName(new QName("displayName"));
        if(displayNameEle!=null){
          policy.setDisplayName(displayNameEle.getText());
        }
        OMElement descriptionEle = docEle.getFirstChildWithName(new QName("description"));
        if(descriptionEle!=null){
          policy.setDescription(descriptionEle.getText());
        }
       
        //LoadThresholds
        OMElement loadThresholdsEle = docEle.getFirstChildWithName(new QName("loadThresholds"));
        LoadThresholds loadThresholds = new LoadThresholds();
       
        //RequestsInFlight
        OMElement reqInFlightEle = loadThresholdsEle.getFirstChildWithName(new QName("requestsInFlight"));
        RequestsInFlight reqInFlight = new RequestsInFlight();
        reqInFlight.setAverage(Float.valueOf(readValueAttr(reqInFlightEle,"average")));
        reqInFlight.setGradient(Float.valueOf(readValueAttr(reqInFlightEle,"gradient")));
        reqInFlight.setSecondDerivative(Float.valueOf(readValueAttr(reqInFlightEle,"secondDerivative")));
                reqInFlight.setScaleDownMarginOfGradient(Float.valueOf(readValueAttr(reqInFlightEle,"scaleDownMarginOfGradient")));
                reqInFlight.setScaleDownMarginOfSecondDerivative(Float.valueOf(readValueAttr(reqInFlightEle,"scaleDownMarginOfSecondDerivative")));
        loadThresholds.setRequestsInFlight(reqInFlight);
       
        //MemoryConsumption
        OMElement memConsumptionEle = loadThresholdsEle.getFirstChildWithName(new QName("memoryConsumption"));
        MemoryConsumption memConsumption = new MemoryConsumption();
        memConsumption.setAverage(Float.valueOf(readValueAttr(memConsumptionEle,"average")));
        memConsumption.setGradient(Float.valueOf(readValueAttr(memConsumptionEle,"gradient")));
        memConsumption.setSecondDerivative(Float.valueOf(readValueAttr(memConsumptionEle,"secondDerivative")));
                memConsumption.setScaleDownMarginOfGradient(Float.valueOf(readValueAttr(memConsumptionEle,"scaleDownMarginOfGradient")));
                memConsumption.setScaleDownMarginOfSecondDerivative(Float.valueOf(readValueAttr(memConsumptionEle,"scaleDownMarginOfSecondDerivative")));
        loadThresholds.setMemoryConsumption(memConsumption);
       
        //LoadAverage
        OMElement loadAvrEle = loadThresholdsEle.getFirstChildWithName(new QName("loadAverage"));
        LoadAverage loadAvr = new LoadAverage();
        loadAvr.setAverage(Float.valueOf(readValueAttr(loadAvrEle,"average")));
        loadAvr.setGradient(Float.valueOf(readValueAttr(loadAvrEle,"gradient")));
        loadAvr.setSecondDerivative(Float.valueOf(readValueAttr(loadAvrEle,"secondDerivative")));
                loadAvr.setScaleDownMarginOfGradient(Float.valueOf(readValueAttr(loadAvrEle,"scaleDownMarginOfGradient")));
                loadAvr.setScaleDownMarginOfSecondDerivative(Float.valueOf(readValueAttr(loadAvrEle,"scaleDownMarginOfSecondDerivative")));
        loadThresholds.setLoadAverage(loadAvr);
       
        policy.setLoadThresholds(loadThresholds);
       
      } else{
        throw new DeploymentException("File is not a valid autoscale policy");
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.