stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject stratos git commit: Implementing KubernetesIaas.setDynamicPayload() method and adding dynamic payload parameters to environment variables
Date Sun, 21 Dec 2014 17:51:55 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 105bbf926 -> d544a083f


Implementing KubernetesIaas.setDynamicPayload() method and adding dynamic payload parameters
to environment variables


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

Branch: refs/heads/master
Commit: d544a083f1a7216729f2b3bb86961b5d8494c3dd
Parents: 105bbf9
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Sun Dec 21 23:21:46 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Sun Dec 21 23:21:46 2014 +0530

----------------------------------------------------------------------
 .../client/CloudControllerClient.java           | 20 +++---
 ...inerClusterContextToKubernetesContainer.java | 50 ++++++++------
 ...erClusterContextToReplicationController.java |  5 +-
 .../cloud/controller/iaases/KubernetesIaas.java | 70 +++++++++++++++++---
 .../impl/CloudControllerServiceImpl.java        | 23 ++++---
 .../org/apache/stratos/common/Property.java     |  2 +-
 .../stratos/common/beans/NameValuePair.java     | 50 ++++++++++++++
 .../common/constants/StratosConstants.java      |  1 +
 .../util/converter/ObjectConverter.java         | 13 ++--
 9 files changed, 176 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
index 430dd97..8bcbde6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
@@ -244,17 +244,17 @@ public class CloudControllerClient {
                                                        Set<ApplicationClusterContext>
appClusterContexts) {
         List<org.apache.stratos.cloud.controller.stub.domain.ApplicationClusterContext>
contextDTOs =
                                         new ArrayList<org.apache.stratos.cloud.controller.stub.domain.ApplicationClusterContext>();
-        for(ApplicationClusterContext context : appClusterContexts) {
+        for(ApplicationClusterContext applicationClusterContext : appClusterContexts) {
             org.apache.stratos.cloud.controller.stub.domain.ApplicationClusterContext dto
= new org.apache.stratos.cloud.controller.stub.domain.ApplicationClusterContext();
-            dto.setClusterId(context.getClusterId());
-            dto.setAutoscalePolicyName(context.getAutoscalePolicyName());
-            dto.setDeploymentPolicyName(context.getDeploymentPolicyName());
-            dto.setCartridgeType(context.getCartridgeType());
-            dto.setHostName(context.getHostName());
-            dto.setTenantRange(context.getTenantRange());
-            dto.setTextPayload(context.getTextPayload());
-            dto.setLbCluster(context.isLbCluster());
-            dto.setProperties(AutoscalerUtil.toStubProperties(context.getProperties()));
+            dto.setClusterId(applicationClusterContext.getClusterId());
+            dto.setAutoscalePolicyName(applicationClusterContext.getAutoscalePolicyName());
+            dto.setDeploymentPolicyName(applicationClusterContext.getDeploymentPolicyName());
+            dto.setCartridgeType(applicationClusterContext.getCartridgeType());
+            dto.setHostName(applicationClusterContext.getHostName());
+            dto.setTenantRange(applicationClusterContext.getTenantRange());
+            dto.setTextPayload(applicationClusterContext.getTextPayload());
+            dto.setLbCluster(applicationClusterContext.isLbCluster());
+            dto.setProperties(AutoscalerUtil.toStubProperties(applicationClusterContext.getProperties()));
             contextDTOs.add(dto);
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
index 4b0916b..ba72fec 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
@@ -28,6 +28,7 @@ import org.apache.stratos.cloud.controller.domain.*;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.Property;
+import org.apache.stratos.common.beans.NameValuePair;
 import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.kubernetes.client.model.Container;
 import org.apache.stratos.kubernetes.client.model.EnvironmentVariable;
@@ -59,13 +60,12 @@ public class ContainerClusterContextToKubernetesContainer implements Function<Me
         }
 
         container.setImage(cartridge.getContainer().getImageName());
-        container.setPorts(getPorts(clusterContext, cartridge));
-        container.setEnv(getEnvironmentVars(memberContext, clusterContext));
-
+        container.setPorts(getPorts(cartridge));
+        container.setEnv(getEnvironmentVariables(memberContext, clusterContext));
         return container;
     }
 
-    private Port[] getPorts(ClusterContext ctxt, Cartridge cartridge) {
+    private Port[] getPorts(Cartridge cartridge) {
         Port[] ports = new Port[cartridge.getPortMappings().size()];
         List<Port> portList = new ArrayList<Port>();
 
@@ -77,28 +77,40 @@ public class ContainerClusterContextToKubernetesContainer implements Function<Me
             p.setName(p.getProtocol() + p.getContainerPort());
             portList.add(p);
         }
-
         return portList.toArray(ports);
     }
 
-    private EnvironmentVariable[] getEnvironmentVars(MemberContext memberCtxt, ClusterContext
ctxt) {
-        String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
+    private EnvironmentVariable[] getEnvironmentVariables(MemberContext memberContext, ClusterContext
clusterContext) {
+        String kubernetesClusterId = CloudControllerUtil.getProperty(clusterContext.getProperties(),
                 StratosConstants.KUBERNETES_CLUSTER_ID);
 
-        List<EnvironmentVariable> envVars = new ArrayList<EnvironmentVariable>();
-        addToEnvironment(envVars, ctxt.getPayload());
-        addToEnvironment(envVars, StratosConstants.KUBERNETES_CLUSTER_ID, kubernetesClusterId);
-        if (memberCtxt.getProperties() != null) {
-            Properties props1 = memberCtxt.getProperties();
-            if (props1 != null) {
-                for (Property prop : props1.getProperties()) {
-                    addToEnvironment(envVars, prop.getName(), String.valueOf(prop.getValue()));
+        List<EnvironmentVariable> environmentVariables = new ArrayList<EnvironmentVariable>();
+        if (memberContext.getProperties() != null) {
+            Properties properties = memberContext.getProperties();
+            if (properties != null) {
+                // Set dynamic payload
+                List<NameValuePair> payload = (List<NameValuePair>) properties.getProperty(
+                        StratosConstants.DYNAMIC_PAYLOAD);
+                if(payload != null) {
+                    for(NameValuePair parameter : payload) {
+                        addToEnvironmentVariables(environmentVariables, parameter.getName(),
parameter.getValue());
+                    }
+                }
+                // Set member string properties as payload parameters
+                for (Property property : properties.getProperties()) {
+                    if(property.getValue() instanceof String) {
+                        addToEnvironmentVariables(environmentVariables, property.getName(),
+                                String.valueOf(property.getValue()));
+                    }
                 }
             }
+            // Set kubernetes cluster id
+            addToEnvironmentVariables(environmentVariables, StratosConstants.KUBERNETES_CLUSTER_ID,
+                    kubernetesClusterId);
         }
 
-        EnvironmentVariable[] vars = new EnvironmentVariable[envVars.size()];
-        return envVars.toArray(vars);
+        EnvironmentVariable[] array = new EnvironmentVariable[environmentVariables.size()];
+        return environmentVariables.toArray(array);
     }
 
     private void addToEnvironment(List<EnvironmentVariable> envVars, String payload)
{
@@ -109,12 +121,12 @@ public class ContainerClusterContextToKubernetesContainer implements
Function<Me
                 if (var.length != 2) {
                     continue;
                 }
-                addToEnvironment(envVars, var[0], var[1]);
+                addToEnvironmentVariables(envVars, var[0], var[1]);
             }
         }
     }
 
-    private void addToEnvironment(List<EnvironmentVariable> envVars, String name, String
value) {
+    private void addToEnvironmentVariables(List<EnvironmentVariable> envVars, String
name, String value) {
         EnvironmentVariable var = new EnvironmentVariable();
         var.setName(name);
         var.setValue(value);

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
index 7aeaa3e..1e66f9e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
@@ -35,8 +35,7 @@ import com.google.common.base.Function;
 /**
  * Is responsible for converting a {@link org.apache.stratos.cloud.controller.domain.MemberContext}
object to a Kubernetes
  * {@link ReplicationController} object:
- * - A replication controller is created for each cluster but uses the same environment variables
- * generated by the member context, hence using member context.
+ * - A replication controller is created for each member and environment variables generated
by the member context.
  */
 public class ContainerClusterContextToReplicationController implements
         Function<MemberContext, ReplicationController> {
@@ -45,7 +44,7 @@ public class ContainerClusterContextToReplicationController implements
     public ReplicationController apply(MemberContext memberContext) {
 
         ReplicationController replicationController = new ReplicationController();
-        replicationController.setId(memberContext.getClusterId());
+        replicationController.setId(memberContext.getMemberId());
         replicationController.setKind("ReplicationController");
         replicationController.setApiVersion("v1beta1");
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
index 5ac0954..082c723 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
@@ -33,6 +33,7 @@ import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceU
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.cloud.controller.util.PodActivationWatcher;
 import org.apache.stratos.common.Property;
+import org.apache.stratos.common.beans.NameValuePair;
 import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.common.kubernetes.KubernetesGroup;
 import org.apache.stratos.common.kubernetes.PortRange;
@@ -51,12 +52,16 @@ public class KubernetesIaas extends Iaas {
 
     private static final Log log = LogFactory.getLog(KubernetesIaas.class);
     private static final long POD_CREATION_TIMEOUT = 60000; // 1 min
+    public static final String PAYLOAD_PARAMETER_SEPARATOR = ",";
+    public static final String PAYLOAD_PARAMETER_NAME_VALUE_SEPARATOR = "=";
 
     private PartitionValidator partitionValidator;
+    private List<NameValuePair> payload;
 
     public KubernetesIaas(IaasProvider iaasProvider) {
         super(iaasProvider);
         partitionValidator = new KubernetesPartitionValidator();
+        payload = new ArrayList<NameValuePair>();
     }
 
     @Override
@@ -64,6 +69,31 @@ public class KubernetesIaas extends Iaas {
     }
 
     @Override
+    public void setDynamicPayload(byte[] payloadByteArray) {
+        // Clear existing payload parameters
+        payload.clear();
+
+        if(payloadByteArray != null) {
+            String payloadString = new String(payloadByteArray);
+            String[] parameterArray = payloadString.split(PAYLOAD_PARAMETER_SEPARATOR);
+            if(parameterArray != null) {
+                for(String parameter : parameterArray) {
+                    if(parameter != null) {
+                        String[] nameValueArray = parameter.split(PAYLOAD_PARAMETER_NAME_VALUE_SEPARATOR);
+                        if ((nameValueArray != null) && (nameValueArray.length ==
2)) {
+                            NameValuePair nameValuePair = new NameValuePair(nameValueArray[0],
nameValueArray[1]);
+                            payload.add(nameValuePair);
+                        }
+                    }
+                }
+                if(log.isDebugEnabled()) {
+                    log.debug("Dynamic payload is set: " + payload.toString());
+                }
+            }
+        }
+    }
+
+    @Override
     public MemberContext startInstance(MemberContext memberContext) throws CartridgeNotFoundException
{
         return startContainer(memberContext);
     }
@@ -132,6 +162,7 @@ public class KubernetesIaas extends Iaas {
                 String kubernetesMasterPort = CloudControllerUtil.getProperty(
                         kubernetesGroup.getKubernetesMaster().getProperties(), StratosConstants.KUBERNETES_MASTER_PORT,
                         StratosConstants.KUBERNETES_MASTER_DEFAULT_PORT);
+
                 KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId,
                         kubernetesMasterIp, kubernetesMasterPort, kubernetesPortRange.getLower(),
                         kubernetesPortRange.getUpper());
@@ -240,11 +271,18 @@ public class KubernetesIaas extends Iaas {
      * @param kubernetesApi
      * @throws KubernetesClientException
      */
-    private ReplicationController createReplicationController(MemberContext memberContext,
String clusterId, KubernetesApiClient kubernetesApi) throws KubernetesClientException {
+    private ReplicationController createReplicationController(MemberContext memberContext,
String clusterId,
+                                                              KubernetesApiClient kubernetesApi)
+            throws KubernetesClientException {
         if (log.isDebugEnabled()) {
             log.debug("Creating kubernetes replication controller: [cluster-id] " + clusterId);
         }
-        ContainerClusterContextToReplicationController controllerFunction = new ContainerClusterContextToReplicationController();
+        // Add dynamic payload to the member context
+        memberContext.getProperties().addProperty(new Property(StratosConstants.DYNAMIC_PAYLOAD,
payload));
+        ContainerClusterContextToReplicationController controllerFunction =
+                new ContainerClusterContextToReplicationController();
+
+        // Create replication controller
         ReplicationController replicationController = controllerFunction.apply(memberContext);
         kubernetesApi.createReplicationController(replicationController);
         if (log.isDebugEnabled()) {
@@ -254,7 +292,7 @@ public class KubernetesIaas extends Iaas {
     }
 
     /**
-     * Create proxy services for the cluster
+     * Create proxy services for the cluster and add them to the cluster context.
      * @param clusterContext
      * @param kubernetesClusterContext
      * @param kubernetesApi
@@ -313,10 +351,22 @@ public class KubernetesIaas extends Iaas {
         return services;
     }
 
+    /**
+     * Prepare kubernetes service id using clusterId, port protocol and port.
+     * @param clusterId
+     * @param portMapping
+     * @return
+     */
     private String prepareKubernetesServiceId(String clusterId, PortMapping portMapping)
{
         return String.format("%s-%s-%s", clusterId, portMapping.getProtocol(), portMapping.getPort());
     }
 
+    /**
+     * Terminate all the containers belong to a cluster by cluster id.
+     * @param clusterId
+     * @return
+     * @throws InvalidClusterException
+     */
     public MemberContext[] terminateContainers(String clusterId)
             throws InvalidClusterException {
         Lock lock = null;
@@ -444,6 +494,15 @@ public class KubernetesIaas extends Iaas {
         }
     }
 
+    /**
+     * Get kubernetes cluster context
+     * @param kubernetesClusterId
+     * @param kubernetesMasterIp
+     * @param kubernetesMasterPort
+     * @param upperPort
+     * @param lowerPort
+     * @return
+     */
     private KubernetesClusterContext getKubernetesClusterContext(String kubernetesClusterId,
String kubernetesMasterIp,
                                                                  String kubernetesMasterPort,
int upperPort, int lowerPort) {
 
@@ -525,9 +584,4 @@ public class KubernetesIaas extends Iaas {
     public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition
partition) {
 
     }
-
-    @Override
-    public void setDynamicPayload(byte[] payload) {
-        // Payload is passed via environment
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index a5d78eb..52d499f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -379,6 +379,7 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
             addToPayload(payload, "LB_CLUSTER_ID", memberContext.getLbClusterId());
             addToPayload(payload, "NETWORK_PARTITION_ID", memberContext.getNetworkPartitionId());
             addToPayload(payload, "PARTITION_ID", partitionId);
+
             if (memberContext.getProperties() != null) {
                 org.apache.stratos.common.Properties properties = memberContext.getProperties();
                 if (properties != null) {
@@ -390,17 +391,6 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
 
             Iaas iaas = iaasProvider.getIaas();
             if (clusterContext.isVolumeRequired()) {
-                if (clusterContext.getVolumes() != null) {
-                    for (Volume volume : clusterContext.getVolumes()) {
-                        if (volume.getId() == null) {
-                            // Create a new volume
-                            createVolumeAndSetInClusterContext(volume, iaasProvider);
-                        }
-                    }
-                }
-            }
-
-            if (clusterContext.isVolumeRequired()) {
                 addToPayload(payload, PERSISTENCE_MAPPING, getPersistencePayload(clusterContext,
iaas).toString());
             }
 
@@ -411,6 +401,17 @@ public class CloudControllerServiceImpl implements CloudControllerService
{
             iaasProvider.setPayload(payload.toString().getBytes());
             iaas.setDynamicPayload(iaasProvider.getPayload());
 
+            if (clusterContext.isVolumeRequired()) {
+                if (clusterContext.getVolumes() != null) {
+                    for (Volume volume : clusterContext.getVolumes()) {
+                        if (volume.getId() == null) {
+                            // Create a new volume
+                            createVolumeAndSetInClusterContext(volume, iaasProvider);
+                        }
+                    }
+                }
+            }
+
             // Start instance in a new thread
             ThreadExecutor exec = ThreadExecutor.getInstance();
             if (log.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java
index 4e50252..b3dc180 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java
@@ -33,7 +33,7 @@ public class Property implements Serializable, Cloneable {
     public Property() {
     }
 
-    public Property(String name, String value) {
+    public Property(String name, Object value) {
         this.setName(name);
         this.setValue(value);
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/NameValuePair.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/NameValuePair.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/NameValuePair.java
new file mode 100644
index 0000000..d21cc55
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/NameValuePair.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.common.beans;
+
+import java.io.Serializable;
+
+/**
+ * Name value pair.
+ */
+public class NameValuePair implements Serializable {
+
+    private static final long serialVersionUID = 6783497955930623020L;
+
+    private final String name;
+    private String value;
+
+    public NameValuePair(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
index 7583f89..c763b90 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
@@ -190,5 +190,6 @@ public class StratosConstants {
 	public static final String LOAD_BALANCED_SERVICE_TYPE = "load.balanced.service.type";
 
     public static final long HAZELCAST_INSTANCE_INIT_TIMEOUT = 300000; // 5 min
+    public static final String DYNAMIC_PAYLOAD = "DYNAMIC_PAYLOAD";
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d544a083/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 83e7d98..a414fd1 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
@@ -532,13 +532,13 @@ public class ObjectConverter {
     }
 
     private static PropertyBean convertStubPropertyToPropertyBean(org.apache.stratos.autoscaler.stub.Property
stubProperty) {
-        if(stubProperty == null) {
+        if ((stubProperty == null) || (!(stubProperty.getValue() instanceof String))) {
             return null;
         }
 
         PropertyBean propertyBean = new PropertyBean();
         propertyBean.setName(stubProperty.getName());
-        propertyBean.setValue(stubProperty.getValue());
+        propertyBean.setValue(String.valueOf(stubProperty.getValue()));
         return propertyBean;
     }
 
@@ -1088,12 +1088,13 @@ public class ObjectConverter {
     }
 
     private static PropertyBean convertAsStubPropertyToPropertyBean(org.apache.stratos.autoscaler.stub.Property
propertyE) {
-        if (propertyE == null) {
+        if ((propertyE == null) || (!(propertyE.getValue() instanceof String))) {
             return null;
         }
+
         PropertyBean propertyBean = new PropertyBean();
         propertyBean.setName(propertyE.getName());
-        propertyBean.setValue(propertyE.getValue());
+        propertyBean.setValue(String.valueOf(propertyE.getValue()));
         return propertyBean;
     }
     
@@ -1272,11 +1273,11 @@ public class ObjectConverter {
                 new ArrayList<org.apache.stratos.manager.composite.application.beans.PropertyBean>();
         if((properties != null) && (properties.getProperties() != null)) {
             for (org.apache.stratos.autoscaler.stub.Property property : properties.getProperties())
{
-                if(property != null) {
+                if((property != null) && (property.getValue() instanceof String))
{
                     org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean
=
                             new org.apache.stratos.manager.composite.application.beans.PropertyBean();
                     propertyBean.setName(property.getName());
-                    propertyBean.setValue(property.getValue());
+                    propertyBean.setValue(String.valueOf(property.getValue()));
                     propertyBeanList.add(propertyBean);
                 }
             }


Mime
View raw message