Remove unnecessary iteration of properties when removing K8s cluster. Add error 
logs if K8s cluster couldn't be removed


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1f86d2fa
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1f86d2fa
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1f86d2fa

Branch: refs/heads/stratos-4.1.x
Commit: 1f86d2faa2bc5ccbf2296b37c94cff44a5dbdca9
Parents: 60b8011
Author: Akila Perera <[email protected]>
Authored: Wed Nov 11 16:56:38 2015 +0530
Committer: Akila Perera <[email protected]>
Committed: Wed Nov 11 16:56:38 2015 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImpl.java        |  73 ++-
 .../client/CloudControllerServiceClient.java    | 116 ++--
 .../rest/endpoint/api/StratosApiV41.java        |  17 +-
 .../rest/endpoint/api/StratosApiV41Utils.java   | 602 +++++++++----------
 4 files changed, 406 insertions(+), 402 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/1f86d2fa/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 d3fa92d..c841a81 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
@@ -42,10 +42,8 @@ import 
org.wso2.carbon.registry.core.exceptions.RegistryException;
 
 import java.util.*;
 import java.util.Map.Entry;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
 import java.util.concurrent.locks.Lock;
 
 /**
@@ -54,14 +52,14 @@ import java.util.concurrent.locks.Lock;
  */
 public class CloudControllerServiceImpl implements CloudControllerService {
 
-       private static final Log log = 
LogFactory.getLog(CloudControllerServiceImpl.class);
+    private static final Log log = 
LogFactory.getLog(CloudControllerServiceImpl.class);
 
     private static final String PERSISTENCE_MAPPING = "PERSISTENCE_MAPPING";
     public static final String PAYLOAD_PARAMETER = "payload_parameter.";
-       public static final String KUBERNETES_PROVIDER = "kubernetes";
-       public static final String KUBERNETES_CLUSTER = "cluster";
+    public static final String KUBERNETES_PROVIDER = "kubernetes";
+    public static final String KUBERNETES_CLUSTER = "cluster";
 
-       private CloudControllerContext cloudControllerContext = 
CloudControllerContext.getInstance();
+    private CloudControllerContext cloudControllerContext = 
CloudControllerContext.getInstance();
     private ExecutorService executorService;
 
     public CloudControllerServiceImpl() {
@@ -399,10 +397,14 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             // if the IaaS Provider type is 'ec2', add region and zone 
information to the Member via
             // properties of Instance Context -> properties of Member Context
             if 
(CloudControllerConstants.IAAS_TYPE_EC2.equalsIgnoreCase(iaasProvider.getType()))
 {
-                instanceContext.getProperties().addProperty(new 
Property(CloudControllerConstants.INSTANCE_CTXT_EC2_REGION,
-                        
instanceContext.getPartition().getProperties().getProperty(CloudControllerConstants.REGION_ELEMENT).getValue()));
-                instanceContext.getProperties().addProperty(new 
Property(CloudControllerConstants.INSTANCE_CTXT_EC2_AVAILABILITY_ZONE,
-                        
instanceContext.getPartition().getProperties().getProperty(CloudControllerConstants.ZONE_ELEMENT).getValue()));
+                instanceContext.getProperties().addProperty(
+                        new 
Property(CloudControllerConstants.INSTANCE_CTXT_EC2_REGION,
+                                instanceContext.getPartition().getProperties()
+                                        
.getProperty(CloudControllerConstants.REGION_ELEMENT).getValue()));
+                instanceContext.getProperties().addProperty(
+                        new 
Property(CloudControllerConstants.INSTANCE_CTXT_EC2_AVAILABILITY_ZONE,
+                                instanceContext.getPartition().getProperties()
+                                        
.getProperty(CloudControllerConstants.ZONE_ELEMENT).getValue()));
                 if (log.isDebugEnabled()) {
                     log.debug("ec2Region in InstanceContext: " + 
instanceContext.getProperties()
                             
.getProperty(CloudControllerConstants.INSTANCE_CTXT_EC2_REGION));
@@ -994,10 +996,10 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 }
 
                 // cache miss
-                IaasProvider iaasProvider = 
CloudControllerContext.getInstance().getIaasProvider
-                        (cartridge.getType(), partition.getProvider());
-                IaasProvider updatedIaasProvider = 
CloudControllerServiceUtil.validatePartitionAndGetIaasProvider(partition,
-                        iaasProvider);
+                IaasProvider iaasProvider = 
CloudControllerContext.getInstance()
+                        .getIaasProvider(cartridge.getType(), 
partition.getProvider());
+                IaasProvider updatedIaasProvider = CloudControllerServiceUtil
+                        .validatePartitionAndGetIaasProvider(partition, 
iaasProvider);
 
                 try {
                     if (updatedIaasProvider != null) {
@@ -1005,7 +1007,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                     }
 
                     // add to cache
-                    
CloudControllerContext.getInstance().addToCartridgeTypeToPartitionIdMap(cartridgeType,
 partition.getId());
+                    CloudControllerContext.getInstance()
+                            .addToCartridgeTypeToPartitionIdMap(cartridgeType, 
partition.getId());
                     if (log.isDebugEnabled()) {
                         log.debug("Partition " + partition.getId() + " added 
to the cache against " + "cartridge: " +
                                 "[cartridge-type] " + cartridgeType);
@@ -1127,11 +1130,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
     /**
      * Find load balancer ips from application subscribable properties or 
network partition properties.
+     *
      * @param applicationId
      * @param applicationClusterContext
      * @return
      */
-    private List<String> findLoadBalancerIps(String applicationId, 
ApplicationClusterContext applicationClusterContext) {
+    private List<String> findLoadBalancerIps(String applicationId,
+            ApplicationClusterContext applicationClusterContext) {
 
         Cartridge cartridge = CloudControllerContext.getInstance().
                 getCartridge(applicationClusterContext.getCartridgeType());
@@ -1142,18 +1147,19 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         String clusterId = applicationClusterContext.getClusterId();
         org.apache.stratos.common.Properties appClusterContextProperties = 
applicationClusterContext.getProperties();
 
-        if(appClusterContextProperties != null) {
+        if (appClusterContextProperties != null) {
             // Find load balancer ips from application subscribable properties
-            Property ipListProperty = 
appClusterContextProperties.getProperty(CloudControllerConstants.LOAD_BALANCER_IPS);
+            Property ipListProperty = appClusterContextProperties
+                    .getProperty(CloudControllerConstants.LOAD_BALANCER_IPS);
             if (ipListProperty != null) {
-                log.info(String.format("Load balancer IPs found in 
application: [application] %s [cluster] %s " +
-                                "[load-balancer-ip-list] %s", applicationId, 
clusterId,
-                        ipListProperty.getValue()));
+                log.info(String.format("Load balancer IPs found in 
application: [application] %s [cluster] %s "
+                        + "[load-balancer-ip-list] %s", applicationId, 
clusterId, ipListProperty.getValue()));
                 return transformToList(ipListProperty);
             }
 
             // Find load balancer ips from network partition properties
-            Property npListProperty = 
appClusterContextProperties.getProperty(CloudControllerConstants.NETWORK_PARTITION_ID_LIST);
+            Property npListProperty = appClusterContextProperties
+                    
.getProperty(CloudControllerConstants.NETWORK_PARTITION_ID_LIST);
             if (npListProperty != null) {
                 String npIdListStr = npListProperty.getValue();
                 if (StringUtils.isNotEmpty(npIdListStr)) {
@@ -1163,16 +1169,18 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                         NetworkPartition networkPartition = 
CloudControllerContext.getInstance().
                                 getNetworkPartition(networkPartitionId);
                         if (networkPartition == null) {
-                            throw new 
CloudControllerException(String.format("Network partition not found: 
[application] %s " +
-                                    "[network-partition] %s", applicationId, 
networkPartitionId));
+                            throw new CloudControllerException(String.format(
+                                    "Network partition not found: 
[application] %s " + "[network-partition] %s",
+                                    applicationId, networkPartitionId));
                         }
 
                         org.apache.stratos.common.Properties npProperties = 
networkPartition.getProperties();
                         if (npProperties != null) {
                             ipListProperty = 
npProperties.getProperty(CloudControllerConstants.LOAD_BALANCER_IPS);
                             if (ipListProperty != null) {
-                                log.info(String.format("Load balancer IPs 
found in network partition: " +
-                                                "[application] %s [cluster] %s 
[load-balancer-ip-list] %s", applicationId,
+                                log.info(String.format("Load balancer IPs 
found in network partition: "
+                                                + "[application] %s [cluster] 
%s [load-balancer-ip-list] %s",
+                                        applicationId,
                                         clusterId, ipListProperty.getValue()));
                                 String[] ipArray = 
ipListProperty.getValue().split(",");
                                 for (String ip : ipArray) {
@@ -1191,7 +1199,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     private List<String> transformToList(Property listProperty) {
         List<String> stringList = new ArrayList<>();
         String[] array = listProperty.getValue().split(",");
-        for(String item : array) {
+        for (String item : array) {
             stringList.add(item);
         }
         return stringList;
@@ -1371,7 +1379,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean removeKubernetesCluster(String kubernetesClusterId) throws 
NonExistingKubernetesClusterException, KubernetesClusterAlreadyUsedException {
+    public boolean removeKubernetesCluster(String kubernetesClusterId)
+            throws NonExistingKubernetesClusterException, 
KubernetesClusterAlreadyUsedException {
         if (StringUtils.isEmpty(kubernetesClusterId)) {
             throw new NonExistingKubernetesClusterException("Kubernetes 
cluster id cannot be empty");
         }
@@ -1379,10 +1388,10 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         for (NetworkPartition networkPartition : networkPartitions) {
             if (networkPartition.getProvider().equals(KUBERNETES_PROVIDER)) {
                 for (Partition partition : networkPartition.getPartitions()) {
-                    for (Property property : 
partition.getProperties().getProperties()) {
-                        if (property.getName().equals(KUBERNETES_CLUSTER) && 
property.getValue().equals(kubernetesClusterId)) {
-                            throw new 
KubernetesClusterAlreadyUsedException("Kubernetes cluster is already used in 
the network partition");
-                        }
+                    if 
(partition.getProperties().getProperty(KUBERNETES_CLUSTER).getValue()
+                            .equals(kubernetesClusterId)) {
+                        throw new KubernetesClusterAlreadyUsedException(
+                                "Kubernetes cluster is already used in the 
network partition");
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/1f86d2fa/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
 
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
index bdc22fd..368cfdf 100644
--- 
a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
+++ 
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
@@ -46,14 +46,17 @@ public class CloudControllerServiceClient {
                 StratosConstants.DEFAULT_CLIENT_SOCKET_TIMEOUT :
                 
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_SOCKET_TIMEOUT);
 
-        String ccConnectionTimeout = 
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT) 
== null ?
-                StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
-                
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT);
+        String ccConnectionTimeout =
+                
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT) 
== null ?
+                        StratosConstants.DEFAULT_CLIENT_CONNECTION_TIMEOUT :
+                        
System.getProperty(StratosConstants.CLOUD_CONTROLLER_CLIENT_CONNECTION_TIMEOUT);
 
         try {
             stub = new CloudControllerServiceStub(epr);
-            
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, 
Integer.valueOf(ccSocketTimeout));
-            
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
 new Integer(ccConnectionTimeout));
+            stub._getServiceClient().getOptions()
+                    .setProperty(HTTPConstants.SO_TIMEOUT, 
Integer.valueOf(ccSocketTimeout));
+            stub._getServiceClient().getOptions()
+                    .setProperty(HTTPConstants.CONNECTION_TIMEOUT, new 
Integer(ccConnectionTimeout));
 
         } catch (AxisFault axisFault) {
             String msg = "Could not initialize cloud controller service 
client";
@@ -66,7 +69,8 @@ public class CloudControllerServiceClient {
         if (instance == null) {
             synchronized (CloudControllerServiceClient.class) {
                 if (instance == null) {
-                    String cloudControllerServiceUrl = 
System.getProperty(StratosConstants.CLOUD_CONTROLLER_SERVICE_URL);
+                    String cloudControllerServiceUrl = System
+                            
.getProperty(StratosConstants.CLOUD_CONTROLLER_SERVICE_URL);
                     if (StringUtils.isBlank(cloudControllerServiceUrl)) {
                         throw new RuntimeException(String.format("System 
property not found: %s",
                                 
StratosConstants.CLOUD_CONTROLLER_SERVICE_URL));
@@ -80,35 +84,40 @@ public class CloudControllerServiceClient {
 
     public void addCartridge(Cartridge cartridgeConfig)
             throws RemoteException, 
CloudControllerServiceCartridgeAlreadyExistsExceptionException,
-            CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
-            CloudControllerServiceInvalidIaasProviderExceptionException {
+                   
CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
+                   CloudControllerServiceInvalidIaasProviderExceptionException 
{
         stub.addCartridge(cartridgeConfig);
     }
 
     public void updateCartridge(Cartridge cartridgeConfig)
             throws RemoteException, 
CloudControllerServiceInvalidCartridgeDefinitionExceptionException,
-            CloudControllerServiceInvalidIaasProviderExceptionException,
-            
CloudControllerServiceCartridgeDefinitionNotExistsExceptionException {
+                   CloudControllerServiceInvalidIaasProviderExceptionException,
+                   
CloudControllerServiceCartridgeDefinitionNotExistsExceptionException {
         stub.updateCartridge(cartridgeConfig);
     }
 
-    public void removeCartridge(String cartridgeType) throws RemoteException, 
CloudControllerServiceInvalidCartridgeTypeExceptionException {
+    public void removeCartridge(String cartridgeType)
+            throws RemoteException, 
CloudControllerServiceInvalidCartridgeTypeExceptionException {
         stub.removeCartridge(cartridgeType);
     }
 
-    public String[] getServiceGroupSubGroups(String name) throws 
RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException {
+    public String[] getServiceGroupSubGroups(String name)
+            throws RemoteException, 
CloudControllerServiceInvalidServiceGroupExceptionException {
         return stub.getServiceGroupSubGroups(name);
     }
 
-    public String[] getServiceGroupCartridges(String name) throws 
RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException {
+    public String[] getServiceGroupCartridges(String name)
+            throws RemoteException, 
CloudControllerServiceInvalidServiceGroupExceptionException {
         return stub.getServiceGroupCartridges(name);
     }
 
-    public Dependencies getServiceGroupDependencies(String name) throws 
RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException {
+    public Dependencies getServiceGroupDependencies(String name)
+            throws RemoteException, 
CloudControllerServiceInvalidServiceGroupExceptionException {
         return stub.getServiceGroupDependencies(name);
     }
 
-    public ServiceGroup getServiceGroup(String name) throws RemoteException, 
CloudControllerServiceInvalidServiceGroupExceptionException {
+    public ServiceGroup getServiceGroup(String name)
+            throws RemoteException, 
CloudControllerServiceInvalidServiceGroupExceptionException {
         return stub.getServiceGroup(name);
     }
 
@@ -116,8 +125,8 @@ public class CloudControllerServiceClient {
         return stub.getCartridges();
     }
 
-    public Cartridge getCartridge(String cartridgeType) throws RemoteException,
-            CloudControllerServiceCartridgeNotFoundExceptionException {
+    public Cartridge getCartridge(String cartridgeType)
+            throws RemoteException, 
CloudControllerServiceCartridgeNotFoundExceptionException {
         return stub.getCartridge(cartridgeType);
     }
 
@@ -126,28 +135,27 @@ public class CloudControllerServiceClient {
         return stub.getClusterContext(clusterId);
     }
 
-    public boolean updateKubernetesCluster(KubernetesCluster 
kubernetesCluster) throws RemoteException,
-            CloudControllerServiceInvalidKubernetesClusterExceptionException {
+    public boolean updateKubernetesCluster(KubernetesCluster kubernetesCluster)
+            throws RemoteException, 
CloudControllerServiceInvalidKubernetesClusterExceptionException {
         return stub.updateKubernetesCluster(kubernetesCluster);
     }
 
-
-    public boolean deployKubernetesCluster(KubernetesCluster 
kubernetesCluster) throws RemoteException,
-            CloudControllerServiceInvalidKubernetesClusterExceptionException,
-            
CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException {
+    public boolean deployKubernetesCluster(KubernetesCluster kubernetesCluster)
+            throws RemoteException, 
CloudControllerServiceInvalidKubernetesClusterExceptionException,
+                   
CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException {
         return stub.addKubernetesCluster(kubernetesCluster);
     }
 
     public boolean addKubernetesHost(String kubernetesClusterId, 
KubernetesHost kubernetesHost)
             throws RemoteException, 
CloudControllerServiceInvalidKubernetesHostExceptionException,
-            
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
+                   
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
 
         return stub.addKubernetesHost(kubernetesClusterId, kubernetesHost);
     }
 
-    public boolean updateKubernetesMaster(KubernetesMaster kubernetesMaster) 
throws RemoteException,
-            CloudControllerServiceInvalidKubernetesMasterExceptionException,
-            
CloudControllerServiceNonExistingKubernetesMasterExceptionException {
+    public boolean updateKubernetesMaster(KubernetesMaster kubernetesMaster)
+            throws RemoteException, 
CloudControllerServiceInvalidKubernetesMasterExceptionException,
+                   
CloudControllerServiceNonExistingKubernetesMasterExceptionException {
         return stub.updateKubernetesMaster(kubernetesMaster);
     }
 
@@ -155,57 +163,57 @@ public class CloudControllerServiceClient {
         return stub.getKubernetesClusters();
     }
 
-    public KubernetesCluster getKubernetesCluster(String kubernetesClusterId) 
throws RemoteException,
-            
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
+    public KubernetesCluster getKubernetesCluster(String kubernetesClusterId)
+            throws RemoteException, 
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
         return stub.getKubernetesCluster(kubernetesClusterId);
     }
 
-    public void undeployKubernetesCluster(String kubernetesClusterId) throws 
RemoteException,
-            
CloudControllerServiceNonExistingKubernetesClusterExceptionException, 
CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException {
+    public void undeployKubernetesCluster(String kubernetesClusterId)
+            throws RemoteException, 
CloudControllerServiceNonExistingKubernetesClusterExceptionException,
+                   
CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException {
         stub.removeKubernetesCluster(kubernetesClusterId);
     }
 
-    public boolean undeployKubernetesHost(String kubernetesHostId) throws 
RemoteException,
-            CloudControllerServiceNonExistingKubernetesHostExceptionException {
+    public boolean undeployKubernetesHost(String kubernetesHostId)
+            throws RemoteException, 
CloudControllerServiceNonExistingKubernetesHostExceptionException {
         return stub.removeKubernetesHost(kubernetesHostId);
     }
 
-    public KubernetesHost[] getKubernetesHosts(String kubernetesClusterId) 
throws RemoteException,
-            
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
+    public KubernetesHost[] getKubernetesHosts(String kubernetesClusterId)
+            throws RemoteException, 
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
         return stub.getHostsForKubernetesCluster(kubernetesClusterId);
     }
 
-    public KubernetesMaster getKubernetesMaster(String kubernetesClusterId) 
throws RemoteException,
-            
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
+    public KubernetesMaster getKubernetesMaster(String kubernetesClusterId)
+            throws RemoteException, 
CloudControllerServiceNonExistingKubernetesClusterExceptionException {
         return stub.getMasterForKubernetesCluster(kubernetesClusterId);
     }
 
-    public boolean updateKubernetesHost(KubernetesHost kubernetesHost) throws 
RemoteException,
-            CloudControllerServiceInvalidKubernetesHostExceptionException,
-            CloudControllerServiceNonExistingKubernetesHostExceptionException {
+    public boolean updateKubernetesHost(KubernetesHost kubernetesHost)
+            throws RemoteException, 
CloudControllerServiceInvalidKubernetesHostExceptionException,
+                   
CloudControllerServiceNonExistingKubernetesHostExceptionException {
         return stub.updateKubernetesHost(kubernetesHost);
     }
 
     public void validateNetworkPartitionOfDeploymentPolicy(String 
cartridgeType, String networkPartitionId)
-            throws RemoteException,
-            CloudControllerServiceInvalidPartitionExceptionException,
-            CloudControllerServiceInvalidCartridgeTypeExceptionException {
+            throws RemoteException, 
CloudControllerServiceInvalidPartitionExceptionException,
+                   
CloudControllerServiceInvalidCartridgeTypeExceptionException {
         stub.validateDeploymentPolicyNetworkPartition(cartridgeType, 
networkPartitionId);
     }
 
-    public void addNetworkPartition(NetworkPartition networkPartition) throws 
RemoteException,
-            
CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException,
-            CloudControllerServiceInvalidNetworkPartitionExceptionException {
+    public void addNetworkPartition(NetworkPartition networkPartition)
+            throws RemoteException, 
CloudControllerServiceNetworkPartitionAlreadyExistsExceptionException,
+                   
CloudControllerServiceInvalidNetworkPartitionExceptionException {
         stub.addNetworkPartition(networkPartition);
     }
 
-    public void removeNetworkPartition(String networkPartitionId) throws 
RemoteException,
-            CloudControllerServiceNetworkPartitionNotExistsExceptionException {
+    public void removeNetworkPartition(String networkPartitionId)
+            throws RemoteException, 
CloudControllerServiceNetworkPartitionNotExistsExceptionException {
         stub.removeNetworkPartition(networkPartitionId);
     }
 
-    public void updateNetworkPartition(NetworkPartition networkPartition) 
throws RemoteException,
-            CloudControllerServiceNetworkPartitionNotExistsExceptionException {
+    public void updateNetworkPartition(NetworkPartition networkPartition)
+            throws RemoteException, 
CloudControllerServiceNetworkPartitionNotExistsExceptionException {
         stub.updateNetworkPartition(networkPartition);
     }
 
@@ -217,12 +225,10 @@ public class CloudControllerServiceClient {
         return stub.getNetworkPartition(networkPartitionId);
     }
 
-    public void createClusterInstance(String serviceType, String clusterId,
-                                      String alias, String instanceId, String 
partitionId,
-                                      String networkPartitionId) throws 
RemoteException {
+    public void createClusterInstance(String serviceType, String clusterId, 
String alias, String instanceId,
+            String partitionId, String networkPartitionId) throws 
RemoteException {
         try {
-            stub.createClusterInstance(serviceType, clusterId, alias,
-                    instanceId, partitionId, networkPartitionId);
+            stub.createClusterInstance(serviceType, clusterId, alias, 
instanceId, partitionId, networkPartitionId);
 
         } catch 
(CloudControllerServiceClusterInstanceCreationExceptionException e) {
             String msg = 
e.getFaultMessage().getClusterInstanceCreationException().getMessage();

http://git-wip-us.apache.org/repos/asf/stratos/blob/1f86d2fa/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 55f37ed..1dad693 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
@@ -2052,11 +2052,20 @@ public class StratosApiV41 extends AbstractApi {
         try {
             StratosApiV41Utils.removeKubernetesCluster(kubernetesClusterId);
         } catch 
(CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
-            return Response.status(Response.Status.NOT_FOUND).entity(new 
ResponseMessageBean(ResponseMessageBean.ERROR,
-                    String.format("Kubernetes cluster not found: [kub-cluster] 
%s", kubernetesClusterId))).build();
+            String message = String
+                    .format("Could not remove Kubernetes cluster. Kubernetes 
cluster not found: [kub-cluster] %s",
+                            kubernetesClusterId);
+            log.error(message);
+            return Response.status(Response.Status.NOT_FOUND)
+                    .entity(new ResponseMessageBean(ResponseMessageBean.ERROR, 
message)).build();
         } catch 
(CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException e) {
-            return Response.status(Response.Status.CONFLICT).entity(new 
ResponseMessageBean(ResponseMessageBean.ERROR,
-                    String.format("Kubernetes cluster is being used by a 
deployed application: [kub-cluster] %s", kubernetesClusterId))).build();
+            String message = String
+                    .format("Could not remove Kubernetes cluster. Kubernetes 
cluster is being used by a deployed "
+                            + "application: [kub-cluster] %s",
+                            kubernetesClusterId);
+            log.error(message);
+            return Response.status(Response.Status.CONFLICT)
+                    .entity(new ResponseMessageBean(ResponseMessageBean.ERROR, 
message)).build();
         }
         return Response.ok().entity(new 
ResponseMessageBean(ResponseMessageBean.SUCCESS,
                 String.format("Kubernetes Cluster removed successfully: 
[kub-cluster] %s", kubernetesClusterId)))

Reply via email to