stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cham...@apache.org
Subject stratos git commit: Fix Application Key regeneration issue when redeploying cartridge
Date Wed, 10 Feb 2016 13:15:06 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 578199438 -> 0a5fec3b9


Fix Application Key regeneration issue when redeploying cartridge


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

Branch: refs/heads/master
Commit: 0a5fec3b9ecf12d3ff37078278d2b56c9b6e3f38
Parents: 5781994
Author: Chamila de Alwis <cs@chamiladealwis.com>
Authored: Wed Feb 10 14:29:42 2016 +0530
Committer: Chamila de Alwis <chamila@apache.org>
Committed: Wed Feb 10 18:44:16 2016 +0530

----------------------------------------------------------------------
 .../parser/DefaultApplicationParser.java             | 15 ++++++++++++++-
 .../messaging/domain/application/Application.java    |  7 +++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0a5fec3b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index 1d93a0e..b5d9296 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.applications.ApplicationUtils;
 import org.apache.stratos.autoscaler.applications.ClusterInformation;
 import org.apache.stratos.autoscaler.applications.MTClusterInformation;
 import org.apache.stratos.autoscaler.applications.STClusterInformation;
+import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.payload.PayloadData;
 import org.apache.stratos.autoscaler.applications.pojo.*;
 import org.apache.stratos.autoscaler.client.IdentityApplicationManagementServiceClient;
@@ -270,7 +271,19 @@ public class DefaultApplicationParser implements ApplicationParser {
                                                    Map<String, SubscribableInfoContext>
subscribableInfoCtxts)
             throws ApplicationDefinitionException, CartridgeGroupNotFoundException, CartridgeNotFoundException
{
 
-        Application application = new Application(applicationContext.getApplicationId());
+        Application application;
+
+        // check if application already exists, and get existing key if true
+        ApplicationHolder.acquireReadLock();
+        Applications persistedApplications = ApplicationHolder.getApplications();
+        if (persistedApplications != null && persistedApplications.applicationExists(applicationContext.getApplicationId()))
{
+            String existingKey = persistedApplications.getApplication(applicationContext.getApplicationId()).getKey();
+            application = new Application(applicationContext.getApplicationId(), existingKey);
+        } else {
+            application = new Application(applicationContext.getApplicationId());
+        }
+
+        ApplicationHolder.releaseReadLock();
 
         // Set tenant information
         application.setTenantId(applicationContext.getTenantId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/0a5fec3b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
index 5dcea72..9c49883 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
@@ -61,6 +61,13 @@ public class Application extends ParentComponent<ApplicationInstance>
{
         this.setInstanceIdToInstanceContextMap(new HashMap<String, ApplicationInstance>());
     }
 
+    public Application(String id, String key) {
+        super();
+        this.id = id;
+        this.key = key;
+        this.setInstanceIdToInstanceContextMap(new HashMap<String, ApplicationInstance>());
+    }
+
     public String getUniqueIdentifier() {
         return id;
     }


Mime
View raw message