You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2013/12/10 15:54:14 UTC
[15/16] git commit: adding a new operation to rest api -
getPartitionsOfPolicy
adding a new operation to rest api - getPartitionsOfPolicy
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/fa3faef3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/fa3faef3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/fa3faef3
Branch: refs/heads/master
Commit: fa3faef3ca707a6943d4728f1a5135a0aea62a30
Parents: fd5a626
Author: Nirmal Fernando <ni...@apache.org>
Authored: Tue Dec 10 20:16:05 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Tue Dec 10 20:16:05 2013 +0530
----------------------------------------------------------------------
.../rest/endpoint/services/ServiceUtils.java | 27 +++++++++++++++++---
.../rest/endpoint/services/StratosAdmin.java | 13 +++++++++-
2 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fa3faef3/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 85da05e..0dd15ab 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
@@ -351,14 +351,35 @@ public class ServiceUtils {
return PojoConverter.populatePartitionPojos(partitions);
}
- public static Partition[] getPartitions (String deploymentPolicyId,
- String partitionGroupId) throws RestAPIException {
+ public static Partition[] getPartitionsOfDeploymentPolicy(String deploymentPolicyId)
+ throws RestAPIException {
org.apache.stratos.cloud.controller.deployment.partition.Partition[] partitions = null;
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
if (autoscalerServiceClient != null) {
try {
- partitions = autoscalerServiceClient.getPartitions(deploymentPolicyId, partitionGroupId);
+ partitions =
+ autoscalerServiceClient.getPartitionsOfDeploymentPolicy(deploymentPolicyId);
+
+ } catch (Exception e) {
+ String errorMsg = "Error getting available partitions";
+ log.error(errorMsg, e);
+ throw new RestAPIException(errorMsg, e);
+ }
+ }
+
+ return PojoConverter.populatePartitionPojos(partitions);
+ }
+
+ public static Partition[]
+ getPartitionsOfGroup(String deploymentPolicyId, String groupId) throws RestAPIException {
+
+ org.apache.stratos.cloud.controller.deployment.partition.Partition[] partitions = null;
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ partitions =
+ autoscalerServiceClient.getPartitionsOfGroup(deploymentPolicyId, groupId);
} catch (Exception e) {
String errorMsg = "Error getting available partitions";
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fa3faef3/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 4c87cc7..0ca7ebf 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -167,7 +167,18 @@ public class StratosAdmin extends AbstractAdmin {
public Partition [] getPartitions (@PathParam("deploymentPolicyId") String deploymentPolicyId,
@PathParam("partitionGroupId") String partitionGroupId) throws RestAPIException {
- return ServiceUtils.getPartitions(deploymentPolicyId, partitionGroupId);
+ return ServiceUtils.getPartitionsOfGroup(deploymentPolicyId, partitionGroupId);
+ }
+
+ @GET
+ @Path("/partition/{deploymentPolicyId}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public Partition [] getPartitionsOfPolicy (@PathParam("deploymentPolicyId") String deploymentPolicyId)
+ throws RestAPIException {
+
+ return ServiceUtils.getPartitionsOfDeploymentPolicy(deploymentPolicyId);
}
@GET