You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/08/12 10:43:22 UTC
[1/2] stratos git commit: Remove UUID and tenantId from response
messages
Repository: stratos
Updated Branches:
refs/heads/tenant-isolation 4c94b482c -> a709db523
Remove UUID and tenantId from response messages
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5806387b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5806387b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5806387b
Branch: refs/heads/tenant-isolation
Commit: 5806387b49924da4da25c925077fdad916b0e875
Parents: 0f6b228
Author: Dinithi <di...@wso2.com>
Authored: Wed Aug 12 13:26:45 2015 +0530
Committer: Dinithi <di...@wso2.com>
Committed: Wed Aug 12 13:26:45 2015 +0530
----------------------------------------------------------------------
.../rest/endpoint/api/StratosApiV41.java | 86 +++++-----
.../rest/endpoint/api/StratosApiV41Utils.java | 165 ++++++++++---------
2 files changed, 131 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5806387b/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 a682c9e..c0f03b7 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
@@ -157,7 +157,8 @@ public class StratosApiV41 extends AbstractApi {
ResponseMessageBean.ERROR, backendErrorMessage)).build();
} catch (AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException e) {
return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Deployment policy already exists")).build();
+ ResponseMessageBean.ERROR, String.format("Deployment policy already exists " +
+ ": [deployment-policy-id] %s", deploymentPolicyId))).build();
}
URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyId).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
@@ -181,7 +182,8 @@ public class StratosApiV41 extends AbstractApi {
DeploymentPolicyBean deploymentPolicyBean = StratosApiV41Utils.getDeploymentPolicy(deploymentPolicyId);
if (deploymentPolicyBean == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Deployment policy not found")).build();
+ ResponseMessageBean.ERROR, String.format("Deployment policy not found: [deployment-policy-id] %s",
+ deploymentPolicyId))).build();
}
return Response.ok(deploymentPolicyBean).build();
}
@@ -240,7 +242,8 @@ public class StratosApiV41 extends AbstractApi {
ResponseMessageBean.ERROR, backendErrorMessage)).build();
} catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Deployment policy not found")).build();
+ ResponseMessageBean.ERROR, String.format("Deployment policy not found [deployment-policy-id] %s",
+ deploymentPolicyId))).build();
}
URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyId).build();
return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
@@ -266,10 +269,12 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyId);
} catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Deployment policy not found")).build();
+ ResponseMessageBean.ERROR, String.format("Deployment policy not found [deployment-policy-id] %s",
+ deploymentPolicyId))).build();
} catch (AutoscalerServiceUnremovablePolicyExceptionException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Deployment policy is in use")).build();
+ ResponseMessageBean.ERROR, String.format("Deployment policy is in use [deployment-policy-id] %s",
+ deploymentPolicyId))).build();
}
URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyId).build();
return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
@@ -305,8 +310,8 @@ public class StratosApiV41 extends AbstractApi {
//Ignore this since this is valid(cartridge is does not exist) when adding the cartridge for first time
}
if (cartridgeBean != null) {
- String msg = String.format("Cartridge already exists: [cartridge-type] %s [cartridge-uuid] %s [tenant-id] %d",
- cartridgeType, cartridgeUuid, tenantId);
+ String msg = String.format("Cartridge already exists: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s ",
+ tenantId, cartridgeUuid, cartridgeType);
log.warn(msg);
return Response.status(Response.Status.CONFLICT)
.entity(new ResponseMessageBean(ResponseMessageBean.ERROR, msg)).build();
@@ -315,8 +320,7 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.addCartridge(cartridgeDefinitionBean, cartridgeUuid, tenantId);
URI url = uriInfo.getAbsolutePathBuilder().path(cartridgeType).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Cartridge added successfully: [cartridge-type] %s [cartridge-uuid] %s [tenant-id] %d",
- cartridgeType, cartridgeUuid, tenantId))).build();
+ String.format("Cartridge added successfully: [cartridge-type] %s", cartridgeType))).build();
}
/**
@@ -335,10 +339,9 @@ public class StratosApiV41 extends AbstractApi {
CartridgeBean cartridgeDefinitionBean) throws RestAPIException {
StratosApiV41Utils.updateCartridge(cartridgeDefinitionBean);
URI url = uriInfo.getAbsolutePathBuilder().path(cartridgeDefinitionBean.getType()).build();
- return Response.ok(url)
- .entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS, "Cartridge updated successfully"))
- .build();
-
+ return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
+ String.format("Cartridge updated successfully: [cartridge-type] %s",
+ cartridgeDefinitionBean.getType()))).build();
}
/**
@@ -465,7 +468,7 @@ public class StratosApiV41 extends AbstractApi {
try {
StratosApiV41Utils.removeCartridge(cartridgeType,carbonContext.getTenantId());
return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Cartridge deleted successfully: [cartridge-type] %s [tenantId] %d", cartridgeType,carbonContext.getTenantId()))).build();
+ String.format("Cartridge deleted successfully: [cartridge-type] %s", cartridgeType))).build();
} catch (RemoteException e) {
throw new RestAPIException(e.getMessage());
} catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
@@ -503,8 +506,8 @@ public class StratosApiV41 extends AbstractApi {
groupBean = StratosApiV41Utils.getServiceGroupDefinition(cartridgeGroupBean.getName(), carbonContext.getTenantId());
if (groupBean != null) {
- String msg = String.format("Cartridge already exists: [cartridge-type] %s [cartridge-uuid] %s [tenant-id] %d",
- cartridgeGroupBean.getName(), cartrideGroupUuid, tenantId);
+ String msg = String.format("Cartridge already exists: [tenant-id] %d [cartridge-uuid] %s [cartridge-type]" +
+ "%s", tenantId, cartrideGroupUuid, cartridgeGroupBean.getName());
log.warn(msg);
return Response.status(Response.Status.CONFLICT)
.entity(new ResponseMessageBean(ResponseMessageBean.ERROR, msg)).build();
@@ -514,9 +517,8 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.addCartridgeGroup(cartridgeGroupBean, cartrideGroupUuid, tenantId);
URI url = uriInfo.getAbsolutePathBuilder().path(cartridgeGroupBean.getName()).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Cartridge Group added successfully: [cartridge-group-uuid] %s " +
- "[cartridge-group-name] %s [tenant-id] %d", cartrideGroupUuid,
- cartridgeGroupBean.getName(), tenantId))).build();
+ String.format("Cartridge Group added successfully: [cartridge-group-name] %s",
+ cartridgeGroupBean.getName()))).build();
} catch (InvalidCartridgeGroupDefinitionException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
ResponseMessageBean.ERROR, e.getMessage())).build();
@@ -553,7 +555,7 @@ public class StratosApiV41 extends AbstractApi {
URI url = uriInfo.getAbsolutePathBuilder().path(cartridgeGroupBean.getName()).build();
return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Cartridge group updated successfully: [cartridge-group-uuid] %s",
+ String.format("Cartridge group updated successfully: [cartridge-group-name] %s",
cartridgeGroupBean.getName()))).build();
} catch (InvalidCartridgeGroupDefinitionException e) {
@@ -776,8 +778,8 @@ public class StratosApiV41 extends AbstractApi {
ResponseMessageBean.ERROR, "Network partition is not found")).build();
}
return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Network partition deleted successfully: [network-partition-id] %s " +
- "[tenant-domain] %s", networkPartitionId, carbonContext.getTenantDomain()))).build();
+ String.format("Network partition deleted successfully: [network-partition-id] %s ",
+ networkPartitionId))).build();
}
// API methods for applications
@@ -804,7 +806,8 @@ public class StratosApiV41 extends AbstractApi {
URI url = uriInfo.getAbsolutePathBuilder().path(applicationUuid).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application added successfully: [application] %s", applicationUuid))).build();
+ String.format("Application added successfully: [application-id] %s",
+ applicationDefinition.getApplicationId()))).build();
} catch (ApplicationAlreadyExistException e) {
return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(
ResponseMessageBean.ERROR, "Application already exists")).build();
@@ -845,8 +848,8 @@ public class StratosApiV41 extends AbstractApi {
carbonContext.getTenantId(), getConfigContext(), getUsername(), getTenantDomain());
URI url = uriInfo.getAbsolutePathBuilder().path(applicationContext.getApplicationUuid()).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application updated successfully: [application] %s",
- applicationContext.getApplicationUuid()))).build();
+ String.format("Application updated successfully: [application-id] %s",
+ applicationDefinition.getApplicationId()))).build();
} catch (RemoteException e) {
throw new RestAPIException(e.getMessage());
} catch (AutoscalerServiceCartridgeNotFoundExceptionException e) {
@@ -927,7 +930,7 @@ public class StratosApiV41 extends AbstractApi {
try {
StratosApiV41Utils.deployApplication(applicationId, applicationPolicyId);
return Response.accepted().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application deployed successfully: [application] %s", applicationId))).build();
+ String.format("Application deployed successfully: [application-id] %s", applicationId))).build();
} catch (ApplicationAlreadyDeployedException e) {
return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(
ResponseMessageBean.ERROR, "Application policy already deployed")).build();
@@ -965,8 +968,8 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.addApplicationPolicy(applicationPolicy, applicationPolicyUuid, tenantId);
URI url = uriInfo.getAbsolutePathBuilder().path(applicationPolicy.getId()).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application policy added successfully: [application-policy-uuid] %s " +
- "[application-policy-id] %s", applicationPolicyUuid, applicationPolicyId))).build();
+ String.format("Application policy added successfully: [application-policy-id] %s",
+ applicationPolicyId))).build();
} catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
String backendErrorMessage = e.getFaultMessage().getInvalidApplicationPolicyException().getMessage();
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
@@ -1000,7 +1003,7 @@ public class StratosApiV41 extends AbstractApi {
ApplicationPolicyBean applicationPolicyBean = StratosApiV41Utils.getApplicationPolicy(applicationPolicyId);
if (applicationPolicyBean == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Application policy not found: [application-policy] " +
+ ResponseMessageBean.ERROR, "Application policy not found: [application-policy-id] " +
applicationPolicyId)).build();
}
return Response.ok(applicationPolicyBean).build();
@@ -1047,7 +1050,7 @@ public class StratosApiV41 extends AbstractApi {
try {
StratosApiV41Utils.removeApplicationPolicy(applicationPolicyId);
return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application policy deleted successfully: [application-policy] %s",
+ String.format("Application policy deleted successfully: [application-policy-id] %s",
applicationPolicyId))).build();
} catch (ApplicationPolicyIdIsEmptyException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
@@ -1060,9 +1063,8 @@ public class StratosApiV41 extends AbstractApi {
.build();
} catch (AutoscalerServiceUnremovablePolicyExceptionException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "This application policy cannot be removed, since it is used in an " +
- "application"))
- .build();
+ ResponseMessageBean.ERROR, String.format("This application policy [application-policy-id] %s " +
+ "cannot be removed, since it is used in an application", applicationPolicyId))).build();
}
}
@@ -1090,11 +1092,11 @@ public class StratosApiV41 extends AbstractApi {
.build();
} catch (AutoscalerServiceApplicatioinPolicyNotExistsExceptionException e) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, String.format("Application policy not found: [application-policy] %s",
+ ResponseMessageBean.ERROR, String.format("Application policy not found: [application-policy-id] %s",
applicationPolicy.getId()))).build();
}
return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application policy updated successfully: [application-policy] %s",
+ String.format("Application policy updated successfully: [application-policy-id] %s",
applicationPolicy.getId()))).build();
}
@@ -1142,7 +1144,7 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.addApplicationSignUp(applicationId, applicationSignUpBean);
URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Successfully signed up for: [application] %s", applicationId))).build();
+ String.format("Successfully signed up for: [application-id] %s", applicationId))).build();
}
/**
@@ -1165,7 +1167,7 @@ public class StratosApiV41 extends AbstractApi {
applicationSignUpBean = StratosApiV41Utils.getApplicationSignUp(applicationId);
if (applicationSignUpBean == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "No application signups found for application: [application]" +
+ ResponseMessageBean.ERROR, "No application signups found for application: [application-id]" +
applicationId)).build();
}
return Response.ok(applicationSignUpBean).build();
@@ -1191,7 +1193,7 @@ public class StratosApiV41 extends AbstractApi {
@PathParam("applicationId") String applicationId) throws RestAPIException {
StratosApiV41Utils.removeApplicationSignUp(applicationId);
return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Application sign up removed successfully: [application] %s", applicationId))).build();
+ String.format("Application sign up removed successfully: [application-id] %s", applicationId))).build();
}
/**
@@ -1461,8 +1463,8 @@ public class StratosApiV41 extends AbstractApi {
StratosApiV41Utils.addAutoscalingPolicy(autoscalePolicy, autoscalingPolicyUuid, tenantId);
URI url = uriInfo.getAbsolutePathBuilder().path(autoscalePolicy.getId()).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("Autoscaling policy added successfully: [autoscale-policy-uuid] %s " +
- "[autoscale-policy-id] %s", autoscalingPolicyUuid, autoscalingPolicyId))).build();
+ String.format("Autoscaling policy added successfully: [autoscaling-policy-id] %s",
+ autoscalingPolicyId))).build();
} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
ResponseMessageBean.ERROR, "Provided Autoscaling policy is invalid")).build();
@@ -1936,7 +1938,7 @@ public class StratosApiV41 extends AbstractApi {
URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesClusterUuid).build();
return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
String.format("Kubernetes cluster added successfully: [kub-host-cluster] %s",
- kubernetesClusterUuid))).build();
+ kubernetesCluster.getClusterId()))).build();
} catch (CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException e) {
return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(
ResponseMessageBean.ERROR, "Kubernetes cluster already exists")).build();
@@ -1971,7 +1973,7 @@ public class StratosApiV41 extends AbstractApi {
URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesCluster.getClusterUuid()).build();
return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
String.format("Kubernetes cluster updated successfully: [kub-host-cluster] %s",
- kubernetesCluster.getClusterUuid()))).build();
+ kubernetesClusterBean.getClusterId()))).build();
} catch (RemoteException e) {
throw new RestAPIException(e.getMessage());
} catch (CloudControllerServiceInvalidKubernetesClusterExceptionException e) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/5806387b/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 6e354ee..389b43f 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
@@ -126,8 +126,8 @@ public class StratosApiV41Utils {
try {
if (log.isDebugEnabled()) {
- log.debug(String.format("Adding cartridge: [cartridge-uuid] %s[cartridge-type] %s ",
- cartridgeUuid, cartridgeBean.getType()));
+ log.debug(String.format("Adding cartridge: [tenant-id] %d [cartridge-uuid] %s[cartridge-type] %s ",
+ tenantId, cartridgeUuid, cartridgeBean.getType()));
}
List<IaasProviderBean> iaasProviders = cartridgeBean.getIaasProvider();
@@ -153,8 +153,8 @@ public class StratosApiV41Utils {
if (log.isDebugEnabled()) {
log.debug(String.format(
- "Successfully added cartridge: [cartridge-uuid] %s [cartridge-type] %s ",
- cartridgeUuid, cartridgeBean.getType()));
+ "Successfully added cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s ",
+ tenantId, cartridgeUuid, cartridgeBean.getType()));
}
} catch (CloudControllerServiceCartridgeAlreadyExistsExceptionException e) {
String msg = "Could not add cartridge as it is already exits";
@@ -195,24 +195,23 @@ public class StratosApiV41Utils {
cartridgeConfig.setUuid(existingCartridge.getUuid());
if (log.isDebugEnabled()) {
- log.debug(String.format("Updating cartridge: [cartridge-uuid] %s [cartridge-type] %s [tenant-id] %d",
- existingCartridge.getUuid(), cartridgeBean.getType(), existingCartridge.getTenantId()));
+ log.debug(String.format("Updating cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s ",
+ existingCartridge.getTenantId(), existingCartridge.getUuid(), cartridgeBean.getType()));
}
List<IaasProviderBean> iaasProviders = cartridgeBean.getIaasProvider();
if ((iaasProviders == null) || iaasProviders.size() == 0) {
- throw new RestAPIException(String.format("IaaS providers not found in cartridge: [cartridge-uuid] %s " +
- "[cartridge-type] %s [tenant-id] %d", existingCartridge.getUuid(), cartridgeBean.getType(),
- existingCartridge.getTenantId()));
+ throw new RestAPIException(String.format("IaaS providers not found in cartridge: [tenant-id] %d " +
+ "[cartridge-uuid] %s [cartridge-type] %s ", existingCartridge.getTenantId(),
+ existingCartridge.getUuid(), cartridgeBean.getType()));
}
-
cloudControllerServiceClient.updateCartridge(cartridgeConfig);
if (log.isDebugEnabled()) {
- log.debug(String.format("Successfully updated cartridge: [cartridge-uuid] %s [cartridge-type] %s " +
- "[tenant-id] %d", existingCartridge.getUuid(), cartridgeBean.getType(),
- existingCartridge.getTenantId()));
+ log.debug(String.format("Successfully updated cartridge: [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s", existingCartridge.getTenantId(), existingCartridge.getUuid(),
+ cartridgeBean.getType()));
}
} catch (CloudControllerServiceCartridgeDefinitionNotExistsExceptionException e) {
String msg = "Could not add cartridge";
@@ -251,8 +250,9 @@ public class StratosApiV41Utils {
throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
}
if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
- throw new RestAPIException(String.format("Category is not specified in cartridge: [cartridge-uuid] %s " +
- "[cartridge-type] %s [tenant-id] %d", cartridgeConfig.getUuid(), cartridgeConfig.getType(),cartridgeConfig.getTenantId()));
+ throw new RestAPIException(String.format("Category is not specified in cartridge: [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s ", cartridgeConfig.getTenantId(), cartridgeConfig.getUuid(),
+ cartridgeConfig.getType()));
}
return cartridgeConfig;
}
@@ -263,7 +263,7 @@ public class StratosApiV41Utils {
* @param cartridgeType Cartridge Type
* @throws RestAPIException
*/
- public static void removeCartridge(String cartridgeType,int tenantId) throws RestAPIException, RemoteException,
+ public static void removeCartridge(String cartridgeType, int tenantId) throws RestAPIException, RemoteException,
CloudControllerServiceCartridgeNotFoundExceptionException,
CloudControllerServiceInvalidCartridgeTypeExceptionException {
@@ -271,11 +271,10 @@ public class StratosApiV41Utils {
Cartridge cartridge= cloudControllerServiceClient.getCartridgeByTenant(cartridgeType, tenantId);
if (log.isDebugEnabled()) {
- log.debug(String.format("Removing cartridge: [cartridge-uuid] %s [cartridge-type] %s [tenant-id] %d",
- cartridge.getUuid(), cartridgeType, tenantId));
+ log.debug(String.format("Removing cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s ",
+ tenantId, cartridge.getUuid(), cartridgeType));
}
-
if (cartridge== null) {
throw new RuntimeException(String.format("Cartridge not found: [cartridge-type] %s in tenant: " +
"[tenant-id] %s", cartridgeType, tenantId));
@@ -285,17 +284,17 @@ public class StratosApiV41Utils {
// Validate whether cartridge can be removed
if (!smServiceClient.canCartridgeBeRemoved(cartridge.getUuid())) {
- String message = String.format("Cannot remove cartridge : [cartridge-uuid] %s [cartridge-type] %s " +
- "[tenant-id] %d since it is used in another cartridge group or an application",
- cartridge.getUuid(), cartridgeType, tenantId);
+ String message = String.format("Cannot remove cartridge : [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s since it is used in another cartridge group or an application",
+ tenantId, cartridge.getUuid(), cartridgeType);
log.error(message);
throw new RestAPIException(message);
}
cloudControllerServiceClient.removeCartridge(cartridge.getUuid());
if (log.isInfoEnabled()) {
- log.info(String.format("Successfully removed cartridge: [cartridge-uuid] %s [cartridge-type] %s from " +
- "tenant: [tenant-id] %s", cartridge.getUuid(), cartridgeType, tenantId));
+ log.info(String.format("Successfully removed cartridge: [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s from tenant: ", tenantId, cartridge.getUuid(), cartridgeType));
}
}
@@ -399,8 +398,8 @@ public class StratosApiV41Utils {
if (cartridgeInfo == null) {
// This cannot happen. But continue
if (log.isDebugEnabled()) {
- log.debug(String.format("Cartridge Info not found: [cartridge-type] %s in the tenant: " +
- "[tenant-id] %s", cartridgeType, tenantId));
+ log.debug(String.format("Cartridge Info not found: [tenant-id] %d [cartridge-type] %s",
+ tenantId, cartridgeType));
}
continue;
}
@@ -679,8 +678,8 @@ public class StratosApiV41Utils {
AutoscalerServiceInvalidPolicyExceptionException,
AutoscalerServiceAutoScalingPolicyAlreadyExistExceptionException {
- log.info(String.format("Adding autoscaling policy: [autoscaling-policy-uuid] %s [autoscaling-policy-id] %s",
- autoscalingPolicyUuid, autoscalePolicyBean.getId()));
+ log.info(String.format("Adding autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] %s " +
+ "[autoscaling-policy-id] %s", tenantId, autoscalingPolicyUuid, autoscalePolicyBean.getId()));
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
if (autoscalerServiceClient != null) {
@@ -890,8 +889,6 @@ public class StratosApiV41Utils {
public static void updateAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException,
AutoscalerServiceInvalidPolicyExceptionException {
- log.info(String.format("Updating autoscaling policy: [autoscaling-policy-id] %s", autoscalePolicyBean.getId()));
-
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
if (autoscalerServiceClient != null) {
try {
@@ -899,6 +896,9 @@ public class StratosApiV41Utils {
String autoscalerUuid = autoscalerServiceClient
.getAutoScalePolicyForTenant(autoscalePolicyBean.getId(), carbonContext.getTenantId())
.getUuid();
+ log.debug(String.format("Updating autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] %s " +
+ "[autoscaling-policy-id] %s", carbonContext.getTenantId(), autoscalerUuid,
+ autoscalePolicyBean.getId()));
org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy =
ObjectConverter.convertToCCAutoscalerPojo(autoscalePolicyBean, autoscalerUuid,
carbonContext.getTenantId());
@@ -920,15 +920,16 @@ public class StratosApiV41Utils {
AutoscalerServicePolicyDoesNotExistExceptionException,
AutoscalerServiceUnremovablePolicyExceptionException {
- log.info(String.format("Removing autoscaling policy: [autoscaling-policy-uuid] [autoscaling-policy-id] %s",
- autoscalePolicyId));
-
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
if (autoscalerServiceClient != null) {
AutoscalePolicy autoscalePolicyBean;
try {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- autoscalePolicyBean =autoscalerServiceClient.getAutoScalePolicyForTenant(autoscalePolicyId,carbonContext.getTenantId());
+ autoscalePolicyBean =autoscalerServiceClient.getAutoScalePolicyForTenant(autoscalePolicyId,
+ carbonContext.getTenantId());
+ log.debug(String.format("Removing autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] %s " +
+ "[autoscaling-policy-id] %s", autoscalePolicyBean.getTenantId(),
+ autoscalePolicyBean.getUuid(), autoscalePolicyId));
autoscalerServiceClient.removeAutoscalingPolicy(autoscalePolicyBean.getUuid());
} catch (RemoteException e) {
log.error(e.getMessage(), e);
@@ -1030,7 +1031,8 @@ public class StratosApiV41Utils {
String[] cartridgeGroupNames;
if (log.isDebugEnabled()) {
- log.debug("Checking cartridges in cartridge group " + cartridgeGroupUuid);
+ log.debug(String.format("Checking cartridges in cartridge group [tenant-id] %d [cartridge-group-uuid] %s " +
+ "[cartridge-group-name] %s", tenantId, cartridgeGroupUuid, serviceGroupDefinition.getName()));
}
ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup
@@ -1050,7 +1052,9 @@ public class StratosApiV41Utils {
try {
validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
} catch (RemoteException e) {
- String message = "Error while validating group duplications in cartridge group: " + cartridgeGroupUuid;
+ String message = String.format("Error while validating group duplications in cartridge group: [tenant-id]" +
+ " %d [cartridge-group-uuid] %s [cartridge-group-name] %s", tenantId, cartridgeGroupUuid,
+ serviceGroupDefinition.getName());
log.error(message, e);
throw new RestAPIException(message, e);
}
@@ -1065,7 +1069,9 @@ public class StratosApiV41Utils {
// if any sub groups are specified in the group, they should be already deployed
if (serviceGroupDefinition.getGroups() != null) {
if (log.isDebugEnabled()) {
- log.debug("checking subGroups in cartridge group " + cartridgeGroupUuid);
+ log.debug(String.format("checking subGroups in cartridge group: [tenant-id] %d [cartridge-group-uuid]" +
+ " %s [cartridge-group-name] %s", tenantId, cartridgeGroupUuid,
+ serviceGroupDefinition.getName()));
}
List<CartridgeGroupBean> groupDefinitions = serviceGroupDefinition.getGroups();
@@ -1099,9 +1105,8 @@ public class StratosApiV41Utils {
StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroup.getUuid(), cartridgeUuids);
} catch (RemoteException e) {
-
- String message = String.format("Could not add the cartridge group: [cartridge-group-id] %s " +
- "[cartridge-group-name] %s ", serviceGroup.getUuid(), serviceGroupDefinition.getName());
+ String message = String.format("Could not add the cartridge group: [cartridge-group-name] %s ",
+ serviceGroupDefinition.getName());
log.error(message, e);
throw new RestAPIException(message, e);
}
@@ -1305,20 +1310,23 @@ public class StratosApiV41Utils {
* @param name Group Name
* @throws RestAPIException
*/
- public static void removeServiceGroup(String name,int tenantId) throws RestAPIException, AutoscalerServiceCartridgeGroupNotFoundExceptionException, CloudControllerServiceCartridgeNotFoundExceptionException {
+ public static void removeServiceGroup(String name, int tenantId) throws RestAPIException,
+ AutoscalerServiceCartridgeGroupNotFoundExceptionException, CloudControllerServiceCartridgeNotFoundExceptionException {
AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Removing cartridge group: [cartridge-group-name] %s [tenant-id] %d " ,name,tenantId));
- }
String serviceGroupUuid;
// Check whether cartridge group exists
try {
ServiceGroup serviceGroup = asServiceClient.getServiceGroupByTenant(name, tenantId);
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Removing cartridge group: [tenant-id] %d [cartridge-group-uuid] %s " +
+ "[cartridge-group-name] %s", tenantId, serviceGroup.getUuid(), name));
+ }
+
if (serviceGroup == null) {
String message = "Cartridge group: [cartridge-group-name] " + name + " cannot be removed since it " +
"does not exist in tenant " + tenantId;
@@ -1328,8 +1336,8 @@ public class StratosApiV41Utils {
// Validate whether cartridge group can be removed
if (!smServiceClient.canCartirdgeGroupBeRemoved(serviceGroup.getUuid())) {
String message = String.format("Cannot remove cartridge group: [cartridge-group-uuid] %s [group-name]" +
- " %s since it is used in another cartridge group or an application in tenant %d", serviceGroup.getUuid(),
- serviceGroup.getName(),tenantId);
+ " %s since it is used in another cartridge group or an application in tenant %d",
+ serviceGroup.getUuid(), serviceGroup.getName(), tenantId);
log.error(message);
throw new RestAPIException(message);
}
@@ -1349,9 +1357,8 @@ public class StratosApiV41Utils {
throw new RestAPIException("Could not remove cartridge groups", e);
}
-
- log.info(String.format("Successfully removed the cartridge group: [cartridge-group-uuid] %s " +
- "[cartridge-group-name] %s" , serviceGroupUuid, name));
+ log.info(String.format("Successfully removed the cartridge group: [tenant-id] %d [cartridge-group-uuid] %s " +
+ "[cartridge-group-name] %s", tenantId, serviceGroupUuid, name));
}
/**
@@ -1387,7 +1394,7 @@ public class StratosApiV41Utils {
}
/**
- * Find Cartrides in GroupBean
+ * Find Cartridges in GroupBean
*
* @param groupBean groupBean
* @param cartridges List of cartridges
@@ -1794,8 +1801,8 @@ public class StratosApiV41Utils {
ApplicationContext application = autoscalerServiceClient.getApplicationByTenant(applicationId, tenantId);
if (log.isInfoEnabled()) {
- log.info(String.format("Starting to deploy application: [application-uuid] %s [application-id] %s",
- application.getApplicationUuid(), applicationId));
+ log.info(String.format("Starting to deploy application: [tenant-id] %d [application-uuid] %s " +
+ "[application-id] %s", tenantId, application.getApplicationUuid(), applicationId));
}
if (application == null) {
@@ -1889,8 +1896,9 @@ public class StratosApiV41Utils {
ApplicationContext asApplication = asServiceClient.getApplicationByTenant(applicationId,
carbonContext.getTenantId());
- log.info(String.format("Starting to remove application: [application-uuid %s [application-id] %s",
- asApplication.getApplicationUuid(), applicationId));
+ log.info(String.format("Starting to remove application: [tenant-id] %d [application-uuid %s " +
+ "[application-id] %s", carbonContext.getTenantId(), asApplication.getApplicationUuid(),
+ applicationId));
ApplicationBean application = ObjectConverter.convertStubApplicationContextToApplicationDefinition(
asApplication);
@@ -2529,14 +2537,14 @@ public class StratosApiV41Utils {
serviceClient.addApplicationSignUp(applicationSignUp);
if (log.isInfoEnabled()) {
- log.info(String.format("Application signup added successfully: [application-id]" +
- " %s [tenant-id] %d", applicationId, tenantId));
+ log.info(String.format("Application signup added successfully: [tenant-id] %d [application-id] %s ",
+ tenantId, applicationId));
}
serviceClient.notifyArtifactUpdatedEventForSignUp(applicationId, tenantId);
if (log.isInfoEnabled()) {
- log.info(String.format("Artifact updated event sent: [application-id] %s " +
- "[tenant-id] %d", applicationId, tenantId));
+ log.info(String.format("Artifact updated event sent: [tenant-id] %d [application-id] %s", tenantId,
+ applicationId));
}
} catch (Exception e) {
String message = String.format("Error in applicationBean signup: [application-id] %s", applicationId);
@@ -2952,9 +2960,9 @@ public class StratosApiV41Utils {
serviceClient.updateNetworkPartition(ObjectConverter.
convertNetworkPartitionToCCStubNetworkPartition(networkPartitionBean, networkPartition.getUuid(),
networkPartition.getTenantId()));
- log.debug(String.format("Updating network partition: [network-partition-uuid] %s, " +
- "[network-partition-id] %s, [tenant-id] %d", networkPartition.getUuid(), networkPartition.getId(),
- networkPartition.getTenantId()));
+ log.debug(String.format("Updating network partition: [tenant-id] %d [network-partition-uuid] %s, " +
+ "[network-partition-id] %s", networkPartition.getTenantId(), networkPartition.getUuid(),
+ networkPartition.getId()));
} catch (RemoteException e) {
String message = e.getMessage();
log.error(message);
@@ -2973,8 +2981,9 @@ public class StratosApiV41Utils {
AutoscalerServiceInvalidDeploymentPolicyExceptionException {
try {
if (log.isDebugEnabled()) {
- log.debug(String.format("Adding deployment policy: [deployment-policy-uuid] %s [deployment-policy-id]" +
- " %s ", deploymentPolicyUuid, deploymentPolicyDefinitionBean.getId()));
+ log.debug(String.format("Adding deployment policy: [tenant-id] %d [deployment-policy-uuid] %s " +
+ "[deployment-policy-id]" +
+ " %s ", tenantId, deploymentPolicyUuid, deploymentPolicyDefinitionBean.getId()));
}
NetworkPartitionBean[] networkPartitions = getNetworkPartitions();
@@ -3011,8 +3020,8 @@ public class StratosApiV41Utils {
deploymentPolicyUuid, tenantId));
if (log.isDebugEnabled()) {
- log.debug(String.format("Successfully added deploymentPolicy: [deployment-policy-uuid] %s " +
- "[deployment-policy-id] %s", deploymentPolicyUuid,
+ log.debug(String.format("Successfully added deploymentPolicy: [tenant-id] %d [deployment-policy-uuid]" +
+ " %s [deployment-policy-id] %s", tenantId, deploymentPolicyUuid,
deploymentPolicyDefinitionBean.getId()));
}
} catch (RemoteException e) {
@@ -3091,7 +3100,7 @@ public class StratosApiV41Utils {
.getNetworkPartitionByTenant(networkPartitionReferenceBean.getId(), tenantId);
if (networkPartition == null) {
- String message = String.format("Network partition not found: for [deployment-policy-id] %s" +
+ String message = String.format("Network partition not found: [deployment-policy-id] %s" +
"[network-partition-id] %s" , deploymentPolicyDefinitionBean.getId(),
networkPartitionReferenceBean.getId());
throw new RestAPIException(message);
@@ -3118,8 +3127,8 @@ public class StratosApiV41Utils {
DeploymentPolicy deploymentPolicy = serviceClient.getDeploymentPolicyByTenant
(deploymentPolicyDefinitionBean.getId(), carbonContext.getTenantId());
if (log.isDebugEnabled()) {
- log.debug(String.format("Updating deployment policy: [deployment-policy-uuid] %s " +
- "[deployment-policy-id] %s ", deploymentPolicy.getUuid(),
+ log.debug(String.format("Updating deployment policy: [tenant-id] %d [deployment-policy-uuid] %s " +
+ "[deployment-policy-id] %s ", tenantId, deploymentPolicy.getUuid(),
deploymentPolicyDefinitionBean.getId()));
}
AutoscalerServiceClient.getInstance().updateDeploymentPolicy(ObjectConverter
@@ -3127,9 +3136,9 @@ public class StratosApiV41Utils {
deploymentPolicy.getUuid(), carbonContext.getTenantId()));
if (log.isDebugEnabled()) {
- log.debug(String.format("DeploymentPolicy updated successfully : [deployment-policy-uuid] %s " +
- "[deployment-policy-id] %s ", deploymentPolicy.getUuid(),
- deploymentPolicyDefinitionBean.getId()));
+ log.debug(String.format("DeploymentPolicy updated successfully : [tenant-id] " +
+ "%d [deployment-policy-uuid] %s [deployment-policy-id] %s ", tenantId,
+ deploymentPolicy.getUuid(), deploymentPolicyDefinitionBean.getId()));
}
} catch (RemoteException e) {
@@ -3744,21 +3753,21 @@ public class StratosApiV41Utils {
/**
* This method is to validate the duplication of cartridges from the given list
*
- * @param cartridges - list of strings which holds the cartridgeTypes values
+ * @param cartridgeNames - list of strings which holds the cartridgeTypes values
* @throws InvalidCartridgeGroupDefinitionException - throws when the cartridges are duplicated
*/
- private static void validateCartridgeDuplicationInGroup(List<String> cartridges)
+ private static void validateCartridgeDuplicationInGroup(List<String> cartridgeNames)
throws InvalidCartridgeGroupDefinitionException {
List<String> checkList = new ArrayList<String>();
- for (String cartridge : cartridges) {
- if (!checkList.contains(cartridge)) {
- checkList.add(cartridge);
+ for (String cartridgeName : cartridgeNames) {
+ if (!checkList.contains(cartridgeName)) {
+ checkList.add(cartridgeName);
} else {
if (log.isDebugEnabled()) {
- log.debug("Duplicate cartridges defined: " + cartridge);
+ log.debug("Duplicate cartridges defined: " + cartridgeName);
}
throw new InvalidCartridgeGroupDefinitionException("Invalid cartridge group definition, " +
- "duplicate cartridges defined: " + cartridge);
+ "duplicate cartridges defined: " + cartridgeName);
}
}
}
[2/2] stratos git commit: Merge branch 'tenant-isolation-v1' of
https://github.com/dinithis/stratos into tenant-isolation
Posted by ga...@apache.org.
Merge branch 'tenant-isolation-v1' of https://github.com/dinithis/stratos into tenant-isolation
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/a709db52
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/a709db52
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/a709db52
Branch: refs/heads/tenant-isolation
Commit: a709db52381e873d80976b0bc292c2631c97833b
Parents: 4c94b48 5806387
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Wed Aug 12 13:55:33 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Wed Aug 12 13:55:33 2015 +0530
----------------------------------------------------------------------
.../rest/endpoint/api/StratosApiV41.java | 86 +++++-----
.../rest/endpoint/api/StratosApiV41Utils.java | 165 ++++++++++---------
2 files changed, 131 insertions(+), 120 deletions(-)
----------------------------------------------------------------------