Updated Branches: refs/heads/master 7de9433d9 -> 593a6978c
addig LoadThreshold information to autoscaler bean Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/593a6978 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/593a6978 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/593a6978 Branch: refs/heads/master Commit: 593a6978c55d0d8fba2b9285ae664778a4bb740c Parents: 7de9433 Author: Isuru <[email protected]> Authored: Thu Dec 5 23:58:55 2013 +0530 Committer: Isuru <[email protected]> Committed: Thu Dec 5 23:58:55 2013 +0530 ---------------------------------------------------------------------- .../policy/autoscale/AutoscalePolicy.java | 2 + .../policy/autoscale/LoadAverage.java | 36 ++++++++++++++++ .../policy/autoscale/LoadThresholds.java | 32 ++++++++++++++ .../policy/autoscale/MemoryConsumption.java | 36 ++++++++++++++++ .../policy/autoscale/RequestsInFlight.java | 36 ++++++++++++++++ .../rest/endpoint/services/ServiceUtils.java | 45 +++++++++++++++++++- 6 files changed, 185 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/AutoscalePolicy.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/AutoscalePolicy.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/AutoscalePolicy.java index a37431e..00e2436 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/AutoscalePolicy.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/AutoscalePolicy.java @@ -29,4 +29,6 @@ public class AutoscalePolicy { public String displayName; public String description; + + public LoadThresholds loadThresholds; } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadAverage.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadAverage.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadAverage.java new file mode 100644 index 0000000..d500f90 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadAverage.java @@ -0,0 +1,36 @@ +/* + * 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.bean.autoscaler.policy.autoscale; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class LoadAverage { + + public float average; + + public float secondDerivative; + + public float gradient; + + public float scaleDownMarginOfGradient; + + public float scaleDownMarginOfSecondDerivative; +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadThresholds.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadThresholds.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadThresholds.java new file mode 100644 index 0000000..a53cf8c --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/LoadThresholds.java @@ -0,0 +1,32 @@ +/* + * 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.bean.autoscaler.policy.autoscale; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class LoadThresholds { + + public RequestsInFlight requestsInFlight; + + public MemoryConsumption memoryConsumption; + + public LoadAverage loadAverage; +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/MemoryConsumption.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/MemoryConsumption.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/MemoryConsumption.java new file mode 100644 index 0000000..b1c9675 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/MemoryConsumption.java @@ -0,0 +1,36 @@ +/* + * 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.bean.autoscaler.policy.autoscale; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class MemoryConsumption { + + public float average; + + public float secondDerivative; + + public float gradient; + + public float scaleDownMarginOfGradient; + + public float scaleDownMarginOfSecondDerivative; +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/RequestsInFlight.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/RequestsInFlight.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/RequestsInFlight.java new file mode 100644 index 0000000..7e5b7cd --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/autoscaler/policy/autoscale/RequestsInFlight.java @@ -0,0 +1,36 @@ +/* + * 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.bean.autoscaler.policy.autoscale; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class RequestsInFlight { + + public float average; + + public float secondDerivative; + + public float gradient; + + public float scaleDownMarginOfGradient; + + public float scaleDownMarginOfSecondDerivative; +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/593a6978/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java ---------------------------------------------------------------------- diff --git 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 index ae87419..e0b846f 100644 --- 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 @@ -37,7 +37,7 @@ import org.apache.stratos.adc.topology.mgt.service.TopologyManagementService; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; -import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.AutoscalePolicy; +import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; 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.IaasProviderBean; @@ -312,12 +312,53 @@ public class ServiceUtils { autoscalePolicy.id = autoscalePolicies[i].getId(); autoscalePolicy.displayName = autoscalePolicies[i].getDisplayName(); autoscalePolicy.description = autoscalePolicies[i].getDescription(); - //other information are not added. TODO add if required + if(autoscalePolicies[i].getLoadThresholds() != null) { + autoscalePolicy.loadThresholds = populateLoadThresholds(autoscalePolicies[i].getLoadThresholds()); + } autoscalePolicyBeans[i] = autoscalePolicy; } return autoscalePolicyBeans; } + private static LoadThresholds populateLoadThresholds (org.apache.stratos.autoscaler.policy.model.LoadThresholds + loadThresholds) { + + LoadThresholds loadThresholdBean = new LoadThresholds(); + if(loadThresholds.getLoadAverage() != null) { + LoadAverage loadAverage = new LoadAverage(); + loadAverage.average = loadThresholds.getLoadAverage().getAverage(); + loadAverage.gradient = loadThresholds.getLoadAverage().getGradient(); + loadAverage.scaleDownMarginOfGradient = loadThresholds.getLoadAverage().getScaleDownMarginOfGradient(); + loadAverage.scaleDownMarginOfSecondDerivative = loadThresholds.getLoadAverage(). + getScaleDownMarginOfSecondDerivative(); + loadAverage.secondDerivative = loadThresholds.getLoadAverage().getSecondDerivative(); + loadThresholdBean.loadAverage = loadAverage; + } + if(loadThresholds.getMemoryConsumption() != null) { + MemoryConsumption memoryConsumption = new MemoryConsumption(); + memoryConsumption.average = loadThresholds.getMemoryConsumption().getAverage(); + memoryConsumption.gradient = loadThresholds.getMemoryConsumption().getGradient(); + memoryConsumption.scaleDownMarginOfGradient = loadThresholds.getMemoryConsumption(). + getScaleDownMarginOfGradient(); + memoryConsumption.scaleDownMarginOfSecondDerivative = loadThresholds.getMemoryConsumption(). + getScaleDownMarginOfSecondDerivative(); + memoryConsumption.secondDerivative = loadThresholds.getMemoryConsumption().getSecondDerivative(); + loadThresholdBean.memoryConsumption = memoryConsumption; + } + if(loadThresholds.getRequestsInFlight() != null) { + RequestsInFlight requestsInFlight = new RequestsInFlight(); + requestsInFlight.average = loadThresholds.getRequestsInFlight().getAverage(); + requestsInFlight.gradient = loadThresholds.getRequestsInFlight().getGradient(); + requestsInFlight.scaleDownMarginOfGradient = loadThresholds.getRequestsInFlight(). + getScaleDownMarginOfGradient(); + requestsInFlight.scaleDownMarginOfSecondDerivative = loadThresholds.getRequestsInFlight(). + getScaleDownMarginOfSecondDerivative(); + requestsInFlight.secondDerivative = loadThresholds.getRequestsInFlight().getSecondDerivative(); + loadThresholdBean.requestsInFlight = requestsInFlight; + } + + return loadThresholdBean; + } public static DeploymentPolicy[] getDeploymentPolicies () throws RestAPIException {
