stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saj...@apache.org
Subject stratos git commit: fixing update payload parameters from cartridge issue. This closes #504
Date Tue, 09 Feb 2016 14:27:48 GMT
Repository: stratos
Updated Branches:
  refs/heads/master c795440d7 -> 578199438


fixing update payload parameters from cartridge issue.   This closes #504


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

Branch: refs/heads/master
Commit: 57819943882b92e7d1335de22ed6bbb02ae241c7
Parents: c795440
Author: Vishanth <vishanth911@gmail.com>
Authored: Tue Feb 9 19:34:44 2016 +0530
Committer: Sajith <sajith@wso2.com>
Committed: Tue Feb 9 19:57:03 2016 +0530

----------------------------------------------------------------------
 .../services/impl/AutoscalerServiceImpl.java    | 35 +++++++++++++++-----
 .../util/converter/ObjectConverter.java         |  7 ++--
 .../kubernetes-cluster-2.json                   | 11 ++----
 3 files changed, 35 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/57819943/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index 0943de0..09110e2 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -124,14 +124,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             log.info(String.format("Adding application: [application-id] %s", applicationContext.getApplicationId()));
         }
 
-        ApplicationParser applicationParser = new DefaultApplicationParser();
-        Application application = applicationParser.parse(applicationContext);
-        ApplicationHolder.persistApplication(application);
-
-        List<ApplicationClusterContext> applicationClusterContexts = applicationParser.getApplicationClusterContexts();
-        ApplicationClusterContext[] applicationClusterContextsArray = applicationClusterContexts
-                .toArray(new ApplicationClusterContext[applicationClusterContexts.size()]);
-        applicationContext.getComponents().setApplicationClusterContexts(applicationClusterContextsArray);
+        Application application = parseApplication(applicationContext);
 
         applicationContext.setStatus(ApplicationContext.STATUS_CREATED);
         AutoscalerContext.getInstance().addApplicationContext(applicationContext);
@@ -146,6 +139,29 @@ public class AutoscalerServiceImpl implements AutoscalerService {
         return true;
     }
 
+    /**
+     * Parse application context, generate application cluster contexts with
+     * payload parameters and build the application object.
+     * @param applicationContext
+     * @return
+     * @throws ApplicationDefinitionException
+     * @throws CartridgeGroupNotFoundException
+     * @throws CartridgeNotFoundException
+     */
+    private Application parseApplication(ApplicationContext applicationContext) throws ApplicationDefinitionException,
+            CartridgeGroupNotFoundException, CartridgeNotFoundException {
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        Application application = applicationParser.parse(applicationContext);
+        ApplicationHolder.persistApplication(application);
+
+        List<ApplicationClusterContext> applicationClusterContexts = applicationParser.getApplicationClusterContexts();
+        ApplicationClusterContext[] applicationClusterContextsArray = applicationClusterContexts
+                .toArray(new ApplicationClusterContext[applicationClusterContexts.size()]);
+        applicationContext.getComponents().setApplicationClusterContexts(applicationClusterContextsArray);
+        return application;
+    }
+
     @Override
     public boolean updateApplication(ApplicationContext applicationContext)
             throws ApplicationDefinitionException, CartridgeGroupNotFoundException, CartridgeNotFoundException
{
@@ -236,6 +252,9 @@ public class AutoscalerServiceImpl implements AutoscalerService {
                 throw new RuntimeException("Application context not found: " + applicationId);
             }
 
+            // Parse application to update payload parameters
+            application = parseApplication(applicationContext);
+
             // validating application policy against the application
             AutoscalerUtil.validateApplicationPolicyAgainstApplication(applicationId, applicationPolicyId);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/57819943/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index d1307eb..7d6ad3b 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -19,6 +19,7 @@
 
 package org.apache.stratos.rest.endpoint.util.converter;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy;
 import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
@@ -1567,13 +1568,15 @@ public class ObjectConverter {
      */
     private static DeploymentBean convertDeploymentToDeploymentBean(String[] directories,
                                                                     String baseDir) {
-        if (baseDir == null || directories == null || directories[0] == null) {
+        if (baseDir == null && (directories == null || directories[0] == null)) {
             return null;
         }
 
         DeploymentBean deploymentBean = new DeploymentBean();
         deploymentBean.setBaseDir(baseDir);
-        deploymentBean.setDir(Arrays.asList(baseDir));
+        if (ArrayUtils.isNotEmpty(directories) && (directories[0] != null)) {
+            deploymentBean.setDir(Arrays.asList(directories));
+        }
         return deploymentBean;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/57819943/samples/kubernetes-clusters/kubernetes-cluster-2.json
----------------------------------------------------------------------
diff --git a/samples/kubernetes-clusters/kubernetes-cluster-2.json b/samples/kubernetes-clusters/kubernetes-cluster-2.json
index ebc7613..39ba9c7 100644
--- a/samples/kubernetes-clusters/kubernetes-cluster-2.json
+++ b/samples/kubernetes-clusters/kubernetes-cluster-2.json
@@ -7,6 +7,9 @@
     "privateIPAddress": "172.17.8.101",
     "publicIPAddress": "172.17.8.101",
     "property": [
+	{ "name": "KUBERNETES_MASTER_PORT", 
+          "value": "8080" 
+        }
     ]
   },
   "portRange": {
@@ -21,14 +24,6 @@
       "publicIPAddress": "172.17.8.102",
       "property": [
       ]
-    },
-    {
-      "hostId": "minion-2",
-      "hostname": "minion-2.dev.kubernetes.org",
-      "privateIPAddress": "172.17.8.103",
-      "publicIPAddress": "172.17.8.103",
-      "property": [
-      ]
     }
   ],
   "property": [


Mime
View raw message