You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/06/02 13:34:46 UTC
git commit: STRATOS-660: Introduced a new method to get load balancer
cluster information of a service subscription
Repository: incubator-stratos
Updated Branches:
refs/heads/master afc87f9ce -> ca7a14a56
STRATOS-660: Introduced a new method to get load balancer cluster information of a service subscription
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/ca7a14a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/ca7a14a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/ca7a14a5
Branch: refs/heads/master
Commit: ca7a14a56009fc87ddf33982be1c7d576fc9be7c
Parents: afc87f9
Author: Imesh Gunaratne <im...@apache.org>
Authored: Mon Jun 2 17:04:30 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Jun 2 17:04:30 2014 +0530
----------------------------------------------------------------------
.../rest/endpoint/services/StratosAdmin.java | 31 ++++++++++++++++++--
1 file changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca7a14a5/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 17fd103..67878db 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
@@ -18,6 +18,7 @@
*/
package org.apache.stratos.rest.endpoint.services;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.common.beans.TenantInfoBean;
@@ -407,7 +408,7 @@ public class StratosAdmin extends AbstractAdmin {
public Cluster getCluster(@PathParam("clusterId") String clusterId) throws RestAPIException {
Cluster cluster = null;
if(log.isDebugEnabled()) {
- log.debug("Finding the Cluster for [id]: "+clusterId);
+ log.debug("Finding cluster for [id]: "+clusterId);
}
Cluster[] clusters = ServiceUtils.getClustersForTenant(getConfigContext());
if(log.isDebugEnabled()) {
@@ -430,9 +431,7 @@ public class StratosAdmin extends AbstractAdmin {
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public StratosAdminResponse unsubscribe(String alias) throws RestAPIException {
-
return ServiceUtils.unsubscribe(alias, getTenantDomain());
-
}
@POST
@@ -1071,4 +1070,30 @@ public class StratosAdmin extends AbstractAdmin {
@PathParam("domainName") String domainName) throws RestAPIException {
return ServiceUtils.removeSubscriptionDomain(getConfigContext(), cartridgeType, subscriptionAlias, domainName);
}
+
+ @GET
+ @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/load-balancer-cluster")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public Response getLoadBalancerCluster(@PathParam("cartridgeType") String cartridgeType,
+ @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("GET /cartridge/%s/subscription/%s/load-balancer-cluster", cartridgeType, subscriptionAlias));
+ }
+ Cartridge subscription = ServiceUtils.getSubscription(subscriptionAlias, getConfigContext());
+ String lbClusterId = subscription.getLbClusterId();
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Load balancer cluster-id found: %s", lbClusterId));
+ }
+ if(StringUtils.isNotBlank(lbClusterId)) {
+ Cluster lbCluster = getCluster(lbClusterId);
+ if(lbCluster != null) {
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Load balancer cluster found: %s", lbCluster.toString()));
+ }
+ Response.ok().entity(lbCluster).build();
+ }
+ }
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
}