You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2015/03/21 04:50:53 UTC
[1/3] stratos git commit: add API method /cluster/{clusterId}
Repository: stratos
Updated Branches:
refs/heads/master df09c973a -> 46f3db899
add API method /cluster/{clusterId}
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/46f3db89
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/46f3db89
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/46f3db89
Branch: refs/heads/master
Commit: 46f3db899f0ed07fc35da249781f9d97581d1abf
Parents: 9c9b3b4
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Mar 20 20:01:20 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Sat Mar 21 09:20:27 2015 +0530
----------------------------------------------------------------------
.../messaging/domain/topology/Topology.java | 20 +++++++++
...StatusClusterTerminatedMessageProcessor.java | 3 ++
...licationClustersCreatedMessageProcessor.java | 2 +
.../CompleteTopologyMessageProcessor.java | 6 +++
.../rest/endpoint/api/StratosApiV41.java | 43 ++++++++++++++++----
.../rest/endpoint/api/StratosApiV41Utils.java | 10 +++++
6 files changed, 77 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index 5b8caa2..86739d4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -33,6 +33,7 @@ import java.util.Map;
*/
public class Topology implements Serializable {
private static final long serialVersionUID = -2453583548027402122L;
+ private final HashMap<String, Cluster> clusterMap;
// Key: Service.serviceName
private Map<String, Service> serviceMap;
@@ -41,6 +42,7 @@ public class Topology implements Serializable {
public Topology() {
this.serviceMap = new HashMap<String, Service>();
+ this.clusterMap = new HashMap<String, Cluster>();
}
public Collection<Service> getServices() {
@@ -75,8 +77,26 @@ public class Topology implements Serializable {
return this.serviceMap.containsKey(serviceName);
}
+ public void addToCluterMap(Cluster cluster){
+ this.clusterMap.put(cluster.getClusterId(), cluster);
+ }
+
+ public void removeFromClusterMap(String cluserId){
+ clusterMap.remove(cluserId);
+ TopologyLockHierarchy.getInstance().removeTopologyLockForCluster(cluserId);
+ }
+
+ public Cluster getCluster(String clusterId){
+ return this.clusterMap.get(clusterId);
+ }
+
+ public boolean clusterExist(String clusterId){
+ return clusterMap.get(clusterId) != null;
+ }
+
public void clear() {
this.serviceMap.clear();
+ this.clusterMap.clear();
}
public void setInitialized(boolean initialized) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
index ae09e33..fca96f2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterTerminatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
@@ -44,6 +45,8 @@ public class ClusterStatusClusterTerminatedMessageProcessor extends MessageProce
if (log.isDebugEnabled()) {
log.debug("Received ClusterStatusClusterTerminatedEvent: " + event.toString());
}
+
+ TopologyManager.getTopology().removeFromClusterMap(event.getClusterId());
// Notify event listeners
notifyEventListeners(event);
return true;
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
index 0e90a35..374ab0f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
@@ -107,11 +107,13 @@ public class ApplicationClustersCreatedMessageProcessor extends MessageProcessor
// Apply changes to the topology
service.addCluster(cluster);
+ topology.addToCluterMap(cluster);
if (log.isInfoEnabled()) {
log.info(String.format("Cluster created: %s",
cluster.toString()));
}
}
+
} finally {
TopologyUpdater.releaseWriteLockForService(serviceName);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
index fd69522..6d60350 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
@@ -94,7 +94,13 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
for (Cluster cluster : service.getClusters()) {
if (TopologyClusterFilter.apply(cluster.getClusterId())) {
clustersToRemove.add(cluster);
+ }else{
+ // Add non filtered clusters to clusterId-cluster map
+ if(!topology.clusterExist(cluster.getClusterId())){
+ topology.addToCluterMap(cluster);
+ }
}
+
}
for (Cluster cluster : clustersToRemove) {
service.removeCluster(cluster);
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index c41f6d2..9781cef 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -20,23 +20,27 @@ package org.apache.stratos.rest.endpoint.api;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.*;
+import org.apache.stratos.common.beans.ApiResponseBean;
+import org.apache.stratos.common.beans.ErrorResponseBean;
+import org.apache.stratos.common.beans.SuccessResponseBean;
+import org.apache.stratos.common.beans.UserInfoBean;
import org.apache.stratos.common.beans.application.ApplicationBean;
import org.apache.stratos.common.beans.application.ApplicationNetworkPartitionIdListBean;
import org.apache.stratos.common.beans.application.GroupBean;
import org.apache.stratos.common.beans.application.domain.mapping.ApplicationDomainMappingsBean;
import org.apache.stratos.common.beans.application.domain.mapping.DomainMappingBean;
import org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
+import org.apache.stratos.common.beans.artifact.repository.GitNotificationPayloadBean;
import org.apache.stratos.common.beans.cartridge.CartridgeBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesClusterBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesHostBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesMasterBean;
-import org.apache.stratos.common.beans.artifact.repository.GitNotificationPayloadBean;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
import org.apache.stratos.common.beans.topology.ApplicationInfoBean;
+import org.apache.stratos.common.beans.topology.ClusterBean;
import org.apache.stratos.common.util.ClaimsMgtUtil;
import org.apache.stratos.common.util.CommonUtil;
import org.apache.stratos.manager.user.management.StratosUserManager;
@@ -70,7 +74,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -1062,6 +1065,32 @@ public class StratosApiV41 extends AbstractApi {
String.format("Autoscaling policy deleted successfully: [autoscale-policy] %s",
autoscalingPolicyId))).build();
}
+
+
+ /**
+ * Get cluster for a given cluster id
+ *
+ * @param clusterId id of the cluster
+ * @return the response
+ * @throws RestAPIException the rest api exception
+ */
+ @GET
+ @Path("/cluster/{clusterId}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/admin/manage/cluster")
+ public Response getCluster(
+ @PathParam("clusterId") String clusterId) throws RestAPIException {
+
+ ClusterBean clusterBean = StratosApiV41Utils.getClusterInfo(clusterId);
+ if(clusterBean == null){
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }else{
+ return Response.ok().entity(clusterBean).build();
+ }
+ }
+
+
// API methods for tenants
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/46f3db89/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 778fefe..4c53f53 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -56,6 +56,7 @@ import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
import org.apache.stratos.common.beans.topology.ApplicationInfoBean;
import org.apache.stratos.common.beans.topology.ApplicationInstanceBean;
+import org.apache.stratos.common.beans.topology.ClusterBean;
import org.apache.stratos.common.beans.topology.GroupInstanceBean;
import org.apache.stratos.common.client.AutoscalerServiceClient;
import org.apache.stratos.common.client.CloudControllerServiceClient;
@@ -2161,4 +2162,13 @@ public class StratosApiV41Utils {
throw new RestAPIException(msg);
}
}
+
+
+ public static ClusterBean getClusterInfo(String clusterId) throws RestAPIException {
+ if(StringUtils.isEmpty(clusterId)){
+ throw new RestAPIException("Cluster Id can not be empty");
+ }
+
+ return ObjectConverter.convertClusterToClusterBean(TopologyManager.getTopology().getCluster(clusterId), clusterId);
+ }
}
[3/3] stratos git commit: fixing: Two different status codes appear
when adding a tenant jiraId:STRATOS-1259
Posted by ud...@apache.org.
fixing: Two different status codes appear when adding a tenant jiraId:STRATOS-1259
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/44d7e938
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/44d7e938
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/44d7e938
Branch: refs/heads/master
Commit: 44d7e938dc073f58e7f2674b690e1da44f2c01af
Parents: df09c97
Author: Udara Liyanage <ud...@wso2.com>
Authored: Wed Mar 18 09:12:28 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Sat Mar 21 09:20:27 2015 +0530
----------------------------------------------------------------------
.../org/apache/stratos/rest/endpoint/api/StratosApiV41.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/44d7e938/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index d98321e..c41f6d2 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -1161,8 +1161,9 @@ public class StratosApiV41 extends AbstractApi {
}
URI url = uriInfo.getAbsolutePathBuilder().path(tenant.getDomain()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),
- String.format("Tenant added successfully: [tenant] %s", tenantDomain))).build();
+ return Response.created(url).entity(
+ new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Tenant added successfully: [tenant] %s", tenantDomain))).build();
}
/**
[2/3] stratos git commit: fixing NPE when a cartridge is removed twice
Posted by ud...@apache.org.
fixing NPE when a cartridge is removed twice
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/9c9b3b46
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9c9b3b46
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9c9b3b46
Branch: refs/heads/master
Commit: 9c9b3b46fc35ecc6b44ed58f3f935f3b70985130
Parents: 44d7e93
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Mar 20 16:46:02 2015 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Sat Mar 21 09:20:27 2015 +0530
----------------------------------------------------------------------
.../cloud/controller/messaging/topology/TopologyBuilder.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/9c9b3b46/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
index 9f88ac5..a6347c1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
@@ -92,7 +92,12 @@ public class TopologyBuilder {
Topology topology = TopologyManager.getTopology();
for (Cartridge cartridge : cartridgeList) {
- if (topology.getService(cartridge.getType()).getClusters().size() == 0) {
+ Service service = topology.getService(cartridge.getType());
+ if(service == null){
+ log.warn("Cartridge does not exist [cartidge] " + cartridge);
+ return;
+ }
+ if (service.getClusters().size() == 0) {
if (topology.serviceExists(cartridge.getType())) {
try {
TopologyManager.acquireWriteLock();