fixing service implementations for https://issues.apache.org/jira/browse/STRATOS-486
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/91f14f39 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/91f14f39 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/91f14f39 Branch: refs/heads/master Commit: 91f14f39b9c406d178116b90e8dc769b89237756 Parents: 016f8ed Author: Nirmal Fernando <[email protected]> Authored: Sat Mar 1 13:41:19 2014 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Sat Mar 1 13:41:19 2014 +0530 ---------------------------------------------------------------------- .../cloud/controller/CloudControllerClient.java | 69 +++++++++++++------- .../autoscaler/partition/PartitionManager.java | 8 +-- 2 files changed, 50 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/91f14f39/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index e231362..d5da490 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -88,14 +88,14 @@ public class CloudControllerClient { } return result; } catch (RemoteException e) { - log.error(e.getMessage()); - throw new PartitionValidationException(e); + log.error(e.getMessage(), e); + throw new PartitionValidationException(e.getMessage(), e); } catch (CloudControllerServiceInvalidPartitionExceptionException e) { - log.error(e.getMessage()); - throw new PartitionValidationException(e); + log.error(e.getFaultMessage().getInvalidPartitionException().getMessage(), e); + throw new PartitionValidationException(e.getFaultMessage().getInvalidPartitionException().getMessage()); } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) { - log.error(e.getMessage()); - throw new PartitionValidationException(e); + log.error(e.getFaultMessage().getInvalidCartridgeTypeException().getMessage(), e); + throw new PartitionValidationException(e.getFaultMessage().getInvalidCartridgeTypeException().getMessage()); } } @@ -117,14 +117,17 @@ public class CloudControllerClient { } return result; } catch (RemoteException e) { - throw new PartitionValidationException(e); + log.error(e.getMessage(), e); + throw new PartitionValidationException(e.getMessage(), e); } catch (CloudControllerServiceInvalidPartitionExceptionException e) { - throw new PartitionValidationException(e.getMessage(),e); + log.error(e.getFaultMessage().getInvalidPartitionException().getMessage(), e); + throw new PartitionValidationException(e.getFaultMessage().getInvalidPartitionException().getMessage(), e); } } - public org.apache.stratos.cloud.controller.pojo.MemberContext spawnAnInstance(Partition partition, String clusterId, String lbClusterId, String networkPartitionId) throws SpawningException { + public org.apache.stratos.cloud.controller.pojo.MemberContext spawnAnInstance(Partition partition, + String clusterId, String lbClusterId, String networkPartitionId) throws SpawningException { try { if(log.isInfoEnabled()) { log.info(String.format("Trying to spawn an instance via cloud controller: [cluster] %s [partition] %s [lb-cluster] %s [network-partition-id] %s", @@ -146,13 +149,23 @@ public class CloudControllerClient { } return memberContext; } catch (CloudControllerServiceIllegalArgumentExceptionException e) { - throw new SpawningException(e); + log.error(e.getMessage(), e); + throw new SpawningException(e.getMessage(), e); } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { - throw new SpawningException(e); + String message = e.getFaultMessage().getUnregisteredCartridgeException().getMessage(); + log.error(message, e); + throw new SpawningException(message, e); } catch (RemoteException e) { - throw new SpawningException(String.format("Error occurred in cloud controller while spawning instance: [cluster] %s [partition] %s [lb-cluster] %s [network-partition-id] %s", - clusterId, partition.getId(), lbClusterId, networkPartitionId), e); - } + log.error(e.getMessage(), e); + throw new SpawningException(e.getMessage(), e); + } catch (CloudControllerServiceIllegalStateExceptionException e) { + log.error(e.getMessage(), e); + throw new SpawningException(e.getMessage(), e); + } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { + String message = e.getFaultMessage().getInvalidIaasProviderException().getMessage(); + log.error(message, e); + throw new SpawningException(message, e); + } } public void terminateAllInstances(String clusterId) throws TerminationException { @@ -167,16 +180,18 @@ public class CloudControllerClient { log.debug(String.format("Service call terminateAllInstances() returned in %dms", (endTime - startTime))); } } catch (RemoteException e) { - String msg = "Error occurred in cloud controller side while terminating instance"; + String msg = e.getMessage(); log.error(msg, e); throw new TerminationException(msg, e); } catch (CloudControllerServiceInvalidClusterExceptionException e) { - log.error(e.getMessage()); - throw new TerminationException(e); + String message = e.getFaultMessage().getInvalidClusterException().getMessage(); + log.error(message, e); + throw new TerminationException(message, e); } catch (CloudControllerServiceIllegalArgumentExceptionException e) { - log.error(e.getMessage()); - throw new TerminationException(e); + String msg = e.getMessage(); + log.error(msg, e); + throw new TerminationException(msg, e); } } @@ -192,13 +207,21 @@ public class CloudControllerClient { log.debug(String.format("Service call terminateInstance() returned in %dms", (endTime - startTime))); } } catch (RemoteException e) { - throw new TerminationException("Could not terminate instance", e); + String msg = e.getMessage(); + log.error(msg, e); + throw new TerminationException(msg, e); } catch (CloudControllerServiceIllegalArgumentExceptionException e) { - throw new TerminationException(e); + String msg = e.getMessage(); + log.error(msg, e); + throw new TerminationException(msg, e); } catch (CloudControllerServiceInvalidMemberExceptionException e) { - throw new TerminationException(e); + String msg = e.getFaultMessage().getInvalidMemberException().getMessage(); + log.error(msg, e); + throw new TerminationException(msg, e); } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) { - throw new TerminationException(e); + String msg = e.getFaultMessage().getInvalidCartridgeTypeException().getMessage(); + log.error(msg, e); + throw new TerminationException(msg, e); } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/91f14f39/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java index 98aaffc..ff09ab0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java @@ -72,12 +72,12 @@ private static final Log log = LogFactory.getLog(PartitionManager.class); /* * Deploy a new partition to Auto Scaler. */ - public boolean addNewPartition(Partition partition) throws AutoScalerException, InvalidPartitionException { + public boolean addNewPartition(Partition partition) throws InvalidPartitionException { if (StringUtils.isEmpty(partition.getId())){ - throw new AutoScalerException("Partition id can not be empty"); + throw new InvalidPartitionException("Partition id can not be empty"); } if (this.partitionExist(partition.getId())) { - throw new AutoScalerException(String.format("Partition already exist in partition manager: [id] %s", partition.getId())); + throw new InvalidPartitionException(String.format("Partition already exist in partition manager: [id] %s", partition.getId())); } if (null == partition.getProvider()) { throw new InvalidPartitionException("Mandatory field provider has not be set for partition " + partition.getId()); @@ -91,7 +91,7 @@ private static final Log log = LogFactory.getLog(PartitionManager.class); } return true; } catch (Exception e) { - throw new AutoScalerException(e); + throw new InvalidPartitionException(e.getMessage(), e); } }
