stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [25/50] [abbrv] git commit: delete application from metadata service when app is undeployed
Date Thu, 30 Oct 2014 04:13:49 GMT
delete application from metadata service when app is undeployed


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

Branch: refs/heads/docker-grouping-merge
Commit: 195303244312d60cb83a1e0d7a0c44f221d05014
Parents: c947820
Author: Udara Liyanage <udara@wso2.com>
Authored: Tue Oct 28 16:31:31 2014 +0530
Committer: Udara Liyanage <udara@wso2.com>
Committed: Tue Oct 28 16:31:31 2014 +0530

----------------------------------------------------------------------
 .../controller/topology/TopologyBuilder.java    | 23 +++++++++++++-------
 .../topology/GroupTerminatingProcessor.java     |  2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/19530324/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index e715130..fac6671 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -31,19 +31,13 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
 import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient;
+import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
 import java.util.*;
@@ -939,10 +933,14 @@ public class TopologyBuilder {
                     }
                 }
 
+
+
                 // remove application
                 topology.removeApplication(event.getAppId());
                 TopologyManager.updateTopology(topology);
 
+                deleteAppResourcesFromMetadataService(event);
+
                 log.info("Removed application [ " + event.getAppId() + " ] from Topology");
 
                 TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(),
@@ -954,6 +952,15 @@ public class TopologyBuilder {
         }
     }
 
+    private static void deleteAppResourcesFromMetadataService(AppStatusApplicationTerminatedEvent
event) {
+        try {
+            MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient();
+            metadataClient.deleteApplicationProperties(event.getAppId());
+        } catch (Exception e) {
+            log.error("Error occurred while deleting the application resources frm metadata
service " , e);
+        }
+    }
+
     public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) {
         Topology topology = TopologyManager.getTopology();
         Application application = topology.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/19530324/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
index ecf6873..27b5cff 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
@@ -94,7 +94,7 @@ public class GroupTerminatingProcessor extends MessageProcessor {
         } else {
             // Apply changes to the topology
             if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " +
GroupStatus.Terminating);
+                log.error("Invalid State Transition from " + group.getStatus() + " to " +
GroupStatus.Active);
             }
             group.setStatus(GroupStatus.Terminating);
 


Mime
View raw message