Updated Branches: refs/heads/master 013a47cd1 -> 63c5c1c14
Exposing Auto Scaler API Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/41f4e813 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/41f4e813 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/41f4e813 Branch: refs/heads/master Commit: 41f4e8132eef2b26b4b2846138df1af7c17b31fc Parents: 8838a2a Author: Udara Liyanage <[email protected]> Authored: Sat Nov 30 18:14:04 2013 -0500 Committer: Udara Liyanage <[email protected]> Committed: Sat Nov 30 18:14:04 2013 -0500 ---------------------------------------------------------------------- .../autoscaler/api/AutoScalerServiceImpl.java | 50 ++++++++++++++++++++ .../autoscaler/partition/PartitionManager.java | 8 ++++ .../deployers/DeploymentPolicyReader.java | 1 - .../src/main/resources/META-INF/services.xml | 31 ++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41f4e813/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java new file mode 100644 index 0000000..723ee0f --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -0,0 +1,50 @@ +/* + * 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.api; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.partition.PartitionManager; +import org.apache.stratos.autoscaler.policy.PolicyManager; +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; +import org.apache.stratos.cloud.controller.deployment.partition.Partition; +import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy; + +/** + * Auto Scaler Service API is responsible getting Partitions and Policies. + */ +public class AutoScalerServiceImpl { + + private static final Log log = LogFactory.getLog(AutoScalerServiceImpl.class); + + public List<Partition> getAllAvailablePartitions(){ + return PartitionManager.getInstance().getAllPartitions(); + } + + public List<DeploymentPolicy> getAllDeploymentPolicies(){ + return PolicyManager.getInstance().getDeploymentPolicyList(); + } + + public List<AutoscalePolicy> getAllAutoScalingPolicy(){ + return PolicyManager.getInstance().getAutoscalePolicyList(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41f4e813/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java index e611ae7..96304ec 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java @@ -19,11 +19,15 @@ package org.apache.stratos.autoscaler.partition; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.InvalidPartitionException; @@ -72,5 +76,9 @@ private static final Log log = LogFactory.getLog(PartitionManager.class); else return null; } + + public List<Partition> getAllPartitions(){ + return Collections.unmodifiableList(new ArrayList<Partition>(partitionListMap.values())); + } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41f4e813/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java index 59689aa..02dc59c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java @@ -30,7 +30,6 @@ import org.apache.axiom.om.OMElement; import org.apache.axis2.deployment.DeploymentException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.InvalidPolicyException; import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup; http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41f4e813/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/services.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/services.xml new file mode 100644 index 0000000..a79fa43 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/services.xml @@ -0,0 +1,31 @@ +<?xml version='1.0'?> +<!-- + + 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. + +--> + +<serviceGroup> + <service name="AutoScalerService" scope="application"> + <parameter name="ServiceClass">org.apache.stratos.autoscaler.api.AutoScalerServiceImpl</parameter> + <messageReceivers> + <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> + </messageReceivers> + </service> +</serviceGroup>
