Repository: incubator-stratos
Updated Branches:
  refs/heads/master 6338416d3 -> 75d74703e


refactoring some duplicated code


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

Branch: refs/heads/master
Commit: 75d74703e538788fc5ba917278b8ebf6cc233a86
Parents: 6338416
Author: Isuru <[email protected]>
Authored: Mon Mar 10 23:19:06 2014 +0530
Committer: Isuru <[email protected]>
Committed: Mon Mar 10 23:19:06 2014 +0530

----------------------------------------------------------------------
 .../behaviour/CartridgeMgtBehaviour.java        |  6 ++---
 .../stratos/manager/deploy/service/Service.java | 25 +++-----------------
 .../service/ServiceDeploymentManager.java       | 14 +++++++----
 3 files changed, 15 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/75d74703/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
index 0e06da6..92633c8 100644
--- 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
+++ 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
@@ -125,12 +125,12 @@ public abstract class CartridgeMgtBehaviour implements 
Serializable {
             
CloudControllerServiceClient.getServiceClient().terminateAllInstances(clusterId);
 
         } catch (AxisFault e) {
-            String errorMsg = "Error in terminating cartridge subscription, 
cluster id: " + clusterId;
+            String errorMsg = "Error in terminating members of cluster " + 
clusterId;
             log.error(errorMsg);
             throw new ADCException(errorMsg, e);
 
         } catch (Exception e) {
-            String errorMsg = "Error in terminating cartridge subscription, 
cluster id: " + clusterId;
+            String errorMsg = "Error in terminating members of cluster " + 
clusterId;
             log.error(errorMsg);
             throw new ADCException(errorMsg, e);
         }
@@ -146,7 +146,7 @@ public abstract class CartridgeMgtBehaviour implements 
Serializable {
             throw new ADCException(errorMsg, e);
         }
 
-        log.info("Unregistered service cluster, domain " + clusterId + ", sub 
domain ");
+        log.info("Unregistered service cluster, domain " + clusterId);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/75d74703/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
index 42405a1..bec212c 100644
--- 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
+++ 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
@@ -27,6 +27,7 @@ import 
org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour;
 import org.apache.stratos.manager.client.CloudControllerServiceClient;
 import org.apache.stratos.manager.dao.Cluster;
 import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.exception.NotSubscribedException;
 import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
 import org.apache.stratos.manager.payload.PayloadData;
 import 
org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
@@ -74,29 +75,9 @@ public abstract class Service extends CartridgeMgtBehaviour {
         setPayloadData(createPayload(cartridgeInfo, subscriptionKey, null, 
cluster, null, null, null));
     }
 
-    public void undeploy () throws ADCException {
+    public void undeploy () throws ADCException, NotSubscribedException {
 
-        try {
-            
CloudControllerServiceClient.getServiceClient().terminateAllInstances(cluster.getClusterDomain());
-
-        } catch (Exception e) {
-            String errorMsg = "Error in undeploying Service with type " + type;
-            log.error(errorMsg, e);
-            throw new ADCException(errorMsg, e);
-        }
-
-        log.info("terminated instance with Service Type " + type);
-
-        try {
-            
CloudControllerServiceClient.getServiceClient().unregisterService(cluster.getClusterDomain());
-
-        } catch (Exception e) {
-            String errorMsg = "Error in unregistering service cluster with 
domain " + cluster.getClusterDomain();
-            log.error(errorMsg);
-            throw new ADCException(errorMsg, e);
-        }
-
-        log.info("Unregistered service with domain " + 
cluster.getClusterDomain());
+        remove(cluster.getClusterDomain(), null);
     }
 
     public String getType() {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/75d74703/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
index eebaaba..e56c795 100644
--- 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
+++ 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
@@ -29,10 +29,7 @@ import 
org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregister
 import org.apache.stratos.manager.client.CloudControllerServiceClient;
 import 
org.apache.stratos.manager.deploy.service.multitenant.MultiTenantService;
 import 
org.apache.stratos.manager.deploy.service.multitenant.lb.MultiTenantLBService;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.exception.ServiceAlreadyDeployedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
+import org.apache.stratos.manager.exception.*;
 import org.apache.stratos.manager.lb.category.*;
 import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
 import org.apache.stratos.manager.subscription.CartridgeSubscription;
@@ -452,7 +449,14 @@ public class ServiceDeploymentManager {
         }
 
         // if service is found, undeploy
-        service.undeploy();
+        try {
+            service.undeploy();
+
+        } catch (NotSubscribedException e) {
+            String errorMsg = "Undeploying Service Cluster failed for " + type;
+            log.error(errorMsg, e);
+            throw new ADCException(errorMsg, e);
+        }
 
         try {
             dataInsertionAndRetrievalManager.removeService(type);

Reply via email to