Updated Branches: refs/heads/master 43debf400 -> fdc992487
adding support for to list the members Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/fdc99248 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/fdc99248 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/fdc99248 Branch: refs/heads/master Commit: fdc992487ce6d6af997088bf66c011eaf2512ecb Parents: 43debf4 Author: rekathiru <[email protected]> Authored: Wed Jan 29 19:48:04 2014 +0530 Committer: rekathiru <[email protected]> Committed: Wed Jan 29 19:48:04 2014 +0530 ---------------------------------------------------------------------- .../rest/endpoint/bean/topology/Cluster.java | 20 +++++++++ .../rest/endpoint/bean/topology/Member.java | 17 ++++++++ .../bean/util/converter/PojoConverter.java | 45 ++++++++++++++++---- .../rest/endpoint/services/ServiceUtils.java | 36 +++++++++++----- .../rest/endpoint/services/StratosAdmin.java | 20 ++++----- .../main/webapp/stratos/WEB-INF/cxf-servlet.xml | 2 + 6 files changed, 112 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java new file mode 100644 index 0000000..3015b33 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java @@ -0,0 +1,20 @@ +package org.apache.stratos.rest.endpoint.bean.topology; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class Cluster { + + public String serviceName; + + public String clusterId; + + public List<Member> member; + + public String tenantRange; + + public List<String> hostNames; + + public boolean isLbCluster; +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java new file mode 100644 index 0000000..236aae4 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Member.java @@ -0,0 +1,17 @@ +package org.apache.stratos.rest.endpoint.bean.topology; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Member { + public String serviceName; + public String clusterId; + public String networkPartitionId; + public String partitionId; + public String memberId; + + public String status; + public String memberIp; + public String lbClusterId; + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index b251a6d..7b13094 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -20,18 +20,13 @@ package org.apache.stratos.rest.endpoint.bean.util.converter; import org.apache.stratos.cloud.controller.pojo.*; +import org.apache.stratos.messaging.domain.topology.Cluster; 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.*; 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; -import org.apache.stratos.rest.endpoint.bean.cartridge.definition.LoadBalancerBean; -import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistanceMappingBean; -import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PortMappingBean; -import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean; -import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistanceMappingBean; - +import org.apache.stratos.rest.endpoint.bean.cartridge.definition.*; +import org.apache.stratos.rest.endpoint.bean.topology.Member; import java.util.ArrayList; import java.util.List; @@ -293,6 +288,40 @@ public class PojoConverter { return partitionGroups; } + public static org.apache.stratos.rest.endpoint.bean.topology.Cluster populateClusterPojos(Cluster cluster) { + org.apache.stratos.rest.endpoint.bean.topology.Cluster cluster1 = new + org.apache.stratos.rest.endpoint.bean.topology.Cluster(); + cluster1.serviceName = cluster.getServiceName(); + cluster1.clusterId = cluster.getClusterId(); + cluster1.isLbCluster = cluster.isLbCluster(); + cluster1.tenantRange = cluster.getTenantRange(); + cluster1.member = new ArrayList<Member>(); + cluster1.hostNames = new ArrayList<String>(); + + for(org.apache.stratos.messaging.domain.topology.Member tmp : cluster.getMembers()) { + Member member = new Member(); + member.clusterId = tmp.getClusterId(); + member.lbClusterId = tmp.getLbClusterId(); + member.networkPartitionId = tmp.getNetworkPartitionId(); + member.partitionId = tmp.getPartitionId(); + member.memberId = tmp.getMemberId(); + if(tmp.getMemberIp() == null) { + member.memberIp = "NULL"; + } else { + member.memberIp = tmp.getMemberIp(); + } + member.serviceName = tmp.getServiceName(); + member.status = tmp.getStatus().toString(); + cluster1.member.add(member); + } + + for(String tmp1 : cluster.getHostNames()) { + cluster1.hostNames.add(tmp1); + } + + return cluster1; + } + private static org.apache.stratos.cloud.controller.deployment.partition.Partition[] convertToCCPartitionPojos (List<Partition> partitionList) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/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 e4a8d3c..f375141 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,6 @@ import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.manager.utils.CartridgeConstants; import org.apache.stratos.manager.utils.PersistenceManager; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Properties; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.util.Constants; @@ -47,6 +46,8 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.Autosca import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; +import org.apache.stratos.cloud.controller.pojo.*; + import java.util.*; import java.util.regex.Pattern; @@ -894,30 +895,45 @@ public class ServiceUtils { } - public static Cluster getCluster (String cartridgeType, String subscriptionAlias, ConfigurationContext configurationContext) { + public static org.apache.stratos.rest.endpoint.bean.topology.Cluster getCluster (String cartridgeType, String subscriptionAlias, ConfigurationContext configurationContext) { - return TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext) + Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext) ,cartridgeType , subscriptionAlias); + return PojoConverter.populateClusterPojos(cluster); } - public static Cluster[] getClustersForTenant (ConfigurationContext configurationContext) { + public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getClustersForTenant (ConfigurationContext configurationContext) { Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil. getTenantId(configurationContext), null); - - return (clusterSet != null && clusterSet.size() > 0 ) ? - clusterSet.toArray(new Cluster[clusterSet.size()]) : new Cluster[0]; + ArrayList<org.apache.stratos.rest.endpoint.bean.topology.Cluster> clusters = + new ArrayList<org.apache.stratos.rest.endpoint.bean.topology.Cluster>(); + for(Cluster cluster : clusterSet) { + clusters.add(PojoConverter.populateClusterPojos(cluster)); + } + org.apache.stratos.rest.endpoint.bean.topology.Cluster[] arrCluster = + new org.apache.stratos.rest.endpoint.bean.topology.Cluster[clusters.size()]; + arrCluster = clusters.toArray(arrCluster); + return arrCluster; } - public static Cluster[] getClustersForTenantAndCartridgeType (ConfigurationContext configurationContext, + public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getClustersForTenantAndCartridgeType (ConfigurationContext configurationContext, String cartridgeType) { Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil. getTenantId(configurationContext), cartridgeType); + List<org.apache.stratos.rest.endpoint.bean.topology.Cluster> clusters = + new ArrayList<org.apache.stratos.rest.endpoint.bean.topology.Cluster>(); + for(Cluster cluster : clusterSet) { + clusters.add(PojoConverter.populateClusterPojos(cluster)); + } + org.apache.stratos.rest.endpoint.bean.topology.Cluster[] arrCluster = + new org.apache.stratos.rest.endpoint.bean.topology.Cluster[clusters.size()]; + arrCluster = clusters.toArray(arrCluster); + return arrCluster; + - return (clusterSet != null && clusterSet.size() > 0 ) ? - clusterSet.toArray(new Cluster[clusterSet.size()]) : new Cluster[0]; } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/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 dafcd91..bed3588 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 @@ -20,14 +20,13 @@ package org.apache.stratos.rest.endpoint.services; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.dto.Cartridge; -import org.apache.stratos.manager.dto.SubscriptionInfo; -import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.common.exception.StratosException; import org.apache.stratos.common.util.ClaimsMgtUtil; import org.apache.stratos.common.util.CommonUtil; -import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.manager.dto.Cartridge; +import org.apache.stratos.manager.dto.SubscriptionInfo; +import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.rest.endpoint.ServiceHolder; import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; @@ -38,7 +37,9 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.Autosca 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.ServiceDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; +import org.apache.stratos.tenant.mgt.core.TenantPersistor; import org.apache.stratos.tenant.mgt.util.TenantMgtUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.RegistryType; @@ -49,7 +50,6 @@ import org.wso2.carbon.user.core.UserStoreException; import org.wso2.carbon.user.core.tenant.Tenant; import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.apache.stratos.tenant.mgt.core.TenantPersistor; import javax.ws.rs.*; import java.util.ArrayList; @@ -295,7 +295,7 @@ public class StratosAdmin extends AbstractAdmin { } @GET - @Path("/cluster") + @Path("/cluster/") @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @@ -305,7 +305,7 @@ public class StratosAdmin extends AbstractAdmin { } @GET - @Path("/cluster/{cartridgeType}") + @Path("/cluster/{cartridgeType}/") @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @@ -684,9 +684,9 @@ public class StratosAdmin extends AbstractAdmin { // super tenant Deploying service (MT) // here an alias is generated ServiceUtils.deployService(serviceDefinitionBean.getCartridgeType(), UUID.randomUUID().toString(), serviceDefinitionBean.getAutoscalingPolicyName(), - serviceDefinitionBean.getDeploymentPolicyName(), getTenantDomain(), getUsername(), getTenantId(), - serviceDefinitionBean.getClusterDomain(), serviceDefinitionBean.getClusterSubDomain(), - serviceDefinitionBean.getTenantRange()); + serviceDefinitionBean.getDeploymentPolicyName(), getTenantDomain(), getUsername(), getTenantId(), + serviceDefinitionBean.getClusterDomain(), serviceDefinitionBean.getClusterSubDomain(), + serviceDefinitionBean.getTenantRange()); } @DELETE http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fdc99248/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml index 11947f4..873bbbc 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml @@ -62,6 +62,8 @@ <value>portMap</value> <value>partitionGroup</value> <value>partition</value> + <value>member</value> + <value>hostNames</value> </list> </property> </bean>
