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/09/01 14:29:42 UTC
[04/50] [abbrv] stratos git commit: Updating logs to display uuid and
tenantId
Updating logs to display uuid and tenantId
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/eb0d28f4
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/eb0d28f4
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/eb0d28f4
Branch: refs/heads/master
Commit: eb0d28f4e2bc6d86b4ce54124e9c40ac6a046722
Parents: b228f11
Author: Dinithi <di...@wso2.com>
Authored: Fri Aug 21 10:21:39 2015 +0530
Committer: Dinithi <di...@wso2.com>
Committed: Fri Aug 21 10:21:39 2015 +0530
----------------------------------------------------------------------
.../autoscaler/pojo/policy/PolicyManager.java | 105 +-
.../services/impl/AutoscalerServiceImpl.java | 102 +-
.../impl/CloudControllerServiceImpl.java | 219 ++--
.../rest/endpoint/api/StratosApiV41.java | 7 +-
.../rest/endpoint/api/StratosApiV41Utils.java | 8 +-
.../src/main/resources/AutoscalerService.wsdl | 396 +++----
.../main/resources/CloudControllerService.wsdl | 1044 +++++++++---------
7 files changed, 956 insertions(+), 925 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/eb0d28f4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
index 1d15c1b..957386b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
@@ -83,8 +83,9 @@ public class PolicyManager {
// Add the policy to information model and persist.
public boolean addAutoscalePolicy(AutoscalePolicy policy) throws AutoScalingPolicyAlreadyExistException {
if (log.isInfoEnabled()) {
- log.info(String.format("Adding autoscaling policy: [autoscaling policy-uuid] %s [autoscaling policy-id] " +
- "%s", policy.getUuid(), policy.getId()));
+ log.info(String.format("Adding autoscaling policy: [tenant-id] %d [autoscaling policy-uuid] %s " +
+ "[autoscaling policy-id] " +
+ "%s", policy.getTenantId(), policy.getUuid(), policy.getId()));
}
if (StringUtils.isEmpty(policy.getUuid())) {
throw new AutoScalerException("Autoscaling policy id cannot be empty");
@@ -92,9 +93,9 @@ public class PolicyManager {
this.addASPolicyToInformationModel(policy);
RegistryManager.getInstance().persistAutoscalerPolicy(policy);
if (log.isInfoEnabled()) {
- log.info(String.format("Autoscaling policy: [autoscaling-policy-uuid] %s [autoscaling-policy-id] %s added" +
- " successfully",
- policy.getUuid(), policy.getId()));
+ log.info(String.format("Autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] %s " +
+ "[autoscaling-policy-id] %s added successfully", policy.getTenantId(), policy.getUuid(),
+ policy.getId()));
}
return true;
}
@@ -106,8 +107,8 @@ public class PolicyManager {
this.updateASPolicyInInformationModel(policy);
RegistryManager.getInstance().persistAutoscalerPolicy(policy);
if (log.isInfoEnabled()) {
- log.info(String.format("Autoscaling policy updated successfully: [autoscaling policy-uuid] %s " +
- "[autoscaling policy-id] %s", policy.getUuid(), policy.getId()));
+ log.info(String.format("Autoscaling policy updated successfully: [tenant-id] %d [autoscaling policy-uuid]" +
+ " %s [autoscaling policy-id] %s", policy.getTenantId(), policy.getUuid(), policy.getId()));
}
return true;
}
@@ -136,8 +137,8 @@ public class PolicyManager {
RegistryManager.getInstance().persistDeploymentPolicy(policy);
if (log.isInfoEnabled()) {
- log.info(String.format("Deployment policy is added successfully: [deployment-policy-id] %s",
- policy.getUuid()));
+ log.info(String.format("Deployment policy added successfully: [tenant-id] %d [deployment-policy-uuid] %s " +
+ "[deployment-policy-id] %s", policy.getTenantId(), policy.getUuid(), policy.getId()));
}
}
@@ -151,12 +152,15 @@ public class PolicyManager {
throws InvalidDeploymentPolicyException {
if (!deploymentPolicyListMap.containsKey(deploymentPolicy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Adding deployment policy: " + deploymentPolicy.getUuid());
+ log.debug(String.format("Adding deployment policy [tenant-id] %d [deployment-policy-uuid] %s " +
+ "deployment-policy-id] %s: ", deploymentPolicy.getTenantId(),
+ deploymentPolicy.getUuid(), deploymentPolicy.getId()));
}
deploymentPolicyListMap.put(deploymentPolicy.getUuid(), deploymentPolicy);
} else {
- String errMsg = "Specified deployment policy [" +
- deploymentPolicy.getUuid() + "] already exists";
+ String errMsg = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid] " +
+ "%s [deployment-policy-id] %s", deploymentPolicy.getTenantId(),
+ deploymentPolicy.getUuid(), deploymentPolicy.getId());
log.error(errMsg);
throw new InvalidDeploymentPolicyException(errMsg);
}
@@ -169,7 +173,9 @@ public class PolicyManager {
this.updateDeploymentPolicyInInformationModel(policy);
RegistryManager.getInstance().persistDeploymentPolicy(policy);
if (log.isInfoEnabled()) {
- log.info(String.format("Deployment policy is updated successfully: [id] %s", policy.getUuid()));
+ log.info(String.format("Deployment policy updated successfully: [tenant-id] %d [deployment-policy-uuid] " +
+ "%s [deployment-policy-id] %s", policy.getTenantId(),
+ policy.getUuid(), policy.getId()));
}
return true;
}
@@ -185,7 +191,7 @@ public class PolicyManager {
RegistryManager.getInstance().removeDeploymentPolicy(deploymentPolicyId);
if (log.isInfoEnabled()) {
- log.info(String.format("Deployment policy is removed successfully: [deployment-policy-id] %s",
+ log.info(String.format("Deployment policy removed successfully: [deployment-policy-id] %s",
deploymentPolicyId));
}
}
@@ -193,11 +199,15 @@ public class PolicyManager {
public void addASPolicyToInformationModel(AutoscalePolicy asPolicy) throws AutoScalingPolicyAlreadyExistException {
if (!autoscalePolicyListMap.containsKey(asPolicy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Adding autoscaling policy: " + asPolicy.getUuid());
+ log.debug(String.format("Adding autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] " +
+ "%s " +
+ "[autoscaling-policy-id] %s", asPolicy.getTenantId(), asPolicy.getUuid(), asPolicy.getId()));
}
autoscalePolicyListMap.put(asPolicy.getUuid(), asPolicy);
} else {
- String errMsg = "Specified autoscaling policy [" + asPolicy.getUuid() + "] already exists";
+ String errMsg = String.format("Specified autoscaling policy already exists: [tenant-id] %d " +
+ "[autoscaling-policy-uuid] %s [autoscaling-policy-id] %s", asPolicy.getTenantId(),
+ asPolicy.getUuid(), asPolicy.getId());
log.error(errMsg);
throw new AutoScalingPolicyAlreadyExistException(errMsg);
}
@@ -206,7 +216,9 @@ public class PolicyManager {
public void updateASPolicyInInformationModel(AutoscalePolicy asPolicy) throws InvalidPolicyException {
if (autoscalePolicyListMap.containsKey(asPolicy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Updating autoscaling policy: " + asPolicy.getUuid());
+ log.debug(String.format("Updating autoscaling policy: [tenant-id] %d [autoscaling-policy-uuid] %s " +
+ "[autoscaling-policy-id] %s", asPolicy.getTenantId(), asPolicy.getUuid(),
+ asPolicy.getId()));
}
autoscalePolicyListMap.put(asPolicy.getUuid(), asPolicy);
}
@@ -215,20 +227,22 @@ public class PolicyManager {
public void updateDeploymentPolicyInInformationModel(DeploymentPolicy deploymentPolicy) throws InvalidPolicyException {
if (deploymentPolicyListMap.containsKey(deploymentPolicy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Updating deployment policy: " + deploymentPolicy.getUuid());
+ log.debug(String.format("Updating deployment policy: [tenant-id] %d [deployment-policy-uuid] " +
+ "%s [deployment-policy-id] %s", deploymentPolicy.getTenantId(),
+ deploymentPolicy.getUuid(), deploymentPolicy.getId()));
}
deploymentPolicyListMap.put(deploymentPolicy.getUuid(), deploymentPolicy);
}
}
- public void removeASPolicyInInformationModel(String policyID) throws PolicyDoesNotExistException {
- if (autoscalePolicyListMap.containsKey(policyID)) {
+ public void removeASPolicyInInformationModel(String policyId) throws PolicyDoesNotExistException {
+ if (autoscalePolicyListMap.containsKey(policyId)) {
if (log.isDebugEnabled()) {
- log.debug("Updating autoscaling policy: " + policyID);
+ log.debug("Removing autoscaling policy: [autoscaling-policy-id] " + policyId);
}
- autoscalePolicyListMap.remove(policyID);
+ autoscalePolicyListMap.remove(policyId);
} else {
- throw new PolicyDoesNotExistException("No such policy ID [" + policyID + "] exists");
+ throw new PolicyDoesNotExistException("No such policy exists: [autoscaling-policy-id] " + policyId);
}
}
@@ -239,7 +253,8 @@ public class PolicyManager {
}
applicationPolicyListMap.remove(applicationPolicyId);
} else {
- throw new InvalidPolicyException(String.format("Application policy not found: [application-policy-id] %s", applicationPolicyId));
+ throw new InvalidPolicyException(String.format("Application policy not found: [application-policy-id] " +
+ "%s", applicationPolicyId));
}
}
@@ -303,11 +318,13 @@ public class PolicyManager {
}
if (!deploymentPolicyListMap.containsKey(policy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Adding deployment policy: [deployment-policy-id] " + policy.getUuid());
+ log.debug(String.format("Adding deployment policy: [tenant-id] %d [deployment-policy-uuid] %s " +
+ "[deployment-policy-id] %s ", policy.getTenantId(), policy.getUuid(), policy.getId()));
}
deploymentPolicyListMap.put(policy.getUuid(), policy);
} else {
- String errMsg = "Deployment policy already exists: [deployment-policy-id] " + policy.getUuid();
+ String errMsg = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid] " +
+ "%s [deployment-policy-id] %s ", policy.getTenantId(), policy.getUuid(), policy.getId());
log.error(errMsg);
}
}
@@ -383,20 +400,21 @@ public class PolicyManager {
return deploymentPolicy;
}
-
public void addApplicationPolicy(ApplicationPolicy applicationPolicy) throws InvalidApplicationPolicyException {
- String applicationPolicyId = applicationPolicy.getUuid();
+ String applicationPolicyUuid = applicationPolicy.getUuid();
if (log.isInfoEnabled()) {
- log.info(String.format("Adding application policy : [application-policy-id] %s", applicationPolicyId));
+ log.info(String.format("Adding application policy : [tenant-id] %d [application-policy-uuid] %s " +
+ "[application-policy-id] %s", applicationPolicy.getTenantId(), applicationPolicyUuid,
+ applicationPolicy.getId()));
}
this.addApplicationPolicyToInformationModel(applicationPolicy);
RegistryManager.getInstance().persistApplicationPolicy(applicationPolicy);
if (log.isInfoEnabled()) {
- log.info(String.format("Application policy is added successfully: [application-policy-id] %s",
- applicationPolicyId));
+ log.info(String.format("Application policy added successfully: [tenant-id] %d [application-policy-uuid] %s " +
+ "[application-policy-id] %s", applicationPolicy.getTenantId(), applicationPolicyUuid,
+ applicationPolicy.getId()));
}
-
}
public boolean removeApplicationPolicy(String applicationPolicyId) throws InvalidPolicyException {
@@ -406,21 +424,26 @@ public class PolicyManager {
this.removeApplicationPolicyInInformationModel(applicationPolicyId);
RegistryManager.getInstance().removeApplicationPolicy(applicationPolicyId);
if (log.isInfoEnabled()) {
- log.info(String.format("Application policy is removed successfully: [id] %s", applicationPolicyId));
+ log.info(String.format("Application policy removed successfully: [application-policy-id] %s",
+ applicationPolicyId));
}
return true;
}
public void addApplicationPolicyToInformationModel(ApplicationPolicy applicationPolicy)
throws InvalidApplicationPolicyException {
- String applicationPolicyId = applicationPolicy.getUuid();
- if (!applicationPolicyListMap.containsKey(applicationPolicyId)) {
+ String applicationPolicyUuid = applicationPolicy.getUuid();
+ if (!applicationPolicyListMap.containsKey(applicationPolicyUuid)) {
if (log.isDebugEnabled()) {
- log.debug("Adding application policy : " + applicationPolicyId);
+ log.debug(String.format("Adding application policy: [tenant-id] %d [application-policy-uuid] %s " +
+ "[application-policy-id] %s", applicationPolicy.getTenantId(), applicationPolicyUuid,
+ applicationPolicy.getId()));
}
- applicationPolicyListMap.put(applicationPolicyId, applicationPolicy);
+ applicationPolicyListMap.put(applicationPolicyUuid, applicationPolicy);
} else {
- String errMsg = "Application policy already exists : " + applicationPolicyId;
+ String errMsg = String.format("Application policy already exists : [tenant-id] %d " +
+ "[application-policy-uuid] %s [application-policy-id] %s",
+ applicationPolicy.getTenantId(), applicationPolicyUuid, applicationPolicy.getId());
log.error(errMsg);
throw new InvalidApplicationPolicyException(errMsg);
}
@@ -456,7 +479,9 @@ public class PolicyManager {
public void updateApplicationPolicyInInformationModel(ApplicationPolicy applicationPolicy) {
if (applicationPolicyListMap.containsKey(applicationPolicy.getUuid())) {
if (log.isDebugEnabled()) {
- log.debug("Updating application policy: " + applicationPolicy.getUuid());
+ log.debug(String.format("Updating application policy: [tenant-id] %d [application-policy-uuid] %s " +
+ "[application-policy-id] %s", applicationPolicy.getTenantId(), applicationPolicy.getUuid(),
+ applicationPolicy.getId()));
}
applicationPolicyListMap.put(applicationPolicy.getUuid(), applicationPolicy);
}
@@ -469,7 +494,7 @@ public class PolicyManager {
this.updateApplicationPolicyInInformationModel(applicationPolicy);
RegistryManager.getInstance().persistApplicationPolicy(applicationPolicy);
if (log.isInfoEnabled()) {
- log.info(String.format("Application policy is updated successfully: [id] %s", applicationPolicy.getUuid()));
+ log.info(String.format("Application policyupdated successfully: [id] %s", applicationPolicy.getUuid()));
}
return true;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/eb0d28f4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index db9a305..e5fd50d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -109,12 +109,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String autoscalePolicyId = autoscalePolicy.getId();
if (PolicyManager.getInstance().getAutoscalePolicyById(autoscalePolicyId) != null && PolicyManager
.getInstance().getAutoscalePolicyById(autoscalePolicyId).getTenantId() == autoscalePolicy.getTenantId()) {
- String logMessage = String.format("Autoscaling policy already exists: [tenant-id] %d " +
+ String message = String.format("Autoscaling policy already exists: [tenant-id] %d " +
"[autoscaling-policy-uuid] %s [autoscaling-policy-id] %s", autoscalePolicy.getTenantId(),
autoscalePolicy.getUuid(), autoscalePolicyId);
- String message = String.format("Autoscaling policy already exists: [autoscaling-policy-id] %s",
- autoscalePolicyId);
- log.error(logMessage);
+ log.error(message);
throw new AutoScalingPolicyAlreadyExistException(message);
}
return PolicyManager.getInstance().addAutoscalePolicy(autoscalePolicy);
@@ -405,9 +403,8 @@ public class AutoscalerServiceImpl implements AutoscalerService {
applicationContext.setStatus(ApplicationContext.STATUS_CREATED);
AutoscalerContext.getInstance().updateApplicationContext(applicationContext);
}
- String logMessage = String.format("Application deployment failed: [application-uuid] %s ", applicationUuid);
- String message = String.format("Application deployment failed: [application-id] %s", applicationUuid);
- log.error(logMessage, e);
+ String message = String.format("Application deployment failed: [application-uuid] %s ", applicationUuid);
+ log.error(message, e);
throw new RuntimeException(message, e);
}
}
@@ -650,11 +647,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
}
if (!applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
- String logMessage = String.format("Application is not deployed: [tenant-id] %d " +
+ String message = String.format("Application is not deployed: [tenant-id] %d " +
"[application-uuid] %s [application-id] %s", applicationContext.getTenantId(),
applicationContext.getApplicationUuid(), applicationId);
- String message = String.format("Application is not deployed: [application-id] %s", applicationId);
- log.error(logMessage);
+ log.error(message);
throw new RuntimeException(message);
}
applicationContext.setStatus(ApplicationContext.STATUS_UNDEPLOYING);
@@ -697,12 +693,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
}
if (application.getInstanceContextCount() > 0) {
- String logMessage = String.format("Application cannot be deleted, undeployment process is still in " +
+ String message = String.format("Application cannot be deleted, undeployment process is still in " +
"progress: [tenant-id] %d [application-uuid] %s [application-id] %s",
applicationContext.getTenantId(), applicationContext.getApplicationUuid(), applicationId);
- String message = String.format("Application cannot be deleted, undeployment process is still in " +
- "progress: [application-id] %s", applicationId);
- log.error(logMessage);
+ log.error(message);
throw new RuntimeException(message);
}
@@ -1026,11 +1020,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
boolean isExist = PolicyManager.getInstance().checkApplicationPolicyInTenant
(applicationPolicy.getId(), applicationPolicy.getTenantId());
if (isExist) {
- String message = "Application policy already exists: [application-policy-id] " + applicationPolicyId;
- String logMessage = String.format("Application policy already exists: [tenant-id] %d " +
+ String message = String.format("Application policy already exists: [tenant-id] %d " +
"[application-policy-uuid] %s [application-policy-id] %s", applicationPolicy.getTenantId(),
applicationPolicy.getUuid(), applicationPolicy.getId());
- log.error(logMessage);
+ log.error(message);
throw new ApplicationPolicyAlreadyExistsException(message);
}
@@ -1038,11 +1031,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
if (PolicyManager.getInstance().getApplicationPolicyByUuid(applicationPolicyUuid) != null && PolicyManager
.getInstance().getApplicationPolicyByUuid(applicationPolicyUuid).getTenantId() == applicationPolicy
.getTenantId()) {
- String message = "Application policy already exists: [application-policy-id] " + applicationPolicyId;
- String logMessage = String.format("Application policy already exists: [tenant-id] %d " +
+ String message = String.format("Application policy already exists: [tenant-id] %d " +
"[application-policy-uuid] %s [application-policy-id] %s", applicationPolicy.getTenantId(),
applicationPolicy.getUuid(), applicationPolicy.getId());
- log.error(logMessage);
+ log.error(message);
throw new ApplicationPolicyAlreadyExistsException(message);
}
@@ -1163,15 +1155,12 @@ public class AutoscalerServiceImpl implements AutoscalerService {
if (networkPartitions != null) {
for (int i = 0; i < networkPartitions.length; i++) {
if (networkPartitions[i].equals(networkPartitionId)) {
- String logMessage = String.format("Cannot remove the network partition since it is used" +
+ String message = String.format("Cannot remove the network partition since it is used" +
" in application: [tenant-id] %d [network-partition-id] %s " +
"[application-uuid] %s [application-id] %s", tenantId,
networkPartitionId, applicationContext.getApplicationUuid(),
applicationContext.getApplicationId());
- String message = String.format("Cannot remove the network partition since it is " +
- "used in application: [network-partition-id] %s [application-id] %s",
- networkPartitionId, applicationContext.getApplicationId());
- log.error(logMessage);
+ log.error(message);
throw new PartitionValidationException(message);
}
}
@@ -1272,24 +1261,20 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String deploymentPolicyUuid = deploymentPolicy.getUuid();
if (PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyUuid) != null) {
- String logMessage = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid]" +
+ String message = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid]" +
" %s [deployment-policy-id] %s ",deploymentPolicy.getTenantId(), deploymentPolicy.getUuid(),
deploymentPolicy.getId());
- String message = String.format("Deployment policy already exists: [deployment-policy-id] %s ",
- deploymentPolicy.getId());
- log.error(logMessage);
+ log.error(message);
throw new DeploymentPolicyAlreadyExistsException(message);
}
String deploymentPolicyId = deploymentPolicy.getId();
if (PolicyManager.getInstance().getDeploymentPolicyById(deploymentPolicyId) != null && PolicyManager
.getInstance().getDeploymentPolicyById(deploymentPolicyId).getTenantId() == deploymentPolicy.getTenantId()) {
- String logMessage = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid]" +
+ String message = String.format("Deployment policy already exists: [tenant-id] %d [deployment-policy-uuid]" +
" %s [deployment-policy-id] %s ",deploymentPolicy.getTenantId(), deploymentPolicy.getUuid(),
deploymentPolicy.getId());
- String message = String.format("Deployment policy already exists: [deployment-policy-id] %s ",
- deploymentPolicy.getId());
- log.error(logMessage);
+ log.error(message);
throw new DeploymentPolicyAlreadyExistsException(message);
}
@@ -1329,12 +1314,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
// deployment policy should contain at least one network partition reference
if (null == deploymentPolicy.getNetworkPartitionRefs() || deploymentPolicy.getNetworkPartitionRefs().length == 0) {
- String logMessage = String.format("Deployment policy does not have any network partition references: " +
+ String message = String.format("Deployment policy does not have any network partition references: " +
"[tenant-id] %d [deployment-policy-uuid] %s [deployment-policy-id] %s",
deploymentPolicy.getTenantId(), deploymentPolicyUuid, deploymentPolicyId);
- String message = String.format("Deployment policy does not have any network partition references: " +
- "[deployment-policy-id] %s", deploymentPolicyId);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
@@ -1344,12 +1327,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
//String networkPartitionUuid = networkPartitionRef.getUuid();
String networkPartitionId = networkPartitionRef.getId();
if (StringUtils.isBlank(networkPartitionId)) {
- String message = String.format("Network partition id is blank: [deployment-policy-id] %s",
- deploymentPolicyId);
- String logMessage = String.format("Network partition id is blank: [tenant-id] " +
+ String message = String.format("Network partition id is blank: [tenant-id] " +
"%d [deployment-policy-uuid] %s [deployment-policy-id] %s", deploymentPolicy.getTenantId(),
deploymentPolicyUuid, deploymentPolicyId);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
@@ -1365,12 +1346,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
}
}
if (networkPartitionForTenant == null) {
- String logMessage = String.format("Network partition not found: [tenant-id] %d " +
+ String message = String.format("Network partition not found: [tenant-id] %d " +
"[deployment-policy-uuid] %s [deployment-policy-id] %s [network-partition-id] %s",
deploymentPolicy.getTenantId(), deploymentPolicyUuid, deploymentPolicyId, networkPartitionId);
- String message = String.format("Network partition not found: [deployment-policy-id] %s " +
- "[network-partition-id] %s", deploymentPolicyId, networkPartitionId);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
@@ -1385,15 +1364,12 @@ public class AutoscalerServiceImpl implements AutoscalerService {
}
}
if (!isPartitionFound) {
- String logMessage = String.format("Partition not found: [tenant-id] " +
+ String message = String.format("Partition not found: [tenant-id] " +
"%d [deployment-policy-uuid] %s [deployment-policy-id] %s [network-partition-id] " +
"%s [network=partition-uuid] %s [partition-id] %s ",
deploymentPolicy.getTenantId(), deploymentPolicy.getUuid(), deploymentPolicyId,
networkPartitionRef.getUuid(), networkPartitionId, partitionRef.getId());
- String message = String.format("Partition not found: [deployment-policy-id] %s " +
- "[network-partition-id] %s [partition-id] %s ", deploymentPolicyId,
- networkPartitionId, partitionRef.getId());
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
}
@@ -1401,44 +1377,35 @@ public class AutoscalerServiceImpl implements AutoscalerService {
// partition algorithm can't be null or empty
String partitionAlgorithm = networkPartitionRef.getPartitionAlgo();
if (StringUtils.isBlank(partitionAlgorithm)) {
- String logMessage = String.format("Partition algorithm is blank: [tenant-id] %d " +
+ String message = String.format("Partition algorithm is blank: [tenant-id] %d " +
"[deployment-policy-uuid] %s [deployment-policy-id] %s [network-partition-uuid] %s " +
"[network-partition-id] %s [partition-algorithm] %s",
deploymentPolicy.getTenantId(), deploymentPolicyUuid, deploymentPolicyId,
networkPartitionRef.getUuid(), networkPartitionId, partitionAlgorithm);
- String message = String.format("Partition algorithm is blank: [deployment-policy-id] %s " +
- "[network-partition-id] %s [partition-algorithm] %s",
- deploymentPolicyId, networkPartitionId, partitionAlgorithm);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
// partition algorithm should be either one-after-another or round-robin
if ((!StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm))
&& (!StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm))) {
- String logMessage = String.format("Partition algorithm is not valid: [tenant-id] %d " +
+ String message = String.format("Partition algorithm is not valid: [tenant-id] %d " +
"[deployment-policy-uuid] %s [deployment-policy-id] %s [network-partition-uuid] %s " +
"[network-partition-id] %s [partition-algorithm] %s", deploymentPolicy.getTenantId(),
deploymentPolicyUuid, deploymentPolicyId, networkPartitionRef.getUuid(), networkPartitionId,
partitionAlgorithm);
- String message = String.format("Partition algorithm is not valid: [deployment-policy-id] %s " +
- "[network-partition-id] %s [partition-algorithm] %s",
- deploymentPolicyId, networkPartitionId, partitionAlgorithm);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
// a network partition reference should contain at least one partition reference
PartitionRef[] partitions = networkPartitionRef.getPartitionRefs();
if (null == partitions || partitions.length == 0) {
- String logMessage = String.format("Network partition does not have any partition references: " +
+ String message = String.format("Network partition does not have any partition references: " +
"[tenant-id] %d [deployment-policy-uuid] %s [deployment-policy-id] %s " +
"[network-partition-uuid] %s [network-partition-id] %s ", deploymentPolicy.getTenantId(),
deploymentPolicyUuid, deploymentPolicyId, networkPartitionRef.getUuid(), networkPartitionId);
- String message = String.format("Network partition does not have any partition references: " +
- "[deployment-policy-id] %s [network-partition-id] %s", deploymentPolicyId,
- networkPartitionId);
- log.error(logMessage);
+ log.error(message);
throw new InvalidDeploymentPolicyException(message);
}
}
@@ -1461,11 +1428,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String deploymentPolicyUuid = deploymentPolicy.getUuid();
if (PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyUuid) == null) {
- String logMessage = String.format("Deployment policy not exists: [tenant-id] %d [deployment-policy-uuid] " +
+ String message = String.format("Deployment policy not exists: [tenant-id] %d [deployment-policy-uuid] " +
"%s [deployment-policy-id] %s", deploymentPolicy.getTenantId(), deploymentPolicyUuid,
deploymentPolicy.getId());
- String message = "Deployment policy not exists: [deployment-policy-id] " + deploymentPolicy.getId();
- log.error(logMessage);
+ log.error(message);
throw new DeploymentPolicyNotExistsException(message);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/eb0d28f4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index 96bb38c..4c12f60 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -38,7 +38,6 @@ import org.apache.stratos.common.Property;
import org.apache.stratos.common.domain.LoadBalancingIPType;
import org.apache.stratos.common.threading.StratosThreadPool;
import org.apache.stratos.messaging.domain.topology.*;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
import java.net.MalformedURLException;
import java.net.URL;
@@ -63,7 +62,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
private CloudControllerContext cloudControllerContext = CloudControllerContext.getInstance();
private ExecutorService executorService;
- private int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
public CloudControllerServiceImpl() {
executorService = StratosThreadPool.getExecutorService("cloud.controller.instance.manager.thread.pool", 50);
@@ -77,9 +75,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
handleNullObject(cartridgeConfig.getUuid(), "Cartridge definition UUID is null");
if (log.isInfoEnabled()) {
- log.info(String.format("Adding cartridge: [cartridge-uuid] %s [cartridge-type] %s [tenant id] %d ",
- cartridgeConfig.getUuid(), cartridgeConfig.getType(),
- cartridgeConfig.getTenantId()));
+ log.info(String.format("Adding cartridge: [tenant id] %d [cartridge-uuid] %s [cartridge-type] %s ",
+ cartridgeConfig.getTenantId(), cartridgeConfig.getUuid(), cartridgeConfig.getType()));
}
if (log.isDebugEnabled()) {
log.debug("Cartridge definition: " + cartridgeConfig.toString());
@@ -88,9 +85,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
try {
CloudControllerUtil.extractIaaSProvidersFromCartridge(cartridgeConfig);
} catch (Exception e) {
- String message = String.format("Invalid cartridge definition: [cartridge-uuid] %s [cartridge-type] %s",
- " [tenant-id] ", cartridgeConfig.getUuid(), cartridgeConfig.getType(),
- cartridgeConfig.getTenantId());
+ String message = String.format("Invalid cartridge definition: " +
+ "[cartridge-type] %s", cartridgeConfig.getType());
log.error(message, e);
throw new InvalidCartridgeDefinitionException(message, e);
}
@@ -98,9 +94,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
String cartridgeUuid = cartridgeConfig.getUuid();
Cartridge existingCartridge = cloudControllerContext.getCartridge(cartridgeUuid);
if (existingCartridge != null) {
- String message = String.format(
- "Cartridge already exists: [cartridge-uuid] %s [cartridge-type] %s [tenant id] %d ", cartridgeUuid,
- existingCartridge.getType(), existingCartridge.getTenantId());
+ String message = String.format("Cartridge already exists: [tenant id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s ", existingCartridge.getTenantId(), cartridgeUuid,
+ existingCartridge.getType());
log.error(message);
throw new CartridgeAlreadyExistsException(message);
}
@@ -115,8 +111,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
TopologyBuilder.handleServiceCreated(cartridgeList);
if (log.isInfoEnabled()) {
- log.info(String.format("Successfully added cartridge: [cartridge-uuid] %s [cartridge-type] %s [tenant-id] %d ",
- cartridgeUuid, cartridgeConfig.getType(), cartridgeConfig.getTenantId()));
+ log.info(String.format("Successfully added cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type]" +
+ " %s", cartridgeConfig.getTenantId(), cartridgeUuid, cartridgeConfig.getType()));
}
return true;
}
@@ -129,7 +125,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
handleNullObject(cartridge, "Cartridge definition is null");
if (log.isInfoEnabled()) {
- log.info("Updating cartridge: [cartridge-type] " + cartridge.getType());
+ log.info(String.format("Updating cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type]" +
+ " %s", cartridge.getTenantId(), cartridge.getUuid(), cartridge.getType()));
}
if (log.isDebugEnabled()) {
log.debug("Cartridge definition: " + cartridge.toString());
@@ -152,7 +149,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
copyIaasProviders(cartridge, cartridgeToBeRemoved);
} else {
- throw new CartridgeDefinitionNotExistsException("This cartridge definition not exists");
+ throw new CartridgeDefinitionNotExistsException("Cartridge definition not exists: [cartridge-type] " +
+ cartridge.getType());
}
// Add cartridge to the cloud controller context and persist
@@ -161,7 +159,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// transaction ends
if (log.isInfoEnabled()) {
- log.info("Successfully updated cartridge: [cartridge-type] " + cartridgeUuid);
+ log.info(String.format("Successfully updated cartridge: tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s", cartridge.getTenantId(), cartridge.getUuid(), cartridge.getType()));
}
return true;
}
@@ -200,8 +199,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
removeCartridgeFromTopology(cartridge);
if (log.isInfoEnabled()) {
- log.info(String.format("Successfully removed cartridge: [cartridge-uuid] %s [cartridge-type] %s " +
- "[tenant-id] %d", cartridge.getUuid(), cartridge.getType(), cartridge.getTenantId()));
+ log.info(String.format("Successfully removed cartridge: [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s", cartridge.getTenantId(), cartridge.getUuid(), cartridge.getType()));
}
return true;
}
@@ -220,13 +219,13 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Successfully removed cartridge: [cartridge-uuid] %s [cartridge-type] %s " +
- "[tenant-id] %d", cartridge.getUuid(), cartridge.getType(), cartridge.getTenantId()));
+ log.info(String.format("Successfully removed cartridge: [tenant-id] %d [cartridge-uuid] %s " +
+ "[cartridge-type] %s", cartridge.getTenantId(), cartridge.getUuid(), cartridge.getType()));
}
return cartridge;
}
}
- String msg = "Cartridge not found: [cartridge-type] " + cartridgeUuid;
+ String msg = "Cartridge not found: [cartridge-uuid] " + cartridgeUuid;
log.error(msg);
throw new InvalidCartridgeTypeException(msg);
}
@@ -253,7 +252,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
public boolean removeServiceGroup(String name) throws InvalidServiceGroupException {
if (log.isDebugEnabled()) {
- log.debug("CloudControllerServiceImpl:removeServiceGroup: " + name);
+ log.debug("Removing service group: [service-group-name] " + name);
}
ServiceGroup serviceGroup = null;
@@ -264,7 +263,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
if (CloudControllerContext.getInstance().getServiceGroups().remove(serviceGroup)) {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info("Successfully removed the cartridge group: [group-name] " + serviceGroup);
+ log.info(String.format("Successfully removed the cartridge group: [service-group-name] %s", name));
}
return true;
}
@@ -299,7 +298,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
public String[] getServiceGroupSubGroups(String name) throws InvalidServiceGroupException {
ServiceGroup serviceGroup = this.getServiceGroup(name);
if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + serviceGroup);
+ throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + name);
}
return serviceGroup.getSubGroups();
@@ -311,7 +310,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
public String[] getServiceGroupCartridges(String name) throws InvalidServiceGroupException {
ServiceGroup serviceGroup = this.getServiceGroup(name);
if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + serviceGroup);
+ throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + name);
}
String[] cs = serviceGroup.getCartridges();
return cs;
@@ -321,7 +320,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
public Dependencies getServiceGroupDependencies(String name) throws InvalidServiceGroupException {
ServiceGroup serviceGroup = this.getServiceGroup(name);
if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + serviceGroup);
+ throw new InvalidServiceGroupException("Invalid cartridge group: [group-name] " + name);
}
return serviceGroup.getDependencies();
}
@@ -489,6 +488,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
MemberContext memberContext = new MemberContext(
applicationId, cartridgeType, instanceContext.getClusterId(), memberId);
+
memberContext.setClusterInstanceId(instanceContext.getClusterInstanceId());
memberContext.setNetworkPartitionId(instanceContext.getNetworkPartitionId());
memberContext.setPartition(cloudControllerContext.getNetworkPartition(instanceContext.getNetworkPartitionId()).
@@ -896,7 +896,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerUtil.sleep(1000);
}
- log.info(String.format("Unregistration of service cluster: [cluster-id] %s [application-id]",
+ log.info(String.format("Unregistration of service cluster: [cluster-id] %s [application-id] %s",
clusterId_, ctxt.getApplicationUuid()));
deleteVolumes(ctxt);
onClusterRemoval(clusterId_);
@@ -929,8 +929,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
} catch (Exception ignore) {
if (log.isErrorEnabled()) {
log.error((String.format("Error while deleting volume [id] %s " +
- "[application-id]", volume.getId(), ctxt.getApplicationUuid())),
- ignore);
+ "[application-id] %s", volume.getId(),
+ ctxt.getApplicationUuid())), ignore);
}
}
}
@@ -980,7 +980,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeUuid);
if (cartridge == null) {
- String msg = "Cartridge not found: " + cartridgeUuid;
+ String msg = "Cartridge not found: [cartridge-uuid] " + cartridgeUuid;
log.error(msg);
throw new InvalidCartridgeTypeException(msg);
}
@@ -1020,8 +1020,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().addToCartridgeTypeToPartitionIdMap(cartridgeUuid, partitionId);
if (log.isDebugEnabled()) {
- log.debug("Partition " + partitionId + " added to the cache against cartridge: " +
- "[cartridge-uuid] " + cartridgeUuid);
+ log.debug(String.format("Partition %s added to the cache against " +
+ "cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s", partitionId,
+ cartridge.getTenantId(), cartridgeUuid, cartridge.getType()));
}
} catch (Exception e) {
String message = "Could not cache partitions against the cartridge: [cartridge-uuid] " + cartridgeUuid;
@@ -1037,8 +1038,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// persist data
CloudControllerContext.getInstance().persist();
- log.info("All partitions [" + CloudControllerUtil.getPartitionIds(networkPartition.getPartitions()) + "]" +
- " were validated successfully, against the cartridge: " + cartridgeUuid);
+ log.info(String.format("All partitions [%s] were validated successfully, " +
+ "against the cartridge: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s",
+ CloudControllerUtil.getPartitionIds(networkPartition.getPartitions()), cartridge.getTenantId(),
+ cartridgeUuid, cartridge.getType()));
return true;
} finally {
@@ -1061,9 +1064,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
handleNullObject(partition, "Partition validation failed. Partition is null.");
String provider = partition.getProvider();
- String partitionId = partition.getUuid();
+ String partitionUuid = partition.getUuid();
- handleNullObject(provider, "Partition [" + partitionId + "] validation failed. Partition provider is null.");
+ handleNullObject(provider, String.format("Partition validation failed. Partition provider is null. " +
+ "[partition-uuid] %s [partition-id] %s ", partitionUuid, partition.getId()));
IaasProvider iaasProvider = CloudControllerConfig.getInstance().getIaasProvider(provider);
return CloudControllerServiceUtil.validatePartition(partition, iaasProvider);
@@ -1245,7 +1249,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
try {
if (CloudControllerContext.getInstance().getKubernetesCluster(kubernetesCluster.getClusterUuid()) != null) {
- throw new KubernetesClusterAlreadyExistsException("Kubernetes cluster already exists");
+ throw new KubernetesClusterAlreadyExistsException("Kubernetes cluster already exists: " +
+ "[kubernetes-cluster] " + kubernetesCluster.getClusterId());
}
} catch (NonExistingKubernetesClusterException ignore) {
}
@@ -1254,8 +1259,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock = CloudControllerContext.getInstance().acquireKubernetesClusterWriteLock();
if (log.isInfoEnabled()) {
- log.info(String.format("Adding kubernetes cluster: [kubernetes-cluster-id] %s",
- kubernetesCluster.getClusterUuid()));
+ log.info(String.format("Adding kubernetes cluster: [tenant-id] %d [kubernetes-cluster-uuid] %s " +
+ "[kubernetes-cluster-id] %s", kubernetesCluster.getTenantId(),
+ kubernetesCluster.getClusterUuid(), kubernetesCluster.getClusterId()));
}
CloudControllerUtil.validateKubernetesCluster(kubernetesCluster);
@@ -1264,8 +1270,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes cluster added successfully: [kubernetes-cluster-id] %s",
- kubernetesCluster.getClusterUuid()));
+ log.info(String.format("Kubernetes cluster added successfully: [tenant-id] %d " +
+ "[kubernetes-cluster-uuid] %s [kubernetes-cluster-id] %s",
+ kubernetesCluster.getTenantId(), kubernetesCluster.getClusterUuid(),
+ kubernetesCluster.getClusterId()));
}
return true;
} catch (Exception e) {
@@ -1287,8 +1295,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock = CloudControllerContext.getInstance().acquireKubernetesClusterWriteLock();
if (log.isInfoEnabled()) {
- log.info(String.format("Updating kubernetes cluster: [kubernetes-cluster-id] %s",
- kubernetesCluster.getClusterUuid()));
+ log.info(String.format("Updating kubernetes cluster: [tenant-id] %d [kubernetes-cluster-uuid] %s " +
+ "[kubernetes-cluster-id] %s", kubernetesCluster.getTenantId(),
+ kubernetesCluster.getClusterUuid(), kubernetesCluster.getClusterId()));
}
CloudControllerUtil.validateKubernetesCluster(kubernetesCluster);
@@ -1297,8 +1306,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes cluster updated successfully: [kubernetes-cluster-id] %s",
- kubernetesCluster.getClusterUuid()));
+ log.info(String.format("Kubernetes cluster updated successfully: [tenant-id] %d " +
+ "[kubernetes-cluster-uuid] %s [kubernetes-cluster-id] %s",
+ kubernetesCluster.getTenantId(), kubernetesCluster.getClusterUuid(),
+ kubernetesCluster.getClusterId()));
}
return true;
} catch (Exception e) {
@@ -1337,7 +1348,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
kubernetesHostArrayList = new ArrayList<KubernetesHost>();
} else {
if (CloudControllerContext.getInstance().kubernetesHostExists(kubernetesHost.getHostId())) {
- throw new InvalidKubernetesHostException("Kubernetes host already exists: [hostname] " +
+ throw new InvalidKubernetesHostException("Kubernetes host already exists: [kubernetes-host-id] " +
kubernetesHost.getHostId());
}
kubernetesHostArrayList = new
@@ -1351,7 +1362,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes host added successfully: [id] %s", kubernetesCluster.getClusterUuid()));
+ log.info(String.format("Kubernetes host added successfully: [kubernetes-cluster-id] %s " +
+ "[kubernetes-host-id] %s", kubernetesCluster.getClusterUuid(), kubernetesHost.getHostId()));
}
return true;
@@ -1381,7 +1393,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().removeKubernetesCluster(groupUuid);
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes cluster removed successfully: [id] %s", groupUuid));
+ log.info(String.format("Kubernetes cluster removed successfully: [kubernetes-cluster-uuid] %s",
+ groupUuid));
}
CloudControllerContext.getInstance().persist();
@@ -1412,7 +1425,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// Kubernetes master cannot be removed
if (kubernetesClusterStored.getKubernetesMaster().getHostId().equals(kubernetesHostId)) {
- throw new NonExistingKubernetesHostException("Kubernetes master is not allowed to be removed [id] " + kubernetesHostId);
+ throw new NonExistingKubernetesHostException("Kubernetes master is not allowed to be removed " +
+ "[kubernetes-host-id] " + kubernetesHostId);
}
List<KubernetesHost> kubernetesHostList = new ArrayList<KubernetesHost>();
@@ -1423,7 +1437,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
// member count will be equal only when host object was not found
if (kubernetesHostList.size() == kubernetesClusterStored.getKubernetesHosts().length) {
- throw new NonExistingKubernetesHostException("Kubernetes host not found for [id] " + kubernetesHostId);
+ throw new NonExistingKubernetesHostException("Kubernetes host not found for [kubernetes-host-id] " +
+ "" + kubernetesHostId);
}
KubernetesHost[] kubernetesHostsArray = new KubernetesHost[kubernetesHostList.size()];
kubernetesHostList.toArray(kubernetesHostsArray);
@@ -1432,7 +1447,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
kubernetesClusterStored.setKubernetesHosts(kubernetesHostsArray);
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes host removed successfully: [id] %s", kubernetesHostId));
+ log.info(String.format("Kubernetes host removed successfully: [kubernetes-host-id] %s", kubernetesHostId));
}
CloudControllerContext.getInstance().persist();
@@ -1490,7 +1505,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock = CloudControllerContext.getInstance().acquireKubernetesClusterWriteLock();
CloudControllerUtil.validateKubernetesHost(kubernetesHost);
if (log.isInfoEnabled()) {
- log.info("Updating Kubernetes Host: " + kubernetesHost);
+ log.info("Updating Kubernetes Host: [kubernetes-host-id] " + kubernetesHost);
}
try {
@@ -1502,7 +1517,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
kubernetesHosts[i] = kubernetesHost;
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes host updated successfully: [id] %s", kubernetesHost.getHostId()));
+ log.info(String.format("Kubernetes host updated successfully: [kubernetes-host-id] %s", kubernetesHost.getHostId()));
}
CloudControllerContext.getInstance().updateKubernetesCluster(kubernetesClusterStored);
@@ -1518,7 +1533,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().releaseWriteLock(lock);
}
}
- throw new NonExistingKubernetesHostException("Kubernetes host not found [id] " + kubernetesHost.getHostId());
+ throw new NonExistingKubernetesHostException("Kubernetes host not found [kubernetes-host-id] " + kubernetesHost.getHostId());
}
@Override
@@ -1530,15 +1545,21 @@ public class CloudControllerServiceImpl implements CloudControllerService {
handleNullObject(networkPartition.getUuid(), "Network Partition Id is null");
if (log.isInfoEnabled()) {
- log.info(String.format("Adding network partition: [network-partition-uuid] %s",
- networkPartition.getUuid()));
+ log.info(String.format("Adding network partition: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(), networkPartition.getUuid(),
+ networkPartition.getId()));
}
String networkPartitionUuid = networkPartition.getUuid();
if (cloudControllerContext.getNetworkPartition(networkPartitionUuid) != null) {
- String message = "Network partition already exists: [network-partition-uuid] " + networkPartitionUuid +
- "[network-partition-id] " + networkPartition.getId();
- log.error(message);
+ String logMessage = String.format("Network partition already exists: [tenant-id] %d " +
+ "[network-partition-uuid]" +
+ " %s [network-partition-id] %s", networkPartition.getTenantId(), networkPartition.getUuid(),
+ networkPartition.getId());
+ String message = String.format("Network partition already exists: [network-partition-id] %s",
+ networkPartition.getId());
+
+ log.error(logMessage);
throw new NetworkPartitionAlreadyExistsException(message);
}
@@ -1546,8 +1567,13 @@ public class CloudControllerServiceImpl implements CloudControllerService {
if (cloudControllerContext.getNetworkPartitionForTenant(networkPartitionId,
networkPartition.getTenantId()) != null) {
- String message = "Network partition already exists: [network-partition-id] " + networkPartitionId;
- log.error(message);
+ String logMessage = String.format("Network partition already exists: [tenant-id] %d " +
+ "[network-partition-uuid]" +
+ " %s [network-partition-id] %s", networkPartition.getTenantId(), networkPartition.getUuid(),
+ networkPartition.getId());
+ String message = String.format("Network partition already exists: [network-partition-id] %s",
+ networkPartition.getId());
+ log.error(logMessage);
throw new NetworkPartitionAlreadyExistsException(message);
}
@@ -1555,9 +1581,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
for (Partition partition : networkPartition.getPartitions()) {
if (partition != null) {
if (log.isInfoEnabled()) {
- log.info(String.format("Validating partition: [network-partition-uuid] %s " +
- "[network-partition-id] %s [partition-id] %s", networkPartitionUuid,
- networkPartition.getId(), partition.getUuid()));
+ log.info(String.format("Validating partition: [tenant-id] %d[network-partition-uuid] %s " +
+ "[network-partition-id] %s [partition-id] %s",
+ networkPartition.getTenantId(), networkPartitionUuid, networkPartition.getId(),
+ partition.getUuid()));
}
// Overwrites partition provider with network partition provider
partition.setProvider(networkPartition.getProvider());
@@ -1566,22 +1593,24 @@ public class CloudControllerServiceImpl implements CloudControllerService {
} catch (InvalidPartitionException e) {
//Following message is shown to the end user in all the the API clients(GUI/CLI/Rest API)
throw new InvalidNetworkPartitionException(String.format("Network partition " +
- "[network-partition-uuid] %s [network-partition-id] %s , " +
+ "[tenant-id] %d [network-partition-uuid] %s [network-partition-id] %s , " +
"is invalid since the partition %s is invalid",
- networkPartition.getUuid(), networkPartition.getId(), partition.getUuid()), e);
+ networkPartition.getTenantId(), networkPartition.getUuid(), networkPartition.getId(),
+ partition.getUuid()), e);
}
if (log.isInfoEnabled()) {
- log.info(String.format("Partition validated successfully: [network-partition-uuid] %s " +
- "[network-partition-id] %s [partition-id] %s", networkPartition.getUuid(),
- networkPartition.getId(), partition.getUuid()));
+ log.info(String.format("Partition validated successfully: [tenant-id] %d " +
+ "[network-partition-uuid] %s [network-partition-id] %s [partition-id] %s",
+ networkPartition.getTenantId(), networkPartition.getUuid(), networkPartition.getId(),
+ partition.getUuid()));
}
}
}
} else {
//Following message is shown to the end user in all the the API clients(GUI/CLI/Rest API)
- throw new InvalidNetworkPartitionException(String.format("Network partition [network-partition-uuid] %s " +
- "[network-partition-id] %s, doesn't not have any partitions ", networkPartition.getUuid(),
- networkPartition.getId()));
+ throw new InvalidNetworkPartitionException(String.format("Network partition [tenant-id] %d " +
+ "[network-partition-uuid] %s [network-partition-id] %s, doesn't not have any partitions ",
+ networkPartition.getTenantId(), networkPartition.getUuid(), networkPartition.getId()));
}
// adding network partition to CC-Context
@@ -1589,8 +1618,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// persisting CC-Context
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Network partition added successfully: [network-partition-uuid] %s " +
- "[network-partition-id] %s", networkPartition.getUuid(),networkPartition.getId()));
+ log.info(String.format("Network partition added successfully: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(), networkPartition.getUuid(),
+ networkPartition.getId()));
}
return true;
}
@@ -1607,13 +1637,15 @@ public class CloudControllerServiceImpl implements CloudControllerService {
String networkPartitionUuid = networkPartition.getUuid();
if (log.isInfoEnabled()) {
- log.info(String.format("Removing network partition: [network-partition-uuid] %s " +
- "[network-partition-id] %s", networkPartitionUuid, networkPartitionId));
+ log.info(String.format("Removing network partition: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(), networkPartitionUuid,
+ networkPartitionId));
}
handleNullObject(networkPartitionId, "Network Partition Id is null");
if (networkPartitionUuid == null) {
- String message = String.format("Network partition not found:[network-partition-id] %s", networkPartitionId);
+ String message = String.format("Network partition not found: [network-partition-id] %s",
+ networkPartitionId);
log.error(message);
throw new NetworkPartitionNotExistsException(message);
}
@@ -1622,8 +1654,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// persisting CC-Context
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Network partition removed successfully: [network-partition-uuid] %s " +
- "[network-partition-id] %s", networkPartitionUuid, networkPartitionId));
+ log.info(String.format("Network partition removed successfully: [tenant-id] %d " +
+ "[network-partition-uuid] %s [network-partition-id] %s", networkPartition.getTenantId(),
+ networkPartitionUuid, networkPartitionId));
}
} else {
String message = String.format("Network partition not found: [network-partition-id] %s",
@@ -1650,14 +1683,17 @@ public class CloudControllerServiceImpl implements CloudControllerService {
handleNullObject(networkPartition.getUuid(), "Network Partition Id is null");
if (log.isInfoEnabled()) {
- log.info(String.format("Updating network partition: [network-partition-id] %s", networkPartition.getUuid()));
+ log.info(String.format("Updating network partition: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(),
+ networkPartition.getUuid(), networkPartition.getId()));
}
String networkPartitionId = networkPartition.getId();
String networkPartitionUuid = networkPartition.getUuid();
if (cloudControllerContext.getNetworkPartition(networkPartitionUuid) == null) {
- String message = String.format("Network partition not found: [network-partition-uuid] %s " +
- "[network-partition-id] %s", networkPartitionUuid, networkPartitionId);
+ String message = String.format("Network partition not found: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(),
+ networkPartition.getUuid(), networkPartition.getId());
log.error(message);
throw new NetworkPartitionNotExistsException(message);
}
@@ -1666,17 +1702,19 @@ public class CloudControllerServiceImpl implements CloudControllerService {
for (Partition partition : networkPartition.getPartitions()) {
if (partition != null) {
if (log.isInfoEnabled()) {
- log.info(String.format("Validating partition: [network-partition-uuid] %s " +
- "[network-partition-id] %s [partition-id] %s", networkPartitionUuid,
- networkPartitionId, partition.getUuid()));
+ log.info(String.format("Validating partition: [tenant-id] %d [network-partition-uuid] %s" +
+ "[network-partition-id] %s [partition-uuid] %s [partition-id] %s ",
+ networkPartition.getTenantId(), networkPartitionUuid, networkPartitionId,
+ partition.getUuid(), partition.getId()));
}
// Overwrites partition provider with network partition provider
partition.setProvider(networkPartition.getProvider());
validatePartition(partition);
if (log.isInfoEnabled()) {
- log.info(String.format("Partition validated successfully: [network-partition-uuid] %s " +
- "[network-partition-uuid] %s [partition-id] %s", networkPartitionUuid,
- networkPartitionId, partition.getUuid()));
+ log.info(String.format("Partition validated successfully: [tenant-id] %d " +
+ "[network-partition-uuid] %s [network-partition-id] %s [partition-uuid] " +
+ "%s [partition-id] %s ", networkPartition.getTenantId(),
+ networkPartitionUuid, networkPartitionId, partition.getUuid(), partition.getId()));
}
}
}
@@ -1687,8 +1725,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// persisting CC-Context
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Network partition updated successfully: [network-partition-uuid] %s " +
- "[network-partition-id] %s", networkPartitionUuid, networkPartitionId));
+ log.info(String.format("Network partition updated successfully: [tenant-id] %d [network-partition-uuid] %s " +
+ "[network-partition-id] %s", networkPartition.getTenantId(),
+ networkPartition.getUuid(), networkPartition.getId()));
}
return true;
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/eb0d28f4/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 32be807..ec1a17c 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
@@ -303,8 +303,7 @@ 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: [tenant-id] %d [cartridge-uuid] %s [cartridge-type] %s ",
- tenantId, cartridgeUuid, cartridgeType);
+ String msg = String.format("Cartridge already exists: [cartridge-type] %s ", cartridgeType);
log.warn(msg);
return Response.status(Response.Status.CONFLICT)
.entity(new ResponseMessageBean(ResponseMessageBean.ERROR, msg)).build();
@@ -499,8 +498,8 @@ public class StratosApiV41 extends AbstractApi {
groupBean = StratosApiV41Utils.getServiceGroupDefinition(cartridgeGroupBean.getName(), carbonContext.getTenantId());
if (groupBean != null) {
- String msg = String.format("Cartridge already exists: [tenant-id] %d [cartridge-uuid] %s [cartridge-type]" +
- "%s", tenantId, cartrideGroupUuid, cartridgeGroupBean.getName());
+ String msg = String.format("Cartridge group already exists: [cartridge-group-name] %s",
+ cartridgeGroupBean.getName());
log.warn(msg);
return Response.status(Response.Status.CONFLICT)
.entity(new ResponseMessageBean(ResponseMessageBean.ERROR, msg)).build();
http://git-wip-us.apache.org/repos/asf/stratos/blob/eb0d28f4/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 ddb4f88..5c9f3f0 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
@@ -284,17 +284,19 @@ public class StratosApiV41Utils {
// Validate whether cartridge can be removed
if (!smServiceClient.canCartridgeBeRemoved(cartridge.getUuid())) {
- String message = String.format("Cannot remove cartridge : [tenant-id] %d [cartridge-uuid] %s " +
+ String logMessage = 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);
+ String message = String.format("Cannot remove cartridge :n[cartridge-type] %s since it is used in another" +
+ " cartridge group or an application", cartridgeType);
+ log.error(logMessage);
throw new RestAPIException(message);
}
cloudControllerServiceClient.removeCartridge(cartridge.getUuid());
if (log.isInfoEnabled()) {
log.info(String.format("Successfully removed cartridge: [tenant-id] %d [cartridge-uuid] %s " +
- "[cartridge-type] %s from tenant: ", tenantId, cartridge.getUuid(), cartridgeType));
+ "[cartridge-type] %s", tenantId, cartridge.getUuid(), cartridgeType));
}
}